Skip to content

Instantly share code, notes, and snippets.

@qwzybug
qwzybug / amtrak.rb
Last active October 11, 2017 13:42
amtrak
#!/usr/bin/env ruby
require 'rubygems'
require 'cgi'
require 'httparty'
require 'nokogiri'
@url = "https://tickets.amtrak.com/itd/amtrak"
@train = '523'
<...SNIP...>
Progress: 80/83
-- While building package openvr-hs-0.1.0.0 using:
/Users/d/.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.24.0.0-ghc-8.0.1 --verbose --builddir=.stack-work/dist/x86_64-osx/Cabal-1.24.0.0 build lib:openvr-hs --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /Users/d/Developer/rumpus/.stack-work/logs/openvr-hs-0.1.0.0.log
Configuring openvr-hs-0.1.0.0...
Dependency base ==4.9.0.0: using base-4.9.0.0
Dependency gl-pal ==0.1.0.0: using gl-pal-0.1.0.0
//: Playground - noun: a place where people can play
import Cocoa
import CoreGraphics
extension CGColor {
static func white(_ value: CGFloat = 1.0, alpha: CGFloat = 1.0) -> CGColor {
return CGColor(red: value, green: value, blue: value, alpha: 1.0)
}
}
@qwzybug
qwzybug / sdf.swift
Created June 22, 2016 07:05
Generate distance field bitmaps from paths in Swift
//: Playground - noun: a place where people can play
import Cocoa
import CoreGraphics
import ImageIO
typealias LineSegment = (CGPoint, CGPoint)
extension CGPoint {
func distance(to point: CGPoint) -> CGFloat {
JIM and his GIRLFRIEND are getting
ready for THE BIG GAME. JIM is wearing
a BLUE AND WHITE JERSEY with the
FACEBOOK LOGO and the name ZUCKERBERG
across the back.
The front door opens. SAM enters,
carrying BREWSKIS.
SAM
// Cons lists are kind of like linked lists
enum List<T> {
case Empty
indirect case Cons(T, List<T>) // doesn't compile yet. will soon.
mutating func add(item: T) {
switch self {
case .Empty:
self = .Cons(item, .Empty)

It wasn't a voice but more like something you just knew, all of a sudden, like a new sense.

Your urine flow is down 4 percent year over year. This is a common early sympton of enlarged prostate and prostate cancer. Your estimated time to further symptons is 3.2 years.

He sighed, angry at himself, like someone twenty years before might have sighed at an unpaid parking ticket come back for collections. Not that long ago it felt like 3.5, even 4 years. Anyway it wasn't hurting yet, though he supposed it probably would soon; these feelings were rarely wrong, if you gave them enough information. Anyway he didn't have enough spare cash at the moment to upgrade his medical plan to an interactive one. He fucking should though, he told himself, he was almost 30 and should be more responsible by now. Or was that just another one of those other feels, maybe a sponsored one? He thought a moment. No, this was nonspecific, a real feeling.

He finished pissing, washed and dried his hands.

He had friends who could affor

@qwzybug
qwzybug / hasklike.swift
Created February 10, 2015 20:44
countdown to haskell-style commas in 3... 2... 1...
for userDict in userList {
if let
id = userDict["id"] as? Int
, name = userDict["name"] as? String
, email = userDict["email"] as? String
, address = userDict["address"] as? [String: AnyObject]
{
users.append(User(id: id, name: name, ...))
}
}
@qwzybug
qwzybug / dev_random.swift
Last active August 29, 2015 14:13
noodling with devices & generators in swift
#!/usr/bin/env swift
import Foundation
class Dev {
let desc: Int32
var data = NSMutableData(length: 1)!
init(_ name: String) {
desc = Darwin.open("/dev/\(name)", O_RDONLY)
}
@qwzybug
qwzybug / janet.md
Created January 4, 2015 09:11
By episode 3, Janet and Larry's relationship remains obscure.

STEVE is a skink. JANET is a sparrow. LARRY is a beaver.


STEVE and JANET enter, continuing a conversation. LARRY is eating a sandwich.

Steve: Oh, that's Larry. Don't mind him, he's a child pornography enthusiast.

Larry (correcting him): Pedophile.