Skip to content

Instantly share code, notes, and snippets.

View zthxxx's full-sized avatar
🐾
Nyaa~

zthxxx zthxxx

🐾
Nyaa~
View GitHub Profile
@zthxxx
zthxxx / PoW-CTFjs
Created March 27, 2018 04:59
Proof of work in CTF-wirteup
cosnt crypto = require('crypto')
const md5sum = str => crypto.createHash('md5').update(str).digest('hex')
function PoW(target, start, end) {
while (true) {
let rand = Math.random().toString(36)
let hash = md5sum(rand).slice(start, end)
if (hash === target) return rand
}
}
@zthxxx
zthxxx / bundle.bat
Created April 17, 2018 12:22
bundle python package to win exe (support pandas)
@echo off
if not exist venv/ call init.bat
call venv\Scripts\activate.bat
pyinstaller -F main.py --hidden-import=pandas._libs.tslibs.timedeltas
call venv\Scripts\deactivate.bat
rd /s/q build
const raw = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
let line
while (line = raw.shift()) {
console.log(line)
}
@zthxxx
zthxxx / deb-install-nvidia-docker.sh
Last active May 8, 2018 13:21
install nvidia-docker on Debian/Ubuntu, and run tensorflow
# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
apt purge -y nvidia-docker
# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
tee /etc/apt/sources.list.d/nvidia-docker.list
apt update
@zthxxx
zthxxx / deb-install-docker.sh
Last active May 9, 2018 17:59
install docker with DEB package on debian / ubuntu
#!/usr/bin/env bash
# curl -sL https://gist.githubusercontent.com/zthxxx/772178f5393b07c1e1bb7536c5f95c3d/raw/deb-install-docker.sh | bash
specify_user="${1:-root}"
apt update
apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common
apt remove -y docker docker-engine docker.io
LSB=`lsb_release -is | tr '[:upper:]' '[:lower:]'`
curl -fsSL https://download.docker.com/linux/${LSB:-debian}/gpg | apt-key add -
@zthxxx
zthxxx / init-swap.sh
Created May 13, 2018 18:56
create a swap space on ubuntu
# https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-16-04
fallocate -l ${SWAP_SIZE:-8G} /swapfile
chmod 600 /swapfile
swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab
@zthxxx
zthxxx / init.sh
Last active August 2, 2018 04:39
server initialize - debian
apt update
apt install -y vim lrzsz python3 python3-dev python3-pip python3-venv
curl -SL# git.io/tvimrc -o ~/.vimrc
curl -sSL git.io/jovial | bash
# curl -sSL git.io/sslaunch | bash
@zthxxx
zthxxx / get-wifi-ssid.sh
Created October 18, 2018 05:11
get WiFi SSID name on MacOS terminal
ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
airport -I | awk -F': ' '/ SSID/ {print $2}'
@zthxxx
zthxxx / D3js5.9-Threejs102-WebGL-force-directed-graph.html
Last active March 4, 2019 08:07
D3js5.9-Threejs102-WebGL-force-directed-graph Demo
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
#root,
body,
html {
width: 100%;
height: 100%;
@zthxxx
zthxxx / jenkins-lastbuild-log.js
Last active April 11, 2019 08:00
jenkins last build log to markdown table
const fs = require('fs');
const os = require('os');
const path = require('path');
const exec = require('child_process').exec;
const axios = require('axios')
const dayjs = require('dayjs')
const getJobInfo = async job => {