Skip to content

Instantly share code, notes, and snippets.

@brasic
brasic / gist:1650177
Created January 20, 2012 23:22 — forked from bibendi/gist:1315929
make action and fragment caching of rails 3.0.9 compatible with content_for
module ActionController
class Metal
attr_internal :cached_content_for
end
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?
@brasic
brasic / gist:2961109
Created June 20, 2012 17:40
Building a CentOS 6 Box for Vagrant
@brasic
brasic / knife_output
Created November 1, 2012 21:11
knife cookbook upload problem
brasca@handel:~$ knife cookbook upload apache2 -V -V
DEBUG: Using configuration from /home/brasca/.chef/knife.rb
DEBUG: No chefignore file found at /home/brasca/gitnon/countertop/cookbooks/chefignore no files will be ignored
DEBUG: No chefignore file found at /home/brasca/ENV['HOME']}/chef-repo-shared/cookbooks/chefignore no files will be ignored
DEBUG: Signing the request as brasic
DEBUG: Sending HTTP Request via GET to chef.pearsonaidevelopment.com:4000/cookbooks
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 200 OK
DEBUG: content-type: application/json; charset=utf-8
DEBUG: connection: close
@brasic
brasic / output
Created November 6, 2012 22:51
chef cookbook problem
brasca@handel:~/.chef$ knife cookbook upload apache2 -V -V
DEBUG: Using configuration from /home/brasca/.chef/knife.rb
DEBUG: No chefignore file found at /home/brasca/gitnon/countertop-aidevops/cookbooks/chefignore no files will be ignored
DEBUG: Signing the request as brasca
DEBUG: Sending HTTP Request via GET to chef.pearsonaidevelopment.com:4000/cookbooks
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 200 OK
DEBUG: content-type: application/json; charset=utf-8
DEBUG: connection: close
DEBUG: server: thin 1.3.1 codename Triple Espresso
@brasic
brasic / .gitignore
Created November 30, 2012 18:59 — forked from karmi/.gitignore
`tail -f` in Node.js and WebSockets
.DS_Store
*.log
tmp/
@brasic
brasic / Timings.txt
Created December 3, 2012 18:43 — forked from jasonroelofs/Timings.txt
Using Go for embarrassingly parallel scripts
] wc -l domains.txt
783 domains.txt
] time go run domain_lookup_parallel.go
real 0m5.743s
user 0m0.359s
sys 0m0.355s
] time go run domain_lookup_sequential.go
@brasic
brasic / s3checker.go
Last active December 26, 2015 04:38
Quick and dirty S3 checker script
package main
import (
"bufio"
"fmt"
"launchpad.net/goamz/aws"
"launchpad.net/goamz/s3"
"os"
"sort"
"strconv"
@brasic
brasic / gist:8788958
Last active August 29, 2015 13:55 — forked from trcarden/gist:3295935
simulating a real https site in localhost:3000 (OSX)
running https://yourssldomain.com
# generate keys, run in ~/.sslcert
openssl genrsa -des3 -out server.orig.key 2048
openssl rsa -in server.orig.key -out server.key
openssl req -new -key server.key -out server.csr
# set Common Name: yourssldomain.com
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
echo "127.0.0.1 yourssldomain.com" | sudo tee -a /private/etc/hosts
@brasic
brasic / aliases.sh
Created August 6, 2014 16:00
Alias to list all specs created or modified since branching from master
# run all specs created or modified since branching from master
# put this in ~/.bash_profile
alias recentspecs='git log --name-status master.. | egrep '^[MA].+spec.rb$' | cut -f2 | uniq'
# example:
#
# $ bundle exec rspec `recentspecs`
# .................
#
# Finished in 0.6187 seconds
@brasic
brasic / clear_redis_script.rb
Last active October 13, 2020 19:52
Clear a large number of redis keys by pattern using SCAN and pipelining
#!/usr/bin/env ruby
require 'redis'
# Clear a large number of keys matching a pattern using SCAN and
# pipelining to avoid killing the server.
class ClearKeys
def initialize(pattern, host='localhost', postprocess_pattern=nil)
@redis = Redis.new(host: host)
@pattern = pattern