Skip to content

Instantly share code, notes, and snippets.

@jperkins
jperkins / gist:1642322
Created January 19, 2012 20:17
Great Books for Kids

General Books ---------------------------

"The Best Christmas Pageant Ever" by Barbara Robinson Wikipedia: http://en.wikipedia.org/wiki/The_Best_Christmas_Pageant_Ever

  • One of my [JNP] favorites. I remember laughing hysterically at the description of the kids playing a game based on slamming the garage door
@jperkins
jperkins / GEM_NAME.gemspec
Created July 14, 2011 20:57 — forked from blowmage/GEM_NAME.gemspec
Simple Gem Template
require "rake"
Gem::Specification.new do |s|
s.name = "GEM_NAME"
s.version = "0.1.0"
s.summary = "GEM_SUMMARY (short)"
s.description = "GEM_DESCRIPTION (longer)"
s.homepage = "http://example.com/GEM_NAME"
s.authors = ["GEM_AUTHOR_NAME"]
s.email = "GEM_AUTHOR_EMAIL"
/*
* Fabrizio Calderan, twitter @fcalderan, 2010.11.02
* I had an idea: could Inception movie be explained by a few javascript closures
* and variable resolution scope (just for fun)?
*
* Activate javascript console =)
*/
<script>
console.group("inception movie");
Places to Visit and Things To Do for Nerds Visiting Chicago
@jperkins
jperkins / gist:564631
Created September 3, 2010 21:54 — forked from tmm1/gist:61762
> - In ruby 1.8.x, what is the functional difference between rb_thread_schedule and rb_thread_select?
rb_thread_schedule() is the guts of the thread scheduler, it traverses
over the linked list of threads (several times) to find the next one
to switch into. The function is long (250 lines) and messy, and covers
all the combinations of thread status (RUNNABLE, TO_KILL, STOPPED,
KILLED) and wait state (FD, SELECT, TIME, JOIN, PID).
If there are no threads doing i/o or waiting on a timeout,
rb_thread_schedule() picks another thread from the list (considering
In response to all the responses to:
http://twitter.com/rtomayko/status/1155906157
You should never do this in a source file included with your library,
app, or tests:
require 'rubygems'
The system I use to manage my $LOAD_PATH is not your library/app/tests
#!/usr/local/bin/ruby
require 'rubygems'
require 'mongrel'
# Add the request handler directory to the load path.
# Files in the 'app/controllers' dir will be mapped against the first segment
# of a URL
$LOAD_PATH.unshift( File.join( File.dirname( __FILE__ ) , 'app/controllers' ) )
PORT = 4000
var xyz = {};
xyz.receiverURL = '.res/save-proxy-image.php';
xyz.resizeImage = function(img, dstw, dsth, fit) {
try {
var w = dstw;
var h = dsth;
if (img.naturalWidth === 0 || img.naturalHeight === 0)
return null;
if (img.naturalWidth > dstw || img.naturalHeight > dsth) {
if (fit) {
# estimate the duration of an ALTER TABLE statement in mysql
# this code estimates the worst case, as most of the time, an ALTER will result in a table that is smaller than the original
percentage = 0
interval = 10
while(true) do
sleep(interval)
new_percentage = (File.size('#sql-5316_1a.ibd')*1.0 / File.size('moves.ibd')*1.0)
change = new_percentage - percentage
intervals = 1.0/change
From bb2a78858cffa7c6937642986e9aca1a4f862c0d Mon Sep 17 00:00:00 2001
From: Ilya Grigorik <[email protected]>
Date: Thu, 10 Jun 2010 00:46:48 -0400
Subject: [PATCH] async rails3
---
Gemfile | 6 ++++++
app/controllers/widgets_controller.rb | 6 ++++++
app/models/widget.rb | 2 ++
config.ru | 1 +