Skip to content

Instantly share code, notes, and snippets.

View codeprimate's full-sized avatar

Patrick Morgan codeprimate

  • Bellingham, WA
  • 12:52 (UTC -07:00)
View GitHub Profile
require 'net/http'
require 'net/https'
def get_feed(server,path,username,password)
http = Net::HTTP.new(server,443)
req = Net::HTTP::Get.new(path)
http.use_ssl = true
req.basic_auth username, password
response = http.request(req)
return response.body
@codeprimate
codeprimate / gist:69643
Created February 24, 2009 16:05
Disable CLI echo
def prompt_password
puts "Ask for Input: "
system "stty -echo"
from_user = $stdin.gets.chomp
system "stty echo"
end
# config/initializers/exception_notification.rb
ExceptionNotifier.exception_recipients = %w(me@example.com)
ExceptionNotifier.sender_address = %("Application Error" <notifier@example.com>)
ExceptionNotifier.email_prefix = "[APPLICATION_NAME] "
# For older versions of Rails 2.x
ExceptionNotifier.class_eval do
remove_method :template_root
ExceptionNotifier.template_root = "#{RAILS_ROOT}/vendor/plugins/exception_notification/lib/../views"
end
# Capistrano Deploy Recipe for Git and Phusion Passenger
#
# After issuing cap deploy:setup. Place server specific config files in
# /home/#{user}/site/[staging|production]/shared
# Set :config_files variable to specify config files that should be
# copied to config/ directory (i.e. database.yml)
#
# To deploy to staging server:
# => cap deploy
# => Deploys application to /home/#{user}/site/staging from master branch
@codeprimate
codeprimate / CategoryWidget.html
Created April 28, 2009 17:11
LI selection widget
<style>
ul.category_selection {
margin: 10px;
}
ul.category_selection li {
padding: 5px;
border: 1px solid #ccc;
margin: 5px 16px 5px 0;
display: block;
#!/bin/bash
# /home/username/bin/backup_db.sh
# MySQL Backup
DATE=`date "+%y%m%d"`
BACKUP_DEST="/home/username/site/production/current/db"
DB="database_name"
DB_USER="db_user"
DB_USER_PW="db_password"
// Requires Prototype.js
ConfirmedEmailValidator = Class.create(
{
initialize: function(email_input, confirmation_input) {
this.valid_class = 'valid'
this.invalid_class = 'invalid'
this.email_id = email_input
this.confirmation_id = confirmation_input
this.re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/
this.add_observers()
#!/bin/bash
# Lists listening processes. For OSX
sudo lsof -i -P | grep -i "listen"
#Example Class
class ProfileWizardController < WizardController
define_steps :profile, :review_profile, :company, :review_company
set_default_error "There was a problem processing the last step!"
before_filter :login_required
skip_before_filter :store_location
def company
user_company
¯\_(ツ)_/¯
┌( ಠ_ಠ)┘
{ಠಠ}_,,|,
ಥ_ಥ
(///_ಥ)
๏̯͡๏
טּ_טּ
◪_◪
◮_◮
◔_◔