Skip to content

Instantly share code, notes, and snippets.

@amirnissim
amirnissim / gist:5639453
Created May 23, 2013 21:11 — forked from ranbena/gist:5263279
Blank 1px transparent gif in Base64
data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw==
@amirnissim
amirnissim / image64.sh
Created July 9, 2013 09:47 — forked from puppybits/image64.sh
convert an image to base64 string #util
#!/bin/sh
# Examples:
# ./image64.sh myImage.png
# outputs: data:image/png;base64,xxxxx
# ./image64.sh myImage.png -img
# outputs: <img src="data:image/png;base64,xxxxx">
filename=$(basename $1)
xtype=${filename##*.}
append=""
#!/bin/sh
# pre-commit git hook to make sure developers don't accidentally commit code they didn't mean to commit :)
REMOVEME_STRING="REMOVEME"
ALLOW_COMMITTING_REMOVEME=`git config hooks.allowcommittingremoveme`
# redirect stdout to stderr
exec 1>&2
if [ "$ALLOW_COMMITTING_REMOVEME" != "true" ] &&
@amirnissim
amirnissim / OSX.sh
Last active December 19, 2015 18:19
OSX aliases
# run iOS simulator
open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
# run Google Chrome with web security disabled
open -a Google\ Chrome\ Canary --args --disable-web-security
@amirnissim
amirnissim / xhr.js
Last active January 26, 2016 14:22
XHR
var resource = "http://my-service/data.json";
var xhr = new XMLHttpRequest();
xhr.onprogress = updateProgress;
xhr.onreadystatechange = updateReadyState;
xhr.open('GET', resource, true);
xhr.send();
function updateProgress (e) {
@amirnissim
amirnissim / gaia.sublime-project
Last active December 26, 2015 00:49
Gaia project settings for SublimeText #fxos
{
"settings": {
"tab_size": 2,
"translate_tabs_to_spaces": true
},
"folders": [{
"follow_symlinks": true,
"path": "apps/homescreen"
}, {
@amirnissim
amirnissim / git-aliases.sh
Last active December 26, 2015 00:49
git aliases
# checkout a branch by partial name
go = "!sh -c \"if [ $(git branch | grep $1 | wc -l) -gt 1 ]; then git branch | grep $1; else git checkout $(git branch | grep $1); fi\""
# open conflicted files in editor
revise = !sh -c \"git diff --name-only | uniq | xargs subl\"
@amirnissim
amirnissim / gaiatest.sh
Last active December 26, 2015 21:29
running gaia ui-tests #fxos
cd gaia
npm install
export GAIATEST_ACKNOWLEDGED_RISKS=true
export GAIATEST_SKIP_WARNING=true
./node_modules/.bin/travisaction gaia_ui_tests install
# run all tests
./node_modules/.bin/travisaction gaia_ui_tests script
# or just one
@amirnissim
amirnissim / gotcha-date-ternary-compare.js
Last active December 27, 2015 05:48
JS dates gotcha when using ternary comparison
now = new Date()
// Sat Nov 02 2013 08:56:45 GMT+0200 (IST)
start = new Date()
start.setMonth(start.getMonth()-1)
start
// Wed Oct 02 2013 08:57:26 GMT+0300 (IDT)
end = new Date()
end.setDate(end.getDate()-1)
// Fri Nov 01 2013 08:57:30 GMT+0200 (IST)
String.prototype.indexOf = function(query, start) {
var streak = 0;
start = Math.min(start || 0, this.length - 1);
// TODO stop at this.length - query.length
for (var i = start; i < this.length; i++) {
if (this[i] === query[streak])
streak++;
else