Skip to content

Instantly share code, notes, and snippets.

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

Andrew Crookston acrookston

👨‍💻
Coding!
View GitHub Profile
@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 / 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
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 September 23, 2014 01:07
Cross-posting my FizzBuzz challenge from Forrst: http://zurb.com/forrst/posts/FizzBuzz-R33
(1..100).each{|i| puts (i%3==0?'Fizz': '')+(i%5==0?'Buzz': '')+(i%3==0||i%5==0?'': i.to_s)}
@acrookston
acrookston / example.rb
Last active August 29, 2015 14:17
Rails update_attributes without updating the updated_at field
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 21:31
Strechy UICollectionView section header
//
// StretchCollectionViewFlowLayout.swift
//
// Created by Andrew C on 5/8/15.
//
import UIKit
class StretchCollectionViewFlowLayout: UICollectionViewFlowLayout {
.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 */
@acrookston
acrookston / gist:1180414
Created August 30, 2011 07:52
Darn Drupal
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,
@acrookston
acrookston / gist:1194290
Created September 5, 2011 07:08
.profile
# Directory listing
alias ls="ls -G"
alias l="ls"
alias ll='ls -Ghlk'
alias la='ls -GAhlka'
alias ..="cd .."
alias G=" | grep "
# Convenience commands
alias flushdns="dscacheutil -flushcache"