Skip to content

Instantly share code, notes, and snippets.

View mrinterweb's full-sized avatar

Sean McCleary mrinterweb

View GitHub Profile
@mrinterweb
mrinterweb / flippin_file
Created July 21, 2008 21:41
Flippin File
This is a flipping file
Barg!
This is a frikin RAD tool
protected function mySFTP($source_file, $destination_file){
if(!$this->connection) return false;
$sftp = ssh2_sftp($this->connection);
$sftpStream = fopen("ssh2.sftp://{$sftp}{$destination_file}", 'wb');
if($sftpStream) stream_set_blocking($sftpStream, true);
else return false;
try {
if (!$sftpStream)
throw new Exception("Could not open remote file: $destination_file");
# this works very nicely
def self.authenticate(email, password)
user = self.find_by_email(email)
locked_for_x_seconds = 0
if user && user.account_locked_until && Time.now < user.account_locked_until
locked_for_x_seconds = (user.account_locked_until - Time.now).round
user = nil
end
if user
expected_password = encrypted_password(password, user.salt)
Merb.logger.info("Compiling routes...")
Merb::Router.prepare do
resources :posts do
resources :comments
end
#resources :categories
#r.match("/posts/:id/add_comment", method => :post).
# to(:controller => "posts", :action => "add_comment").name(:post_add_comment)
# The following responds to:
# /locations/nearby/45.513906/-122.645548
# /locations/nearby/45.513906/-122.645548/100
# /locations/nearby/45.513906/-122.645548/100/5
# /locations/nearby/45.513906/-122.645548/100/5.xml
# The following urls work now:
# /locations/nearby/45.513906/-122.645548.xml
# /locations/nearby/45.513906/-122.645548/100.xml
#
# :range and :limit are intended to be optional
#!/bin/bash
# This script synchronizes the luminis files on this server with the live luminis server
# remote dir on the luminis server
luminis_dir="/u01/luminis/webapps/luminis/www/CC/"
# The following variables change based on server running this script
this_dir="/var/www/luminis_sync"
local_luminis_files="/var/www/html/cake/app/webroot/files/luminis_base/*"
# derived variables
class Favorite < ActiveRecord::Base
# Uses composite_primary_keys gem: http://compositekeys.rubyforge.org/
set_primary_keys :user_id, :location_id
belongs_to :user
belongs_to :location
validates_uniqueness_of :user_id, :scope => :location_id
end
/* Firefox Google By Date bookmark by Sean McCleary
* I love to search google with a date criteria, but I always was upset with the advanced search interface
* To use this, in Firefox, Go to Bookmarks->Organize Bookmarks...->Bookmarks Menu. Then, add new bookmark.
* Name: Google by Date
* Location: <copy and paste javascript below in this field>
* Keyword: gbd
*
* Useage Example: Say you wanted to search for "funny lolcats" and you only want to see results from the last 5 weeks.
* type in Firefox's location bar
* gbd funny lolcats w5
@mrinterweb
mrinterweb / install.error.log
Created August 26, 2009 23:37
errors with rvm install of ruby 1.9.1
+ case "$action" in
+ rvm-use ruby 1.9
+ implementation=ruby
+ case "$implementation" in
+ '[' 1.9 = 1.8.7 ']'
+ '[' 1.9 = 1.8.6 -o 1.9 = 1.8 ']'
+ '[' 1.9 = 1.9.2 ']'
+ '[' 1.9 = 1.9.1 -o 1.9 = 1.9 ']'
+ level=243
+ MY_RUBY_HOME=/Users/sean/.rvm/ruby-1.9.1-p243
@mrinterweb
mrinterweb / sdoc-all.rb
Created October 1, 2009 08:03
sdoc all your installed gems
# with the help of the sdoc gem, this will generate the sdocs for all
# of your most recent gems.
# Caution! This will take a long time to run if you have a lot of gems installed.
# set an absolute path to the directory you would like your docs generated.
docs_path = "/Users/sean/tmp/docs/"
gems_output = `gem list --local`
gem_list = gems_output.gsub(/^([^ ]+).*\)/, '\1').split(/\n/)
latest_gem_dirs = gems_output.gsub(/^([^ ]+) \(([0-9\.]+).*\)/, '\1-\2').split(/\n/)