Skip to content

Instantly share code, notes, and snippets.

@brentsowers1
brentsowers1 / pre-commit.bash
Created May 3, 2012 18:24
Git pre-commit hook to prevent non-ascii characters
#!/bin/bash
# Save these contents to .git/hooks/pre-commit in your project
# folder, and give it executable permissions with
# "chmod u+x .git/hooks/pre-commit"
# Git will abort a commit if you have non ASCII characters in
# the commit, and output the non ASCII characters.
output=`git diff HEAD | tr -d "\000-\011\013-\177" | tr -d '\n'`
cnt=${#output}
if [ -n "$output" ]; then
@brentsowers1
brentsowers1 / gist:2907372
Created June 10, 2012 21:21
jQuery attachment types common code
// Used for measuring performance
var clickStartTime;
function callbackFunction() {
var doneDate = new Date();
var diff = doneDate.getTime() - clickStartTime.getTime();
alert("It took " + diff + " ms");
return false;
}
@brentsowers1
brentsowers1 / gist:2907597
Created June 10, 2012 22:59
jQuery attachment types common code
var clickStartTime;
function timeAction(localThis, actionFunction) {
var startTime = new Date();
actionFunction.call(localThis);
var endTime = new Date();
alert("Took " + (endTime.getTime() - startTime.getTime()) + " ms to run");
}
function callbackFunction() {
@brentsowers1
brentsowers1 / gist:2907631
Created June 10, 2012 23:07
jQuery attachment types test case 1
// Some action that triggers generating 10,000 elements
function generate10KElements(attachEventDirectly) {
var generateFunction = function() {
var containerElement = $("#container");
containerElement.html("");
if (!attachEventDirectly) {
// This is the magic, all items within the container div that have a CSS class
// of sameClassItem get the callbackFunction handler.
containerElement.on('click', ".sameClassItem", callbackFunction);
}
@brentsowers1
brentsowers1 / gist:2907639
Created June 10, 2012 23:10
jQuery attachment types test case 2
function generate10KRandomClass(attachEventDirectly) {
var generateFunction = function() {
var containerElement = $("#container");
containerElement.html("");
if (!attachEventDirectly) {
// There will be 100 possible classes, call .on for each
for (var i=0; i < 100; i++) {
containerElement.on('click', ".randomClassItem" + i, callbackFunction);
}
}
@brentsowers1
brentsowers1 / gist:2907648
Created June 10, 2012 23:12
jQuery attachment types test cases 3 and 4
function generateUniqueClasses(attachEventDirectly, elementsToGenerate) {
var generateFunction = function() {
var containerElement = $("#container");
containerElement.html("");
for (var i=0; i < elementsToGenerate; i++) {
var element = $('<div id="element' + i + '" class="differentClassItem' + i + '"><a href="#">click me</a> &nbsp;</div>');
containerElement.append(element);
if (attachEventDirectly) {
element.click(callbackFunction);
} else {
@brentsowers1
brentsowers1 / AudaxHealthSoftwareEngineer.scala
Last active September 24, 2021 18:03
Audax Health is looking for good software engineers
object AudaxHealthSoftwareEngineer {
val headline = """
Audax Health is hiring! Come join our incredible team of engineers in Washington, DC or San Francisco,
to help build the first truly social health platform, Zensey.com. We've embraced Scala and the
Lift web framework for most of our software, so if you have experience in or want to learn Scala,
we're looking for you!
"""
val requirementsDescription = """We don't have a firm list of requirements, we're just looking for
@brentsowers1
brentsowers1 / gist:6118765
Created July 31, 2013 02:08
Script to show lines attributed to each author
# Get all current files in your repo of the extensions that you want to be considered code
# (.scala and .js for my example)
git ls-files | egrep "\.(scala|js)$" > files.txt
# Now edit files.txt to remove files that you don't want counted, like jQuery extensions
cat files.txt | xargs -n1 git blame -w | ruby -n -e '$_ =~ /^.*\((.*?)\s[\d]{4}/; puts $1.strip' | sort -f | uniq -c | sort -n
@brentsowers1
brentsowers1 / gist:6118766
Created July 31, 2013 02:08
Script to show lines attributed to each author
# Get all current files in your repo of the extensions that you want to be considered code
# (.scala and .js for my example)
git ls-files | egrep "\.(scala|js)$" > files.txt
# Now edit files.txt to remove files that you don't want counted, like jQuery extensions
cat files.txt | xargs -n1 git blame -w | ruby -n -e '$_ =~ /^.*\((.*?)\s[\d]{4}/; puts $1.strip' | sort -f | uniq -c | sort -n
@brentsowers1
brentsowers1 / warbler.rb
Created March 6, 2014 02:17
config/warbler.rb for including database migrations in WAR
# Disable Rake-environment-task framework detection by uncommenting/setting to false
# Warbler.framework_detection = false
# Warbler web application assembly configuration file
Warbler::Config.new do |config|
# Application directories to be included in the webapp.
# Add script and db/migrate here
config.dirs = %w(app config lib log vendor tmp script db/migrate)
# Uncomment this if you're running in 1.9 mode