Skip to content

Instantly share code, notes, and snippets.

@cfurrow
cfurrow / .bash_profile
Created March 24, 2011 20:43
Git alias to remove deleted files (seems to detect renamed files as well after they're added to the index)
alias grm="git status | grep deleted | awk '{print \$3}' | xargs git rm"
@viola
viola / gist:1070410
Created July 7, 2011 20:00
Example of fetching Hash (key,value) to the simple_form collection.
-- model
some sort of constant hash:
HASH_NAME = {
0 => "Choose:",
1 => "On-Campus Recruiting - CSO",·
2 => "CSO Staff Referral",
3 => "Faculty Contact",·
4 => "Career Day",·
5 => "CSO Summer Job Listing",·
6 => "Alumni Contact",·
@justincarter
justincarter / gist:1306983
Created October 23, 2011 07:17
CFEclipse-style key bindings for Sublime Text 2
[
// cf tags
//
// cfabort
{ "keys": ["ctrl+shift+a"], "command": "insert_snippet", "args": {"contents": "<cfabort>" } },
// cfdump
{ "keys": ["ctrl+shift+d"], "command": "insert_snippet", "args": {"contents": "<cfdump var=\"#${0:$SELECTION}#\">" } },
// cfoutput
{ "keys": ["ctrl+shift+o"], "command": "insert_snippet", "args": {"contents": "<cfoutput>${0:$SELECTION}</cfoutput>" } },
@johannesnagl
johannesnagl / Tweetsheets
Created August 9, 2012 10:25
Use Twitter directly in your Google Doc, so no one will ever blame you for being social
var CONSUMER_KEY = "<< YOUR KEY HERE >>";
var CONSUMER_SECRET = "<< YOUR SECRET HERE >>";
function getConsumerKey() {
return CONSUMER_KEY;
}
function getConsumerSecret() {
return CONSUMER_SECRET;
}
@adamgit
adamgit / .gitignore
Last active June 27, 2024 13:16
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@DiegoSalazar
DiegoSalazar / validate_credit_card.js
Last active April 24, 2024 12:51
Luhn algorithm in Javascript. Check valid credit card numbers
// Takes a credit card string value and returns true on valid number
function valid_credit_card(value) {
// Accept only digits, dashes or spaces
if (/[^0-9-\s]+/.test(value)) return false;
// The Luhn Algorithm. It's so pretty.
let nCheck = 0, bEven = false;
value = value.replace(/\D/g, "");
for (var n = value.length - 1; n >= 0; n--) {
@phantom42
phantom42 / __useful regular expressions.txt
Last active December 14, 2015 02:49
useful regular expressions and regex related stuff
-- collection of useful regular expressions
@phantom42
phantom42 / gist:6000014
Last active December 19, 2015 18:38
command to export list of file names to a text file
dir /A:-D /N /S /B > filenames.txt
forfiles /S /C "cmd /c echo @path0x09@fsize0x09@fdate" > filenames.txt
for %f in (*.txt) do type "%f" >> combined.txt
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active June 4, 2024 04:16
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote