This file contains hidden or 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://www.jetbrains.com/help/idea/content-roots.html | |
// https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003198659-PyCharm-Fails-to-resolve-references-to-installed-modules-and-even-built-ins | |
sourceSets { | |
main { | |
resources { | |
srcDir file('.venv/lib/python3.6/site-packages') | |
} | |
} | |
} |
This file contains hidden or 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
# install development packages | |
pipenv install --dev | |
poetry install | |
# install packages without development | |
pipenv install | |
poetry install --no-dev | |
# shell into virtualenv | |
pipenv shell |
This file contains hidden or 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
SHELL = /bin/bash | |
# https://get-coursier.io/docs/cli-launch.html#java-options | |
define AMM_SCRIPT | |
#!/bin/bash | |
command -v scala &>/dev/null || { | |
echo "cannot execute scala. is it installed?" | |
exit 1 | |
} |
This file contains hidden or 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
/** | |
* ## Load jars ## | |
*/ | |
import ammonite.ops._ | |
// e.g. /opt/.ivy2/local/sh.almond/ammonite-spark_2.12/0.8.0+16-fc59944f-SNAPSHOT/jars/ammonite-spark_2.12.jar => ammonite-spark | |
val toPackageName = (jarPath: Path) => jarPath.baseName.split("-").dropRight(1).mkString("-") | |
// { "[0-9]$".r findFirstIn _._2.baseName isEmpty } | |
val jarFilter = (jarPath:Path) => jarPath.ext == "jar" && !List("-tests", "-javadoc", "-sources", "jre7", "empty-to-avoid-conflict-with-guava").exists(jarPath.baseName.endsWith) |
This file contains hidden or 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
#!/usr/bin/env python3 | |
import attr | |
import cattr | |
from attrs_serde import serde | |
name_path = ["contact", "personal", "Name"] | |
phone_path = ["contact", "Phone"] | |
This file contains hidden or 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://plantuml.com/text-encoding | |
# https://github.com/dougn/python-plantuml/blob/master/plantuml.py#L64 | |
import zlib | |
import base64 | |
maketrans = bytes.maketrans | |
plantuml_alphabet = string.digits + string.ascii_uppercase + string.ascii_lowercase + '-_' | |
base64_alphabet = string.ascii_uppercase + string.ascii_lowercase + string.digits + '+/' |
This file contains hidden or 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
# for fancyindex | |
include /etc/nginx/modules-enabled/*.conf; | |
# https://github.com/alibaba/tengine/issues/818 | |
events { | |
} | |
http { | |
map $http_upgrade $connection_upgrade { | |
default upgrade; |
This file contains hidden or 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
#!/usr/bin/env python3 | |
# https://github.com/h2oai/h2o-3/blob/master/h2o-core/src/main/java/water/AutoBuffer.java#L269 | |
from struct import unpack | |
with open("x.bin", "rb") as f: | |
magic = unpack(">h", f.read(2))[0] | |
assert magic == 0x1CED |
This file contains hidden or 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
// ported date utility function from http://howardhinnant.github.io/date_algorithms.html | |
// @param z Days since epoch | |
// @return Civic date tuple [y, m, d] | |
local civil_from_days(z) = ( | |
local z1 = z + 719468; | |
local era = std.floor((if z1 >= 0 then z1 else z1 - 146096) / 146097); | |
local doe = (z1 - era * 146097); // [0, 146096] | |
local yoe = std.floor((doe - std.floor(doe / 1460) + std.floor(doe / 36524) - std.floor(doe / 146096)) / 365); // [0, 399] | |
local y = yoe + era * 400; |
This file contains hidden or 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
#!/usr/bin/env bash | |
#------------------------------------------------------------------------------- | |
# Patch target file with content from content file | |
# | |
# If begin/end marks exist, replace the content in between, otherwise append the section. | |
# It's not a function, because sometime we need to run it with sudo. | |
#------------------------------------------------------------------------------- | |
target_file="$1" |