Skip to content

Instantly share code, notes, and snippets.

View codatory's full-sized avatar

Alex Conner codatory

View GitHub Profile
@codatory
codatory / WeightWatchersCalculatorFn.php
Created April 10, 2009 16:10
PHP Function for calculating weight watcher's point values.
<?php
function calculate ($calories, $fiber, $fat) {
$points_from_fat = $fat / 12;
if ($fiber = 0) {
$fiber_caloric_reduction = 0;
} elseif ($fiber < 4) {
$fiber_caloric_reduction = $fiber * 10;
} elseif ($fiber > 4) {
$fiber_caloric_reduction = 40;
@codatory
codatory / pitoval_import.rake
Created February 5, 2011 19:35
Pivotal Tracker Importer for Redmine
begin
require 'ruport'
rescue LoadError => err
warn "Couldn't load ruport gem: #{err}"
end
namespace :import do
desc 'Import tickets from CSV File'
task :csv => :environment do
@codatory
codatory / bashrc
Created March 7, 2011 17:37
Ubuntu Ruby Development Bootstrapper Script
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
if [[ -n "$PS1" ]]; then
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
@codatory
codatory / gist:892502
Created March 29, 2011 15:04
git-goodness
# This is in my .profile, you could also put it in your .bash_profile
feature_deliver() {
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
feature_update
git checkout master
git merge --squash --no-commit ${CURRENT}
git commit
}
feature_update() {
@codatory
codatory / deprecation_logger.rb
Created April 4, 2011 21:07
Rails Deprecation Logger
# Stick this in config/initializers and restart your app to install
# Then you can log your deprecations to log/deprecations.log quickly and easily
# To log with this, just call:
# DeprecationLogger.notify('StringDescriptionOfMethod', DeprecationLogger.caller_method)
class DeprecationLogger < Logger
@logfile = File.open(Rails.root.join('log','deprecations.log'), 'a')
@logfile.sync = true
if (-f $request_filename) {
break;
}
try_files $uri $uri/ @wordpress;
index index.html, index.php;
}
location @wordpress {
~ :❯ time curl http://direct.indygeek.net/ > /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 29504 0 29504 0 0 191k 0 --:--:-- --:--:-- --:--:-- 242k
real 0m0.159s
user 0m0.004s
sys 0m0.006s
~ :❯ time curl http://www.indygeek.net/ > /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
@codatory
codatory / fedora-init.sh
Created May 20, 2011 17:48
Fedora 15 Setup Script
#!/bin/bash
clear
function echo_newline {
echo -e "\n"
}
function pretty_echo {
echo_newline
=border-radius-left($radius)
-moz-border-radius-topleft = $radius
-webkit-border-top-left-radius = $radius
-border-top-left-radius= $radius
-moz-border-radius-bottomleft = $radius
-webkit-border-bottom-left-radius = $radius
-border-bottom-left-radius= $radius
=border-radius-top($radius)
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost