Skip to content

Instantly share code, notes, and snippets.

View jgraham909's full-sized avatar

Jeff Graham jgraham909

View GitHub Profile
@jgraham909
jgraham909 / font.bash
Created March 6, 2013 21:33
Ubuntu instructions for using font-awesome-to-png.git
#!/bin/bash
sudo apt-get install python-imaging
cd ~
mkdir fontawesome
cd fontawesome/
git clone git://github.com/odyniec/font-awesome-to-png.git
git clone https://github.com/FortAwesome/Font-Awesome
cd font-awesome-to-png/
./font-awesome-to-png.py --font ../Font-Awesome/font/fontawesome-webfont.ttf --size 32 ALL
@jgraham909
jgraham909 / image_link_update.php
Created March 6, 2013 21:43
Update content after Drupal 7.20 update to account for image cache tokens
@jgraham909
jgraham909 / reset
Created March 29, 2013 19:02
Drupal DB, settings.php and filesdir reset I use when developing install profiles that outside scope of drush. Warning this clobbers your db and files dir. USE AT YOUR OWN RISK
#!/bin/bash
# File used for Drupal development.
# WARNING: This deletes your drupal DB and files directory.
# This resets the database and sets up settings.php and files dir.
#
# Usage: `./reset`
# base dir no trailing slash (change these next 5 lines; the lower code shouldn't need adjustment.
@jgraham909
jgraham909 / widget.go
Created April 8, 2013 08:35
golang template idea
package main
import "fmt"
import "bytes"
import "html"
func main() {
s := Widget("myWidget", "checkbox", map[string] string{"checked": "checked", "someattr": "Value"})
fmt.Println(s)
}
@jgraham909
jgraham909 / bloggo_0001.js
Created July 15, 2013 22:12
bloggo update article.Tags field from string to array
db.articles.find().snapshot().forEach( function(x) {
x.Tags = x.Tags.split(',');
db.articles.save(x);
});
@jgraham909
jgraham909 / setTemplateParm.go
Created September 25, 2013 08:47
Setting revel template parameters from filters or interceptors, from https://groups.google.com/forum/#!topic/revel-framework/HN75x32HoXI
var ContextFilter = func(c *Controller, fc []Filter) {
c.RenderArgs["mycontext"] = xyz
fc[0](c, fc[1:])
}
#!/bin/bash
FAIL=1 # or some non zero error number you want
MAX_TRIES=4
COUNT=0
BACKOFF=1
if [ $# -lt 1 ];then
echo "You must provide a command to execute. Commands with arguments must be quoted."
exit 1
fi
@jgraham909
jgraham909 / one line retry and backoff
Created November 16, 2015 18:48
One line retry with exponential backoff
#!/bin/bash
# Currently runs "make deploy" just change that to whatever you want
(MAXTRIES=4; COUNT=0; BACKOFF=1; while [ $COUNT -lt $MAXTRIES ]; do (make deploy); if [ $? -eq 0 ];then exit 0; fi; let COUNT=COUNT+1; let BACKOFF=BACKOFF*2; echo "Attempt $COUNT failed retrying after $BACKOFF seconds"; sleep $BACKOFF; done; echo "Tried and failed $COUNT times. Giving up."; exit 1;)
#!/bin/bash
NEWRAND=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
echo "Type the following; '$NEWRAND'"
read var1
echo "You typed $var1"
@jgraham909
jgraham909 / fileLines2Array.sh
Created January 6, 2016 23:36 — forked from akwala/fileLines2Array.sh
Bash function to read the lines of a file into an array using the builtin, mapfile.
#!/bin/bash
### Pretty-print dedicated (array) var, MAPFILE.
prettyPrintMAPFILE() {
let i=0
echo "[MAPFILE]"
for l in "${MAPFILE[@]}"
do
echo "$i. |$l|"
let i++
done