Skip to content

Instantly share code, notes, and snippets.

@juil
juil / .gitignore
Created March 2, 2018 23:34 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
#!/bin/sh
SPACE="SERVER$(spacefinder | sed 's/Current Space ID: //')"
mvim --serverlist | grep $SPACE
if [ $? -eq 1 ]
then
mvim --servername $SPACE $*
else
mvim --servername $SPACE --remote $*
fi
@juil
juil / gist:2127754
Created March 19, 2012 22:37 — forked from dhh/gist:1975644
attr_accessible fix
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@juil
juil / gist:1680170
Created January 26, 2012 01:04 — forked from fennb/gist:1284002
nginx microcaching, concurrency 500
$ ab -n 10000 -c 500 http://wp-demo.local/
Server Software: nginx/0.8.54
Server Hostname: wp-demo.local
Server Port: 80
Document Path: /
Document Length: 5728 bytes
Concurrency Level: 500
@juil
juil / gist:1680142
Created January 26, 2012 01:03 — forked from fennb/gist:1283999
Benchmark, wordpress + apache2 + php-fpm + apc / EC2 small
$ ab -n 200 -c 4 http://wp-demo.local:8080/
Server Software: Apache/2.2.17
Server Hostname: wp-demo.local
Server Port: 8080
Document Path: /
Document Length: 5726 bytes
Concurrency Level: 4
@juil
juil / gist:1680141
Created January 26, 2012 01:02 — forked from fennb/gist:1283573
nginx microcaching config example
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 80;
server_name yourhost.domain.com;
# Define cached location (may not be whole site)
@juil
juil / gist:1679989
Created January 26, 2012 00:26 — forked from fennb/gist:1124535
node.js proxy server in 20 lines of JS (via http://www.catonmat.net/http-proxy-in-nodejs/)
var http = require('http');
http.createServer(function(request, response) {
var proxy = http.createClient(80, request.headers['host'])
var proxy_request = proxy.request(request.method, request.url, request.headers);
proxy_request.addListener('response', function (proxy_response) {
proxy_response.addListener('data', function(chunk) {
response.write(chunk, 'binary');
});
proxy_response.addListener('end', function() {
@juil
juil / onchange.sh
Created August 19, 2011 17:43 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@juil
juil / about.md
Created August 9, 2011 16:46 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer