Skip to content

Instantly share code, notes, and snippets.

Mike Piccolo mfpiccolo

Block or report user

Report or block mfpiccolo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View blue-chip-virtual.js
// I am trying to decide on an API for blue-chip's virtual models.
class Owner extends BaseModel {
static get hasMany() {return [Dog]}
}
class Dog extends BaseModel {
static get belongsTo() {return [Owner]}
}
class VirtualOwner extends BaseModel {
@mfpiccolo
mfpiccolo / fetch_json.js
Created Oct 17, 2016
Concept for json api deserializer fetch wrapper.
View fetch_json.js
api_config = {
base_url: 'http://localhost:8065/api/v3',
defaluts: { // if none passed here then use JSON.parse()
success_deserializer: successJsonApiDerserializer,
error_deserializer: errorJsonApiDerserializer,
// has the same defaults as fetch
},
resources: {
all_team_listings: {
endpoint: 'teams/all_team_listings',
@mfpiccolo
mfpiccolo / diesel.js
Last active Apr 20, 2016
Concept for ruby-diesel
View diesel.js
var diesel = require("diesel")
var User = require('User');
diesel.config({
infer_schema = true
infer_models = true # I was thinking this would create Queriable structs with sane defaults based on schema
database_url = "postgres://localhost/ruby_diesel_dev"
model_mapping: {
users: User
}
View sqlite_numeric.rs
use sqlite::Sqlite;
use types::{self, FromSql, FromSqlRow, HasSqlType, Numeric, Float};
use std::error::Error;
use sqlite::connection::SqliteValue;
use std::str::FromStr;
use query_source::Queryable;
use row::Row;
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub enum SqliteNumeric {
View test.rs
impl<T, U> ToJsonApi for Vec<(T, Option<U>)>
where T: ToResourceObject + Default, U: ToResourceObject
{
fn serialize(&self) -> String {
self.into_iter().group_by(|&&(a, b)| a)
.map(|(c, d)| d.into_iter().filter_map(|(e,f)| f).collect())
.collect();
"some".to_string()
}
View example_products_labels_cli.rs
#![feature(custom_derive, core)]
extern crate core;
use std::io;
use std::io::prelude::*;
use core::fmt::Debug;
#[derive(Debug)]
struct Product {
id: i32,
View converter.rs
pub trait Converter {
fn blah(&self) -> &String;
}
struct This {
convert: String,
}
struct That {
convert: String,
}
View ghost.css
pre code {
font-size: 14px;
line-height: 1.2em;
width: 672px;
}
#disqus_thread {
margin-left: 19%;
margin-right: 19%;
}
View a-rubyist-rusting-part-5-2.rs
extern crate hyper;
use std::sync::Arc;
use std::thread;
use hyper::Client;
use std::io::Read;
extern crate time;
#[no_mangle]
pub extern fn run_threads() {
let start_time = time::now();
View a-rubyist-rusting-part-5-2.rb
require 'ffi'
module Scrape
extend FFI::Library
ffi_lib './target/debug/libscrape.dylib'
attach_function :run_threads, [], :void
end
Scrape.run_threads()
You can’t perform that action at this time.