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
def run_pg_fouine(): | |
info = host_info[env.host_string] | |
db_name = info.tags.get('Name') | |
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 0/" /etc/postgresql/9.*/main/postgresql.conf') | |
sudo('/etc/init.d/postgresql reload') | |
time.sleep(30) | |
sudo('perl -pi -e "s/log_min_duration_statement = .*/log_min_duration_statement = 500/" /etc/postgresql/9.*/main/postgresql.conf') | |
sudo('/etc/init.d/postgresql reload') | |
run('tail -n 100000 /var/log/postgresql/postgresql-9.*-main.log > /tmp/pgfouine.txt') | |
run('gzip -f /tmp/pgfouine.txt') |
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
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
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/sh | |
set -u | |
set -e | |
# Example init script, this can be used with nginx, too, | |
# since nginx and unicorn accept the same signals | |
# Feel free to change any of the following variables for your app: | |
APP_ROOT=/k/app_name/current | |
PID=/var/run/unicorn/unicorn.pid | |
ENV=production |
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 XhrHelpers | |
def xhr(path, params = {}) | |
verb = params.delete(:as) || :get | |
send(verb,path, params, "HTTP_X_REQUESTED_WITH" => "XMLHttpRequest") | |
end | |
alias_method :ajax, :xhr | |
end | |
RSpec.configuration.include XhrHelpers, :type => :controller |
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
Choose a ticket class: <select id="tickets"></select> | |
<p id="ticketOutput"></p> | |
<script id="ticketTemplate" type="text/x-jquery-tmpl"> | |
{{if chosenTicket}} | |
You have chosen <b>${ chosenTicket().name }</b> | |
($${ chosenTicket().price }) | |
<button data-bind="click: resetTicket">Clear</button> | |
{{/if}} |
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
desc "migrate", "Runs Sequel migrations" | |
def migrate(version=nil, database_url=DATABASE_URL) | |
require 'sequel' | |
Sequel.extension :migration | |
db = Sequel.connect(database_url, :test => true) | |
puts 'Running migrations...' | |
Sequel::Migrator.apply(db, 'db/migrate', version && version.to_i) | |
dump_schema |
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
def mote(template, params = {}) | |
variables = mote_process_variables(mote_cache, template, params) | |
mote_cache[template] ||= Mote.parse(template, self, variables) | |
mote_cache[template][params] | |
end | |
def mote_file(filename, params = {}) | |
variables = mote_process_variables(mote_files, filename, params) | |
mote_files[filename] ||= Mote.parse(File.read(filename), self, variables) | |
mote_files[filename][params] |
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
# -*- coding: utf-8 -*- | |
module Tpl | |
def self.new_proc(template, variables = []) | |
render_definition = "Proc.new do |__v, __o|\n __v ||= {}; __o ||= ''\n" | |
compile(template, variables, render_definition) | |
render_definition << "__o\nend" | |
eval(render_definition) | |
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
def path matcher | |
lambda {|req| | |
return unless match = req.env["PATH_INFO"].match(/^\/(#{matcher})(\/|$)/) | |
path = match.captures[0] | |
req.env["SCRIPT_NAME"] += "/#{path}" | |
req.env["PATH_INFO"] = "/#{match.post_match}" | |
} | |
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
def daemonize(name = File.basename($0), options = {}) | |
pid_path = options[:pid_path] || File.expand_path("tmp/pids/#{name}.pid") | |
# If the pid file exists, check that the process is actually still running. | |
begin | |
if File.exists?(pid_path) && Process.kill(0, File.read(pid_path).to_i) | |
$stderr.puts "Already running." | |
exit 1 | |
end | |
rescue Errno::ESRCH |