Skip to content

Instantly share code, notes, and snippets.

View hauntedhost's full-sized avatar
💭
👻

Jules Omlor hauntedhost

💭
👻
View GitHub Profile
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@syntagmatic
syntagmatic / README.md
Created August 30, 2012 22:29
Spiral for John Hunter

A tribute to John Hunter (1968-2012), creator of matplotlib, an open-source plotting library for Python.

I stumbled across this polar-plot example exploring the matplotlib site. The chart title struck me. I know how exciting it can be to break out of the rectilinear coordinate system. Spirals are mysterious and beautiful, reaching from the origin out towards infinity.

Thank you John, for the wonderful plots.

<iframe width="640" height="480" src="http://www.youtube.com/embed/e3lTby5RI54" frameborder="0" allowfullscreen></iframe>

If you appreciate John's work, consider donating to the John Hunter Memorial Fund to help support his childrens' education.

@coreyti
coreyti / application.rb
Created September 26, 2012 21:33
Load settings for Rails from YAML files
require File.expand_path('../boot', __FILE__) # etc.
module Example
class Application < Rails::Application
# Helper for loading deeply nested environment config.
def load_env(context, key, value)
if value.is_a?(Hash)
options = begin
context.send(key) || ActiveSupport::OrderedOptions.new
rescue
@ramseyp
ramseyp / hide-editor.php
Created November 12, 2012 15:48
Hide the content editor for certain pages in WordPress
<?php
/**
* Hide editor on specific pages.
*
*/
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
// Get the Post ID.
anonymous
anonymous / concerning.rb
Created December 18, 2012 18:00
class Module
# We often find ourselves with a medium-sized chunk of behavior that we'd
# like to extract, but only mix in to a single class.
#
# We typically choose to leave the implementation directly in the class,
# perhaps with a comment, because the mental and visual overhead of defining
# a module, making it a Concern, and including it is just too great.
#
#
# Using comments as lightweight modularity:
@markpundsack
markpundsack / heroku-CVE-2013-0156.rb
Last active November 27, 2023 15:44 — forked from elliottkember/heroku-CVE-2013-0156.rb
Forked from https://gist.github.com/4489689 by elliottkember. CVE-2013-0156 is a nasty vulnerability in many versions of Rails. This script checks all your Heroku apps for this vulnerability in one quick (slow) move. More info: https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
## The quick-and-nasty CVE-2013-0156 Heroku inspector!
## Originally brought to you by @elliottkember with changes by @markpundsack @ Heroku
## Download and run using:
## ruby heroku-CVE-2013-0156.rb
`heroku list`.split("\n").each do |app|
app = app.strip
# Some "heroku apps" lines have === formatting for grouping. They're not apps.
next if app[0..2] == "==="
n = 50000;
Benchmark.bm(15) do |x|
x.report("Array Include:"){ n.times{ foo = 5; arr = [1,2,3,4,5]; arr.include? foo }}
x.report("Array access:"){ n.times{ foo = 5; arr = [1,2,3,4,5]; foo == arr[0] || foo == arr[1] || foo == arr[2] || foo == arr[3] || foo == arr[4] } }
x.report("Array Alloc:"){ n.times{ foo = 5; arr = [1,2,3,4,5]; foo == 1 || foo == 2 || foo == 3 || foo == 4 || foo == 5 } }
x.report("Just Ors:"){ n.times{foo = 5; foo == 1 || foo == 2 || foo == 3 || foo == 4 || foo == 5 }}
end
n = 50000;
foo = 1
@amueller
amueller / Diagram1.dia
Last active August 18, 2022 05:03
Machine learning cheat sheet diagram svg and dia file
def rec_intersection(rec_a, rec_b)
#if rec_a is contained within rec_b, return rec_a
if rec_a[0][0] > rec_b[0][0] && rec_a[0][1] > rec_b[0][1]
if rec_a[1][0] < rec_b[1][0] && rec_a[1][1] < rec_b[1][1]
return rec_a
end
end
#if rec_b is contained within rec_a, return rec_b
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active June 30, 2026 18:13
A badass list of frontend development resources I collected over time.