Skip to content

Instantly share code, notes, and snippets.

@NatashaTheRobot
NatashaTheRobot / StanfordBreakoutGame
Created November 18, 2011 05:58
Stanford CS106A Breakout Game Solution
/*
* File: Breakout.java
* -------------------
* Name:
* Section Leader:
*
* This file will eventually implement the game of Breakout.
*/
import acm.graphics.*;
@NatashaTheRobot
NatashaTheRobot / YahtzeeCheckCategory
Created November 23, 2011 20:46
This is the solution to Stanford CS106A YahtzeeMagicStub checkCategory replacement method
/* Pre-condition: The player has finished rolling the dice and selects a category.
* This method returns true if the selected category matches
* to the actual category correctly, and false if it does not match. */
private boolean checkCategory(int[] dice, int category) {
boolean categoryMatch = false;
if(category >= ONES && category <= SIXES || category == CHANCE) {
categoryMatch = true;
}
else {
@NatashaTheRobot
NatashaTheRobot / YahtzeeSolution
Created November 23, 2011 21:10
This is the solution to Stanford CS106A Yahtzee Assignment 5
/*
* File: Yahtzee.java
* ------------------
* This program will eventually play the Yahtzee game.
*/
import acm.io.*;
import acm.program.*;
import acm.util.*;
import java.util.*;
@NatashaTheRobot
NatashaTheRobot / timeformattingRuby
Created December 12, 2011 19:10
Format Time To Today At Midnight GMT In Ruby
require 'time'
#convert today's time to a string
today = Time.now.to_s # => "Mon Dec 12 10:52:45 -0800 2011"
#replace the hours:minutes:seconds and time-zone to the time and time zone that you need
today[11, 14] = "00:00:00 +0000" # => "Mon Dec 12 00:00:00 +0000 2011"
#convert the time string back into time format
Time.parse(today) # => Sun Dec 11 16:00:00 -0800 2011 - The time is adjusted for my time-zone (-0800), but it is equivalent to midnight in GMT time (Mon Dec 12 00:00:00 +0000 2011)
@NatashaTheRobot
NatashaTheRobot / dictionary.html
Created June 13, 2012 02:23
Working with Javascript Hashes
<script>
var english = {
house: "A building for human habitation",
tree:"A woody perennial plant",
street: "A public road in a city or town"
};
var americanEnglish = Object.create(english, {
elevator: "A platform or compartment housed in a shaft for raising and lowering people or things to different floors or levels",
@NatashaTheRobot
NatashaTheRobot / typhoeus.rb
Created June 20, 2012 21:21
Twitter API Example
#https://dev.twitter.com/docs/api/1/get/search
require 'Typhoeus'
require 'JSON'
url = 'http://api.twitter.com/search.json?q=dev+bootcamp&rpp=5&include_entities=true&result_type=mixed'
response = Typhoeus::Request.get(url)
p all_tweets = JSON.parse(response.body)
<!DOCTYPE html>
<html lang='en'>
<head>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type=text/javascript src="/game.js"></script>
<meta charset="UTF-8">
<link rel="stylesheet" href="game.css">
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
@NatashaTheRobot
NatashaTheRobot / psql
Created July 21, 2012 17:05 — forked from rubyonrailstutor/psql
psql code
development:
adapter: postgresql
encoding: unicode
database: url_development
pool: 5
username: jd
password:
host: localhost
port: 5432
protocol AgeClasificationProtocol {
var age: Int { get }
func agetype() -> String
}
class Person {
var firstname: String
var lastname: String
var age: Int
@NatashaTheRobot
NatashaTheRobot / WatchConnectivitySingletonDemo.swift
Last active May 21, 2024 18:21
WatchConnectivity Singleton Demo
//
// WatchSessionManager.swift
// WatchConnectivityDemo
//
// Created by Natasha Murashev on 9/3/15.
// Copyright © 2015 NatashaTheRobot. All rights reserved.
//
import WatchConnectivity