Skip to content

Instantly share code, notes, and snippets.

@NebulaFox
NebulaFox / LICENSE
Created July 6, 2014 21:08
University of Illinois/NCSA Open Source License
Copyright (c) 2013 Helium End All rights reserved.
Developed by: Robbie Bykowski
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution.
@NebulaFox
NebulaFox / httpclientstreams.nim
Last active November 13, 2016 11:56
Change usage of strings to streams
#
#
# Nim's Runtime Library
# (c) Copyright 2016 Dominik Picheta, Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
## This module implements a simple HTTP client that can be used to retrieve
@NebulaFox
NebulaFox / main.dart
Created December 19, 2018 19:54
test tan π/2 and -π/2 is infinity
import 'dart:math';
void main() {
final v = tan(pi * 0.5);
final u = tan(-pi * 0.5);
print("tan(π/2) = $v");
print("tant(-π/2) = $v");
}
@NebulaFox
NebulaFox / main.dart
Last active December 24, 2018 18:07
Dart / Duration
void main() {
final sunrise = Duration.fromTime(
hours:8,
seconds:39,
);
final dayLength = Duration.fromTime(
hours: 7,
minutes: 51,
seconds: 45
@NebulaFox
NebulaFox / playground.rs
Last active March 20, 2020 18:17
lazy loading problem
struct Context {
foo: Option<String>,
bar: Option<String>
}
impl Context {
fn new() -> Self {
Context {
foo: None,
bar: None
@NebulaFox
NebulaFox / playground.rs
Last active March 20, 2020 18:16
lazy loading solution
struct Context {
foo: String,
bar: String
}
struct ContextBuilder {
foo: Option<String>,
bar: Option<String>
}
use std::collections::HashSet;
#[derive(Debug)]
enum Check {
Known(String),
Duplicate(String),
Missing(String),
Unknown(String)
}
use std::collections::HashSet;
use std::rc::Rc;
#[derive(Debug)]
enum Check {
Known(Rc<String>),
Duplicate(Rc<String>),
Missing(Rc<String>),
Unknown(Rc<String>)
use std::collections::HashSet;
#[derive(Debug)]
enum Check<'a> {
Known(&'a str),
Duplicate(&'a str),
Missing(&'a str),
Unknown(&'a str)
}
@NebulaFox
NebulaFox / playground.rs
Last active March 16, 2020 15:52
HashSet<&String> to be coerced into HashSet<&str>
use std::collections::HashSet;
fn main() {
// move strings into HashSet
let known_values: HashSet<&str> = ["a", "b", "c"]
.iter().cloned().collect();
// provided an Vec<String>
let provided_values: Vec<String> = vec![