Skip to content

Instantly share code, notes, and snippets.

View jcf's full-sized avatar
❤️

James Conroy-Finn jcf

❤️
View GitHub Profile
%w(red amber green).map.with_index do |color, index|
color if ((index + 1) / 3.0) < (count.to_f / total.to_f)
end.compact.first
@jcf
jcf / email_validator.rb
Created September 2, 2011 10:48 — forked from stauntonknight/email_validator.rb
Rails 3 Email Validator
require 'mail'
class EmailValidator < ActiveModel::EachValidator
attr_reader :record, :attribute, :value, :email, :tree
def validate_each(record, attribute, value)
@record, @attribute, @value = record, attribute, value
@email = Mail::Address.new(value)
@tree = email.__send__(:tree)
@jcf
jcf / query_trace.rb
Created January 17, 2012 15:30 — forked from belt/query_trace.rb
QueryTrace... ported to rails3
require 'term/ansicolor'
# yeilds a stacktrace for each SQL query
# put this file in config/initializers
class QueryTrace < ActiveSupport::LogSubscriber
include Term::ANSIColor
attr_accessor :trace_queries
def sql(event) #:nodoc:
return unless QueryTrace.enabled? && logger.debug? && Rails.env.development?
start() {
set -e
if [ $# -ne 1 ]; then
echo "You need to supply a queue number. Usage: start queue-number"
else
cd ~/Code/broadcast
export RAILS_ENV=production
export QUEUE=support"$1"
git pull --rebase origin master
@jcf
jcf / 0-readme.md
Created September 18, 2012 17:22 — forked from burke/0-readme.md
ruby-1.9.3-p194 cumulative performance patch.

Patched ruby 1.9.3-p194 for 30% faster rails boot

Overview

This script installs a patched version of ruby 1.9.3-p194 with boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84). It also includes the new backported GC from ruby-trunk.

Many thanks to funny-falcon for the performance patches.

@jcf
jcf / log.txt
Last active October 11, 2015 13:28 — forked from mislav/log.txt
Analyze shell history; zsh edition + alias expansion
686 git commit -v
365 git commit -av
169 git checkout -b
160 git push -u
111 nocorrect mkdir -p
102 nocorrect rm -rf
89 nocorrect rm -r
88 git push -f
79 git branch -D
71 git push origin
(require '[datomic.api :as d])
(def uri "datomic:mem://test")
(d/create-database uri)
(def conn (d/connect uri))
(d/transact conn [{:db/id #db/id [:db.part/db]
:db/ident :enum/ns
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "Enum's namespace. Help enforce fk constraints on :db.type/ref enum references"
@jcf
jcf / checkpoint.sh
Last active March 4, 2024 18:38 — forked from bubenkoff/checkpoint.sh
Endpoint Security VPN FULL start/stop script for Mac OS X
#!/bin/bash
# Toggle Checkpoint VPN firewall and VPN client
#
# http://git.io/vWAPU
set -e
APP='/Applications/Endpoint Security VPN.app'
KEXT='/System/Library/Extensions/cpfw.kext'
PLIST='/Library/LaunchDaemons/com.checkpoint.epc.service.plist'
SERVICE='com.checkpoint.epc.service'
@jcf
jcf / Install
Created October 1, 2016 15:32 — forked from jasonwryan/Install
Arch Linux installation procedure for LVM on LUKS: UEFI EFISTUB boot with gumiboot on a Samsung Series 9 laptop.
# Notes for installing on Samsung Series 9
# UEFI boot: LVM on LUKS
#
# See the full blog post:
# http://jasonwryan.com/blog/2013/01/25/uefi/
# check you are booted in uefi
modprobe efivars
ls /sys/firmware/efi/vars
@jcf
jcf / uefisetup.sh
Created October 1, 2016 15:32 — forked from Apsu/uefisetup.sh
Arch Linux UEFI Setup
# **************** READ THIS FIRST ******************
#
# This is not a script for you to run. I repeat, do not download and run this!
#
# This is only a guide to show the required steps for successful UEFI + GRUB2 installation
# Many of the choices are examples or assumptions; don't blindly type shit into your machine
# until/unless you at least read the comments around each command
#
# These steps assume you've booted in UEFI mode by preparing your USB stick per these instructions:
# https://wiki.archlinux.org/index.php/UEFI#Archiso