This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# quickly run this by executing this: | |
# | |
# curl -sSL https://gist.githubusercontent.com/colindean/335f5f55073462b114f3/raw/get_scala.sh | sudo bash -s | |
if [ -z "$1" ]; then | |
VERSION="2.11.6" | |
else | |
VERSION="$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
def h | |
{"header" => "value", "header2" => "value2"} | |
end | |
n = 50_000 | |
Benchmark.bm(20) do |x| | |
x.report("split interpolation") { n.times {h.collect{|k,v| "#{k}:#{v}"} }} | |
x.report("split array.join") { n.times {h.collect{|k,v| [k,v].join(':')} }} | |
x.report("split string cat +") { n.times {h.collect{|k,v| k+':'+v} }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mash = ["cmd", "alt", "ctrl"]; | |
var mashShift = ["cmd", "alt", "shift"]; | |
var MARGIN_X = 5; | |
var MARGIN_Y = 5; | |
var GRID_WIDTH = 4; | |
Window.prototype.getGrid = function() { | |
var winFrame = this.frame(); | |
var screenRect = this.screen().frameWithoutDockOrMenu(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'set' | |
ranges = [ "a".."z", "A".."Z", 0..9 ] | |
n = ARGV[0].to_i || 100 | |
Benchmark.bm do |x| | |
#array | |
x.report "array" do | |
n.times do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'set' | |
ranges = [ "a".."z", "A".."Z", 0..9 ] | |
n = ARGV[0].to_i || 100 | |
Benchmark.bm do |x| | |
#array | |
x.report "array" do | |
n.times do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'lifx' | |
available_colors = LIFX::Colors.instance_methods | |
if ARGV.length > 0 | |
# see if a specific lamp is addressed | |
label = /^on|off|0x[0-9a-f]{6}$/.match(ARGV[0]) || available_colors.member?(ARGV[0]) ? nil : ARGV[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 -O | |
import argparse | |
import subprocess | |
import sys | |
def usage(): | |
print("%s target_host target_port" % sys.argv[0]) | |
if len(sys.argv) < 3: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Angle { val degrees: Int } | |
private final case object Perpendicular extends Angle { val degrees = 90 } | |
private final case object Straight extends Angle { val degrees = 180 } | |
private final case class Acute(degrees: Int) extends Angle | |
private final case class Obtuse(degrees: Int) extends Angle | |
private final case class Reflex(degrees: Int) extends Angle | |
object Angle { | |
def apply(degrees: Int): Either[String,Angle] = degrees match { | |
case _ if degrees == 90 ⇒ | |
Right(Perpendicular) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# warning: this was never tested. | |
# license: cc0 | |
require 'win32/registry' | |
module SteamR; module Registry | |
STEAM_HKEY_ROOT = 'SOFTWARE\Valve\Steam' | |
HKEYS = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NodeId(val id: Int) | |
case class DocumentId(override val id: Int) extends NodeId(id) | |
case class ContainerId(override val id: Int) extends NodeId(id) | |
case class UserId(override val id: Int) extends NodeId(id) | |
// how can I get DocumentId, ContainerId, and UserId to be a NodeId and still extend AnyVal? | |
// this seems to work: |