Skip to content

Instantly share code, notes, and snippets.

@ukyo
ukyo / b64.js
Created September 2, 2012 04:26
base64 encode decode with HTML5
var b64 = (function() {
var hash = {'=': 0};
Array.prototype.forEach.call(
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
function(c, i){hash[c] = i});
function b64decode(s) {
@jasonmadigan
jasonmadigan / 404_finder.rb
Created August 24, 2012 09:55
404 Finder - Simple Ruby site crawler, finds 404s
#!/usr/bin/env ruby
# Simple 404 finder
require 'rubygems'
require 'anemone'
url = ARGV[0]
if url.nil?
pair = 'BTCUSD'
csv = [['Date', 'Open', 'High', 'Low', 'Close', 'Volume']]
end_t = Time.now.to_i * 1000
loop do
body = HTTParty.get("https://api.bitfinex.com/v2/candles/trade:1h:t#{pair}/hist?_bfx=1&limit=1500&end="+end_t.to_s).body
body = Oj.load(body) rescue nil
break if body.nil?
break if body.size == 0
body.each do |e|
csv << [Time.at(e[0] / 1000).strftime('%Y-%m-%d %H:00:00'), e[1], e[3], e[4], e[2], e[5]]
@AgiosAndreas
AgiosAndreas / uninstall-mono.sh
Created December 26, 2011 16:21
This script removes Mono from an OS X System. It must be run as root
#!/bin/sh -x
#This script removes Mono from an OS X System. It must be run as root
rm -r /Library/Frameworks/Mono.framework
rm -r /Library/Receipts/MonoFramework-*
for dir in /usr/bin /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man5; do
(cd ${dir};
@jugyo
jugyo / gist:865475
Created March 11, 2011 05:02
TextMate command to convert slim to html
#!/usr/bin/env ruby
# Input: Selected Text or Nothing
# Output: Replace Selected Text
require 'tempfile'
def unindent(text)
lines = text.split(/\n/)
level = lines.map{|l| l[/^\s*/].size}.min
@bmaeser
bmaeser / subtitle-extract.txt
Created September 2, 2011 23:25
extract subtitles from *.mkv-files on osx
lines with $ are commands
### install mkvtoolnix:
$ brew install mkvtoolnix
### list content of the mkv-file:
$ mkvmerge -i mymoviefile.mkv
### what will give you:
@anchetaWern
anchetaWern / laravel-ums.markdown
Created December 6, 2012 11:14
Building a User Management System in Laravel

There's no shortage of good resources for learning laravel. So instead of the usual introductory tutorial were just gonna learn Laravel by building a project from scratch and that's gonna be a User Management System.

I don't know if my definition of a User Management System is correct but here's my idea of what's it's capable of doing:

  • Register Roles
  • Register Users
  • Update Users
@rxin
rxin / ramdisk.sh
Last active December 13, 2023 02:40
ramdisk create/delete on Mac OS X.
#!/bin/bash
# From http://tech.serbinn.net/2010/shell-script-to-create-ramdisk-on-mac-os-x/
#
ARGS=2
E_BADARGS=99
if [ $# -ne $ARGS ] # correct number of arguments to the script;
then
@justinweiss
justinweiss / filterable.rb
Last active January 11, 2024 07:28
Filterable
# Call scopes directly from your URL params:
#
# @products = Product.filter(params.slice(:status, :location, :starts_with))
module Filterable
extend ActiveSupport::Concern
module ClassMethods
# Call the class methods with names based on the keys in <tt>filtering_params</tt>
# with their associated values. For example, "{ status: 'delayed' }" would call
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.