Skip to content

Instantly share code, notes, and snippets.

View comma-first-var.js
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
@macek
macek / myFirst.py
Created May 19, 2010
My First Python
View myFirst.py
def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters
Returns string."""
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
myParams = {
"server": "mpilgrim",
"database": "master",
"uid": "sa",
View affiliate_tree.txt
affiliate
+ referrals
| + referral
| | + player
| | | + rake
| | | + rake
| | + player
| | + rake
| + referral
| | + player
View monty_hall.rb
require "benchmark"
ITERATIONS = (ARGV[0] || 10000).to_i
def pick(set)
set[rand(set.size)]
end
def trial(method)
View Compile.tmCommand
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
response = Net::HTTP.post_form(
URI.parse("http://closure-compiler.appspot.com/compile"),
{
:js_code => STDIN.read,
@macek
macek / access_default_search.rb
Created Sep 24, 2010
Advanced Techniques for Searchlogic 2
View access_default_search.rb
# your custom search
@search = Product.search(params[:search])
# searchlogic default
@search = Product.searchlogic(params[:search])
@macek
macek / .htaccess
Created Sep 29, 2010
Redirect without www on Nginx and Engine Yard
View .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
@macek
macek / Gemfile
Created Nov 16, 2010
Quick Sinatra App on Heroku
View Gemfile
source 'http://rubygems.org'
gem "sinatra"
@macek
macek / sql_sanitizer.php
Created Apr 15, 2011
POS410 SQL sanitizer example
View sql_sanitizer.php
<?php
class Mysql {
static public function query(){
$args = func_get_args();
return mysql_query(call_user_func_array(array("self", "queryf"), $args));
}
static public function queryf(){
@macek
macek / config.mk
Created Oct 18, 2011
configure irssi-xmpp
View config.mk
LDFLAGS += -flat_namespace -undefined warning -fPIC
You can’t perform that action at this time.