Skip to content

Instantly share code, notes, and snippets.

@vanntastic
vanntastic / convert-source-map-no-source-map-comment
Created August 25, 2016 21:36
this removes the source map comments from mapFileCommentRx so that devtools doesn't accidentally mistake it for an actual source map
'use strict';
var fs = require('fs');
var path = require('path');
var commentRx = /^\s*\/(?:\/|\*)[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+;)?base64,(.*)$/mg;
var mapFileCommentRx =
//Example (Extra space between slashes added to solve Safari bug. Exclude space in production):
/(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg
function decodeBase64(base64) {
@vanntastic
vanntastic / commit-msg
Created August 22, 2016 20:17 — forked from monkseal/commit-msg
'commit-msg' hook that pulls your Jira issue number from your branch name
#!/bin/sh
# Add git branch if relevant
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# Extact tracker abbreviation and ticket number (e.g. DS-123)
parse_git_tracker_and_ticket() {
parse_git_branch | grep -e '[A-Z]\+-[0-9]\+' -o
@vanntastic
vanntastic / minify
Created February 11, 2011 16:23 — forked from benpickles/minify
minify script using closure compiler
#!/usr/bin/env ruby
dry_run = ARGV.delete('--dry-run')
force = ARGV.delete('--force')
if ARGV.empty?
puts <<-USAGE
minify, swiftly concat and minify JavaScript files from the command line
Pass a single argument to create a .min.js version:
#!/usr/bin/env ruby
# A quick deployment script using rsync, just define FROM, SERVER, and TO
# HOW TO USE:
# 1. set FROM, SERVER, and TO
# 2. run : chmod 755 deploy.rb
# 3. you can add post deploy tasks at the bottom
# 4. ./deploy.rb
# the location of the project
# abstract append text behavior into a function
append () {
if [[ -n "$1" ]]; then
echo $1 >> $2;
else
echo "USAGE : append 'your text' [file_to_append]";
fi
}
http://github.com/search?type=Everything&language=&q=%s&repo=&langOverride=&x=0&y=0&start_value=1
#!/usr/bin/env ruby -wKU
if ARGV[0].nil?
puts " gh_search [name_of_repo]: \n - Copies repo url to clipboard (via pbcopy) if only one repo is found"
else
search_string = "Searching github for #{ARGV[0]}...."
border = "="*search_string.length
#!/bin/bash
if [[ -n "$1" ]]; then
cd /Applications/CrashPlan.app/Contents/Resources/Java/conf/
echo "Linking remote settings, open Crashplan once you are logged in.";
ln -nfs ui.remote.properties ui.properties;
ssh $1;
echo "Linking local settings, Crashplan is back at local settings.";
ln -nfs ui.local.properties ui.properties;
cd ~;
var is = function() {
return {
// is.not_defined(obj_or_var)
not_defined : function(obj) {
return typeof(obj) == 'undefined';
},
// is.defined(obj_or_var)
defined : function(obj) {
return typeof(obj) != "undefined";
}
# should be in Ruby Core
class String
# grab the first character
def first
self[0..0]
end
# grab the last character
def last
self[(self.length-1)..(self.length-1)]