Skip to content

Instantly share code, notes, and snippets.

Tom Milewski tmilewski

Block or report user

Report or block tmilewski

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
tmilewski / gist:11407741
Last active Aug 29, 2015
View gist:11407741
# Install stud
brew install
# Download and install the powssl script
curl > ~/bin/powssl
chmod +x ~/bin/powssl
# Add ~/bin to your PATH
export PATH="$HOME/bin:$PATH"
View powssl


  • Install stud $ brew install
  • Download and install the powssl script $ curl > ~/bin/powssl $ chmod +x ~/bin/powssl
  • Run powssl to create development certificate and configure stud.
    • $ powssl
View gist:107123
class ApplicationController < ActionController::Base
def rescue_optional_error_file(status_code)
known_codes = ["404", "422", "500"]
status = interpret_status(status_code)
if known_codes.include?(status_code)
render :template => "/errors/#{status[0,3]}.html.erb", :status => status, :layout => 'application.html.erb'
render :template => "/errors/unknown.html.erb", :status => status, :layout => 'application.html.erb'
tmilewski / gist:132033
Created Jun 18, 2009
Trying to get the num of faculty assoc w/ a dept incl. the depts w/o any associations
View gist:132033
SELECT as dept_id, d.department, count( as cnt
FROM departments d JOIN faculty f ON f.department_primary =
GROUP BY d.department
SELECT as dept_id, d.department, 0 as cnt
FROM departments d
WHERE NOT IN (SELECT DISTINCT(department_primary) FROM faculty)
ORDER BY department ASC
View gist:382881
# Author: John Trupiano
# Script to upgrade an REE installation on a hot server and maintain sane directory names
if [ "$(whoami)" != "root" ]; then
echo "You need to be root to run this!"
exit 2
View mysql_csv_export.php
$csv_terminated = "\n";
$csv_separator = ",";
$csv_enclosed = '"';
$csv_escaped = "\\";
$db = new mysqli('[HOST]', '[USERNAME]', '[PASSWORD]', '[DATABASE]');
$result = $db->query("SELECT * FROM [TABLE]");
$field_count = $result->field_count;
tmilewski / gist:620644
Created Oct 11, 2010
$field_input_name always returns NULL. It doesn't get much simpler than this.
View gist:620644
# Testing without inputs
function _xprofile_registration_display_field( $field_input_name = 'field_1' ) {
$fields = array(
'field_1' => true,
'field_10' => true,
'field_2' => true,
'field_4' => true,
'field_6' => false
tmilewski / railscasts.rb
Created Jan 2, 2011
Download all Railscasts Episodes
View railscasts.rb
require 'rubygems'
require 'hpricot'
require 'open-uri'
doc = open('') { |f| Hpricot(f) }
total_episodes = (doc/'div.number').first.inner_html[1,3].to_i
total_pages = (total_episodes / 10).ceil
(1..total_pages).each do |i|
puts "PAGE #{i} ================================"
tmilewski / gist:820666
Created Feb 10, 2011
Verbose be_valid RSpec matcher
View gist:820666
RSpec::Matchers.define :be_valid do
match do |model|
failure_message_for_should do |model|
"expected valid? to return true, got false:\n #{model.errors.full_messages.join("\n ")}"
failure_message_for_should_not do |model|
tmilewski / jquery.filterBy.custom.js
Created Apr 13, 2011
Filters a select field based a selection from another.
View jquery.filterBy.custom.js
$(document).ready(function() {
$('.search select#search_tour_stop').filterBy('.search select#search_year');
jQuery.fn.filterBy = function(watch) {
options = new Array;
target = $(this);
target.find('option').each(function(index, option) {
You can’t perform that action at this time.