Skip to content

Instantly share code, notes, and snippets.

@dsomel21
dsomel21 / irb_Math.rb
Created April 27, 2016 08:18
Interactive Ruby Practice (with Math)
dilraj@TurboGrafix16:~$ pry
[1] pry(main)> Math.sqrt(69)
=> 8.306623862918075
[2] pry(main)> Time.now
=> 2016-04-27 04:15:58 -0400
[3] pry(main)> Array.new(10)
=> [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
[4] pry(main)> Array.new(10,"yeezy")
=> ["yeezy",
"yeezy",
class Robot
attr_accessor :x, :y, :position
def initialize
@x = 0
@y = 0
@position = []
end
@dsomel21
dsomel21 / array_of_light.js
Created May 30, 2016 15:31
Main method for Ultra Lightbeams
function arrayOfLight(x) {
var ultraLightBeam = [];
for (var i = 0; i <= x; i++) {
ultraLightBeam.push(i);
}
console.log(ultraLightBeam);
}
var amount = prompt("Enter the Ultraight Beamness level!");
arrayOfLight(amount);
@dsomel21
dsomel21 / benchmark_with_block.rb
Last active June 4, 2016 17:26
Simple bench mark test using ruby Time class
def benchmark
# Initialize the times
start_time = Time.now
yield
end_time = Time.now
running_time = end_time - start_time
puts "string.reverse took #{running_time} seconds to run"
end
benchmark {
@dsomel21
dsomel21 / candidates.rb
Created June 4, 2016 18:56
Simple application that filters our candidates based on experience, languages, points, etc. Create your own CSV to get started!
# An important extention for Ruby... we need it for the date to manipulate data
require 'active_support/all'
@candidates =
[
{
id: 5,
years_of_experience: 4,
github_points: 293,
languages: ['C', 'Ruby', 'Python', 'Clojure'],
@dsomel21
dsomel21 / max.rb
Created June 4, 2016 19:00
Return the highest value of an array
def maximum(arr)
highest = arr[0]
arr.each {|num| return highest = num if num>highest}
return highest
end
puts maximum([19, 69, 21, 55])
@dsomel21
dsomel21 / application.js
Created June 17, 2016 01:28
quick parse of csv
var dilraj = {
date: '',
time:[],
bg:[],
bolus:[],
carbs:[],
total:[]
};
$(document).ready(function(){
/* Listening for keypress events on the firstname input box */
$("#fname").keypress(function(event){
switch(event.which){
case 65:
console.log("[SHIFT] + [A]")
break;
case 16:
console.log("[SHIFT]")
break;
@dsomel21
dsomel21 / attempt1_game.js
Last active June 17, 2016 04:45
Single-player betting game that runs in the browser. The player starts off with a bankroll of $100 and bets money to guess a number randomly chosen by the game. If the player loses all their money, the game ends. Refactored code is in the final edition game.js!
// 'use strict';
// console.log('You got $' + cash);
// var amount = function bet(){
// amount = prompt("Place a bet between $5-$10: ");
// while (amount < 5 || amount > 10){
// alert("That's not right!");
// amount = prompt("Bet must be between $5-$10. Try Again: ");
// }