Skip to content

Instantly share code, notes, and snippets.

View compressed's full-sized avatar

compressed

  • Frostly LLC ❅
  • Boston, MA
View GitHub Profile
@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();
#[macro_use]
extern crate diesel;
use diesel::{
prelude::*, query_builder::{InsertStatement, UndecoratedInsertRecord},
query_dsl::methods::ExecuteDsl,
};
trait LoadTable {
type Insertable;
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 / 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;
# /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");
julia> type MyType
f::Function
end
julia> MyType() = MyType(() -> randi(2000)/1000.0 - 1)
julia> s = MyType()
MyType(#<function>)
julia> [s.f() for j=1:10]
# iphone.rb
Teacup::Stylesheet.new :iphone do
style :root,
backgroundColor: UIColor.redColor,
rowHeight: 100
end
# mycontroller.rb
class MyController < UITableViewController
@compressed
compressed / story.rb
Created March 17, 2012 22:57
Celluloid Actor Pool
class Story < Ohm::Model
include Celluloid
attribute :url
index :url
@pool = Celluloid::Pool.new(Story, {initial_size:10,max_size:100})
class << self; attr_accessor :pool end