Skip to content

Instantly share code, notes, and snippets.

location /socket.io {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
@sikanrong
sikanrong / transaction_buckets_models.rb
Last active August 29, 2015 13:59
Hypothetical Bucket-Transaction Architecture
class TransactionItem < ActiveRecord::Base
has_many :transaction_bucket_item_links
before_save :sub_account_balance
before_destroy :sub_account_balance, :destroy_links
after_save :add_account_balance
def destroy_links
TransactionBucketItemLink.destroy(:all, ["transaction_item_id = ?", self.id])
end
Alexs-MacBook-Pro:rv8 sikanrong$ git remote -v
origin git@bitbucket.org:sikanrong/rv8.git (fetch)
origin git@bitbucket.org:sikanrong/rv8.git (push)
upstream git@bitbucket.org:restoin/rv8.git (fetch)
upstream git@bitbucket.org:restoin/rv8.git (push)
Alexs-MacBook-Pro:rv8 sikanrong$ git pull upstream market
From bitbucket.org:restoin/rv8
* branch market -> FETCH_HEAD
Already up-to-date.
Alexs-MacBook-Pro:rv8 sikanrong$ git push upstream market
#!/usr/bin/env ruby
#Alex Pilafian - Zeller Algorithm. 2015
#https://docs.google.com/document/d/1BKHrV0SEhblnPUgcISKV1oIJ8ejC6jjhtXs_jX8CbWU/edit
$days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
print "Enter your date of birth (dd/mm/yyyy):\n"
input = gets.chomp
#!/usr/bin/env ruby
#Alex Pilafian - "Manchester United"-themed data parsing program. 2015
#https://docs.google.com/document/d/1NWtzQj1irzL86cv3A48HVxWdT2tRpJw7UQ8dWYHaHgA/edit?usp=drive_web
#The $-sign just denotes a global variable.
$scores = "Manchester United 1 Chelsea 0, Arsenal 1 Manchester United 1, Manchester United 3 Fulham 1, Liverpool 2 Manchester United 1, Swansea 2 Manchester United 4"
def is_number?(str)
scores = "Manchester United 1 Chelsea 0, Arsenal 1 Manchester United 1, Manchester United 3 Fulham 1, Liverpool 2 Manchester United 1, Swansea 2 Manchester United 4"
games_won = 0
games_lost = 0
games_drawn = 0
goals_scored = 0
goals_conceded = 0
scores_array = scores.split(",")
@sikanrong
sikanrong / animate.js
Last active August 29, 2015 14:22
javascript animate loop
var animate = function(){
var frameDuration = 1000; //milliseconds
var my = this;
setTimeout(function(){
//do animate stuff here. Use "my" in place of "this" to access the outer object scope within the setTimeout function, if needed.
animate(); //re-calls itself.
}, frameDuration);
}
<html>
<body>
<script type="text/javascript">
var newDiv = $('<div/>', {
id: 'elementID',
class: 'className'
}).appendTo('body');
</script>
</body>
</html>
zE(function(){$zopim(function(){
$zopim.livechat.window.setOffsetHorizontal(100);
$zopim.livechat.window.setOffsetVertical(200);
});});
zE(function(){$zopim(function() {
$zopim.livechat.setLanguage('sv');
})});
zE(function(){$zopim(function() {
{
"cities": [
{
"name": "Madrid",
"Country": 1,
"lat": 40.429203,
"lng": -3.694986
},