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 http = require('http'); | |
var net = require('net'); | |
var url = require('url'); | |
var connections = {}; | |
var subscriber = http.createServer(function(req, res){ | |
params = url.parse(req.url, true); | |
var channel = params.pathname; | |
channel = channel.substr(1, channel.length - 1); | |
if(params.query.callback){ |
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
#!/bin/bash | |
# resize_instance.sh | |
# Resize specified instance with given size | |
# resize_instance.sh [instance_id] [size] | |
# This script is based on http://alestic.com/2010/02/ec2-resize-running-ebs-root | |
E_BADARGS=65 | |
if [ ! -n "$1" ] | |
then |
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
$t = TransactionRecharge.order(:id).first.created_at + 1.month | |
WINNING_TABLE_LOOKUP = {} | |
def winning_rate_of(user) | |
WINNING_TABLE_LOOKUP[user.id] || begin | |
counts = MatchingResult.including(user).where('matching_id > ?', 1707043).group("winner_id = #{user.id}").count | |
WINNING_TABLE_LOOKUP[user.id] = counts.empty? ? 0 : (counts['t'] || 0).to_f / counts.values.sum | |
end | |
end |
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
revelations_by_dates = {} | |
Revelation.select([:id, :created_at]).find_in_batches(batch_size: 10000) do |revelations| | |
revelations.each do |revelation| | |
revelations_by_dates[revelation.created_at.to_date.to_s] ||= 0 | |
revelations_by_dates[revelation.created_at.to_date.to_s] += 1 | |
end | |
end; nil | |
revelations_by_dates.sort.each do |date, revelations_count| |
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
dates_messages = {} | |
Message.where(message_type: 'MESSAGE').select([:message_type, :created_at, :id]).find_in_batches(batch_size: 10000) do |messages| | |
messages.each do |message| | |
dates_messages[message.created_at.to_date.to_s] ||= 0 | |
dates_messages[message.created_at.to_date.to_s] += 1 | |
end | |
end; nil | |
dates_messages.each do |date, messages_count| |
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
dates_matchings = {} | |
Matching.unscoped.select([:id, :created_at]).find_each do |matching| | |
dates_matchings[matching.created_at.to_date.to_s] ||= 0 | |
dates_matchings[matching.created_at.to_date.to_s] += 1 | |
end; nil | |
dates_matchings.sort.each do |date, matchings_count| | |
puts "#{date}\t#{matchings_count}" | |
end; nil |
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
birthyears_users = {} | |
User.unscoped.registered.select([:id, :birthday]).find_each do |user| | |
if user.birthday | |
birthyears_users[user.birthday.year] ||= [] | |
birthyears_users[user.birthday.year] << user.id | |
else | |
birthyears_users[0] ||= [] | |
birthyears_users[0] << user.id | |
end |
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
# Path to your oh-my-zsh configuration. | |
ZSH=$HOME/.oh-my-zsh | |
# Set name of the theme to load. | |
# Look in ~/.oh-my-zsh/themes/ | |
# Optionally, if you set this to "random", it'll load a random theme each | |
# time that oh-my-zsh is loaded. | |
ZSH_THEME="robbyrussell" | |
# Example aliases |
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
# config/deploy.rb | |
# config valid only for Capistrano 3.1 | |
lock '3.1.0' | |
set :application, 'my_app' | |
set :repo_url, '[email protected]:USER/my_app.git' | |
# Default deploy_to directory is /var/www/my_app | |
set :deploy_to, '/var/node/my_app' |
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
1. `$ sudo rpm -ivh https://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-7.noarch.rpm` | |
2. Edit priority of puppetlabs repository | |
``` | |
[puppetlabs-products] | |
name=Puppet Labs Products El 6 - $basearch | |
baseurl=http://yum.puppetlabs.com/el/6/products/$basearch | |
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs | |
enabled=1 |
OlderNewer