Skip to content

Instantly share code, notes, and snippets.

View snewcomer's full-sized avatar

Scott Newcomer snewcomer

View GitHub Profile
@snewcomer
snewcomer / up-and-running-with-edeliver-on-do.md
Created August 3, 2016 01:48 — forked from mattweldon/up-and-running-with-edeliver-on-do.md
Getting Elixir / Phoenix running on Digital Ocean with edeliver

Build Server

  • Go to Digital Ocean
  • Create new droplet
  • London
  • Ubuntu
  • No apps
  • Add SSH keys
import Ember from 'ember';
export default Ember.Component.extend({
tagName: ''
});
@snewcomer
snewcomer / flatten.exs
Created September 15, 2019 01:15 — forked from veelenga/flatten.exs
Flattening array in elixir
def flatten(list), do: flatten(list, []) |> Enum.reverse
def flatten([h | t], acc) when h == [], do: flatten(t, acc)
def flatten([h | t], acc) when is_list(h), do: flatten(t, flatten(h, acc))
def flatten([h | t], acc), do: flatten(t, [h | acc])
def flatten([], acc), do: acc
const getBooleanTable = number => Array(Math.pow(2, number))
.fill()
.map((_, idx) => idx)
.map(num => num.toString(2).padStart(number, '0'))
.map(stringOfBits =>
stringOfBits.split('').map(bit => Boolean(parseInt(bit)))
)
console.log(getBooleanTable(3))
// Code from: http://patshaughnessy.net/2020/1/20/downloading-100000-files-using-async-rust
//
// Cargo.toml:
// [dependencies]
// tokio = { version = "0.2", features = ["full"] }
// reqwest = { version = "0.10", features = ["json"] }
// futures = "0.3"
use std::io::prelude::*;
use std::fs::File;
const minute = 60;
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const month = day * 30;
const year = day * 365;
/**
* Convert a date to a relative time string, such as
* "a minute ago", "in 2 hours", "yesterday", "3 months ago", etc.

Let's Make A Dropdown

Here, we intend a component that can be used for something like a user menu in a nav. Maybe you've heard it called "popover" or something like that.

It is not meant to be a select element, or used in a <form>.

Goals:

  • make a component that other developers can consume as an addon
  • it should be accessible
@snewcomer
snewcomer / autotracking.js
Created April 1, 2022 16:47 — forked from pzuraq/autotracking.js
Autotracking Simplified
// The global revision clock. Every time state changes, the clock increments.
let $REVISION = 0;
// The current dependency tracker. Whenever we compute a cache, we create a Set
// to track any dependencies that are used while computing. If no cache is
// computing, then the tracker is null.
let CURRENT_TRACKER = null;
// Storage represents a root value in the system - the actual state of our app.
class Storage {
# Import module for data manipulation
import pandas as pd
# Import module for linear algebra
import numpy as np
# Import module for Fuzzy string matching
from fuzzywuzzy import fuzz, process
# Import module for regex
import re
# Import module for iteration
import itertools