Skip to content

Instantly share code, notes, and snippets.

@richhickey
richhickey / bintree.clj
Created March 17, 2011 13:01
Binary Tree benchmark for Clojure 1.3
;; The Computer Language Benchmarks Game
;; http://shootout.alioth.debian.org/
;
;; Adapted from the Java -server version
;
;; contributed by Marko Kocic
;; modified by Kenneth Jonsson, restructured to allow usage of 'pmap'
;; modified by Andy Fingerhut to use faster primitive math ops, and
;; deftype instead of defrecord for smaller tree nodes.
;; https://github.com/jafingerhut/clojure-benchmarks/blob/master/binarytrees/binarytrees.clj-4.clj modified by RH for 1.3
@denmarkin
denmarkin / mysql.god.rb
Created May 10, 2011 07:45
God recipes examples for Rackspace Cloud (Ubuntu) with resque and php-cgi. Try any of them with "sudo god -c /path/to/config -D"
God.watch do |w|
w.name = "mysqld"
w.interval = 30.seconds # default
w.start = "service mysql start"
w.stop = "service mysql stop"
w.restart = "service mysql restart"
w.start_grace = 20.seconds
w.restart_grace = 20.seconds
w.pid_file = "/var/lib/mysql/hostname.pid"
@parndt
parndt / gist:1011435
Created June 7, 2011 00:32
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
@dshaw
dshaw / application.js
Created June 8, 2011 17:43 — forked from fabware/application.js
socket.io application and haproxy configuration
var express = require('express');
var redis = require('redis');
const serverType = process.argv[2];
const serverHost = process.argv[3];
const serverPort = parseInt(process.argv[4]);
const redisPort = 6379;
const redisHost = '127.0.0.1';
# Pass in the name of the site you wich to create a cert for
domain_name = ARGV[0]
if domain_name == nil
puts "Y U No give me a domain name?"
else
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'"
system "cp #{domain_name}.key #{domain_name}.key.bak"
@noonat
noonat / extract_pak.c
Created August 5, 2011 14:13
Extract files from a Quake PAK
// Extract a PAK file (from Quake 1 and 2)
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
typedef struct {
char id[4];
anonymous
anonymous / gist:1401035
Created November 28, 2011 16:45
#Main frontend
frontend app 0.0.0.0:80
mode tcp
# allow for many connections, with long timeout
maxconn 200000
timeout client 86400000
default_backend webapp
# two URLs need to go to the node pubsub backend
@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active June 5, 2024 22:16 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@beanmoss
beanmoss / RestControllerTrait.php
Created April 18, 2015 12:12
Playing with Laravel Lumen: simple RESTful trait.
<?php namespace App\Http\Controllers;
use Illuminate\Http\Request;
trait RestControllerTrait
{
public function index()
{
$m = self::MODEL;
return $this->listResponse($m::all());
@DmitryTsepelev
DmitryTsepelev / 1_graphql_ruby_n_plus_one.md
Last active January 5, 2024 15:16
N+1 in graphql-ruby

How to run examples:

  1. Run $ createdb nplusonedb to create DB
  2. Run specs $ rspec demo.rb