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
| your_string.gsub!(/\e\[(\d+)(;\d+)*m/, '') |
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 show_single_key | |
| c = read_char | |
| case c | |
| when " " | |
| puts "SPACE" | |
| when "\t" | |
| puts "TAB" | |
| when "\r" | |
| puts "RETURN" | |
| when "\n" |
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 removeSpecialChars(str) | |
| str.gsub(/[.:;?!-'`&"()\/]/, '') | |
| 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
| class Integer | |
| def to_filesize | |
| { | |
| 'B' => 1024, | |
| 'KB' => 1024 * 1024, | |
| 'MB' => 1024 * 1024 * 1024, | |
| 'GB' => 1024 * 1024 * 1024 * 1024, | |
| 'TB' => 1024 * 1024 * 1024 * 1024 * 1024 | |
| }.each_pair { |e, s| return "#{(self.to_f / (s / 1024)).round(2)}#{e}" if self < s } | |
| 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
| class Numeric | |
| def percent_of(n) | |
| self.to_f / n.to_f * 100.0 | |
| 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
| uri = URI.parse(THE_URL) | |
| https = Net::HTTP.new(uri.host,uri.port) | |
| https.use_ssl = true | |
| https.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
| request = Net::HTTP::Get.new(uri.request_uri) | |
| request["Authorization"] = "Bearer THE_AUTH_TOKEN" | |
| request["Content-Type"] = "THE_TYPE" | |
| body = '' | |
| https.request(request) do |response| | |
| fileSize = response['Content-Length'].to_i |
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 getMarkdownText(str) | |
| str.gsub %r{ | |
| \[ # Literal opening bracket | |
| ( # Capture what we find in here | |
| [^\]]+ # One or more characters other than close bracket | |
| ) # Stop capturing | |
| \] # Literal closing bracket | |
| \( # Literal opening parenthesis | |
| ( # Capture what we find in here | |
| [^)]+ # One or more characters other than close parenthesis |
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
| body { | |
| -webkit-font-smoothing: antialiased; | |
| -moz-osx-font-smoothing: grayscale; | |
| } |
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
| # alias last and save | |
| # use `als c NAME` to chop off the last argument (for filenames/patterns) | |
| als() { | |
| local aliasfile chop x | |
| [[ $# == 0 ]] && echo "Name your alias" && return | |
| if [[ $1 == "c" ]]; then | |
| chop=true | |
| shift | |
| fi | |
| aliasfile=~/.bashrc |
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
| # read man page in preview app | |
| function pman () { | |
| man -t $@ | open -f -a /Applications/Preview.app | |
| } |
OlderNewer