Skip to content

Instantly share code, notes, and snippets.

View jkirkpatrick24's full-sized avatar
💭
💻

James Kirkpatrick jkirkpatrick24

💭
💻
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="arrayoflight.js"></script>
</head>
<body>
</body>
#Practice
SELECT * FROM books;
SELECT last_name FROM authors;
SELECT b.id, b.author_id, b.title
FROM books AS b;
SELECT b.id, b.title, a.id, a.last_name
FROM books AS b, authors AS a
def benchmark
start_time = Time.now
yield
end_time = Time.now
final_time = end_time - start_time
puts "string.reverse took #{final_time} seconds to run"
end
# Be careful, pasting this into IRB will take a long time to print.
# It's a loooong string. :)
@jkirkpatrick24
jkirkpatrick24 / gist:b872ac4fcc3d1b16f87ca455f6f9a1b1
Created July 24, 2016 00:39 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
require 'benchmark'
# Sort the array from lowest to highest
def sort(arr)
n = arr.length
loop do
swapped = false
(n-1).times do |i|
if arr[i] > arr[i+1]
@jkirkpatrick24
jkirkpatrick24 / shakil_the_dog.rb
Created July 19, 2016 23:43
Chat with Shakil!
def talk
while true
print "Talk to shakil "
input = gets.strip
return input if input.length > 0
puts "Invalid input"
end
end
def conversation(talk)
def maximum(arr)
maxVal = arr[0]
arr.each do |x|
if x > maxVal
maxVal = x
end
end
maxVal
end
def rent?(furnished, rent, baller)
baller && (furnished || rent < 2100)
end
#def rent?(furnished, rent, baller)
# if baller && (furnished || rent < 2100); puts "rent" ;else puts "dont rent";end
#end
###
@jkirkpatrick24
jkirkpatrick24 / FizzBuzz Refactor
Created July 19, 2016 19:20
FizzBuzz Refactor
def fizzbuzz(x,y)
number = x..y
number.each do |i|
if i % 15 == 0
puts "FizzBuzz"
elsif i % 3 == 0
puts "Fizz"
elsif i %5 == 0
puts "Buzz"
@jkirkpatrick24
jkirkpatrick24 / Interactive Ruby (Practice)
Created July 19, 2016 17:45
Interactive Ruby (Practice)
2.3.0 :001 > def say_hi(name)
2.3.0 :002?> "Hi, #{name}"
2.3.0 :003?> end
=> :say_hi
2.3.0 :004 > say_hi("James")
=> "Hi, James"
2.3.0 :005 >
2.3.0 :006 >
2.3.0 :007 > myarray = [0,0,0,0]
=> [0, 0, 0, 0]