Skip to content

Instantly share code, notes, and snippets.

View compressed's full-sized avatar

compressed

  • Frostly LLC ❅
  • Boston, MA
View GitHub Profile
#[macro_use]
extern crate diesel;
use diesel::{
prelude::*, query_builder::{InsertStatement, UndecoratedInsertRecord},
query_dsl::methods::ExecuteDsl,
};
trait LoadTable {
type Insertable;
@compressed
compressed / Cargo.toml
Last active March 20, 2017 18:23
serde deserialization error for skipped fields
[package]
name = "serde_test"
version = "0.1.0"
[dependencies]
serde = "0.9"
serde_json = "0.9"
serde_derive = "0.9"
#![feature(conservative_impl_trait, plugin)]
#![plugin(tarpc_plugins)]
extern crate futures;
#[macro_use]
extern crate tarpc;
extern crate tokio_core;
use app1::FutureServiceExt;
use app2::FutureServiceExt as F;
@compressed
compressed / playground.rs
Created February 1, 2016 15:08 — forked from anonymous/playground.rs
rust: map + filter_map + Result examples
use std::collections::HashMap;
fn main() {
// println!("{:?}", go(&[1, 2, 3]));
// println!("{:?}", go(&[1, 3, 4, 5, 6]));
println!("go_while {:?}", go_while(&[1, 3, -4, 4, 5, 6]));
println!("go_filter_map {:?}", go_filter_map(&[1, 3, 4, -4, 5, 6]));
let mut hm = HashMap::new();
set nocompatible " be iMproved, required
set hidden
filetype off " required
" line numbers
set number
set relativenumber
set backspace=2 "allow deleting any chars in insert mode
set laststatus=2
set ruler " show the cursor position all the time
@compressed
compressed / sma.jl
Last active August 29, 2015 14:10 — forked from IainNZ/sma.jl
function sma_original(avect, numPer)
numEle = length(avect)
tout = Array(Float32, numEle)
for ndx = 1:numEle
tsum = 0.0
begndx = max(1, ndx - numPer)
for slicendx = begndx:ndx
tsum += avect[slicendx]
end
tout[ndx] = tsum / float32(numPer)
@compressed
compressed / .vimrc
Last active August 29, 2015 14:04
.vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'tComment'
extern crate collections;
use collections::HashMap;
struct Item {
id: int,
name: StrBuf,
}
fn build_hash(vec: Vec<Item>) -> HashMap<int, Item> {
# /Users/<user>/Library/Application Support/Sublime Text 2/Packages/User
# comment-param.sublime-snippet
<snippet>
<content><![CDATA[
# @param [${1:class}] ${2:arg} - ${3:comment}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>cprm</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@compressed
compressed / tradeking.js
Created August 13, 2013 20:29
TradeKing json parsing example - messages may be sent in chunks
var message = ""
, first_data = true
// message terminator
// all JSON requests will terminate with }}
, terminator = "}}";
request = consumer.get(url, access_token, access_secret);
request.on("response", function (response) {
response.setEncoding("utf8");