Skip to content

Instantly share code, notes, and snippets.

View rainforest-of-code's full-sized avatar

rainforest-of-code

View GitHub Profile
@rxg
rxg / globe.rkt
Last active October 31, 2018 11:39
What proportion of the earth's surface is covered in water? A Bayesian Inference Approach.
#lang racket
(require plot)
(require math/base)
(require math/number-theory)
(require math/distributions)
;; Integration, from https://github.com/mkierzenka/Racket_NumericalMethods
(require "Numerical_Integration.rkt")
;;
@rxg
rxg / urn.rkt
Last active November 12, 2018 00:01
Bayesian Inference example: Urn with Replacement
#lang racket
;; urn.rkt:
;; 5-ball urn statistical process:
;; - A Sampling Engine
;; - An Inference Engine
;; - Some Viz/Rendering tools (under construction)
(require math/distributions)
(require pict)
(require plot)
@snoyberg
snoyberg / README.md
Last active August 27, 2018 05:57
Miniature Haskell interactive environment for my kids to play around with
@JoelQ
JoelQ / MagicStrings.elm
Created August 10, 2018 15:32
Refactoring magic strings in Elm views
view : Model -> Html Msg
view model =
div []
[ div [ class "icon" ] [ span [class "icon-profile" ] [] ]
, div [ class "icon" ] [ span [ class "icon-clock" ] [] ]
]
-- REFACTOR TO
view : Model -> Html Msg
@thbar
thbar / notes.md
Last active July 11, 2018 11:48
Little things about JRuby heap size

Verifying the current JRuby max heap size

I think I'm able to measure the max heap using this code:

# size in bytes
jruby -e "puts java.lang.management.ManagementFactory.memory_mx_bean.heap_memory_usage.max"

Tweaking & measuring

@rainforest-of-code
rainforest-of-code / clipboard.md
Created June 28, 2018 13:21 — forked from krisleech/clipboard.md
3 ways to copy to clipboard in Javascript
if(document.queryCommandSupported('copy')) {
        if(text=='') { text = ' '; } // empty inputs do not get selected

        // copy text to off-screen input
        $('#clipboard').val(text);

        // 1.) does copy empty inputs, but adds newline before content
        var range = document.createRange();
 range.selectNode(document.querySelector('#clipboard'));
// handy method to create a Higher Order Component out of a
// Render Prop Component (like a Context.Consumer).
// handles, statics, displayName, refs, and value forwarding
function createHOCFromRenderProp({prop, Consumer}) {
return Component => {
function Wrapper(props, ref) {
return (
<Consumer>
{value => <Component {...{...props, [prop]: value, ref}} />}

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

@joom
joom / lambda-cube.tex
Created April 14, 2018 02:03
Barendregt's lambda cube in tikzcd, with labels on arrows
\documentclass{standalone}
\usepackage{tikz-cd}
\usepackage{amsmath}
\usepackage{tgpagella}
\begin{document}
\begin{tikzcd}
& & \lambda\omega \arrow[rrr] & & & \lambda\Pi\omega \\
& & & & & \\
\lambda 2 \arrow[rruu] \arrow[rrr] & & & \lambda\Pi 2 \arrow[rruu] & & \\
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Debouncing</title>
<meta name="viewport" content="width=device-width">
<style>
</style>
</head>