Skip to content

Instantly share code, notes, and snippets.

View jpbassalot's full-sized avatar

Joseph White jpbassalot

  • Southern California
View GitHub Profile
@jpbassalot
jpbassalot / batchrename
Created July 2, 2014 15:38
Batch rename files with different extensions
#!/bin/sh
# first argument - basename of files to be moved
# second arguments - basename of destination files
if [ $# -ne 2 ]; then
echo "Two arguments required."
exit;
fi
for i in $1.*; do
if [ -e "$i" ]; then
@jpbassalot
jpbassalot / npm_change_bin
Created April 1, 2014 14:38
NPM bin dir to local user dir
# Change global npm install dir to local user dir
npm config set prefix ~/npm
@jpbassalot
jpbassalot / map.js
Created March 30, 2014 21:50
Map function, callback exercise
var map = function(list, callback) {
var arrList = [];
if (!list) {
throw new Error('Error, list is undefined');
}
if (list.constructor === Array && list[0].constructor === Object) {
@jpbassalot
jpbassalot / coffee_filter.coffee
Last active August 29, 2015 13:57
Coffee-script lo-dash filter through nested array
_ = require 'lodash'
data = [{
"id": 0,
"guid": "b9425cd2-c93e-4cd3-ba98-bb31e792cdf5",
"isActive": false,
"balance": "$2,073.00",
"picture": "http://placehold.it/32x32",
"age": 29,
"name": "Regina Emerson",
var aaa = [
{name: "AAA", id: 845},
{name: "BBB", id: 839},
{name: "CCC", id: 854}
];
var bbb = [
{id: 839},
{id: 854}
];
@jpbassalot
jpbassalot / gist:8734083
Created January 31, 2014 15:23
Convert Array to Object - Pure Javascript
function toObject(arr) {
var rv = {};
for (var i = 0; i < arr.length; ++i)
if (arr[i] !== undefined) rv[i] = arr[i];
return rv;
}