Skip to content

Instantly share code, notes, and snippets.

View chrisle's full-sized avatar
💭
probably partying...

Chris Le (TRIODE) chrisle

💭
probably partying...
View GitHub Profile
@paulmillr
paulmillr / method-missing.coffee
Created January 20, 2012 16:27
ECMAScript 6 proxies fun (method missing, negative array indexes)
# Ruby’s “method missing” analog with ES6 proxies.
proxify = (object) ->
new Proxy object, get: (receiver, name) ->
object[name] ? object.methodMissing.bind object, name
object = proxify
a: 1,
b: 15,
c: ->
'called'
@gasman
gasman / pnginator.rb
Created April 30, 2012 18:08
pnginator: pack Javascript into a self-extracting PNG
#!/usr/bin/env ruby -w
# pnginator.rb: pack a .js file into a PNG image with an HTML payload;
# when saved with an .html extension and opened in a browser, the HTML extracts and executes
# the javascript.
# Usage: ruby pnginator.rb input.js output.png.html
# By Gasman <http://matt.west.co.tt/>
# from an original idea by Daeken: http://daeken.com/superpacking-js-demos
@walterdavis
walterdavis / document.rb
Created July 1, 2012 13:17
Text extraction processor for Paperclip to read PDF files
def extract_text
file = File.open("#{pdf.queued_for_write[:text].path}","r")
plain_text = ""
while (line = file.gets)
# plain_text << line.gsub(/[^\x00-\x7F]/n,'').gsub(/`/,"'").gsub(/^\d+$/,'').to_s + "\n"
plain_text << Iconv.conv('ASCII//IGNORE', 'UTF8', line)
end
self.plain_text = plain_text
#self.plain_text = Iconv.conv('ASCII//IGNORE', 'UTF8', file.read)
end
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active March 27, 2024 06:33
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@seamusabshere
seamusabshere / excelwebservice.vb
Created September 28, 2012 15:44
Excel VB for accessing http://carbon.brighterplanet.com/flights.txt as a web service (early 2011)
Option Explicit
Function GetBrighterPlanetApiKey()
GetBrighterPlanetApiKey = ActiveWorkbook.Worksheets("Setup").Range("C2").Value
End Function
Function IsEmissionEstimateServiceOnline()
If LCase(ActiveWorkbook.Worksheets("Setup").Range("C3").Value) = "online" And ThisWorkbook.HasFinishedWorkbookOpen() = True Then
IsEmissionEstimateServiceOnline = True
Else
@admackin
admackin / tmux-build.sh
Created October 15, 2012 00:29
Build tmux (iTerm2 version) as a local single-user installation on Ubuntu 10.04
#!/bin/sh
mkdir tmp
cd tmp
wget https://github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz | tar xzf -
cd libevent-2.0.20-stable
./configure --prefix=$HOME/local && make && make install
cd ..