Skip to content

Instantly share code, notes, and snippets.

View darrenclark's full-sized avatar

Darren Clark darrenclark

View GitHub Profile
@darrenclark
darrenclark / no_cache_sprockets.rb
Created September 3, 2011 19:22
Hack-job of a class to force Sprockets to rebuild assets every request
# Hack-job of a class to force Sprockets to rebuild assets every request
class NoCacheSprockets < Sprockets::Environment
# Bypass Sprockets::Environment's caching, and call Sprockets::Base's method directly
def find_asset(path, options = {})
self.class.superclass.superclass.instance_method(:find_asset).bind(self).call(path, options)
end
# Prevent any 304 responses (for the web browser's sake)
def not_modified?(asset,env)
@darrenclark
darrenclark / progress-bar.sh
Created November 25, 2011 05:02
Shell Progress Bar
# After wondering how commands like curl showed a progress bar, with the very big help of
# Google, I decided to write a shell script to show a progress bar
#
# Having not done much shell scripting, I learned a few (very likely quite obvious) things:
# * It looks much nicer to create the string to echo in a variable, then echo it. If I echo'ed
# each part of the string instead of concatenating it with the rest of the string, the cursor
# jumped around quite a bit.
# * 'let x=x+1' is a lot faster than 'x=`expr $x + 1`' (I have a feeling this is probably because
# let is implemented directly in bash, instead of a separate command)
@darrenclark
darrenclark / xmlrecord.rb
Created December 1, 2011 07:33
A fairly easy to use class for parsing XML elements (from Nokogiri) into value objects
require 'rubygems'
require 'nokogiri'
class XMLRecord
class << self
def tag_handlers
@tag_handlers ||= []
end
end
@darrenclark
darrenclark / Request Headers.md
Last active August 29, 2015 14:24
Tinder API info

Overview

Miscellanious information discovered from sniffing Tinder's API traffic.

See also: https://gist.github.com/rtt/10403467, has a lot of valuable information & is much better formatted

URL

Requests are made to api.gotinder.com

@darrenclark
darrenclark / post-checkout
Created October 5, 2015 14:36
Update submodules on branch switch
#!/bin/sh
# To skip submodule update:
# IGNORE_SUBMODULES=1 git checkout <...>
# Third arg is "1" when doing a branch checkout (as opposed to a file
# checkout)
if [ "$3" = "1" ] && [ -z "$IGNORE_SUBMODULES" ]; then
@darrenclark
darrenclark / README.md
Last active June 20, 2016 16:21
genstrings for your clipboard

(Swift only)

Easily add entries to Localizable.strings file by copy/pasting code with new NSLocalizedStrings

Usage:

  1. Copy your code containing NSLocalizedString(_:comment:) function calls

  2. Pipe it through the pbgenstrings.sh script:

@darrenclark
darrenclark / git-brc
Last active September 2, 2016 15:27
Git BRanchClean - Remove local branches that have been merged
#!/bin/bash
set -eu -o pipefail
## Git BRanchClean (removes local branches that have been merged into the current branch)
# List of branches to ignore separated by vertical bars/pipes (|)
IGNORED_BRANCHES="develop|master"
branches="$(git branch --no-column --no-color --merged | egrep -v '\* ' | sed 's/^[\* ] //' | (egrep -v "$IGNORED_BRANCHES" || true))"
@darrenclark
darrenclark / swift-default-init.sh
Last active September 2, 2016 20:28
Generate default swift initializer from properties
#!/bin/bash
# Usage:
# 1. Copy your properties to clipboard
# 2. `pbpaste | swift-default-init.sh | pbcopy`
# 3. Paste into code
set -eu -o pipefail
# Switch to \t for tab indenting
import UIKit
import PlaygroundSupport
extension NSNotification.Name {
static let todoListItemUpdated = NSNotification.Name("TodoListItemUpdated")
}
class TodoList {
static let shared = TodoList()
import UIKit
import PlaygroundSupport
extension NSNotification.Name {
static let todoListItemUpdated = NSNotification.Name("TodoListItemUpdated")
}
class TodoList {
static let shared = TodoList()