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
#--- Credit: http://kzk9.net/unicorn-configuration-on-heroku | |
# config.ru | |
# This file is used by Rack-based servers to start the application. | |
require ::File.expand_path('../config/environment', __FILE__) | |
# Unicorn self-process killer |
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
#8GB => set count=8192 | |
#16GB => set count=16384 <-- for m2.xlarge with 16GB memory, as per official Redis documentation, use the same amount of swap as there is memory | |
sudo dd if=/dev/zero of=/var/swapfile bs=1M count=1657 && | |
sudo chmod 600 /var/swapfile && | |
sudo mkswap /var/swapfile && | |
echo /var/swapfile none swap defaults 0 0 | sudo tee -a /etc/fstab && | |
sudo swapon -a | |
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
#encoding: utf-8 | |
require 'rubygems' | |
require 'bundler/setup' | |
require 'redis' | |
class RedisKeyCleaner | |
attr_accessor :redis, :temp_file_path |
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
// Contains questionable Javascript and Regex. You have been warned. | |
function () { | |
var counting_object = { | |
count_hash : {}, | |
clean_endpoint : function(endpoint) { | |
return endpoint.replace(/posts\/[\d]+/,'posts/:id') |
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
// Contains questionable Javascript and Regex. You have been warned. | |
function () { | |
var counting_object = { | |
count_hash : {}, | |
clean_endpoint : function(endpoint) { | |
return endpoint.replace(/(\/[\w]+\/[\d]+)/, function(v){return v.replace(/\/[\d]+/, "/:id")}) |
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
// Contains questionable Javascript and Regex. You have been warned. | |
function () { | |
var counting_object = { | |
count_hash : {}, | |
clean_endpoint : function(endpoint) { | |
return endpoint.replace(/(\/[\w]+\/[\d]+)/, function(v){return v.replace(/\/[\d]+/, "/:id")}) |
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 listOfConsecutivePairsInRange(start: Double, end: Double, step: Double = 1) = { | |
val initialRange = start to end by step | |
def splitIntoConsecutivePairs(xs: List[Double]):List[(Double,Double)] = { | |
xs match { | |
case x::y::Nil => { | |
if (y != end) { | |
List((x, end)) | |
} else { | |
List((x, y)) |
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
package org.beachape.support | |
object RichRange { | |
implicit def range2RichRange(r: Range) = RichRange(r) | |
} | |
case class RichRange(range: Range) { | |
def listOfConsecutivePairsInSteps(step: Int) = { | |
val steppedRange = range by step |
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 cleanout_nonce(key) | |
loop do | |
print "." | |
break unless $redis.spop key | |
end | |
end | |
cleanout_nonce("nonce_set") |
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
# encoding: UTF-8 | |
class String | |
def contains_cjk? | |
!!(self =~ /\p{Han}|\p{Katakana}|\p{Hiragana}|\p{Hangul}/) | |
end | |
def for_each_continous_cjk_alpha_part | |
split_into_cjk_alpha_phrases.each.with_index do |part, i| |
OlderNewer