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
| # | |
| # TEST SERVE WEBAPP | |
| # | |
| echo "hello world" > index.html | |
| nohup python -m SimpleHTTPServer 80 & |
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
| Last login: Tue Aug 28 17:47:56 on ttys015 | |
| $ cat >> ~/.bashrc <<EOS | |
| > function commit_fortune { curl -s "https://whatthecommit.com"| tr -d "\n\r" | perl -pe 's/.*<div id="content"><p>(.*)(?:<\/p><p class="permalink">).*/\1/';} | |
| > function gcf { git commit -am "\$(commit_fortune)";} | |
| > export -f commit_fortune | |
| > export -f gcf | |
| > EOS | |
| $ source ~/.bashrc | |
| $ echo $(commit_fortune) | |
| I'm totally adding this to epic win. +300 |
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
| admin@ip-172-31-90-86:~$ json=$( | |
| cat <<- EOF | |
| { | |
| "foo": "baru-1", | |
| "su": "baru-2", | |
| "dive": "baru-3" | |
| } | |
| EOF | |
| ) | |
| admin@ip-172-31-90-86:~$ echo $json |
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
| Last login: Fri Feb 23 16:16:47 on ttys004 | |
| dev-2:pumpone-rails dev$ irb | |
| irb(main):001:0> def is_int?(arg) | |
| irb(main):002:1> arg.to_s.to_i.to_s == arg.to_s | |
| irb(main):003:1> end | |
| => :is_int? | |
| irb(main):004:0> is_int? 1 | |
| => true | |
| irb(main):005:0> is_int? "1" | |
| => true |
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
| irb(main):016:0> "cool_id".camelcase | |
| => "CoolId" | |
| irb(main):017:0> "cool_id".camelcase(:lower) | |
| => "coolId" | |
| irb(main):018:0> "ServerID".underscore | |
| => "server_id" | |
| irb(main):019:0> "ServerID".underscore.camelcase(:lower) | |
| => "serverId" | |
| irb(main):020:0> "ServerID".camelcase(:lower) | |
| => "serverID" |
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
| irb(main):003:0> "cool_bro".camelize | |
| => "CoolBro" | |
| irb(main):004:0> "cool_bro".camelize(:lower) | |
| => "coolBro" | |
| irb(main):005:0> "cool_bro".camelize() | |
| => "CoolBro" | |
| irb(main):006:0> "cool_bro".camelize(nil) | |
| => nil | |
| irb(main):007:0> "cool_bro".camelize(x) | |
| NameError: undefined local variable or method `x' for main:Object |
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
| require 'active_support/all' | |
| # https://stackoverflow.com/questions/4474028/ruby-on-rails-uncapitalize-first-letter#13083654 | |
| "coolat_cat".camelize(:lower) # => "coolCat" |
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
| # via http://www.seanbehan.com/how-to-get-a-list-of-all-registered-mime-types-in-rails/ | |
| # | |
| # How To Get A List of All Registered Mime Types in Rails | |
| # When mime types are registered they are placed in a hash constant | |
| # EXTENSION_LOOKUP in the module Mime. For reference, the file with | |
| # the relevant code is in rails/action_pack/lib/action_dispatch/http/mime_type.rb available | |
| # on Github at https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/http/mime_type.rb | |
| # | |
| # You can check for existence of certain mime types with | |
| Mime::Type.lookup_by_extension(:json) |
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
| # "Easily load config files | |
| # OK, I might be biased. But having a built-in way to load config files is going to be awesome. | |
| # config_for, new in Rails 4.2, works exactly like you’d expect:" | |
| # http://www.justinweiss.com/articles/the-lesser-known-features-in-rails-4-dot-2/ | |
| Rails.application.config_for(:database) | |
| # => {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"development_db", "username"=>"root", "password"=>nil, "host"=>"localhost", "pool"=>5, "socket"=>"/tmp/mysql.sock"} |
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
| #!/usr/bin/env ruby | |
| require 'rocketamf' | |
| require 'stringio' | |
| # Monkey patch for RocketAMF (0.2.1 gem) that handles IExrternalizable types | |
| # in the input, storing their type as "__as3_type" parameter: | |
| module RocketAMF | |
| module Values #:nodoc: | |
| class TypedHash |