Skip to content

Instantly share code, notes, and snippets.

View claudiouzelac's full-sized avatar
🎯
Focusing

claudiouzelac

🎯
Focusing
View GitHub Profile
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.
@davetron5000
davetron5000 / Checkstyle pre-commit hook
Created December 18, 2008 02:40
Pre Commit Hook for running checkstyle on changed files
#!/usr/bin/perl
#
# Pre-commit hook for running checkstyle on changed Java sources
#
# To use this you need:
# 1. checkstyle's jar file somewhere
# 2. a checkstyle XML check file somewhere
# 3. To configure git:
# * git config --add checkstyle.jar <location of jar>
# * git config --add checkstyle.checkfile <location of checkfile>
@jesstess
jesstess / wget_spider_https
Created November 27, 2010 20:02
Use wget to spider a site as a logged-in user.
http://addictivecode.org/FrequentlyAskedQuestions
To spider a site as a logged-in user:
1. post the form data (_every_ input with a name in the form, even if it doesn't have a value) required to log in (--post-data).
2. save the cookies that get generated (--save-cookies), including session cookies (--keep-session-cookies), which are not saved when --save-cookies alone is specified.
2. load the cookies, continue saving the session cookies, and recursively (-r) spider (--spider) the site, ignoring (-R) /logout.
# log in and save the cookies
wget --post-data='username=my_username&password=my_password&next=' --save-cookies=cookies.txt --keep-session-cookies https://foobar.com/login
@virtualstaticvoid
virtualstaticvoid / dirinbash
Created December 30, 2010 22:09
How to list all subdirectories of a directory in bash
# taken from http://www.daybarr.com/blog/how-to-list-all-subdirectories-of-a-directory-in-bash
To (non-recursively) list all children of a directory in bash
find . -type d -maxdepth 1 -mindepth 1
and to do the same but omitting the .svn directory (subversion's working copy info)
find . -type d -maxdepth 1 -mindepth 1 -not -name .svn
Useful in constructs such as
view sourceprint?
@huljas
huljas / PrintSchemaUpdate.java
Created February 12, 2011 19:45
Example on how you could use Hibernate schema update when creating database migrations for play applications.
package play.modules.migrate;
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import play.Play;
import play.db.DB;
import play.db.DBPlugin;
import play.utils.Utils;
@imathis
imathis / gist_tag.rb
Created June 15, 2011 17:58 — forked from chrisjacob/gist_tag.rb
A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers.
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
@leegao
leegao / Rationale.md
Created July 9, 2011 02:30
JIT for dummies: JIT compiling RPN in python

If you don't care about the explanation, scroll down to find the code, it's 50 some odd lines and written by someone who doesn't know any better. You have been warned.

What it does

This is a very simple proof of concept jitting RPN calculator implemented in python. Basically, it takes the source code, tokenizes it via whitespace, and asks itself one simple question: am I looking at a number or not?

First, let's talk about the underlying program flow. Pretend that you are a shoe connoisseur with a tiny desk. You may only have two individual shoes on that desk at any one time, but should you ever purchase a new one or get harassed by an unruly shoe salesman without realizing that you have the power to say no (or even maybe?), you can always sweep aside one of the two shoes on the desk (the one on the right, because you're a lefty and you feel that the left side is always superior) onto the messy floor, put the other shoe on the right hand side, and then place your newly acquired shoe in

@jbenet
jbenet / current_utc_time.c
Created July 17, 2011 16:17
work around lack of clock_gettime in os x
/*
author: jbenet
os x, compile with: gcc -o testo test.c
linux, compile with: gcc -o testo test.c -lrt
*/
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
@NeoCat
NeoCat / gtest.html
Created September 16, 2011 00:01
Google+ API JavaScript Sample
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Google+ API Test</title>
</head>
<body>
<button onclick="authBegin()">Login</button><br>
<button onclick="getPublicActivities($('user').value)">Get activities of user </button><input id="user" size="10" value="me"><br>
@siddhi
siddhi / pyconindia_dsl.py
Created September 16, 2011 06:33
Domain Specific Languages in Python - Pycon India - 17 Sep 2011
from pyparsing import *
# By default, PyParsing treats \n as whitespace and ignores it
# In our grammer, \n is significant, so tell PyParsing not to ignore it
ParserElement.setDefaultWhitespaceChars(" \t")
def parse(input_string):
def convert_prop_to_dict(tokens):
"""Convert a list of field property tokens to a dict"""
prop_dict = {}