Skip to content

Instantly share code, notes, and snippets.

View danryan's full-sized avatar
🔥

Dan Ryan danryan

🔥
View GitHub Profile
@kennethkalmer
kennethkalmer / deploy.rb
Created October 4, 2012 10:16
Capistrano config for near-zero downtime deployments
#
# Based heavily on the deployment recipe dicussed in the article at
# http://ariejan.net/2011/09/14/lighting-fast-zero-downtime-deployments-with-git-capistrano-nginx-and-unicorn
# but tweaked to fit our setup...
#
# NO WARRANTY, IMPLIED OR OTHERWISE
#
# Multistage setup
set :stages, %w(production staging)
if ENV['ES_CACHE']
config.vm.provision :shell do |shell|
shell.inline = "apt-get update; apt-get install -y apt-cacher-ng bindfs; service apt-cacher-ng stop; bindfs --mirror=apt-cacher-ng:@apt-cacher-ng /vagrant/cache /var/cache/apt-cacher-ng; echo 'Acquire::http { Proxy \"http://127.0.0.1:3142\"; };' > /etc/apt/apt.conf.d/01proxy; echo 'Acquire::https::Proxy::apt.repo.enstratus.com \"DIRECT\";' >> /etc/apt/apt.conf.d/01proxy; service apt-cacher-ng start"
end
end
@jbyck
jbyck / gist:5036615
Created February 26, 2013 07:19
403 Error in Chef Run List
"exception": "Net::HTTPServerException: deploy_revision[wikiposit] (/var/chef/cache/cookbooks/application/providers/default.rb line 122) had an error: Net::HTTPServerException: template[/etc/unicorn/wikiposit.rb] (/var/chef/cache/cookbooks/unicorn/definitions/unicorn_config.rb line 38) had an error: Net::HTTPServerException: 403 \"Forbidden\"",
"backtrace": [
"/opt/chef/embedded/lib/ruby/1.9.1/net/http.rb:2632:in `error!'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:259:in `block in streaming_request'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:280:in `retriable_rest_request'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:236:in `streaming_request'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/rest.rb:97:in `get'",
"/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.4.0/lib/chef/cookbook/remote_file_vendor.rb:63:in `get_filename'",
"/opt/chef/embedded/lib/ruby/gems
@mudge
mudge / logstash.conf
Last active April 17, 2019 07:58
A grok pattern for Rails 3.2 logs for use with logstash. Assumes that you have a multiline filter to combine Rails logs into one line and only one worker is logging to a file (c.f. https://gist.github.com/mudge/5063930).
multiline {
tags => ["rails"]
pattern => "^Started"
negate => true
what => "previous"
}
@gnarf
gnarf / ..git-pr.md
Last active January 27, 2025 01:56
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
@andreas
andreas / gist:5432990
Created April 22, 2013 07:14
Use [rblineprof](https://github.com/tmm1/rblineprof) for profiling Rails apps
class RBLineProfiler
WALL_TIME_LIMIT = 10e3 # ms
def initialize(app)
@app = app
end
def call(env)
result = nil
profile = lineprof(/./) { result = @app.call(env) }
@andrewkatz
andrewkatz / .zshrc
Created May 6, 2013 17:22
Simple command for ssh'ing into rails hosts. Thanks to @trobrock for the ruby script.
# Usage:
# rails_ssh release cron
# => ssh [email protected]
rails_ssh()
{
username=$1
hostname="$(ruby $HOME/Scripts/parse_cap_config.rb $2)"
ssh $username@$hostname
}
@trobrock
trobrock / notify.rb
Created June 20, 2013 17:06
weechat ruby notifications, thanks @joelteon
require 'ruby_gntp'
Weechat.register "notify", "otters", "0.2", "GPL", "notify: A real time notification system for weechat", "", ""
Settings = {
:show_hilights => "on",
:show_priv_msg => "on"
}
def notify_show data, buffer, empty, tagsn, isdisp, ishilight, prefix, msg
@allanmac
allanmac / sha256.cu
Last active May 2, 2025 07:10
A CUDA SHA-256 subroutine using macro expansion
// -*- compile-command: "nvcc -m 32 -arch sm_35 -Xptxas=-v,-abi=no -cubin sha256.cu"; -*-
//
// Copyright 2013 Allan MacKinnon <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
@lyrixx
lyrixx / segfault-finder.php
Last active August 15, 2023 21:17
How to find a segfault in PHP
<?php
register_tick_function(function() {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
$last = reset($bt);
$info = sprintf("%s +%d\n", $last['file'], $last['line']);
file_put_contents('/tmp/segfault.txt', $info, FILE_APPEND);
// or
// file_put_contents('php://output', $info, FILE_APPEND);
});