Skip to content

Instantly share code, notes, and snippets.

Avatar

compressed

  • Frostly LLC ❅
  • Boston, MA
View GitHub Profile
View main.rs
#[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 Mar 20, 2017
serde deserialization error for skipped fields
View Cargo.toml
[package]
name = "serde_test"
version = "0.1.0"
[dependencies]
serde = "0.9"
serde_json = "0.9"
serde_derive = "0.9"
View same_client_different_servers.rs
#![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 Feb 1, 2016 — forked from anonymous/playground.rs
rust: map + filter_map + Result examples
View playground.rs
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();
View init.vim
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
View 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)
View .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'
View hash.rs
extern crate collections;
use collections::HashMap;
struct Item {
id: int,
name: StrBuf,
}
fn build_hash(vec: Vec<Item>) -> HashMap<int, Item> {
View comment-param.sublime-snippet
# /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 Aug 13, 2013
TradeKing json parsing example - messages may be sent in chunks
View tradeking.js
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");