This file contains hidden or 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
| def block_new | |
| puts Proc.new.call | |
| end | |
| block_new{"hello"} | |
| #slow practice | |
| def herp_pass_block(&block) | |
| derp_call_block &block | |
| end |
This file contains hidden or 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
| #Person | |
| class Person | |
| end | |
| #class method | |
| class Person | |
| def self.address | |
| puts "hangzhou" | |
| end | |
| end |
This file contains hidden or 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
| #0> non-block call | |
| Thread.new do | |
| blahbla... | |
| end | |
| #1> 4 simple ways to call shell or cmd | |
| `ps aux` |
This file contains hidden or 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
| #!/bin/bash | |
| # Renames subtitles files according to tv shows names found in a directory | |
| # Acceped syntaxes for season/episode are: 304, s3e04, s03e04, 3x04 (case insensitive) | |
| # | |
| # Usage: | |
| # Put this gist somewhere in your $PATH, like /usr/local/bin/subtitles-renamer | |
| # Chmod +x it | |
| # cd ~/YourHolidaysTvShowsWithSubtitles | |
| # subtitles-renamer |
This file contains hidden or 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
| # backup_db.rb | |
| # Remotely back up and securely download a copy of a MySQL database. | |
| # Can be used in conjunction with cron to run nightly with a crontab like this: | |
| # 0 0 * * * ruby /home/user/scripts/backup_db.rb | |
| # Written by C. Scott Andreas (http://twitter.com/cscotta) | |
| # No warranties, use entirely at your own risk. The author assumes no liability | |
| # for any consequences of this script, including data loss, security breaches, and service unavailability. | |
| # Released under an MIT-style License. Use, modify, and distribute this script as you like. |
This file contains hidden or 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
| #!/bin/sh | |
| # Use socat to proxy git through an HTTP CONNECT firewall. | |
| # Useful if you are trying to clone git:// from inside a company. | |
| # Requires that the proxy allows CONNECT to port 9418. | |
| # | |
| # Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run | |
| # chmod +x gitproxy | |
| # git config --global core.gitproxy gitproxy | |
| # | |
| # More details at http://tinyurl.com/8xvpny |
This file contains hidden or 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
| RED="\[\033[0;31m\]" | |
| YELLOW="\[\033[0;33m\]" | |
| GREEN="\[\033[0;32m\]" | |
| BLUE="\[\033[0;34m\]" | |
| LIGHT_RED="\[\033[1;31m\]" | |
| LIGHT_GREEN="\[\033[1;32m\]" | |
| WHITE="\[\033[1;37m\]" | |
| LIGHT_GRAY="\[\033[0;37m\]" | |
| COLOR_NONE="\[\e[0m\]" |
NewerOlder