Skip to content

Instantly share code, notes, and snippets.

View sosiristseng's full-sized avatar
🐧
Coding

Wen Wei Tseng sosiristseng

🐧
Coding
View GitHub Profile
@sosiristseng
sosiristseng / utils.jl
Created December 2, 2022 05:05
Commonly used functions
##################################
### Commonly-used functions
##################################
"""
Regular Hill function
"""
hill(x, k=one(x)) = x / (x + k)
hill(x, k, n) = hill(x^n, k^n)
@sosiristseng
sosiristseng / svg2tiff
Created October 2, 2022 08:18 — forked from matsen/svg2tiff
A script to convert SVG to a TIFF acceptable to PLOS
#!/bin/sh
# Convert all arguments (assumed SVG) to a TIFF acceptable to PLOS
# Requires Inkscape and ImageMagick 6.8 (doesn't work with 6.6.9)
for i in $@; do
BN=$(basename $i .svg)
inkscape --without-gui --export-png="$BN.png" --export-dpi 300 $i
convert -compress LZW -alpha remove $BN.png $BN.tiff
mogrify -alpha off $BN.tiff
@sosiristseng
sosiristseng / firefox.desktop
Last active September 26, 2022 07:08 — forked from zzag/firefox-nightly.desktop
Firefox Nightly desktop file
[Desktop Entry]
Version=1.0
Name=Firefox
GenericName=Web Browser
Comment=Browse the Web
Exec=/home/sosiristseng/bin/firefox/firefox %u
Icon=/home/sosiristseng/bin/firefox/browser/chrome/icons/default/default128.png
Terminal=false
Type=Application
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
@sosiristseng
sosiristseng / submodule-updater.yml
Created July 10, 2022 01:57 — forked from Supercip971/submodule-updater.yml
update all your submodule when you want with this github action !
name: update all submodules
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
fetch-depth: 0
@sosiristseng
sosiristseng / gitpush-gitlab.yml
Last active March 23, 2022 02:21
Git Operations in GitLab
script:
- bash update.sh
- |
if [[ -n $(git status --porcelain) ]]; then
echo "Commiting updates"
git config --global user.name "${GITLAB_USER_NAME}"
git config --global user.email "${GITLAB_USER_EMAIL}"
git add .
git commit -m "Automated update: $(date '+%Y-%m-%d-%H-%M-%S')"
git push "https://${GITLAB_USER_NAME}:${GIT_PUSH_TOKEN}@${CI_REPOSITORY_URL#*@}"
@sosiristseng
sosiristseng / bwmorph_thin.py
Created March 31, 2021 14:29 — forked from joefutrelle/bwmorph_thin.py
bwmorph('thin') in Python
import numpy as np
from scipy import ndimage as ndi
# lookup tables for bwmorph_thin
G123_LUT = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1,
0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0,
1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
@sosiristseng
sosiristseng / cartpole.py
Last active January 4, 2020 03:20 — forked from stefanopalmieri/whatever.py
Cartpole using simple policy
import numpy as np
import gym
from gym import wrappers
env = gym.make('CartPole-v1')
env = wrappers.Monitor(env, '/tmp/cartpole-experiment-v1', force=True)
for i_episode in range(100):
observation = env.reset()
while True: