#all

// Add new codez here:

7afce8b5a283 "Try"

print "whoa"

b7f310f01ddd "wassa"

javascript:void(alert('wassa'))

b2f723f3d8bc "test"

(+ 1 4)

(comment 
 "just testin")

c261dc60cc07 "Reitit db middleware"

(def db
  {:name    ::db
   :compile (fn [router-data router-opts]
              (fn [handler]
                (fn [request]
                  (handler (assoc request :db (:db router-data))))))})

74bb8b172ccd ""

zsawd

17dcdf3450a2 ":test"

(def foo :foo)

3339bd6fc30f "dawran6/emoji 0.1.4 released"

;; clojure -Sdeps '{:deps {dawran6/emoji {:mvn/version "0.1.4"}}}'
(require '[emoji.core :as e])

(e/emojify "Clojure is awesome :thumbsup:")
;; => "Clojure is awesome 👍"

(e/demojify "Clojure is awesome 👍")
;; => "Clojure is awesome :thumbsup:"


;; Emojify everything
(e/emojify-all "pen pineapple apple pen")
;; => "pen 🍍 🍎 pen"

0e8ce5edf271 "file"

with open('Data/File.csv', 'r') as fi:
    r = fi.readlines()

cb322a60a72a "Make some pretty Charts"

# github/tallguyjenks 

library(readxl)
library(tidyverse)
library(chron)
library(rmarkdown)
library(knitr)


ggplot(data = df) +
    geom_bar(filter(df, Year == params$curYear, 
                    SentToHQQM == "Y", 
                    Inst != "R1"), 
             mapping = aes(x = Inst, fill = Inst)) +
    xlab('2019 Emails By Inst') +
    ylab('Count') +
    facet_wrap(~ Month, ncol = 4) +
    coord_flip() +
    scale_x_discrete(limits = rev(levels(df$Inst))) +
    ggtitle('2019 Received Emails to HQ by Inst Faceted by Month') +
    theme(plot.title = element_text(hjust = 0.5))

8476691710f0 "Hello World(revised)"

'~~ Comments ~~'
'~~~~~~~~~~~~~~'
' github/tallguyjenks '
'~~~~~~~~~~~~~~'

sub helloWorld

    dim message as string
        message = "Hello World!"
    msgbox(message)

end sub

b2c8dc5b5219 "Hello World"

sub helloWorld

    dim message as string

    msgbox(message)

end sub

97df656d9bd2 "Testing"

console.log("this is a great site");

09d5fe7017f9 "dawran6/emoji 0.1.2"

;; clojure -Sdeps '{:deps {dawran6/emoji {:mvn/version "0.1.2"}}}'
(require '[emoji.core :as e])

(e/->emoji "smile")
;; => "😄"

e4faed1246d8 "package dependency install sequence"

installed = set()
processing = set()
def install(x):

    if x in installed:return

    if x in processing: raise Exception("cyclic dependency")
    processing.add(x)

    dependencies = get_dependencies(x)
    for d in dependencies:
        install(d)

    installed.add(x)
    processing.remove(x)

    print(x)

def get_dependencies(x):
    return pkgs.get(x, [])

if __name__ == '__main__':
    # question. note the order is arbitrary
    pkgs = dict()
    pkgs[4]= [5]
    pkgs[2]= [4,5]
    pkgs[1]= [2,3,4,5]


    for p in pkgs.keys():
        install(p)

76fa0662a2fc "package dependency install sequence"

installed = set()
processing = set()
def install(x):

    if x in installed:return

    if x in processing: raise Exception("cyclic dependency")
    processing.add(x)

    dependencies = get_dependencies(x)
    for d in dependencies:
        install(d)

    installed.add(x)
    processing.remove(x)

    print(x)

def get_dependencies(x):
    return pkgs.get(x, [])

if __name__ == '__main__':
    # question. note the order is arbitrary
    pkgs = dict()
    pkgs[4]= [5]
    pkgs[2]= [4,5]
    pkgs[1]= [2,3,4,5]


    for p in pkgs.keys():
        install(p)

136b59a94871 "dare to lead"

clear is kind, and unclear is unkind. Brene Brown

6e91e647eaff "statistical bias -1 proven by simulation"

'''
when using n samples to estimate population std,
we will put (n-1) in the denominator:

population_std = sqrt( sample_sum_of_err_sq / (n-1))

i.e.,

population_var * (n-1) = sample_sum_of_err_sq

i.e.,

-1 = sample_sum_of_err_sq / population_var - n

This simulation is to evidence the -1 in the statistic sense

'''
import random

N = 10000 # population size
n = 30 # sample size
num_of_simulation = 500


def sum_of_err_sq(samples):
    N = len(samples)
    mean = sum(samples) / N
    errsq = [(e - mean) ** 2 for e in samples]
    return sum(errsq)


def get_bias():
    samples = random.sample(population, n)
    sample_sum_of_err_sq = sum_of_err_sq(samples)

    # true_var * (n-1) = sample_sum_of_err_sq
    # n-1 = sample_sum_of_err_sq / true_var
    # -1 = sample_sum_of_err_sq / true_var - n

    return sample_sum_of_err_sq / population_var - n  # ~= -1


def bias_avg_gen(iteration: int):
    n = 0
    bias_avg = 0
    while n < iteration:
        bias_new = get_bias()
        bias_sum = (bias_avg * n + bias_new)
        n += 1
        bias_avg = bias_sum / n
        yield bias_avg


if __name__ == '__main__':

    population = [random.random() for _ in range(N)]  # any population works
    population_var = sum_of_err_sq(population) / N
    for i, bias_avg in enumerate(bias_avg_gen(num_of_simulation)):
        print(i, bias_avg)

8f81a0f09ac5 "Newton method"

(defn newton
   [f fprime tol max-iteration x]
   (if (<= max-iteration 0)
     nil
     (let [y (f x)
           yprime (fprime x)
           x-new (- x (/ y yprime))]
       (if (<= (Math/abs(- x-new x)) (* tol (Math/abs x-new)))
         x-new
         (newton f fprime tol (dec max-iteration) x-new)))))

(newton #(- (* % %) 2) #(* 2 %) 0.00000001 20 100)
;; => 1.4142135623730951

0e380c374a0d "Generate 16-bytes server secret key "

import secrets
import string

alphabet = string.ascii_letters + string.digits
print(''.join(secrets.choice(alphabet) for i in range(16)))

bcb1e75038a8 "Time-ago function"

;; https://stackoverflow.com/questions/32511405/how-would-time-ago-function-implementation-look-like-in-clojure
(defn time-ago [epoch-second]
  (let [units [{:name "second" :limit 60 :in-second 1}
               {:name "minute" :limit 3600 :in-second 60}
               {:name "hour" :limit 86400 :in-second 3600}
               {:name "day" :limit 604800 :in-second 86400}
               {:name "week" :limit 2629743 :in-second 604800}
               {:name "month" :limit 31556926 :in-second 2629743}
               {:name "year" :limit Long/MAX_VALUE :in-second 31556926}]
        diff  (t/in-seconds (t/interval (c/from-epoch epoch-second) (t/now)))]
    (if (< diff 5)
      "just now"
      (let [unit (first (drop-while #(or (>= diff (:limit %))
                                         (not (:limit %)))
                                    units))]
        (-> (/ diff (:in-second unit))
            Math/floor
            int
            (#(str % " " (:name unit) (when (> % 1) "s") " ago")))))))

5d6bc505d8c2 "Flask"

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

f13455592a36 "Coast server"

(ns server
  (:require [coast]))

(defn home [request]
  (coast/ok "You're coasting on clojure"))

(def routes (coast/routes [:get "/" ::home]))

(def app (coast/app {:routes routes}))

(coast/server app {:port 1337})

4c90ac73beef "Hello World"

print("Hello World")

9dba5d8157c7 "Hello World"

console.log("Hello World");

1f541de3bd7e "Hello World"

(println "Hello World!")