Skip to content

Instantly share code, notes, and snippets.

View thehydroimpulse's full-sized avatar

Daniel Fagnan thehydroimpulse

View GitHub Profile
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
# https://leetcode.com/problems/linked-list-cycle/description/
class Solution:
def hasCycle(self, head: Optional[ListNode]) -> bool:
Kd77m5oUskHYSTiIBNw0pGHczswvQGTi
/// An example that somewhat translates Twitter's use of Thrift within the
/// FlockDb database to Thrust, a Rust implementation of Thrift.
/// This should illustrate the rough API that Thrust exposes and how code generation
/// using the `thrust!` procedural macro works.
extern crate thrust;
use thrust::{Server, ThriftResult};
use flockdb::thrift::{FlockDb};
import serialize from 'stacks/serialize';
import Team from 'stacks/model/team';
let user = serialize('user')
// We want to expose the key `token` under the key `id`, replacing
// whatever `id` used to be.
.map('token', 'id')
// A promise mapping, allowing us to take a single
// key and returning a promise. The resolved value
// must be of the format:
/Users/daniel/Projects/rust/nanomsg.rs/src/lib.rs:1:1: 1:1 error: internal compiler error: Type parameter out of range when substituting in region 'a (root type='amut Socket<'a>) (space=FnSpace, index=1)
/Users/daniel/Projects/rust/nanomsg.rs/src/lib.rs:1 #![crate_type = "lib"]
^
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:116
@thehydroimpulse
thehydroimpulse / cache.coffee
Last active August 29, 2015 14:08
Offline experience
# Provide an interface for working with an offline cache
# that makes it easy to create an offline experience.
class Jobber.Cache
@extend Jobber.EmitterMixin
# An in-memory cache for simplistic case. This should be something on disk to ensure
# the persistence quality one needs for an offline experience.
#
# @property _cache Array<CacheItem>
@_cache: []
extern crate gossip;
use gossip::{Server};
fn main() {
// Node A
spawn(proc() {
// Create a new node.
let mut server = Server::new();
#[phase(plugin)]
extern crate resource_macros;
extern crate resource;
use resource::Resource;
resource! {
table "users"
attr username: String (validate presence, email)
attr password: String (validate presence)
trait Foo<M> {
fn bar<T>(&self, a: M<T>) -> M<T>;
}
rustc --debuginfo=2 des.rs
error: internal compiler error: Type metadata for unique id '{&{&[]{struct 7edd98819e2e66bc/2157e}}}' is already in the TypeMap!
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libsyntax/diagnostic.rs:162