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 module1 = function(param1, param2) { | |
var m_param1 = param1; | |
var m_param2 = param2; | |
var private_method = function(param3) { | |
return param3 + m_param1 + m_param2; | |
}; | |
return { | |
public_method1: function(param1) { |
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
# bootstrapping new node: | |
knife bootstrap <hostname> -x <username> -P <password> --sudo | |
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
<meta property="product:price:amount" content="0.99"/> | |
<meta property="product:price:currency" content="USD"/> | |
<meta property="product:price:amount" content="0.79"/> | |
<meta property="product:price:currency" content="EUR"/> |
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
Unlimited gdb print command: | |
set print elements 0 | |
Print void* string content: | |
p (char *)variable+16 |
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
def age(time) | |
if time.kind_of?(Date) | |
timestamp = time.to_time.to_i | |
elsif time.kind_of?(Time) | |
timestamp = time.to_i | |
else | |
return 0 | |
end | |
(Time.now.to_i - timestamp) / 31536000 |
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
#!/usr/bin/env ruby | |
require 'syslog' | |
require 'net/http' | |
require 'aws-sdk' | |
Syslog.open | |
AWS.config({ | |
:access_key_id => '<iam user key>', | |
:secret_access_key => '<iam user secret>' |
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
#rvm | |
\curl -#L https://get.rvm.io | sudo bash -s stable --autolibs=3 --ruby | |
#passenger | |
gem install passenger --pre | |
#nginx | |
#http://nginx.org/en/download.html | |
#set paths |
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
CREATE USER <user> WITH PASSWORD '<password>'; | |
CREATE DATABASE <db>; | |
CREATE SCHEMA <schema>; | |
GRANT ALL PRIVILEGES ON DATABASE <db> TO <user>; | |
GRANT ALL PRIVILEGES ON SCHEMA <schema> TO <user>; | |
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA <schema> TO <user>; | |
#clone db command | |
createdb -O <owner> -T <db> <new db> |
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
#run a command every day at midnight under user ubuntu | |
0 0 * * * ubuntu /<path to your rails project>/crontab.sh bundle exec rake <parameters> > /dev/null 2> /dev/null |
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
//I found out that I’d need to close Facebook dialog that I invoke by calling: | |
FB.ui(<parameters>, <callback>); | |
//Facebook, doesn’t provide any documentation do these dialogs, with one exception - how to open them, so I had to manually trace how they close the dialog window. I found out that it’s a good practice to open all their dialogs like this | |
//open the dialog and save off the reference | |
var dialog = FB.ui(<parameters>, <callback>); | |
... | |
//force close the dialog via it's id accessible through the saved reference |