Skip to content

Instantly share code, notes, and snippets.

View micahblu's full-sized avatar

Micah Blu micahblu

View GitHub Profile
@micahblu
micahblu / gist:08c86f215fc303e9827b0cf5a93bc40b
Created February 1, 2020 21:27
bash script to create local git branches from remote branches
for i in `git branch -a | grep remote | grep -v HEAD | grep -v master`; do git branch --track ${i#remotes/origin/} $i; done
@micahblu
micahblu / ~
Last active October 3, 2018 15:56
console log print method, for cases where console log doesn't expand consoled objects
const print = (obj, log=true) => {
let tab = ` `;
let tabs = [tab];
let output = '';
const quotify = (value) => typeof value === 'string' ? `"${value}"` : value;
const _print = (_obj) => {
let output = '';
for (let prop in _obj) {
if (!_obj.hasOwnProperty(prop)) continue;
@micahblu
micahblu / gist:cc60696d77bdcab4be9f
Created November 23, 2015 22:35
Checking for running service, start it if not
#!/bin/bash
service=replace_me_with_a_valid_service
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is running!!!"
else
/etc/init.d/$service start
fi
@micahblu
micahblu / gist:312cd787051e2879d521
Created March 18, 2015 17:19
Make duplicate .htm files from .html files
find . -name "*.html" -exec bash -c 'cp "$1" "${1/.html/.htm}"' -- {} \;
@micahblu
micahblu / gist:6b3a220f53bda40e7d6d
Created March 9, 2015 17:56
search and replace all filenames
find . -name '*.scss' -exec bash -c 'mv "$1" "${1/.scss/.less}"' -- {} \;
@micahblu
micahblu / gist:59b6b0e37aeb3da56c82
Created February 23, 2015 19:38
collect url params as an array of key/value objects
function getURLParams () {
var params = [];
window.location.search.substring(1).split("&").every(function (pair){
var obj = {};
pair = pair.split("=");
obj[pair[0]] = pair[1];
params.push(obj);
});
return params;
}
@micahblu
micahblu / GistList!.md
Created January 22, 2015 23:33
Try GistList for iOS! http://gistlist.io/

##alt text GistList: TODO for coders alt text

{"result":"true","errors":[],"data":[["{\"1\":[{\"0\":\"Hunky\"},{\"1\":\"Male\"}],\"2\":[{\"0\":\"Dory\"},{\"1\":\"727455767\"}]}",null,"{\"1\":[],\"2\":[]}"]],"fields":{}}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
</body>
</html>
@micahblu
micahblu / gist:6263901
Created August 18, 2013 20:43
Awesome little prototype javascript function to Replace "ALL" occurrences in a string not just the first match by Ben Nadel http://www.bennadel.com/blog/142-Ask-Ben-Javascript-String-Replace-Method.htm
// Replaces all instances of the given substring.
String.prototype.replaceAll = function(strTarget, strSubString)
{
var strText = this;
var intIndexOfMatch = strText.indexOf( strTarget );
// Keep looping while an instance of the target string
// still exists in the string.
while (intIndexOfMatch != -1){
// Relace out the current instance.