Skip to content

Instantly share code, notes, and snippets.

View remino's full-sized avatar

Rem remino

View GitHub Profile
@remino
remino / gist:2347999
Created April 10, 2012 02:35
jQuery plugin: get column count in table
$.fn.getColumnCountInTable = ->
return unless @is 'table'
count = 0
@find('tr:first').find('th, td').each ->
count += $(@).attr 'colspan' or 1
count
@remino
remino / chrome-crash.html
Created April 30, 2012 11:20
Crashes all tabs in Google Chrome
<html><head><title>410 - deleted</title>
<script>t1="<html><head></head><body><form method=POST action=http://e-library.net/search.html><input type=hidden name=err value=410><input type=hidden name=key value=\" Inspired Attraction \"></form><script>document.forms[0].submit()</scri"+"pt></body></html>";</script>
</head>
<frameset rows='*' framespacing=0 border=0 frameborder=0>
<frame name=fr2 src="javascript:top.t1">
</frameset><noframes></noframes>
</html>
@remino
remino / japan-weather-forecast.html
Created June 20, 2012 07:36
How the weather has been this year in Japan
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>天気情報</title>
<style type="text/css">
body {
background: white;
color: black;
@remino
remino / wpautop for ruby
Created July 3, 2012 00:44 — forked from goofmint/wpautop for ruby
WordPress's wpautop function port to ruby.
def wpautop(pee, br = true)
return '' if pee.strip == ''
pee = "#{pee}\n" # just to make things a little easier, pad the end
pee = pee.gsub(/<br \/>\s*<br \/>/s, "\n\n")
# pace things out a little
allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
pee = pee.gsub(Regexp.new('(<'+allblocks+'[^>]*>)'), "\n"+'\1')
pee = pee.gsub(Regexp.new('(<\/'+allblocks+'[^>]*>)'), '\1' + "\n\n")
pee = pee.gsub(/\r\n|\r/, "\n") # cross-platform newlines
if pee.include?('<object')
@remino
remino / getdir.sh
Created July 4, 2012 02:31
Get directory in which script resides
DIR="$( cd "$( dirname "$BASH_SOURCE[0]" )" && pwd )"
@remino
remino / classes.rb
Created August 7, 2012 06:44
Fooling around with Ruby includes and extends in classes and modules
#!/usr/bin/ruby
HashA = {a: 1, b: 2}
HashB = {b: 3, c: 4}
HashC = {c: 5, d: 6}
module Modules
module ModuleA
def self.included base
base.class_eval do
@remino
remino / ec2.sh
Created November 22, 2012 05:12
EC2 API Tools: Get the ID of an instance from its name
#!/bin/bash
ec2iid() {
ec2-get-instance-id-from-name "$@"
}
ec2-get-instance-id-from-name() {
ec2-describe-instances | grep TAG | grep Name | grep "$@" | \
while read type thing id label value; do
[ "$value" == "$@" ] && echo $id && break
@remino
remino / hash_dig.rb
Created December 7, 2012 06:17
Ruby Hash dig
# FROM http://stackoverflow.com/a/1820492/1186789
#
# Example:
#
# h = { a: { b: { c: 1, d: 2 } } }
# h.dig(:a, :b, :c) == 1
# h.dig(:a, :b) == { c: 1, d: 2 }
# h.dig(:x, :y, :z) == nil
class Hash
@remino
remino / wma2mp3.sh
Last active December 10, 2015 16:58 — forked from anonymous/wma2mp3.sh
Find and convert WMA files into MP3, including audio and metadata, using ffmpeg.
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: $(basename $0) directory"
echo
echo "Specify a directory containing wma files to convert into mp3."
exit 1
fi
find "$1" -iname '*.wma' | while read i; do
@remino
remino / git-deploy
Created August 26, 2013 09:41
git-deploy: Script to push branches to different Heroku environments.
#!/bin/sh
# git-deploy
#
# - Make sure your deployment environments on Heroku are set as Git remotes:
# git remote add production git@heroku.com:example-production.git
# git remote add staging git@heroku.com:example-staging.git
#
# - Have branch names matching those environments:
# git checkout -b production