Skip to content

Instantly share code, notes, and snippets.

View kfaustino's full-sized avatar

Kevin Faustino kfaustino

View GitHub Profile
@mperham
mperham / gist:5050311
Created February 27, 2013 18:31
monit causes memcached performance issues
--- a/site-cookbooks/monit/templates/default/memcached.conf.erb
+++ b/site-cookbooks/monit/templates/default/memcached.conf.erb
@@ -2,5 +2,5 @@ check process memcached
with pidfile /var/run/memcached.pid
start program = "/etc/init.d/memcached start"
stop program = "/etc/init.d/memcached stop"
- if failed port 11211 protocol memcache 4 times within 6 cycles then restart
+ if failed port 11211 4 times within 6 cycles then restart
if 5 restarts within 5 cycles then timeout
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :api
draw :account
draw :session
@Maciek416
Maciek416 / gist:991545
Created May 25, 2011 18:20
Crockford-style Backbone.Model with privates
var Circle = function(options){
var private = {
privateSecretToken: "this is a secret"
};
return new (Backbone.Model.extend({
initialize: function(){
console.log("");

Different services I can suggest when a non-tech friend or family member asks me how they can cheaply make a website and possibly use it to sell stuff online.

Website Hosting

@chriseppstein
chriseppstein / 1_variable_behavior.scss
Created January 15, 2011 18:34
Sass's variable semantic are very likely to change in an upcoming release to match proposed behavior of CSS variables. We recommend that you avoid relying on this current behavior to make upgrading in the future simpler.
$font-color: red;
div.red { color: $font-color; }
$font-color: blue;
div.blue { color: $font-color; }
@pkieltyka
pkieltyka / fib.rb
Created November 22, 2010 17:15
Benchmark calculating Fibonacci to n=33 sixteen times in parallel with and without GIL
require 'thread'
require 'benchmark'
N = 33
NUM_THREADS = 16
def fib(n)
if n == 0
0
elsif n == 1
@radar
radar / generate
Created October 24, 2010 08:24
Allows you to run generators outside the context of a Rails application.
#!/usr/bin/env ruby
require 'rails'
require 'rails/generators'
# Set up a fake Rails app.
# Hey, don't diss me. This is how Rails itself does.
# Checkout railties/test/abstract_unit.rb
class Generator < Rails::Application
config.generators do |g|
g.orm :active_record
@dchelimsky
dchelimsky / gist:590557
Created September 21, 2010 21:10 — forked from qrush/gist:590466
describe SomeClass do
freeze { 1.day.from_now }
it "does some stuff with time" do
end
end
# this actually does...
describe SomeClass do
around { |example| Timecop.freeze(1.day.from_now, &example) }
@technoweenie
technoweenie / github_oauth_busy_developer_guide.md
Created May 30, 2010 18:34
GitHub OAuth Busy Developer's Guide

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
@tmm1
tmm1 / gist:329682
Created March 11, 2010 21:31
EM Chat Server Demo
require 'rubygems'
require 'eventmachine'
require 'em-http' # gem install em-http-request
require 'yajl' # gem install yajl-ruby
class String
def bold
"\033[1m#{self}\033[0m"
end
end