Skip to content

Instantly share code, notes, and snippets.

@mikbe
mikbe / nokogiri_sucks.txt
Last active July 10, 2016 04:07
How to install Nokogiri
## Do this before doing bundle install
# Make sure you have Xcode installed with command line utilities.
# Install Home Brew (if you already have it installed update it):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update --system
brew update
@mikbe
mikbe / gist:6cb1254a3cca53a2b8d2
Last active August 29, 2015 14:09
Always start tabindex with 1
<html>
<head>
<title>TabIndex Example - 1</title>
</head>
<body>
This will jump from tab 1 to tab 2.
<br />
<label>Tab 1</label>
<input tabindex="1" type="text" />
<br />
@mikbe
mikbe / gist:e4b68c89f678556afd8e
Created November 13, 2014 18:01
Never start tab index with zero!
<html>
<head>
<title>TabIndex Example - 0</title>
</head>
<body>
This will jump from tab 0 to the address bar.
<br />
<label>Tab 0</label>
<input tabindex="0" type="text" />
<br />
@mikbe
mikbe / pageload.coffee
Created May 11, 2014 19:47
TurboLink Workaround
$(window).on 'ready page:load', ->
# Your code
@mikbe
mikbe / FriendlyChgDir.sh
Created February 15, 2013 21:48
A friendlier change directory for Bash and OS X.
# Change to a directory given a full or partial name
# You don't have to wrap directory names in quotes either
function chd() {
friendlyChgDirOptions
if [ -n "$1" ]; then
if [ -n "`ls "$@"* 2>/dev/null`" ]; then
cd "$1"*
else
echo "-bash: chd: "$1": No directory found from partial name"
@mikbe
mikbe / CaseInsensitiveBash.sh
Created February 15, 2013 21:22
Make Bash case insensitive when globbing (using wildcards)
shopt -s nocaseglob
@mikbe
mikbe / gist:4945780
Created February 13, 2013 16:23
Download all Railscast Pro and regular episodes (if you have a subscription)
#!/usr/bin/env ruby
require 'rss'
require 'open-uri'
require 'net/http'
# Your subscription ID
sub_id = "xxx"
url = "http://railscasts.com/subscriptions/#{sub_id}/episodes.rss"
puts "Reading RSS"
@mikbe
mikbe / gist:2974686
Created June 22, 2012 19:42
Storyline index file example
<!-- index.html -->
<html>
<head>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="0">
<META HTTP-EQUIV="REFRESH" CONTENT="0;https://mywebsite.com/ab.007/story.html">
<script type="text/javascript">
window.location = "https://mywebsite.com/ab.007/story.html"
</script>
@mikbe
mikbe / fiber.rb
Created July 28, 2011 09:35
Fiber Creation
#!/usr/bin/env ruby
#Thread.abort_on_exception = true
require 'fiber'
require 'benchmark'
class FiberRing
attr_reader :id
def initialize(id)
@id = id
@mikbe
mikbe / cairo.h.rb
Created July 10, 2011 15:27
Cairo.h converted to FFI
CAIRO_VERSION_STRING = CAIRO_VERSION_MAJOR.CAIRO_VERSION_MINOR.CAIRO_VERSION_MICRO
attach_function :cairo_version, [ ], :int
attach_function :cairo_version_string, [ ], :string
class CairoMatrix < FFI::Struct
layout(
:xx, :double,
:yx, :double,
:xy, :double,
:yy, :double,
:x0, :double,