Skip to content

Instantly share code, notes, and snippets.

var i = 99
while (i >= 2)
{
document.write(i + ' bottles of beer on the wall, ' + i + ' bottles of beer! If one of those bottles should happen to fall...')
document.write('<br>')
i--
}
@ChandraNalaani
ChandraNalaani / drink-more-water.js
Created October 3, 2012 20:33
Drink More Water (javascript)
// a node.js command line program
var rl = require('readline');
// requires node's readline module
var prompts = rl.createInterface(process.stdin, process.stdout);
prompts.question("How many 8oz glasses of water have you had today? ", function (glasses) {
var message = '';
@ChandraNalaani
ChandraNalaani / republibot.rake
Created September 12, 2012 19:37
RepubliBot (ruby)
require 'twitter'
namespace :republibot do
desc "Tweet something ridiculous"
task :tweet do
Twitter.configure do |config|
config.consumer_key = '-----'
config.consumer_secret = '-----'
config.oauth_token = '-----'
@ChandraNalaani
ChandraNalaani / health.js
Created May 31, 2012 18:16
Health suggestions in a multilevel conditional (javascript)
// multilevel conditional - switch/case statement
window.onload = initAll;
function initAll() {
document.getElementById("Mental").onclick
= health;
document.getElementById("Physical").onclick
= health;
document.getElementById("Spiritual").onclick
= health;
@ChandraNalaani
ChandraNalaani / therapist.rb
Created December 13, 2011 18:23
Ruby therapist (ruby)
thoughts = ask "What are you thinking about?"
alert "I hear you. You're thinking about " + thoughts + "."
feelings = ask "How does that make you feel?"
alert "Interesting. So you feel " + feelings + ", then."
# That'll be $150, please.
@ChandraNalaani
ChandraNalaani / say-yes.htm
Created November 28, 2011 21:31
"Say Yes" (javascript/html5)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Say Yes</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>
<script src="say-yes.js"></script>
</head>
<body>
@ChandraNalaani
ChandraNalaani / weDidntStartTheFire.js
Created November 28, 2011 02:35
"We Didn't Start The Fire" (javascript)
// for The Front End Web Dev Playlist http://bit.ly/sEiZUZ
function weDidntStartTheFire(){
var itWasAlwaysBurning = $("#sinceTheWorldsBeenTurning");
// we didn't start the fire
// no we didn't light it
var butWeTriedToFightIt = ["birth control", "Ho Chi Minh", "Richard Nixon back again", "Moonshot", "Woodstock", "Watergate", "punk rock", "Begin", "Reagan", "Palestine", "terror on the airline", "Ayatollah's in Iran", "Russians in Afghanistan", "Wheel of Fortune", "Sally Ride", "heavy metal", "suicide", "foreign debts", "homeless vets", "AIDS", "crack", "Bernie Goetz", "hypodermics on the shores", "China's under martial law", "rock and roller cola wars", "I can't take it anymore"];
$.each(butWeTriedToFightIt, function(intIndex, objValue){
itWasAlwaysBurning.append(
$("<li>" + objValue + "</li>")
irb --simple-prompt
>> temp = ['a','b','c']
=> ["a", "b", "c"]
>> temp[3]
=> nil
>> temp[4]
=> nil
>> temp[10,0]
=> nil
>> temp[9,0]