Skip to content

Instantly share code, notes, and snippets.

@bigthyme
bigthyme / LessNaive.js
Created March 24, 2013 07:28
Less Naive implementation of uniform distribution
/**
* Given a function which produces a random integer in the range 1 to 5, write
* a function which produces a random integer in the range 1 to 7.
*/
//returns a random number between 1-5 (inclusive)
var random1to5 = function() {
return Math.ceil(Math.random() * 5);
};
@bigthyme
bigthyme / NaiveRandom.js
Created March 24, 2013 07:09
JS function to find random number between 1-7
/**
* Given a function which produces a random integer in the range 1 to 5, write
* a function which produces a random integer in the range 1 to 7.
*/
//returns a random number between 1-5 (inclusive)
var random1to5 = function() {
return Math.ceil(Math.random() * 5);
};
def run
puts "Welcome to the Command Line Twitter Client"
command = ""
#[6]use cases, if a user types button "x" do something, if a user types button "y" do something.
while command != "q"
printf "enter command: "
input = gets.chomp
parts = input.split
command = parts[0]
case command
#We are using a twitter API method here: http://tutorials.jumpstartlab.com/topics/environment/environment.html
def tweet(message)
#[5]if logic that will check if the user's message is equal to 140. If the message is shorter,
#then it'll tell the user how many characters were used out of 140. If not, it will throw an
#error message.
if message.length >= 140
puts "People are yawning, please shorten your message"
#[1]Require dependent libs
require "jumpstart_auth"
#[2]Adds Class name for scope purposes
class JSTwitter
#[3]Grabs the client attribute from jumpstart library.
attr_reader :client
def initialize
puts "Initializing..."
@bigthyme
bigthyme / jstwitter.rb
Created November 24, 2012 23:36
Easily Integrate with Twitter API (testing purposes only)
#require dependent libs
require "jumpstart_auth"
class JSTwitter
attr_reader :client
def initialize
puts "Initializing..."
@client = JumpstartAuth.twitter
end
@bigthyme
bigthyme / gist:3739442
Created September 17, 2012 20:02
Code for Twilio
begin
client.account.sms.message.create({
:from => "+1##########", #enter your Twilio numbers here
:to => '+1##########',
:body => "Hey there Good Lookin!"
})
rescue Exception => e
#Console log just to confirm your SMS went through
puts "Message successfully sent!"
end
@bigthyme
bigthyme / gist:3739422
Created September 17, 2012 19:58
Initial setup instructions
account_sid = "ACXXXXXXXXXXXXXXXXXX" #enter your Twilio account information
auth_token = "XXXXXXXXXXXXXXXXXX"
client = Twilio::REST::Client.new account_sid, auth_token
@bigthyme
bigthyme / gist:3739413
Created September 17, 2012 19:57
Require Instructions
require 'rubygems'
require 'twilio-ruby'
@bigthyme
bigthyme / webpage.html
Created August 8, 2012 18:33
HTML code for bootstrap example
<body>
<!--fluid attribute gives the div the ability to be responsive for mobile
devices-->
<div class="row-fluid" style="min-width: 100%;">
<!--span12 makes the css class full screen no matter how big or small
the device is-->
<div class="span12 top_bar">
<h3>Goodbye World!</h3>
</div>
<div class="span12 main_container">