Archive

Archive for February, 2019

Mastering Markdown

February 27, 2019 Leave a comment

What is Markdown?

Markdown is a way to style text on the web. You control the display of the document; formatting words as bold or italic, adding images, and creating lists are just a few of the things we can do with Markdown. Mostly, Markdown is just regular text with a few non-alphabetic characters thrown in, like # or *.

https://guides.github.com/features/mastering-markdown/

Advertisements
Categories: git

Naming Branches

February 26, 2019 Leave a comment

Problem:
I was wondering if there is a convention for naming git branches. Though this really depends on what your organization has, what do you follow when there are no standards?

Solution:
After a quick google I opted to go for:

* feat-short-name
* test-short-name
* fix-short-name
* bug-short-name
* chore-short-name

When naming branches. Then still have

* develop for most of the work and
* master for releases.

Source:
https://github.com/agis/git-style-guide
https://stackoverflow.com/questions/273695/what-are-some-examples-of-commonly-used-practices-for-naming-git-branches

Categories: git Tags: ,

How to use `git mergetool` to resolve conflicts

February 18, 2019 Leave a comment

https://gist.github.com/karenyyng/f19ff75c60f18b4b8149

Have the following in .gitconfig

[merge]                                                                                                                           
    tool = vimdiff  
Categories: git Tags: ,

Change the last line in a file

February 12, 2019 Leave a comment

Problem:
I needed to remove a comma from the last line of a file.

Solution:
Learnt that I can specify the last line with sed.

# File with commas
$ less minerals.csv
"copper",
"bronze",
"gold",
"platinum",
$ sed '$ s/,//' minerals.csv
$ less minerals.csv
"copper",
"bronze",
"gold",
"platinum"

Addresses

Sed commands can be given with no addresses, in which case the command will be executed for all input lines; with one address, in which case the command will only be executed for input lines which match that address; or with two addresses, in which case the command will be executed for all input lines which match the inclusive range of lines starting from the first address and continuing to the second address. Three things to note about address ranges: the syntax is addr1,addr2 (i.e., the addresses are separated by a comma); the line which addr1 matched will always be accepted, even if addr2 selects an earlier line; and if addr2 is a regexp, it will not be tested against the line that addr1 matched.

After the address (or address-range), and before the command, a ! may be inserted, which specifies that the command shall only be executed if the address (or address-range) does not match.

The following address types are supported:

number
Match only the specified line number.

first~step
Match every step’th line starting with line first. For example, ”sed -n 1~2p” will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)
$
Match the last line.

/regexp/
Match lines matching the regular expression regexp.
\cregexpc
Match lines matching the regular expression regexp. The c may be any character.
GNU sed also supports some special 2-address forms:
0,addr2
Start out in “matched first address” state, until addr2 is found. This is similar to 1,addr2, except that if addr2 matches the very first line of input the 0,addr2 form will be at the end of its range, whereas the 1,addr2 form will still be at the beginning of its range. This works only when addr2 is a regular expression.
addr1,+N
Will match addr1 and the N lines following addr1.
addr1,~N
Will match addr1 and the lines following addr1 until the next line whose input line number is a multiple of N.

Source:
https://stackoverflow.com/questions/3576139/sed-remove-string-only-in-the-last-line-of-the-file
https://linux.die.net/man/1/sed

Categories: bash, sed

The never-ending REST API design debate by Guillaume Laforge

February 11, 2019 Leave a comment

What should a good REST API look like? Should you use verbs or nouns in your resource paths? How do you handle versioning of APIs? How to deal with partial responses and pagination? Which status codes should I make use of? What about sorting, filtering, and searching? Have you thought about content negotiation, cross-domain access, hypermedia, and authentication?

Guillaume will got through all these topics, offering advice on the best approaches to those questions, and opening up the debate on the various options available, so as to make your Web API at REST, as clean and elegant as possible.

Categories: Interesting Tags: ,

YOW! West 2015 Damian Conway – Everything You Know About Regexes Is Wrong #YOWWest

February 4, 2019 Leave a comment

For most programmers, regular expressions are a riddle wrapped in a mystery inside an enigma shrouded in line-noise. So most sensible programmers either don’t use them at all (and are thereby forced to reinvent worse wheels…badly), or else they fall back on an “evolutionary programming” approach: find an existing regex that looks like it might do, then randomly permute its “genome” over and over again until it appears to work.

In this talk, we’ll go back to basics and discover that regexes mostly aren’t what you think they are, mostly don’t work the way you were taught they did, and mostly shouldn’t be created the way everyone tells you to.

More usefully, we’ll also talk about what regexes really are, how they actually work, and see how normal programmers can make use of their existing software development skills to construct correct and efficient regexes…without selling their souls or losing their minds.

Damian Conway holds a B.Sc. and a Ph.D. in Computer Science.

A widely sought-after speaker and trainer, he is also the author of numerous well-known Open Source software libraries and developer tools, as well as several books and series of articles on programming. Between 2001 and 2010 was Adjunct Associate Professor with the Faculty of Information Technology, Monash University, Australia.

Other technical areas in which he has worked and published include: developer education, presentation skills, programming language design, language paradigms, software engineering, testing and debugging, documentation systems, natural language generation, synthetic language generation, emergent systems, image morphing, human-computer interaction, geometric modelling, the psychophysics of perception, nanoscale simulation, and parsing techniques.

Categories: Interesting Tags:

Useful GPG commands

February 3, 2019 Leave a comment
Categories: Interesting