This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Do you like python named parameters (kvargs) ? | |
# Well, you can have it in bash too!! | |
$ function myfunc() { local $*; echo "foo=$foo, bar=$bar"; } | |
$ myfunc bar=world foo=hello | |
foo=hello, bar=world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ VAR='XOXOXOX' | |
$ echo ${VAR/X/.} ## first occurence only (anywhere) | |
.OXOXOX | |
$ echo ${VAR//X/.} ## all occurences | |
.O.O.O. | |
$ VAR='OXOXOX' | |
$ echo ${VAR/#X/.} ## first occurence (only if beginning match) | |
OXOXOX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 1 - Create an account in http://movies.io and setup a RSS for your movies | |
#### | |
## 2 - Install and configure flexget | |
#### | |
$ sudo easy_install flexget | |
$ cat <<EOF > ~/.flexget/config.yml | |
feeds: | |
movies.io: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This should extract the value of a variable from a text file. | |
It works fine with bash/sh and makefile variables. | |
Had to use 2 sed()s to deal with name='value' cases. | |
Fixes are welcome. | |
$ VAR_NAME=PREFIX | |
$ sed --version | |
GNU sed version 4.1.5 | |
$ cat filename.conf | \ | |
sed -ne \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' metatuple - Recursive namedtuple from arbitrary dict | |
After 2 hours of intensive coding and some tequila sips I found | |
a "simple" solution to create a namedtuple from any dictionary, | |
recursivelly creating any necessary namedtuple. | |
Probably there are tons of easiest ways of doing that, like some | |
well documented method or standart function in the python library, | |
but that wouldn't be fun.''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i, j in { 'a': 1, 'b': 2 }.iteritems(): | |
print i, j | |
for i, j in [ ('a', 1), ('b', 2) ]: | |
print i, j |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Section "InputDevice" | |
Identifier "touchpad" | |
Driver "synaptics" | |
Option "LeftEdge" "1766" | |
Option "RightEdge" "5382" | |
Option "TopEdge" "1645" | |
Option "BottomEdge" "4563" | |
Option "FingerLow" "25" | |
Option "FingerHigh" "30" | |
Option "FingerPress" "256" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Just found the amazing builtin 'mapfile', perfect | |
# for substitution variable inside a file by its values. | |
## | |
mateus@mateus:/tmp$ cat input.txt | |
a = $a | |
b = $b | |
mateus@mateus:/tmp$ echo a=$a, b=$b | |
a=1, b=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ FILE=/some/path/to/file.txt | |
################################### | |
### Remove matching suffix pattern | |
################################### | |
$ echo ${FILE%.*} # remove ext | |
/some/path/to/file | |
$ FILE=/some/path/to/file.txt.jpg.gpg # note various file exts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHOW_APPLICATION: | |
404 Not Found: | |
101: "Application '#{id}' not found" | |
127: "Domain '#{domain_id}' not found" | |
UPDATE_CARTRIDGE: | |
404 Not Found: | |
163: "Cartridge '#{cartridge_name}' for application '#{app_id}' not found" | |
101: "Application '#{app_id}' not found for domain '#{domain_id}'" |
OlderNewer