Skip to content

Instantly share code, notes, and snippets.

View dsomel21's full-sized avatar

Dilraj Singh dsomel21

View GitHub Profile
@dsomel21
dsomel21 / reverse_array.rb
Created September 20, 2016 22:07
reverse array without reverse method
def reverse_array(array = [])
reverse_array = []
(1..array.length).each { |n|
reverse_array << array[n*-1]
}
puts reverse_array
end
reverse_array(["00", "01", "02", "03", "04", "05"])
@dsomel21
dsomel21 / yeezyyeezy.txt
Created June 27, 2016 22:24
Sample .txt files for programming
[Max B]
Yeezy, Yeezy, what's good?
It's your boy Max B, what's going on?
Just checking in on you
Appreciate the love and support
The wave is here
You a wavey dude anyway, so you already know
Ain't no problem, man, the game...
You already know how this game thing goes
Do your wave
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script>
<title>Document</title>
</head>
<body>
<div id="ex-step-pies"></div>
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.legacy {
font-size: 12px;
}
rect {
stroke-width: 2;
}
@dsomel21
dsomel21 / fizzbuzz.rb
Created June 17, 2016 05:08
The Classic Fizz Buzz! But with a twist!
def fizzbuzz_value(i)
if i % 5 == 0 && i % 3 == 0
"FizzBuzz"
elsif i % 5 == 0
"Buzz"
elsif i % 3 == 0
"Fizz"
else
i
@dsomel21
dsomel21 / regex.rb
Created June 17, 2016 05:05
Collection of challenging intro regex exercises
# Determine whether a string contains a SIN (Social Insurance Number).
# A SIN is 9 digits and we are assuming that they must have dashes in them
require 'pry'
def has_sin?(string)
!!string.match(/\b\d{3}-\d{3}-\d{3}\b/)
end
puts "\nhas_sin? returns true if it has what looks like a SIN"
puts has_sin?("please don't share this: 234-604-142") #== true
@dsomel21
dsomel21 / dog.rb
Created June 17, 2016 05:02
Fun little dog exercise I did a while back!
# Save this file to your computer so you can run it
# via the command line (Terminal) like so:
# $ ruby shakil_the_dog.rb
#
# Your method should wait for user input, which corresponds
# to you saying something to your dog (named Shakil).
# You'll probably want to write other methods, but this
# encapsulates the core dog logic
def shakil_the_dog
@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: ");
// }
$(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 / application.js
Created June 17, 2016 01:28
quick parse of csv
var dilraj = {
date: '',
time:[],
bg:[],
bolus:[],
carbs:[],
total:[]
};