Skip to content

Instantly share code, notes, and snippets.

👨‍💻
Coding!

Andrew Crookston acrookston

👨‍💻
Coding!
Block or report user

Report or block acrookston

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View .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 Aug 29, 2015
basic nginx config for rails and puma
View nginx_default.conf
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 / retina_downsize
Created Feb 25, 2014
Downsamples all retina @2x.png images
View retina_downsize
#!/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
View colors_from_image.rb
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)
@acrookston
acrookston / fizzbuzz.rb
Created Sep 23, 2014
Cross-posting my FizzBuzz challenge from Forrst: http://zurb.com/forrst/posts/FizzBuzz-R33
View fizzbuzz.rb
(1..100).each{|i| puts (i%3==0?'Fizz': '')+(i%5==0?'Buzz': '')+(i%3==0||i%5==0?'': i.to_s)}
@acrookston
acrookston / proc_cpu_pid
Last active Aug 29, 2015
Munin plugin to track CPU usage from specific processes based on process id's
View proc_cpu_pid
#!/bin/sh
#
# Extended 2015 by Andrew Crookston <andrew@caoos.com> to use pidfiles instead of process names
# Original (c) 2010, Andrew Johnstone andrew @ajohnstone.com
# Based on the 'proc_mem' plugin, written by Rodrigo Sieiro rsieiro @gmail.com
#
# Configure it by using the pidfiles env. Format: name:pidfile name:pidfile. e.g.:
#
# [proc_cpu_pid]
# env.pidfiles munin-node:/var/run/munin/munin-node.pid
@acrookston
acrookston / example.rb
Last active Aug 29, 2015
Rails update_attributes without updating the updated_at field
View example.rb
class Example < ActiveRecord::Base
include WithoutTimestamps
def update_something
update_without_timestamps something: "is changed"
end
def alternatively
self.something = "is changed"
update_without_timestamps
@acrookston
acrookston / StretchCollectionViewFlowLayout.swift
Created May 8, 2015
Strechy UICollectionView section header
View StretchCollectionViewFlowLayout.swift
//
// StretchCollectionViewFlowLayout.swift
//
// Created by Andrew C on 5/8/15.
//
import UIKit
class StretchCollectionViewFlowLayout: UICollectionViewFlowLayout {
View ie-box-shadow.css
.box-shadow {
width: 100px;
height: 100px;
position: absolute;
z-index: 100;
top: 10;
left: 10;
background: #fff;
-moz-box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.8); /* FF3.5+ */
-webkit-box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.8); /* Saf3.0+, Chrome */
View gist:1180414
SELECT
node.nid AS nid,
node_data_field_spot_permalink.field_spot_permalink_value AS node_data_field_spot_permalink_field_spot_permalink_value,
node.type AS node_type,
node.vid AS node_vid,
node_data_field_spot_permalink.field_spot_image_fid AS node_data_field_spot_permalink_field_spot_image_fid,
node_data_field_spot_permalink.field_spot_image_list AS node_data_field_spot_permalink_field_spot_image_list,
node_data_field_spot_permalink.field_spot_image_data AS node_data_field_spot_permalink_field_spot_image_data,
node.title AS node_title,
node_data_field_spot_permalink.field_spot_bloggname_value AS node_data_field_spot_permalink_field_spot_bloggname_value,
You can’t perform that action at this time.