Skip to content

Instantly share code, notes, and snippets.

(defui UserView
static om/Ident
(ident [this {:keys [user/id]}]
[:user/by-id id])
static om/IQuery
(query [this]
'[:user/id :user/name :user/authenticated]))
(defui UserProfilesView
@txus
txus / plumbing.rs
Last active October 7, 2015 11:18
Pipe together standard Rust [sync] channels and cool comm::mpmc channels!
extern crate comm;
use std::sync::mpsc::{SyncSender, Receiver, SendError, RecvError};
use comm::{Error as CommError};
use comm::mpmc::bounded::Channel;
use std::thread;
use std::marker::Sized;
pub enum Xor<A, B> {
Left(A),
@txus
txus / pipe.rs
Created October 6, 2015 09:01
Piping two channels together in Rust
enum Xor<A, B> {
Left(A),
Right(B)
}
type PipeError<T> = Xor<RecvError, SendError<T>>;
fn pipe<T: 'static + Send, U: 'static + Send>(f: fn(T) -> U, from: Receiver<T>, to: Sender<U>) -> thread::JoinHandle<()> {
thread::spawn(move || {
loop {
@txus
txus / core-typed-live-coding.clj
Created May 15, 2015 11:36
Live coding a lambda calculus with core.typed
(ns achilles.live
(:require [clojure.core.typed :as t]))
"term : x (Variable)
λx.term (Abstraction)
term term (Application)"
(t/ann-datatype TVar [name :- t/Str])
(deftype TVar [name])
@txus
txus / core-typed-interop.clj
Last active August 29, 2015 14:19
Core Typed interop
(ns typed.core
(:require [clojure.core.typed :as t]))
(t/ann-datatype Foo [fooName :- t/Str])
(deftype Foo [fooName])
(t/ann-datatype Bar [barName :- t/Str])
(deftype Bar [barName])
(t/ann theName [(t/U Foo Bar) -> t/Str])
@txus
txus / wtf.rb
Created October 31, 2014 10:56
Haskell-like function composition in Ruby - let the mad horses unleash
require 'blankslate'
class Proc
def self.comp(f, g)
lambda { |*args| f[g[*args]] }
end
def *(g)
Proc.comp(self, g)
end
@txus
txus / brokers.rb
Created October 27, 2014 15:50
sigh
require 'json'
require 'verkehr/zookeeper'
module Verkehr
class Brokers
Broker = Struct.new(:id, :host, :port) do
def to_s
"#{host}:#{port}"
end
@txus
txus / keybase.md
Created March 17, 2014 14:58
keybase.md

Keybase proof

I hereby claim:

  • I am txus on github.
  • I am txus (https://keybase.io/txus) on keybase.
  • I have a public key whose fingerprint is E0E1 1635 59E0 285A 5CBF DD8D 8CBD 973F AA87 A28E

To claim this, I am signing this object:

@txus
txus / pgpkey.rb
Created January 9, 2014 15:50
nifty nice yeah
#!/usr/bin/env ruby
require 'open-uri'
abort("Usage: pgpkey [my.friend@gmail.com|emails.txt]") unless ARGV.first
emails = if File.exist?(ARGV.first)
File.readlines(ARGV.first).map(&:chomp)
elsif ARGV.first =~ /@/
[ARGV.first]
end
@txus
txus / shit.rb
Created November 29, 2013 13:31
this could very well be the ugliest, shittiest, most procedural code I've ever written in my life
#TODO: kill me plz
def find_change(filename, subjective_line, type)
find = Regexp.escape(type == :addition ? '+' : '-')
skip = Regexp.escape(type == :addition ? '-' : '+')
line = 1
commit = @patch[line].scan(/From ([a-z0-9]+)/).first.first
line += 1 until @patch[line] =~ /\+\+\+ b\/#{filename}/
line += 1