This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm(list = ls()) #Clear the workspace | |
library(ggplot2) | |
time = seq(1:1000) | |
starting_population = 2 | |
reproduction_rate = 1.0192 | |
population = cbind(time, starting_population*reproduction_rate^time) | |
starting_resources = population[time==length(time)-1][2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These instructions work for OS X 10.6 with homebrew pre-installed. | |
brew install python --framework | |
brew install gfortran | |
# install other dependencies through pip: | |
pip install numpy | |
# the regular pip build for matplotlib is b0rken, and it can't find the built-in libraries for OSX | |
export LDFLAGS="-L/usr/X11/lib" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PusherController < ApplicationController | |
def auth | |
if current_user | |
response = Pusher[params[:channel_name]].authenticate(params[:socket_id], { | |
:user_id => current_user.id, | |
:user_info => { | |
:username => current_user.username, | |
:status => Point.user_status(current_user), | |
:list_html => render_to_string(:partial => "chat_messages/user", :locals => {:user => current_user}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc | |
. ~/.bashrc | |
mkdir ~/local | |
mkdir ~/node-latest-install | |
cd ~/node-latest-install | |
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 | |
./configure --prefix=~/local | |
make install # ok, fine, this step probably takes more than 30 seconds... | |
curl http://npmjs.org/install.sh | sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Item | |
include Mongoid::Document | |
field :fulltext, :type => String, :default => "" | |
field :_keywords, :type => Array | |
index :_keywords | |
field :created_by_id, :type => Integer | |
index :created_by_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Some CSS */ | |
.loading_div { | |
background: white; | |
opacity: 0.7; | |
filter: alpha(opacity=70); | |
width: 100%; | |
height: 100%; | |
position: absolute; | |
top: 0px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def nl2br(string) | |
if string | |
string.gsub("\n\r","<br />").gsub("\r", "").gsub("\n", "<br />") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DEBUG HTTP Connection | |
class ActiveResource::Connection | |
# Creates new Net::HTTP instance for communication with | |
# remote service and resources. | |
def http | |
http = Net::HTTP.new(@site.host, @site.port) | |
http.use_ssl = @site.is_a?(URI::HTTPS) | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl | |
http.read_timeout = @timeout if @timeout | |
#Here's the addition that allows you to see the output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function change_filter(input, accept_blank, query_string_var) | |
{ | |
var accept_blank = (accept_blank) ? accept_blank : false; | |
if ((input && input.value) || (input && accept_blank)) | |
{ | |
filter_name = (query_string_var) ? query_string_var : "filter"; | |
url = add_or_update_query_param(filter_name, input.value) | |
window.location.href = url | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add_or_update_query_param(name, value, starter_url) | |
{ | |
url = starter_url || window.location.href; | |
query_string_chunks = url.split("?"); | |
base_url = query_string_chunks[0]; | |
query_string = (query_string_chunks.length == 2) ? query_string_chunks[1] : null; | |
chunks = []; | |
new_value_updated = false; | |
if (query_string) | |
{ |
NewerOlder