Skip to content

Instantly share code, notes, and snippets.

mod test;
fn f() -> i32 { 0 }
mod test_test;
fn f() -> i32 { 0 }
<?php
// HOW TO CREATE A NODE
$node = new stdClass();
$node->title = 'the title';
$node->type = 'node_type';
node_object_prepare($node);
$node->language = LANGUAGE_NONE;
$node->uid = 1;
$node->status = 1;
package main
import (
"bytes"
"compress/gzip"
"fmt"
"io"
"net/http"
"os"
"time"
fn parse_seg_count<R: TryRead>(&mut self,
mut stream: R,
off: usize,
scratch: usize) -> Result<Option<Message>> {
match try!(parse_u32(&mut stream, off, scratch)) {
PartialUsize::More(off, scratch) => {
self.state = State::SegCount(off, scratch);
Ok(None)
}
PartialUsize::Done(seg_count) => {
// ex:ts=4:sts=4:sw=4:et:
#![allow(dead_code, unused_variables)]
use std::io::Result;
use byteorder::{ByteOrder, LittleEndian};
use mio::TryRead;
use super::util::{PartialUsize, bytes_into_words, fill_vec, parse_u32};
@tynor
tynor / years.sql
Last active December 8, 2016 03:21
CREATE TABLE years (
id uuid PRIMARY KEY,
start_date date NOT NULL,
end_date date NOT NULL,
CHECK (start_date < end_date),
CONSTRAINT overlapping_dates EXCLUDE USING GIST (
box(
point(date_part('epoch', start_date), date_part('epoch', start_date)),
@tynor
tynor / map.rs
Last active February 21, 2017 00:04
map.iter() // Get an iterator over the map as (key, value) pairs: Iter<K, V>
.find(|&(k, _)| *k >= index) // Find the first key that is greater than the desired index: Option<(&K, &V)>
.map(|(_, v)| v) // Extract the value from (key, value): Option<&V>
.or_else(|| map.values().next()) // If an index was not found, just get the first value: Option<&V>
map.range(index..) // Get an iterator over the map, starting at the first node equal to or greater than index: Range<K, V>
.map(|(_, v)| v) // Extract the value from (key, value): Option<&V>
.or_else(|| map.values().next()) // If an index was not found, just get the first value: Option<&V>

Keybase proof

I hereby claim:

  • I am tynor on github.
  • I am tynor (https://keybase.io/tynor) on keybase.
  • I have a public key ASAFpOInxl1C-VVjj9GgO3GAKT3CqhmYfg-qPqDUktQwuwo

To claim this, I am signing this object:

git b (. ~/.githelpers && pretty_git_branch):

   lockr-api-cp  122e757  (12 days)  <Tynor Fujimoto>  Add barebones lockr-api capnp schema
*  master        f464998  (12 days)  <Tynor Fujimoto>  Merge branch 'lockr-api-storage'

git l (. ~/.githelpers && pretty_git_log):

*   f464998  (12 days)  <Tynor Fujimoto>   (HEAD -> master, origin/master) Merge branch 'lockr-api-storage'

|\