Skip to content

Instantly share code, notes, and snippets.

@amirnissim
amirnissim / dontforget.bash
Created February 26, 2019 09:43 — forked from ttscoff/dontforget.bash
Quick reminders from Terminal (bash)
#!/bin/bash
# dontforget
#
# A stupid script for short term reminders in bash
#
# Arguments just need to contain a number and a bunch of words.
#
# The number can be anywhere in the arguments, but there shouldn't
# be any other numeric digits.
#
@amirnissim
amirnissim / downscale.sh
Last active October 22, 2017 11:51 — forked from lanceli/downscale.sh
sips downscale image by percentage in Mac OS X
#!/bin/bash
if [ $1 ]
then
echo Processing file $1;
else
# macOS find syntax
for file in `find . -type f -name *.png`; do
echo Processing file "$file";
sips -Z $(($(sips -g pixelWidth "$file" | cut -s -d ':' -f 2 | cut -c 2-) / 2)) "$file" --out "$file" &> /dev/null
@amirnissim
amirnissim / downscale.sh
Created October 22, 2017 11:49 — forked from lanceli/downscale.sh
sips downscale image by percentage in Mac OS X
#!/bin/bash
if [ $1 ]
then
echo Processing file $1;
else
for var in `find *.png`;
do
echo Processing file $var;
sips -Z $(($(sips -g pixelWidth "$var" | cut -s -d ':' -f 2 | cut -c 2-) / 2)) "$var" --out "resized_$var" &> /dev/null
@amirnissim
amirnissim / myExtension.rb
Created July 7, 2016 09:22
Sample Middleman extension
class MyExtension < Middleman::Extension
def initialize(app, options_hash={}, &block)
puts "MyExtension: init"
super
end
def after_configuration
puts "MyExtension: after_configuration"
end
@amirnissim
amirnissim / server.py
Last active August 29, 2015 14:10
Simple Tornado server sending 500 reponses
import tornado.httpserver
import tornado.ioloop
import tornado.web
class Handler(tornado.web.RequestHandler):
def error(self):
self.set_header("Access-Control-Allow-Credentials", "true")
self.set_header("Access-Control-Allow-Origin", "")
self.set_header("Access-Control-Allow-Methods", "GET, POST")
class Foo():
def __init__(self, name):
self.name = name
def get_name(self):
return self.name
x = Foo('x')
y = Foo('y')
@amirnissim
amirnissim / pr.sh
Last active August 29, 2015 14:02
Local branch for a Github Pull Request
cd my-repo
git fetch upstream
git checkout --detach upstream/master
git pull --no-commit upstream refs/pull/<pr-id>/head
# local repo now has (uncommited) changes from pull request
for next in `cat $1`
do
say "$next"
read
done
exit 0
# this file documents the process I used to migrate the project from
# mercurial (bitbucket) to git (github)
#
# we are going to need
# - fast export: https://github.com/frej/fast-export
# - bfg: http://rtyley.github.io/bfg-repo-cleaner/
alias bfg="java -jar bfg.jar"
# clone single revision of the hg repo to eliminate unwanted heads
from marionette import Marionette
m = Marionette()
m.start_session()
from gaiatest.apps.homescreen.app import Homescreen
hs = Homescreen(m)
from gaiatest import GaiaDevice
gd = GaiaDevice(m)
gd.unlock()
hs.launch()
hs.open_context_menu()