Skip to content

Instantly share code, notes, and snippets.

View gist:36646
# From http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
function is_git_svn {
git config --get svn-remote.svn.url > /dev/null
if [ $? == 0 ]; then
echo "(svn) "
View gist:47992
require 'benchmark'
N = 1_000_000
a = []
100.times { a << (rand(10) > 5 ? true : false) }
Benchmark.bm(20) { |x|
x.report("String#to_i(base)") {
View gist:55085
CmdUtils.CreateCommand({
name: "wowhead",
arguments: [{role: 'object', nountype: noun_arb_text, label: 'query'}],
icon: "http://www.wowhead.com/favicon.ico",
homepage: "http://www.wowhead.com",
author: { name: "Carlos Moll", email: "carlos@tallon.org"},
license: "MPL,GPL",
description: "Search Wowhead",
help: "Search for an item, quest, NPC, etc on Wowhead",
View gist:57662
#!/usr/bin/perl -w
#
# Simple Flash Socket Policy Server
# http://www.lightsphere.com/dev/articles/flash_socket_policy.html
#
# Copyright (C) 2008 Jacqueline Kira Hamilton
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
View gist:59482
[user]
name = Jason Roelofs
email = jameskilton@gmail.com
[color]
diff = auto
status = auto
branch = auto
[color "branch"]
current = yellow reverse
local = yellow
View scene.cpp
// leaks memory because a copy of the value of scene is returned and the pointer is never deleted
Image Scene::draw() const {
Image scene = *(new Image());
// build the scene
return *scene;
}
// doesn't leak memory, but is ugly
View gist:62081
// Turn this:
$.post("/cameras/" + cameraId + "/wireless", {
"_method": "delete"
},
function(response) {
$.prompt(
"<h3>Disconnecting from Wireless</h3>" +
"<ul><li class=\"processing\">Sending Request to Camera</li></ul>", {
View gist:62789
def some_method
4
end
some_method {|ret_val| puts ret_val} #=> 4
View gist:69691
diff --git a/lib/gamebox/template_app/crate_boot.c b/lib/gamebox/template_app/crate_boot.c
index ebb0c76..0126574 100644
--- a/lib/gamebox/template_app/crate_boot.c
+++ b/lib/gamebox/template_app/crate_boot.c
@@ -173,6 +173,9 @@ int main( int argc, char** argv )
/* initialize all extensions */
Init_ext();
+ /* Force setup of amalgamite */
+ Init_amalgalite3();
View gist:71708
>> "#1123:somethinghere" =~ /(#[\d.]+)(?:\(.+?\))?/
=> 0
>> $1
=> "#1123"
You can’t perform that action at this time.