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
| # Basic benchmarks | |
| # SET key val # 87489.06 | |
| # SETRANGE key2 6 "Redis" # 75757.58 req/s | |
| # INCR key 245 # 70224.72 req/s | |
| # INCRBY key 245 22 # 67114.09 req/s | |
| # EVAL SET key val # 46296.29 req/s | |
| # SETIFHIGHER (set or update key if new value is higher than current) # 41666.67 req/s | |
| # if not exists return OK , if updated return the increment , if not updated return 0 | |
| SCRIPT LOAD "local c = tonumber(redis.call('get', KEYS[1])); if c then if tonumber(ARGV[1]) > c then redis.call('set', KEYS[1], ARGV[1]) return tonumber(ARGV[1]) - c else return 0 end else return redis.call('set', KEYS[1], ARGV[1]) end" |
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
| for_real = false | |
| idle_max = 86400 | |
| # redis_constant is a connection pool, the variable c is a single redis client | |
| (clients = redis_constant.with { |c| c.method_missing("client", "list") }.split("\n")).nil? | |
| (addrs = clients. | |
| # select idle clients | |
| select { |client_string| client_string.match(/idle=([\d|\.|:]*)/).captures.first.to_i > idle_max }. | |
| # return ip addresses | |
| map { |client_string| client_string.match(/addr=([\d|\.|:]*)/).captures.first }).nil? |
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
| #!/bin/bash | |
| # This script will migrate schema and data from a SQLite3 database to PostgreSQL. | |
| # Schema translation based on http://stackoverflow.com/a/4581921/1303625. | |
| # Some column types are not handled (e.g blobs). | |
| # | |
| # See also: | |
| # - http://stackoverflow.com/questions/4581727/convert-sqlite-sql-dump-file-to-postgresql | |
| # - https://gist.github.com/bittner/7368128 |
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
| <div id="mainTemplate"> | |
| <div id="contentOne">Content One</div> | |
| <div id="contentTwo"> {{ somevar }} </div> | |
| <div id="contentThree"></div> | |
| </div> |
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
| wget -q -O - https://raw.github.com/gist/2204072/install_tmux_1.6_on_ubuntu_10.04.sh | sudo bash |
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 'bundler/capistrano' | |
| default_run_options[:pty] = true | |
| ssh_options[:forward_agent] = true | |
| set :user, "<<your webfaction user>>" | |
| set :domain, "#{user}@<<your domain>>" | |
| set :application, "<<your application>>" | |
| set :repository, "<< your ssh repository link >>" | |
| set :deploy_to, "/home/#{user}/webapps/#{application}" |
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
| upstream myapp { | |
| server unix:///myapp/tmp/puma.sock; | |
| } | |
| server { | |
| listen 80; | |
| server_name myapp.com; | |
| # ~2 seconds is often enough for most folks to parse HTML/CSS and | |
| # retrieve needed images/icons/frames, connections are cheap in |
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 'formula' | |
| class Pdftk < Formula | |
| url 'http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk-1.44-src.zip' | |
| homepage 'http://www.pdflabs.com/' | |
| md5 '9eb50fffcd621a627d387750c60982b4' | |
| depends_on 'gcc' # with "--enable-java" option , required "Homebrew-alt" . | |
| # via : https://github.com/adamv/homebrew-alt/ | |
| def install |
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
| app.csrf_token = $('meta[name="csrf-token"]').attr('content') | |
| $.ajaxSetup | |
| beforeSend: (xhr, settings) -> | |
| return if (settings.crossDomain) | |
| return if (settings.type == "GET") | |
| if (app.csrf_token) | |
| xhr.setRequestHeader('X-CSRF-Token', app.csrf_token) |
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
| module InterruptibleSleep | |
| def interruptible_sleep(seconds) | |
| @_sleep_check, @_sleep_interrupt = IO.pipe | |
| IO.select([@_sleep_check], nil, nil, seconds) | |
| end | |
| def interrupt_sleep | |
| @_sleep_interrupt.close if @_sleep_interrupt | |
| end | |
| end |
NewerOlder