Skip to content

Instantly share code, notes, and snippets.

View acrookston's full-sized avatar
👨‍💻
Coding!

Andrew Crookston acrookston

👨‍💻
Coding!
View GitHub Profile
#!/bin/bash
# Depends on pngbai script: https://gist.github.com/acrookston/6877287
# And don't forget to install pngbai's dependencies (documeted there)
FILES=`git diff --name-only origin/master | grep '\.png$'`
for file in $FILES; do
echo "$file"
git add $file
pngbai $file "${file}2"
@acrookston
acrookston / pngbai
Last active December 24, 2015 22:59
#!/bin/sh
## Packages:
# brew install pngcrush optipng advancecomp
# brew install https://gist.github.com/acrookston/7726731/raw/3e3ce6c177a450c375e3622636f4d55bbe5289f6/pngout.rb
function usage {
echo "Usage: $0 infile outfile"
exit 1
}
@acrookston
acrookston / adb-all
Last active March 3, 2023 07:00
Script to execute an adb command on all connected devices. eg: adb-all uninstall com.example.test
#!/bin/bash
DEVICES=`adb devices | tail -n +2 | cut -f1`
for DEVICE in $DEVICES
do
RUN="adb -s $DEVICE $@"
echo $RUN
${RUN}
done
@acrookston
acrookston / parse_colors.rb
Last active December 26, 2015 20:29
Cross-posting from https://forrst.com/posts/Collecting_colours_from_an_image_Ruby-Lgo Collecting colours from an image with Ruby
require 'rmagick'
number_of_colors = 100
file_path = "/path/to/file.jpg"
begin
temp_file = Magick::Image.read(file_path).first.quantize(number_of_colors)
pixels = {}
pixel_count = 0
temp_file.each_pixel do |p,c,r|
pixel_count += 1
pix = p.to_color(Magick::AllCompliance, false, 8)
require 'formula'
class Pngout < Formula
url 'http://static.jonof.id.au/dl/kenutils/pngout-20110722-darwin.tar.gz'
homepage 'http://www.jonof.id.au/kenutils'
md5 'ce70a9d70e08b1920e5ac88d130d0eb9'
version '20110722'
def install
prefix.install Dir['*']
@acrookston
acrookston / .gemrc
Created February 8, 2014 21:50 — forked from jch/.gemrc
# http://docs.rubygems.org/read/chapter/11
---
gem: --no-ri --no-rdoc
benchmark: false
verbose: true
update_sources: true
sources:
- http://gems.rubyforge.org/
- http://rubygems.org/
backtrace: true
@acrookston
acrookston / nginx_default.conf
Last active August 29, 2015 13:56
basic nginx config for rails and puma
upstream rails {
server unix:///var/www/CHANGE/current/tmp/sockets/puma.sock;
}
server {
listen 80;
server_name CHANGE;
root /var/www/CHANGE/current/public;
client_max_body_size 8M;
@acrookston
acrookston / config_puma.rb
Last active August 26, 2017 23:47
puma config for rvm, capistrano 3 and upstart. Tested on Ubuntu 12.04 LTS and 14.04 LTS
#!/usr/bin/env puma
app_path = '/var/www/YOUR_APP_NAME/current'
directory app_path
environment 'production'
daemonize true
pidfile "#{app_path}/tmp/pids/puma.pid"
state_path "#{app_path}/tmp/pids/puma.state"
stdout_redirect "#{app_path}/log/puma_error.log", "#{app_path}/log/puma_access.log", true
threads 0,16
@acrookston
acrookston / retina_downsize
Created February 25, 2014 22:01
Downsamples all retina @2x.png images
#!/bin/bash
# Downsamples all retina ...@2x.png images.
# Requires `sips` to be installed
echo "Downsampling retina images..."
dir=$(pwd)
find "$dir" -name "*@2x.png" | while read image; do
outfile=$(dirname "$image")/$(basename "$image" @2x.png).png
@acrookston
acrookston / etc_init_sidekiq.conf
Last active December 28, 2015 10:59
sidekiq rvm ubuntu upstart config
# /etc/init/sidekiq.conf - Sidekiq config
# This example config should work with Ubuntu 12.04+. It
# allows you to manage multiple Sidekiq instances with
# Upstart, Ubuntu's native service management tool.
#
# See workers.conf for how to manage all Sidekiq instances at once.
#
# Save this config as /etc/init/sidekiq.conf then mange sidekiq with:
# sudo start sidekiq index=0