Skip to content

Instantly share code, notes, and snippets.

View dustinheestand's full-sized avatar

Dustin Heestand dustinheestand

  • San Francisco
View GitHub Profile
-- Show the current time in your time zone.
--
-- Read how it works:
-- https://guide.elm-lang.org/effects/time.html
--
-- For an analog clock, check out this SVG example:
-- https://elm-lang.org/examples/clock
--
import Browser
-- Press a button to generate a random number between 1 and 6.
--
-- Read how it works:
-- https://guide.elm-lang.org/effects/random.html
--
import Browser
import Html exposing (..)
import Html.Events exposing (..)
import Process
import Browser
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput, onBlur, onFocus)
-- MAIN
/*****************************************************************************
This is a Node.js script. It requires any supported version of Node, i.e.
Node LTS 8, LTS 10, or 12.
Node may be downloaded here: https://nodejs.org/en/.
The script has been tested on Ubuntu Linux and on Windows.
Once you have installed Node, save this file where you wish the output to
@dustinheestand
dustinheestand / anagram-detector.md
Created January 24, 2019 16:38
Anagram detector

Prompt

You are given an array of strings only (could be words, phrases etc). Create a function to find all the anagrams within that array. The output should be an array where each element in the array is itself an array of anagrams.


Examples

const words = ['cat', 'act', 'ignore', 'a phrase', 'tape', 'pate', 'e hpsara'];
@dustinheestand
dustinheestand / permutations.md
Created January 10, 2019 22:46
Permutations!

Prompt

Given a string, return an array of all the permutations of that string. The permutations of the string should be the same length as the original string (i.e. use each letter in the string exactly once) but do not need to be actual words.

The array that is returned should only contain unique values and its elements should be in alphabetical order.

Examples

stringPermutations('one');
@dustinheestand
dustinheestand / decimal-to-binary.md
Created November 19, 2018 18:37
Decimal-To-Binary & reverse

Decimal-To-Binary & reverse


Prompt

Write 2 functions, one that takes the a number in base 10 (decimal) and converts it to the string representation of that number in base 2 (binary), and one that converts back.

You may not use parseInt, toString, or any similar function which does base conversion for you.

class: center middle

Priority Queue


Definitions

A queue is a data structure that stores pieces of data and returns them in the same order in which they were inserted. One way of implementing them is as a linked list.

A priority queue is a data structure that takes a priority value with each piece of data and returns the data in order of priority.

var React = require('react')
export default class Elm extends React.Component {
ref = node => {
if (node === null) return
const app = this.props.src.init({node, flags: this.props.flags})
if (typeof this.props.ports !== 'undefined') this.props.ports(app.ports)
}
shouldComponentUpdate = () => {
return false
var React = require('react');
var createReactClass = require('create-react-class');
module.exports = createReactClass({
initialize: function (node) {
if (node === null) return;
var app = this.props.src.embed(node, this.props.flags);
if (typeof this.props.ports !== 'undefined') {
this.props.ports(app.ports);
}