Skip to content

Instantly share code, notes, and snippets.

View edwardloveall's full-sized avatar
👈
there he is

Edward Loveall edwardloveall

👈
there he is
View GitHub Profile
@edwardloveall
edwardloveall / Readme.md
Last active August 29, 2015 13:56
Open Spotify web player in Spotify app

Spotify Open web player in Spotify App Bookmarklet

This bookmarklet will open a Spotify link in the Spotify app. To install, create a new bookmarklet and paste the contents of the spotify.js file as the URL. Use something like Open in Spotify for the name.

for i in (1...100) {
if (i % 3 == 0 && i % 5 == 0) {
println("fizzbuzz")
} else if i % 3 == 0 {
println("fizz")
} else if i % 5 == 0 {
println("buzz")
} else {
println(i)
}
let path = NSURL(string: NSHomeDirectory())
let fileManager = NSFileManager.defaultManager()
let enumerator = fileManager.enumeratorAtURL(path, includingPropertiesForKeys: [NSURLIsDirectoryKey], options: nil, errorHandler: nil)
for urls in enumerator {
}
@edwardloveall
edwardloveall / gist:3f15785bbe28d6cc51bf
Created November 6, 2014 15:09
No Conditionals Fizz Buzz
def fizz_buzz(n)
three = ['fizz', nil, nil]
five = ['buzz', nil, nil, nil, nil]
three_five = ['fizzbuzz', nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
1.upto(n) do |i|
puts three_five[i % 15] || three[i % 3] || five[i % 5] || i
end
end
require 'socket'
host = 'their.ip.address'
port = 33_333
udpsock = UDPSocket.new
udpsock.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true)
loop do
data = gets.chomp
@edwardloveall
edwardloveall / multiple_threads.rb
Last active August 29, 2015 14:10
Trying out multiple threads to see how printing multiple things to the screen at the same time might work
require 'colored'
christmas = Thread.new do
1.upto(10) do
print "Christmas\n".green
sleep(1)
end
end
merry = Thread.new do
@edwardloveall
edwardloveall / waves.rb
Last active August 29, 2015 14:10
Having some fun with stdout
class String
def rotate(n = 1)
chars.rotate(n).join
end
def rotate!(n = 1)
replace(rotate(n))
end
end
@edwardloveall
edwardloveall / migrate.rb
Created March 7, 2015 00:09
Rails: Migrate table from integer based primary keys to UUID
remove_column :table, :id, :primary_key
add_column :table, :id, :uuid, default: 'uuid_generate_v4()'
execute('ALTER TABLE table ADD PRIMARY KEY (id);')
@edwardloveall
edwardloveall / gist:1390880
Created November 24, 2011 08:15
Return Current Season According to Equinoxes/Solstices
function getSeason (dateString) { // format "mm/dd/yy"
var d = typeof(dateString) == "undefined" ? new Date() : new Date(dateString), // use today if nothing is passed in
month = d.getMonth()+1,
day = d.getDate(),
seasonCode = month+(day/100); // mm.dd
if (seasonCode < 3.21) { return "Winter"}
else if (seasonCode < 6.21) { return "Spring"}
else if (seasonCode < 9.22) { return "Summer"}
else if (seasonCode < 12.21) { return "Fall"}
@edwardloveall
edwardloveall / gist:1406484
Created November 29, 2011 21:00
Soft Button
button {
-moz-box-shadow: inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow: inset 0px 1px 0px 0px #ffffff;
box-shadow: inset 0px 1px 0px 0px #ffffff;
background: -webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf) );
background: -moz-linear-gradient( center top, #ededed 5%, #dfdfdf 100% );
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf');
background-color: #ededed;
-moz-border-radius: 2em;