Skip to content

Instantly share code, notes, and snippets.

Avatar

Jack Fransham jFransham

View GitHub Profile
View min.rs
struct A<T: Test> {
a: T,
}
impl<T: Test> A<T> {
fn new<U: Test>(t: T) -> A<T> {
A { a: t }
}
}
View Git PS1 script.sh
__git_ps1() {
if [ "$(git status -s 2>&1 1>/dev/null)" ]; then
return
fi
local nn=$(git status -s 2>/dev/null | grep "??" | sed -n '$=')
local nc=$(git status -s 2>/dev/null | grep M | sed -n '$=')
local branch=$(git branch 2>/dev/null | grep "*" | sed 's/^* //')
nn=$nn
nc=$nc
View Git PS1 update.sh
#!/bin/bash
__git_ps1() {
if [ "$(git status -s 2>&1 1>/dev/null)" ]; then
return
fi
if [ -z "$(ps | grep fetch | grep -v grep)" ]; then
(git fetch 2>/dev/null 1>/dev/null &) > /dev/null
fi
View Separation of axis using iterator adaptors.rs
// requires the 'graphics' package
use graphics::math::{Vec2d, Matrix2d};
fn transform(t: Matrix2d, e: [Vec2d; 2]) -> [Vec2d; 2] {
use graphics::math::transform_pos;
[
transform_pos(t, e[0]),
transform_pos(t, e[1]),
]
View git stuff.sh
function bchangedat {
git log -1 $@ | grep 'Date: ' | perl -pe 's|^\S+\s+(.+?)\s+\S+$|\1|'
}
function mywork {
bwithdates=$(
for i in $(git branch | sed 's/^..//'); do
chng=$(bchangedat $i --date=raw --author=`git config --global user.name`)
if [ "$chng" ]; then
echo $chng $i "($(
View ketos_macro.rs
extern crate ketos;
use ketos::{Interpreter, FromValue};
macro_rules! ketos_mod {
(
mod $name:ident {
$( $inner:tt )*
}
) => {
mod $name {
View overload.rs
macro_rules! overloaded {
(
fn $name:ident
$(
($first_name:ident : $first_type:ty) -> $out:ty;
$body:block
)*
) => {
fn $name<T: Inner>(f: T) -> <T as Inner>::Output {
Inner::do_inner(f)
View mod.rs
use ::set::Set;
use std::convert::TryFrom;
use std::ops::Add;
use sdl2::rect::Rect as SdlRect;
use num::Num;
pub type Bounds = Rectangle<f64>;
pub type Clip = Rectangle<u32>;
View Not scheme
$def is_even:a (
$def is_even_internal: counter even
$if counter
is_even_internal: sub: counter 1 not:even
even;
is_even_internal: a 1
);
$def ?a $if a "yes" "no";
@jFransham
jFransham / stack_router.rs
Last active Aug 26, 2016 — forked from anonymous/playground.rs
Trying to improve on the Iron router's performance without sacrificing ergonomics
View stack_router.rs
#![feature(pattern)]
use std::str::pattern::Pattern;
use std::marker::PhantomData;
#[derive(PartialEq, Eq)]
enum Method {
Get,
Post,
Put,
You can’t perform that action at this time.