Skip to content

Instantly share code, notes, and snippets.

View mfpiccolo's full-sized avatar

Mike Piccolo mfpiccolo

View GitHub Profile
// 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 October 17, 2016 02:47
Concept for json api deserializer fetch wrapper.
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 April 20, 2016 03:16
Concept for ruby-diesel
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
}
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 {
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()
}
#![feature(custom_derive, core)]
extern crate core;
use std::io;
use std::io::prelude::*;
use core::fmt::Debug;
#[derive(Debug)]
struct Product {
id: i32,
pub trait Converter {
fn blah(&self) -> &String;
}
struct This {
convert: String,
}
struct That {
convert: String,
}
pre code {
font-size: 14px;
line-height: 1.2em;
width: 672px;
}
#disqus_thread {
margin-left: 19%;
margin-right: 19%;
}
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();
require 'ffi'
module Scrape
extend FFI::Library
ffi_lib './target/debug/libscrape.dylib'
attach_function :run_threads, [], :void
end
Scrape.run_threads()