Skip to content

Instantly share code, notes, and snippets.

<html>
<head>
<script defer src=https://cdn.jsdelivr.net/npm/p5></script>
<script defer src=https://cdn.jsdelivr.net/npm/p5/lib/addons/p5.dom.min.js></script>
<script defer src=https://cdn.jsdelivr.net/npm/p5/lib/addons/p5.sound.min.js></script>
<script src="js/lib/toxiclibs.js"></script>
<script src="vector.js"></script>
<!-- Select which file to run -->
@jackcallister
jackcallister / babel.config.json
Created July 11, 2020 21:39
React Webpack Babel Minimal Setup (2020)
{
"presets": ["@babel/preset-react", "@babel/preset-env"]
}
import axios from 'axios'
import cache from '../utils/cache'
export function get(slug) {
const url = `${process.env.GILBERT_URL}/api/v1/content/pages/${slug}`
const call = axios.get(url)
return cache({
key: slug,
exp: 120,
other pane cx o
close pane cx 0
go to end of line ce
go to start of line ca
go to end of file m>
go to start of file m<
go to forward word mf
go to back word mb
# EMI::ICPConnectionDataClient.new.find(id)
module EMI
class ICPConnectionDataClient
include HTTParty
class ICP < OpenStruct; end;
base_uri 'https://emi.azure-api.net/ICPConnectionData'
(ns icp-api.core
(:require [org.httpkit.server :as s]
[clojure.data.json :as json]
[clj-http.client :as client]
[inflections.core :as i]))
(def api-key "XXXXXXXXXXXXXXXXXXXXX")
(def uri "https://emi.azure-api.net/ICPConnectionData/single")
(defn- get-icp
;; Objective ; print out x rows of pascals trianlge
;; https://www.mathsisfun.com/pascals-triangle.html
;; (factorial 4) => 4 * 3 * 2 * 1 = 24
(defn factorial [n]
(reduce * (range 1 (inc n))))
;; (binomial-coefficient n k) => n! / k!(n-k)!
;;
;; (binomial-coefficient 4 2) => 24 / 2 * 2 => 24 / 4 => 6
(def puzzle [ 3 0 0 0 0 5 0 1 0
0 7 0 0 0 6 0 3 0
1 0 0 0 9 0 0 0 0
7 0 8 0 0 0 0 9 0
9 0 0 4 0 8 0 0 2
0 6 0 0 0 0 5 0 1
0 0 0 0 4 0 0 0 6
0 4 0 7 0 0 0 2 0
0 2 0 6 0 0 0 0 3 ])
(ns bank-account)
(defn open-account []
(atom 0)
)
(defn close-account [account]
(reset! account nil)
)
# Example of concurrency issue:
class Account
attr_accessor :amount
def initialize
@amount = 0
end
def get_balance