Skip to content

Instantly share code, notes, and snippets.

@canweriotnow
canweriotnow / ugh.json
Created June 9, 2015 20:55
My horrid JSON
{
"result_ok":true,
"total_count":"11",
"page":1,
"total_pages":1,
"results_per_page":50,
"data":[
{
"id":"1",
"contact_id":"100009393",
@canweriotnow
canweriotnow / helloworld.pony
Created July 21, 2015 18:04
Hello, Ponytest!
class HelloWorld
let hello: String = "Hello, "
new create() =>
hello
fun say_hello(who: String = "World"): String =>
hello.add(who)
@canweriotnow
canweriotnow / euler022.rb
Created September 4, 2010 17:48
Solution to Euler problem 22 in Ruby
# Ruby script to solve Euler Problem 22
# names.txt d/l'd from http://projecteuler.net/project/names.txt
nf = File.open("names.txt", 'r')
names = nf.gets.scan(/\w+/).sort
total = 0
names.each_with_index do |n,i|
tmp = 0
@canweriotnow
canweriotnow / euler048.rb
Created September 9, 2010 00:08
Solution to Euler problem 048
#!/usr/bin/ruby
sum = 0
x = (1..1000).to_a
x.each do |n|
sum += n**n
end
puts sum
@canweriotnow
canweriotnow / jayz.rb
Created September 10, 2010 00:19
Jay-Z in Ruby!
#!/usr/bin/ruby
foo = "a bitch"
problems = (1..99).to_a
sum = 0
problems.each do |x|
if x == foo
next
else
sum += 1
@canweriotnow
canweriotnow / fixdate.coffee
Created May 10, 2011 15:38
Patching Date.parse() to accept ISO dates (bug in Safari)
origParse = Date.parse
Date.parse = (date) ->
timestamp = origParse(date)
if isNaN(timestamp) && date.match(/^\d{4}-\d{2}-\d{2}/)
dary = date.split('-')
timestamp = origParse(dary[1] + '/' + dary[2] + '/' + dary[0])
return timestamp
@canweriotnow
canweriotnow / funnyjunk.txt
Created May 25, 2011 20:14
Funnyjunk.com ISP info
DNS Info:
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
Domain Name: FUNNYJUNK.COM
Registrar: MONIKER ONLINE SERVICES, INC.
@canweriotnow
canweriotnow / quinebunny.rb
Created November 1, 2011 12:37
A quine and a wabbit walk into a bar...
#!/usr/bin/env ruby
file = File.read(__FILE__)
name = "quinebunny-#{Time.now.to_s.gsub(/\s/, '')}.rb"
io = File.new(name, 'w')
io.write(file)
io.close
%x(ruby #{name})
@canweriotnow
canweriotnow / fib.clj
Created November 4, 2011 19:41
Finding Fibonacci w/ anonymous function in Clojure
;; solution to Fibonacci Sequence
;; https://4clojure.com/problem/26
(fn [n] (take n (map first (iterate (fn [[a b]] (vector b (+ a b))) [1 1])))))
@canweriotnow
canweriotnow / maybe.rb
Created February 7, 2012 19:22
Evil params checking
# In the controller:
private
def maybe(param)
if params[param]
{param => params[param]}
end
end