Skip to content

Instantly share code, notes, and snippets.

@dsueiro
dsueiro / gist:1230262
Created September 20, 2011 20:43
solid.php
<?php
# Generate solid pgn square
if (count($argv) != 3) die("Bad Format:\nUsage:\tphp gen_image rgb file");
$im = @imagecreate(100, 100)
or die("Cannot Initialize new GD image stream");
$rgb = hex2RGB($argv[1]);
$background_color = imagecolorallocate($im, $rgb['red'], $rgb['green'], $rgb['blue']);
imagepng($im,$argv[2] . '.png');
@dsueiro
dsueiro / gist:1320767
Created October 27, 2011 20:24
Recursive wc -l (excluding .git repo files)
find ./ -not -type d | grep -v ".git/" | xargs wc -l | cut -c 1-8 | awk '{total += $1} END {print total}'
@dsueiro
dsueiro / pubsub.md
Created November 5, 2011 21:20 — forked from addyosmani/pubsub.md
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)

#Four Ways To Do Pub/Sub With jQuery 1.7 and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

@dsueiro
dsueiro / gemspec-usage.md
Created February 13, 2012 03:25 — forked from holman/gemspec-usage.md
test/spec/mini

Just install this in your apps like so:

gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'

@dsueiro
dsueiro / my.cnf
Created April 1, 2012 11:53 — forked from sowawa/my.cnf
mysql config for rackhub
# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
@dsueiro
dsueiro / tree.md
Created April 30, 2012 00:48 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@dsueiro
dsueiro / README.md
Created July 5, 2012 02:25 — forked from mbostock/.block
Stacked Radial Area

This plot might be suitable for showing cyclical trends, though I'm not sure it’s a great idea as the radial display has a number of limitations:

  • The underlying data goes from Sunday to Saturday, but the chart shows continuity from Saturday through to the previous Sunday. Time does not flow backwards, so you might instead prefer to plot two values for Sunday; this would show a discontinuity on opposite sides of the Sunday axis.

  • Displaying the discontinuity requires an open interpolator, rather than cardinal-closed as used here. However, this causes the tangents of the incoming and outgoing lines to no longer be orthogonal to the axis. To display the discontinuity properly, you’d need to write a custom interpolator to generate the correct tangents.

  • Due to the interpolation taking place in Cartesian (rather than polar) coordinates, the intermediate values of the lines do not have the correct radial values: if you tried to measure t

@dsueiro
dsueiro / cfb2.rb
Created July 14, 2012 13:57 — forked from jimweirich/cfb2.rb
Inspired by "Programming with Nothing" http://experthuman.com/programming-with-nothing. See comment below for some details.
require './interface'
puts to_strings(->(limit) {
->(lst) {
->(f) {
->(f) {
->(g) {
->(n) {
f.(g.(g)).(n)
}
}.(->(g) {
@dsueiro
dsueiro / dnsd.rb
Created July 28, 2012 05:20 — forked from peterc/dnsd.rb
Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Requires Ruby 1.9
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
@dsueiro
dsueiro / gist:3262021
Created August 5, 2012 05:31 — forked from anonymous/gist:3260973
Dump all Session Related PHP ini Values
<?php
$paths = array('session.save_path',
'session.name',
'session.save_handler',
'session.auto_start',
'session.gc_probability',
'session.gc_divisor',
'session.gc_maxlifetime',
'session.serialize_handler',