Skip to content

Instantly share code, notes, and snippets.

View metacritical's full-sized avatar
Creating Black holes.

Pankaj Doharey metacritical

Creating Black holes.
View GitHub Profile
@tomdunning
tomdunning / application.rhtml
Created March 6, 2010 00:03
Growl for rails helper method. Growl flash[:notice] or flash[:error] in rails
<% if flash[:notice] %>
<%= growl_a_flash("Thanks", flash[:notice]) %>
<% end %>
<% if flash[:error] %>
<%= growl_a_flash("Error", flash[:error]) %>
<% end %>
@bytesource
bytesource / csv_parser_csv_gem_benchmark.rb
Created September 4, 2011 03:47
Simple CSV Parser vs. CSV Gem Benchmark
require 'open-uri'
require 'nokogiri'
require 'parslet'
require 'csv'
# --------------------------------------------------
# Auxiliary code
class String
@metacritical
metacritical / gist:1404985
Created November 29, 2011 14:30 — forked from seanlilmateus/gist:1386468
Macruby Face Detection in Mac OS X Lion
framework 'Cocoa'
framework 'QuartzCore'
class NSColor
def toCGColor
colorRGB = self.colorUsingColorSpaceName NSCalibratedRGBColorSpace
components = Array.new(4){Pointer.new(:double)}
colorRGB.getRed components[0], green:components[1], blue:components[2], alpha:components[3]

Continued from Results from the January 2012 Core Skills Course, by Gregory Brown

For our integration exercise we had students build multi-user email based applications. All ten students who completed the course worked on this exercise, and we ended up with everything from an email-based wiki to a system for sharing funny stories and jokes.

For our academic exercise, we asked students to make use of Markov Chains to do something interested. Seven of our students participated in this exercise, and we ended up all sorts of cool results, including a jazz chart generator and a tool which predicts movements in currency exchange rates.

For our [modeling e

@hajimes
hajimes / logsumexp-asm.js
Last active January 29, 2017 02:25
handwritten asm.js code for logsumexp
// MIT License. Copyright (c) 2016 Hajime Senuma.
/**
* asm.js module for logsumexp
*/
function asmModule(stdlib, foreign, heap) {
'use asm';
var exp = stdlib.Math.exp;
var log = stdlib.Math.log;
@benolee
benolee / 00-creating-a-ruby-extension.md
Last active August 6, 2017 17:18
how easy it is to create and load a C extension in ruby

create a new dir

$ mkdir /tmp/ruby
$ cd /tmp/ruby

create extconf.rb

@nagua
nagua / lgtm.md
Created March 11, 2016 16:37
LGTM Markdown

LGTM

@mfikes
mfikes / bad-codegen.md
Last active March 1, 2018 04:29
Bad codegen

The following code should evaluate to true:

((or int? string?) 1)

But instead it evaluates to the int? function. In other words this evaluates to true:

(= int? ((or int? string?) 1))
clj -Sdeps '{:deps {github-mfikes/chambered {:git/url "https://github.com/mfikes/chambered" :sha "50265ab42f149450f15375117dcdf5d83c5efcf3"}}}' -m cljs.main -c chambered.core -r

After the REPL starts, if it doesn't automatically, open your browser to

http://localhost:9000

The source for this project is at https://github.com/mfikes/chambered

@mfikes
mfikes / README.md
Last active June 25, 2018 15:00
Bocko in browser using cljs.main and synthetic index.html

First start up the REPL by issuing this command:

clj -Sdeps '{:deps {github-mfikes/e00202b2de7cc2352fedcf92b1fe60dc {:git/url "https://gist.github.com/mfikes/e00202b2de7cc2352fedcf92b1fe60dc" :sha "68ef581813e08a92bd52e7beeea1535ab7b3337f"}}}' -m cljs.main -i @index.cljs -r

Once the REPL is waiting for the browser to connect, if it doesn't automatically, open http://localhost:9000 in your browser.

You will now be running Bocko. The following forms evaluated in the REPL will draw an American flag.