Skip to content

Instantly share code, notes, and snippets.


Jan T. Sott idleberg

View GitHub Profile
pguillory / gist:729616
Created December 5, 2010 23:51
Hooking into Node.js stdout
View gist:729616
var util = require('util')
function hook_stdout(callback) {
var old_write = process.stdout.write
process.stdout.write = (function(write) {
return function(string, encoding, fd) {
write.apply(process.stdout, arguments)
callback(string, encoding, fd)
rtomayko / optparse-template.rb
Last active March 12, 2023 21:44
Ruby optparse template
View optparse-template.rb
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
Ocramius / Notes
Created October 15, 2011 20:09
PHP Benchmark for array_search against foreach
View Notes
Tested on PHP 5.3.8 on Mac OS 10.6.8.
These results are just micro-optimization, which is quite useless, but the foreach construct seems to be always slower than array_search.
I expected much better results, but I frankly don't know why I didn't get them this time. Unfortunately I don't have the previous benchmark anymore.
robnyman / blob-filereader-localStorage.js
Last active September 14, 2021 13:58
Get file as a blob, read through FileReader and save in localStorage
View blob-filereader-localStorage.js
// Getting a file through XMLHttpRequest as an arraybuffer and creating a Blob
var rhinoStorage = localStorage.getItem("rhino"),
rhino = document.getElementById("rhino");
if (rhinoStorage) {
// Reuse existing Data URL from localStorage
rhino.setAttribute("src", rhinoStorage);
else {
// Create XHR and FileReader objects
var xhr = new XMLHttpRequest(),
kevinSuttle /
Last active March 25, 2023 13:07 — forked from lancejpollard/
List of Usable HTML Meta and Link Tags
krypton / colormeter.js
Created April 16, 2012 17:22
Calculate difference in percentage between 2 hex colors
View colormeter.js
function color_meter(cwith, ccolor) {
if (!cwith && !ccolor) return;
var _cwith = (cwith.charAt(0)=="#") ? cwith.substring(1,7) : cwith;
var _ccolor = (ccolor.charAt(0)=="#") ? ccolor.substring(1,7) : ccolor;
var _r = parseInt(_cwith.substring(0,2), 16);
var _g = parseInt(_cwith.substring(2,4), 16);
var _b = parseInt(_cwith.substring(4,6), 16);
kasparsd /
Last active March 3, 2023 13:44
Using Git with Subversion Mirroring for WordPress Plugin Development
iambibhas / scopes.txt
Last active March 28, 2023 16:00
Sublime Text 2: Snippet scopes
View scopes.txt
Here is a list of scopes to use in Sublime Text 2 snippets -
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
desandro /
Last active December 30, 2021 23:11
Bower logo

In addition to awesome docs #228, Bower deserves a proper logo. See below for sketches. I'm curious if you think any of these are worth me putting more effort into.

Take a look at Yeoman right now.

Screen Shot 2013-02-19 at 4 43 10 PM

The other two entities have awesome logos. Bower's got to represent.

bosskovic / I18n_test.php
Last active March 14, 2023 02:13
Example of PHP file translated using gettext
View I18n_test.php
if (isset($_GET["locale"])) {
$locale = $_GET["locale"];
else if (isset($_SESSION["locale"])) {
$locale = $_SESSION["locale"];
else {