Skip to content

Instantly share code, notes, and snippets.

View willhyper's full-sized avatar

Chao-Wei Chen willhyper

View GitHub Profile
@willhyper
willhyper / mermaid.html
Created April 1, 2024 22:28
mermaid.html
<html>
<body>
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
const config = {
startOnLoad: true,
flowchart: { useMaxWidth: true, htmlLabels: true, curve: 'cardinal' },
@willhyper
willhyper / bokeh_vbar_stack.py
Last active August 10, 2022 08:29
vbar vs. vbar_stack
#%%
from bokeh.io import output_file, show
from bokeh.plotting import figure
output_file("stacked.html")
fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
years = ["2015", "2016", "2017"]
colors = ["#c9d9d3", "#718dbf", "#e84d60"]
# https://docs.getdbt.com/dbt-cli/install/homebrew
brew update
brew install postgres
brew upgrade postgres
brew install dbt-postgres
brew upgrade dbt-postgres
@willhyper
willhyper / dep.py
Last active May 25, 2022 17:24
use python-pptx to generate dependency diagram
from pptx import Presentation
from pptx.enum.shapes import MSO_SHAPE, MSO_CONNECTOR
from pptx.util import Inches
from pptx.oxml import parse_xml
prs = Presentation()
title_only_slide_layout = prs.slide_layouts[5]
slide = prs.slides.add_slide(title_only_slide_layout)
@willhyper
willhyper / gist:6fc51d323a7264a80b7f7c237646d584
Last active December 29, 2020 04:51
(defn intersect? [[A B] [C D]])
(def A [1 0])
(def B [-1 0])
(def C [0 1])
(def D [0 -1])
(defn v- [[px py] [qx qy]]
[(- qx px) (- qy py)])
(defn outer-product
([[px py] [qx qy]] (- (* px qy) (* py qx)))
@willhyper
willhyper / core.cljs
Created August 25, 2020 04:38
lein new figwheel app; cd app; npm install; lein figwheel
; (base) chaoweichen@cwmbp:~/repo $ lein new figwheel app
; Generating fresh 'lein new' figwheel project.
; Change into your 'app' directory
; Install npm dependencies via 'npm install'
; Then run 'lein figwheel'
; Wait for it to finish compiling
; A browser window should open to the demo application, if not
; then open 'http://localhost:3449/index.html' in your browser
@willhyper
willhyper / core.clj
Last active August 25, 2020 01:24
lein new app; lein run; lein uberjar; java -jar target/app-0.1.0-SNAPSHOT-standalone.jar
(ns app.core)
(defn -main
"I don't do a whole lot."
[x]
(println x "Hello, World!"))
@willhyper
willhyper / Library.java
Created August 24, 2020 06:40
clojure-java interop. adding off-shored jar
/*
* gradle init
* gradle jar
* cp build/libs/*.jar ../interop-clj/resources
*/
package jlib;
public class Library {
public boolean method1() {
return true;
@willhyper
willhyper / Main.java
Last active August 24, 2020 03:55
calling clojure from java ; jshell
import clojure.java.api.Clojure;
import clojure.lang.IFn;
public class Main{
public static void main(String[] args){
IFn plus = Clojure.var("clojure.core", "+");
var ans = plus.invoke(1, 2);
System.out.println(ans);
}
@willhyper
willhyper / tile_2_x_3.py
Created July 28, 2020 04:32
tile photo 2 by 3
import sys
img_name = sys.argv[1]
import matplotlib.pyplot as plt
import numpy as np
im = plt.imread(img_name)
im23 = np.tile(im, [2,3,1])
plt.imsave("output.jpg", im23)