Skip to content

Instantly share code, notes, and snippets.

View BirkhoffLee's full-sized avatar
🎓
Learning about CS

birkhoff BirkhoffLee

🎓
Learning about CS
View GitHub Profile
let a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const unflatten = (arrayToUnflatten, unflattenLength) => {
return Promise.all(new Array(Math.ceil(arrayToUnflatten.length / unflattenLength)).fill('').map((_, index) => new Promise(resolve => {
resolve(arrayToUnflatten.slice(index * unflattenLength, index * unflattenLength + unflattenLength))
})))
}
unflatten(a, 2).then(result => console.log(result))
#!/bin/bash
sudo yum update -y
sudo yum install tmux gcc wget htop epel-release fail2ban -y
wget -O vpnserver.tar.gz http://jp.softether-download.com/files/softether/v4.22-9634-beta-2016.11.27-tree/Linux/SoftEther_VPN_Server/64bit_-_Intel_x64_or_AMD64/softether-vpnserver-v4.22-9634-beta-2016.11.27-linux-x64-64bit.tar.gz
tar -zxvf vpnserver.tar.gz
cd vpnserver/
# printf '1\n1\n1\n' | ./.install.sh
@BirkhoffLee
BirkhoffLee / install.sh
Last active November 9, 2017 11:55
Install magic-warmhole on CentOS 7
#!/bin/sh
sudo yum install -y python-pip libsodium-devel python-devel
sudo pip install --upgrade pip
sudo pip install magic-wormhole
@BirkhoffLee
BirkhoffLee / docker.sh
Last active January 31, 2019 11:52
Install Docker and docker-compose on CentOS
#!/bin/sh
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 net-tools
sudo yum-config-manager --add-repo -y https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce
sudo systemctl start docker
sudo usermod -aG docker $USER
sudo curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo "alias dc=docker-compose" >> ~/.bashrc
@BirkhoffLee
BirkhoffLee / autoexec.cfg
Created February 2, 2018 16:56
My edited CS:GO autoexec.cfg based on C9 Shroud's original one
// repositions the gunmodel to mimic CSS more closely.
viewmodel_presetpos "0"
viewmodel_fov "68"
viewmodel_offset_x "2.5"
viewmodel_offset_y "1"
viewmodel_offset_z "-1.500000"
// removes the shifting of the arm when crouching down.
@BirkhoffLee
BirkhoffLee / config.cfg
Last active February 2, 2018 17:00
My edited CS:GO config.cfg based on C9 Shroud's original one
unbindall
bind "1" "slot1"
bind "2" "slot2"
bind "3" "slot3"
bind "4" "slot4"
bind "5" "slot5"
bind "9" "slot9"
bind "a" "+moveleft"
bind "b" "buymenu"
bind "c" "slot6"
@BirkhoffLee
BirkhoffLee / steamguard.js
Last active June 28, 2019 04:42
Steamguard data & device id extractor
// yarn add binary-cookies bplist-parser
/*
To get the Steamguard file, you don't necessarily need to be jailbroken, but
if you're jailbroken: head to
/private/var/mobile/Containers/Data/Application/6BE5C937-51C0-4365-811D-F2717BAD1213/Documents
and you can get them. I'm not sure the UUID is same on all devices, but this is the actual path
on my device (iOS 12)
If you're non-jailbroken, you need to get an unencrypted backup using iTunes,
@BirkhoffLee
BirkhoffLee / ss_subscribe_to_surge.js
Created October 11, 2018 06:02
This node script converts a base64-encoded ShadowSocks subscription string to a Surge proxies configuration.
const querystring = require('querystring')
let args = process.argv.slice(2)
if (!args[0]) {
console.error("Usage: node index.js [subscribe_list_base64_encoded]")
process.exit(1)
}
@BirkhoffLee
BirkhoffLee / script.sh
Last active December 5, 2018 14:47
CentOS firewalld + Docker companion
cp /etc/docker/daemon.json /etc/docker/daemon.json.old
echo '{"iptables": false}' > /etc/docker/daemon.json
firewall-cmd --permanent --direct --add-rule ipv4 nat POSTROUTING 0 -o eth0 -j MASQUERADE # this enables containers access outside internet
firewall-cmd --reload
@BirkhoffLee
BirkhoffLee / base64.js
Created January 13, 2019 08:13
base64 in nodejs
const encode = s => Buffer.from(s).toString('base64')
const decode = s => Buffer.from(s, 'base64').toString()