Beating your sleepsort by magnitudes! Takes only SUM(argv) ticks and does not overflow the stack either. Fork the gist if you can reduce the size of ticksort.coffee.
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 <[email protected]> | |
# | |
# Requires Linux, bash and inotifywait (from inotify-tools package). | |
# | |
# To avoid executing the command multiple times when a sequence of |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ActionController::Base | |
def create | |
Post.create(post_params) | |
end | |
def update | |
Post.find(params[:id]).update_attributes!(post_params) | |
end | |
private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
OlderNewer