Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan danneu

  • Texas
View GitHub Profile
View .elm
module Main exposing (Flags, Model, Msg(..), init, main, subscriptions, update, view)
import Browser
import Browser.Navigation as Nav exposing (Key)
import Html exposing (Html, a, button, div, h1, img, li, text, ul)
import Html.Attributes as Attr
import Html.Events as Events
import Time
import Url exposing (Url)
@danneu
danneu / Main.elm
Last active May 3, 2018
my ellie apps
View Main.elm
module Main exposing (main)
import Array.Hamt as Array exposing (Array)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events
import Random
-- QUILT LIBRARY --
View Quilt.elm
module Quilt exposing (..)
import Array.Hamt as Array exposing (Array)
{-| A quilt is a datastructure for maintaining a Pinterest-like
grid of images. Each image is wrapped with a Cell which calculates
its width/height from the image, but scales the dimensions to
something that fits.
@danneu
danneu / db.rs
Created Apr 13, 2018
Creates a Conn wrapper around postgres::Connection and r2d2::PooledConnection so db fns work with both.
View db.rs
#![allow(warnings)]
// This example stubs out a Conn wrapper around postgres::Connection
// and r2d2_postgres::PooledConnection so that my database functions
// like `insert_user(&conn)` can take my wrapper as an argument and
// work regardless of the underlying connection type.
//
// Example:
//
// // conn is r2d2::PooledConnection
@danneu
danneu / main.rs
Created Apr 13, 2018
soa_serive to make unnest() sql ergonomic
View main.rs
extern crate uuid;
#[macro_use]
extern crate soa_derive;
#[derive(StructOfArray)]
struct Thing {
a: String,
b: i32,
c: uuid::Uuid
}
View noisy.log
Warning: Each child in an array or iterator should have a unique "key" prop.
Check the top-level render call using <small>. See https://fb.me/react-warning-keys for more information.
in a
in MessagePanel
in div
in div
in Homepage
in div
in body
View rust-buffered-concurrency.rs
extern crate tokio_core;
extern crate futures_cpupool;
extern crate futures;
use std::time::Duration;
use std::thread;
use futures::stream::{self, Stream};
use futures_cpupool::CpuPool;
use tokio_core::reactor::Core;
View inet_util.rs
#![feature(i128)]
#![feature(i128_type)]
use std::u128;
use std::net::{Ipv4Addr, Ipv6Addr};
use ipnetwork::IpNetwork;
// Convert 128-bit number to ipv6 address.
fn decimal_to_ipv6(n: u128) -> Ipv6Addr {
Ipv6Addr::new(
@danneu
danneu / image-upload-server.js
Created Feb 11, 2018
This is a naive impl of a node server that accepts image uploads at POST /uploads/:uuid but will stream inflight-uploads from GET /uploads/:uuid.
View image-upload-server.js
// curl -X POST --data-binary "@../massive.jpg" http://localhost:3001/uploads/xxx
// curl -X POST --data-binary "@../massive.jpg" http://localhost:3001/uploads/xxx --limit-rate 32k
'use strict'
const fs = require('fs')
const { EventEmitter } = require('events')
const express = require('express')
const PORT = 3001
View codec.rs
// Since an Encoder and Decoder live as long as a Codec, I'd
// like for them both to share a reference to one instread
// of cloning it.
//
// And do I want refs or slices in this sort of situation? I seem to pick one at random.
// EXAMPLE
fn main() {
You can’t perform that action at this time.