- Create a gist if you haven't already.
- Clone your gist:
# make sure to replace `<hash>` with your gist's hash git clone https://gist.github.com/<hash>.git # with https git clone git@gist.github.com:<hash>.git # or with ssh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DummyController < ApplicationController | |
def do | |
render json: { balance: 50 } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
# If this file is edited, it must be removed from EC2 instance prior to deploy. | |
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_yarn_install.sh" : | |
mode: "000775" | |
owner: root | |
group: users | |
content: | | |
#!/usr/bin/env bash | |
set -xe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type tree = Leaf | Node(int, tree, tree); | |
let rec sum = (item) => { | |
switch (item) { | |
| Leaf => 0 | |
| Node(value, left, right) => value + sum(left) + sum(right); | |
} | |
}; | |
let rec height = (root) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function iframeURLChange(iframe, callback) { | |
var lastDispatched = null; | |
var dispatchChange = function () { | |
var newHref = iframe.contentWindow.location.href; | |
if (newHref !== lastDispatched) { | |
callback(newHref); | |
lastDispatched = newHref; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
// Add these two imports | |
import Elm from 'react-elm-components'; | |
import Main from "./Main"; | |
function App() { | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Extracted from: https://guide.elm-lang.org | |
-- Read more about this program in the official Elm guide: | |
-- https://guide.elm-lang.org/architecture/buttons.html | |
module Main exposing (main) | |
import Browser | |
import Html exposing (Html, button, div, text) | |
import Html.Events exposing (onClick) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/a/30638226 | |
// When printing an “Element” Chrome developer tools will request the 'id' property | |
// If the 'id' property is fetched, then the devtools is open | |
let checkStatus; | |
let customElement = document.createElement('p'); | |
document.body.appendChild(customToString); | |
let element = new Image(); | |
Object.defineProperty(element, 'id', { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
componentDidUpdate(prevProps, prevState) { | |
Object.entries(this.props).forEach(([key, val]) => | |
prevProps[key] !== val && console.log(`Prop '${key}' changed`) | |
); | |
Object.entries(this.state).forEach(([key, val]) => | |
prevState[key] !== val && console.log(`State '${key}' changed`) | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn compute-collatz [num steps] | |
(cond | |
(= num 1) steps | |
(even? num) (compute-collatz (/ num 2) (inc steps)) | |
(odd? num) (compute-collatz (+ 1 (* num 3)) (inc steps)))) | |
(defn collatz [num] | |
{:pre [(pos? num)]} | |
(compute-collatz num 0)) |
NewerOlder