Skip to content

Instantly share code, notes, and snippets.

@dorkrawk
dorkrawk / 🐙..cr
Last active March 9, 2024 17:57
Testing emjoi usage in Crystal.
# this works!
🐙 = 8
puts 🐙
#> 8
# this doesn't work
class 🍕
def eat

Monero Address:

42ETQViAC5gfxMnto9eQXLL1tQNgGZBzUKDJN4CXVfSthwn2vAmPdv6EqA7VAV3K1Cfu7ZQYkBMdeFdASxnXdWqwAz8vJBG

Pools:

gulf.moneroocean.stream:443 us-west.minexmr.com:443

@dorkrawk
dorkrawk / dijkstras.cr
Created March 27, 2017 05:06
Dijkstra's Algorithm implemented in Crystal
class Node
getter name, edges
def initialize(@name : String)
@edges = {} of Node => Float64
end
def add_edge(node, weight)
@edges[node] = weight
end
@dorkrawk
dorkrawk / field_set_values.rb
Created July 19, 2013 04:24
Possible long ugly way to get a "field name" => "field value" hash from a Lawn Tent field set.
fs.project.template.fields.map{ |x| fs.field_values.select{|fv| fv.field == x }.map{|fv| {x.name => fv.string_value}}}
@dorkrawk
dorkrawk / primes.scala
Created July 10, 2013 00:16
Use lazy evaluation to compute primes.
def from(n: Int): Stream[Int] = n #:: from(n + 1)
def sieve(s: Stream[Int]): Stream[Int] = s.head #:: sieve(s.tail filter (_ % s.head != 0))
val primes = sieve(from(2))
primes.take(10).toList // produces first 10 primes
primes.take(100).toList // produces first 100 primes
@dorkrawk
dorkrawk / blue_red_green.ino
Created April 10, 2013 05:03
This is the first little Arduino program I wrote (outside of basic tutorials). It turns on a blue, red, or green LED based on a key stroke. Neat!
char input = 0;
int blue = 9;
int red = 10;
int green = 11;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(100);
@dorkrawk
dorkrawk / boolean_evil.py
Created February 20, 2013 19:18
An incredibly evil little piece of Python to toss into unsuspecting code.
import random
if random.randint(0,1):
(True,False) = (False,True)
@dorkrawk
dorkrawk / fitocracy_run_total.rb
Created September 16, 2012 01:56
This script takes in a Fitocracy username and uses my unofficial Fitocracy Runs API to return the total miles run for the user.
require 'rubygems'
require 'net/http'
require 'json'
require 'date'
if ARGV[0]
username = ARGV[0]
else
abort("You must supply a Fitocracy username.")
end
@dorkrawk
dorkrawk / commands
Last active August 29, 2015 14:14
Useful Commands
git pull -r # pull with rebase instead of merge
rspec -c -fd # run rspec tests with color, verbose output
#########################
# Sane Ruby Setup on OSX
# Install X-Code Command Line Tools
xcode-select --install
# Install Home Brew
@dorkrawk
dorkrawk / singleton_struct.rb
Created December 11, 2014 00:22
A monkeypatch to Ruby Struct to get rid of "warning: redefining constant Struct::whatever" when using Structs
class Struct
def self.new_singleton(name, *fields)
if Struct::const_defined?(name)
Struct.const_get(name)
else
Struct.new(name, *fields)
end
end
end