Skip to content

Instantly share code, notes, and snippets.

@mikesjewett
mikesjewett / gist:3289589
Created August 7, 2012 21:36
setInterval help
var int = self.setInterval(function(){clock()},1000);
function clock()
{
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("clock").value = t;
}
@mikesjewett
mikesjewett / gist:3378689
Created August 17, 2012 13:27
Restoring RoR dev environment after Mountain Lion upgrade
rvm gemset empty
rvm gemset create mike_dev
rvm use 1.9.3@mike_dev
bundle install
(also had to run bundle update first on macbook, but not iMac. -- this was due to addressable-2.3.1 not being found.)
module InWords
def in_words
return "n/a" if self > 999
num = []
h_num = self - (self%100)
t_num = self - h_num - (self%10)
o_num = self - h_num - t_num - (self%1)
h_words = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
t_words = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
@mikesjewett
mikesjewett / gist:3630077
Created September 5, 2012 03:50
Unix cp example
MICHAELs-MacBook-Pro:rails_projects mike$ pwd
#=> this is where I'm starting the example
/Users/mike/rails_projects
MICHAELs-MacBook-Pro:rails_projects mike$ touch example.txt
#=> I'm creating a blank text file called example.txt
MICHAELs-MacBook-Pro:rails_projects mike$ mkdir newfolder1
#=> I'm creating a new directory called newfolder1
@mikesjewett
mikesjewett / gist:3694445
Created September 10, 2012 22:29
Setup Foreman to use environment constants for hiding sensitive info - local dev environment
# install Foreman
gem install foreman
#bash
export CONSTANT_NAME='name'
export CONSTANT_SOMETHING_ELSE='something_else'
#in app root directory create Procfile, .env and .gitignore
#Procfile
web: bundle exec rails s -p $PORT
@mikesjewett
mikesjewett / gist:3699237
Created September 11, 2012 14:42
Chat about multiple environment config for PS
https://devcenter.heroku.com/articles/multiple-environments
#=> just create a new git remote for ps-staging and then push to it
# PS local constants
store in config/initializers
add to gitignore
commit something.yml.sample to show the contents that the file should have, so other devs can run their own local instance
@mikesjewett
mikesjewett / gist:3765102
Created September 22, 2012 04:20
PG reinstall from scratch
new-host-2:ltp mike$ brew remove postgresql
Uninstalling /usr/local/Cellar/postgresql/9.1.4...
new-host-2:ltp mike$ brew install postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.1.4/postgresql-9.1.4.tar.bz2
Already downloaded: /Library/Caches/Homebrew/postgresql-9.1.4.tar.bz2
==> Patching
patching file src/pl/plpython/Makefile
patching file contrib/uuid-ossp/uuid-ossp.c
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.4 --datadir=/usr/local/Cellar/postgresql
==> make install-world
@mikesjewett
mikesjewett / gist:3777569
Created September 24, 2012 18:46
sample rake routes
meeting_comments POST /meetings/:meeting_id/comments(.:format) comments#create
meeting_comment DELETE /meetings/:meeting_id/comments/:id(.:format) comments#destroy
meeting_meeting_users POST /meetings/:meeting_id/meeting_users(.:format) meeting_users#create
meeting_meeting_user PUT /meetings/:meeting_id/meeting_users/:id(.:format) meeting_users#update
DELETE /meetings/:meeting_id/meeting_users/:id(.:format) meeting_users#destroy
meetings GET /meetings(.:format) meetings#index
POST /meetings(.:format) meetings#create
new_meeting GET /meetings/new(.:format) meetings#new
edit_meeting GET /meetings/:id/edit(.:format) meetings#edit
meeting GET /meetings/:id(.:format) meetings#show
@mikesjewett
mikesjewett / gist:3872369
Created October 11, 2012 13:43
Postgresql Stuff
rails new <name of app> -d postgresql
rails g scaffold User name:string
rake db:migrate
Install Postgres.app
brew install postgresql
Problem: FATAL: role "<name of app/db here>" does not exist
Solution:
cd /usr/lib
@mikesjewett
mikesjewett / _live_meeting.html.erb
Created October 16, 2012 17:52
Simple Javascript Timer
<div class="row">
<div class="span6">
<% if @meeting.started && [email protected]? %>
<%= content_for :javascripts do %>
<script>
var count = <%= @meeting.before_time %>;
var cost = <%= @meeting.cost %>;
</script>
<% end %>
<div class="live_input">