Skip to content

Instantly share code, notes, and snippets.


Donn Felker donnfelker

View GitHub Profile
tobytailor / get_barcode_from_image.js
Created Jun 1, 2010
Barcode recognition with JavaScript - Demo:
View get_barcode_from_image.js
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
View gist:1063033
View friendly_urls.markdown

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:


But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

donnfelker / demo.txt
Created Sep 21, 2011
Maven Third Party Repo
View demo.txt
# This will create a pom, md5 and sha1 for the jar and pom in your ~/.m2/ directory.
# here i'm installing the FlurryAgent from my /tmp/ directory
mvn install:install-file -Dfile=/tmp/FlurryAgent.jar -DgroupId=com.flurry -DartifactId=FlurryAgent -Dversion=2.2 -Dpackaging=jar -DcreatePom=true -DcreateChecksum=true
# Copy this entire folder from your ~/.m2/ folder
# Place it into your repo (local repo checked into source control)
# In your applications pom file, add a third party repo
lucapette / application.css
Created Oct 19, 2011
twitter bootstrap rails 3.1 notes
View application.css
*= require_self
html, body {
background-color: #eee;
body {
padding-top: 40px; /* 40px to make the container go all the way to the bottom of the topbar */
gudbergur / README.markdown
Created Feb 19, 2012
Bootstrap's Typeahead plugin extended (allowing for AJAX functionality) among other things
View README.markdown

This is a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

For example, process typeahead list asynchronously and return objects

  # This example does an AJAX lookup and is in CoffeeScript
    # source can be a function
    source: (typeahead, query) ->
      # this function receives the typeahead object and the query string
romannurik / button_bar_layout.xml
Created Apr 10, 2012
How to make a proper button bar on ICS
View button_bar_layout.xml
A button bar is a set of buttons at the bottom of an activity.
An example is an AlertDialog with OK/Cancel buttons.
Note that something similar can be accomplished using a
split action bar and text-only action buttons, but this is an
alternate presentation that's often preferred.
<LinearLayout xmlns:android=""
romannurik /
Last active Sep 8, 2021
Android helper class for showing cheat sheets (tooltips) for icon-only UI elements on long-press. This is already default platform behavior for icon-only action bar items and tabs. This class provides this behavior for any other such UI element.
* Copyright 2012 Google Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
i386 / hn.css
Created Feb 14, 2013
Sylish style to make Hacker News less raw
View hn.css
.title {
font-size: 12pt;
.comhead !important {
font-size: 12pt;
.topsel a {
color: #ff9913;
tyvsmith /
Created Jul 22, 2013
"`classes.dex` method count helpers. Requires smali/baksmali from and dexdump from the build-tools in the Android SDK be on your PATH." Use this to keep track of methods and fields in your apk. They are both limited to 65536. Example use: $ source; $ dex-field-count classes.dex; Original method scrip…
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)