Skip to content

Instantly share code, notes, and snippets.

View TyOverby's full-sized avatar
😸

Ty Overby TyOverby

😸
View GitHub Profile
extern crate serde;
use serde::{Serialize, Deserialize};
struct PathInfo;
struct QueryInfo;
trait ApiFunction<I: Deserialize<'static>, R: Serialize> {
fn build(self) -> Box<Fn(PathInfo, QueryInfo, I) -> R>;
}
open System.Collections.Generic;
let memoize f =
let table = new Dictionary<_, _>()
fun k ->
if lock table (fun () -> table.ContainsKey(k))
then
lock table (fun () -> table.[k])
else
let res = f k
@TyOverby
TyOverby / colors.md
Created December 3, 2016 08:57
color problem

Context

There exists a Color space.

weight(Color) = real number between 0 and 1 

difference(Color, Color) = real number between 0 and 100
find . | grep "Cargo.toml$" | # Find all cargo.toml files \
sed 's#/[^/]*$##' | # Remove the filename leaving us with the directories containing cargo.toml files \
xargs -L1 printf "cd \"%s\"; cargo clean; cd -\n" | # Print "cd path/to/crate; cargo clean; cd -" \
bash # Execute

Abstract

Create a "as-a-library" implementation of Bash, offering live-inspection capabilities.

Capabilities

  • Run any batch script as normal
  • Ask for a semantic bound-tree of an arbitrary expression
  • Ask for a lint in a specific environment (detect undefined env-vars)
  • Debug shell script
@TyOverby
TyOverby / .bashrc
Last active February 28, 2016 04:56
export PATH="$PATH:$HOME/.cargo/bin"
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"
set_fg()
{
printf "\001\e[38;5;${1}m\002"
}
set_bg()
{
@TyOverby
TyOverby / gist:ebee310a07149131d712
Created May 19, 2015 22:03
raw C pre-processor
cpp -undef -o foo.txt -nostdinc -E -P
# Make it use C-a, similar to screen..
unbind C-b
unbind l
set -g prefix C-a
bind-key C-a last-window
# Reload key
bind r source-file ~/.tmux.conf
set -g default-terminal "screen-256color"
Process: window [58777]
Path: /Users/USER/*/window
Identifier: window
Version: 0
Code Type: X86-64 (Native)
Parent Process: bash [56204]
Responsible: Terminal [326]
User ID: 501
Date/Time: 2015-02-02 12:50:13.794 -0800
/home/ty/workspace/rust/bincode/examples/basic.rs:4:3: 4:55 warning: `deriving` is deprecated; use `derive`
/home/ty/workspace/rust/bincode/examples/basic.rs:4 #[deriving(RustcEncodable, RustcDecodable, PartialEq)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ty/workspace/rust/bincode/examples/basic.rs:10:3: 10:55 warning: `deriving` is deprecated; use `derive`
/home/ty/workspace/rust/bincode/examples/basic.rs:10 #[deriving(RustcEncodable, RustcDecodable, PartialEq)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ty/workspace/rust/bincode/src/test.rs:68:7: 68:65 warning: `deriving` is deprecated; use `derive`
/home/ty/workspace/rust/bincode/src/test.rs:68 #[deriving(RustcEncodable, RustcDecodable, PartialEq, Show)]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ty/workspace/rust/bincode/src/test.rs:79:7