Skip to content

Instantly share code, notes, and snippets.

nc -l 8888
@lawvs
lawvs / addKeys.sh
Created August 5, 2018 14:44
Adding public key
#!/bin/bash
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
# vim ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
@lawvs
lawvs / timerWrapper.py
Last active October 11, 2018 03:34
Function timer
import importlib
# @timer
def timer(fn):
time = importlib.import_module('time') # dynamic import
def wrapper(*args, **kw):
print('[{}]: Task starting...'.format(fn.__name__))
START = time.time()
res = fn(*args, **kw)
@lawvs
lawvs / guess_number.py
Last active July 19, 2018 06:32
Guess number
#!/usr/bin/env python3
import sys
import zlib
# from binascii import crc32
ans = int(sys.argv[1], 16)
for i in range(100000, 999999):
if i % 100000 == 0:
print('cracking',i)
if zlib.crc32(bytes(str(i), encoding='utf8')) == ans:
@lawvs
lawvs / check_proxy.py
Created July 16, 2018 15:04
check proxy availability
#!/usr/bin/env python3
import requests
TEST_URL = 'https://www.baidu.com/'
def check_proxy(proxyIp, proxyPort='8080', proxyType='https'):
if len(proxyIp) <= 0:
return False
proxy = "{proxyIp}:{proxyPort}".format(proxyIp=proxyIp, proxyPort=proxyPort)
@lawvs
lawvs / customize.ahk
Created April 26, 2018 04:05
a AHK Script
/*
enhance CapsLock
CapsLock -> Backspace
C - CapsLock -> Delete
A - CapsLock -> Enter
*/
SetCapsLockState, AlwaysOff
CapsLock::SendInput {Backspace}
+CapsLock::SendInput {Delete}
^CapsLock::SendInput {Enter}
@lawvs
lawvs / addSwapfile.sh
Last active August 28, 2018 04:43
新建交换分区
#/bin/bash
# set flag fast fail
set -e
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
@lawvs
lawvs / .sh
Created April 12, 2018 16:04
bash color
#!/bin/bash
red='\e[91m'
green='\e[92m'
yellow='\e[93m'
magenta='\e[95m'
cyan='\e[96m'
none='\e[0m'
# Root
@lawvs
lawvs / changeEmail.sh
Last active March 10, 2018 14:12
Git核弹级操作
#!/bin/sh
git filter-branch --commit-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="your-correct-name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ];
then
GIT_AUTHOR_NAME="$CORRECT_NAME";
@lawvs
lawvs / highlights.js
Created March 2, 2018 01:54
高亮HTMLElement
/**
* Highlights text within a dom element.
*
* Specifically this is designed to work with the output
* positions of terms returned from a lunr search.
*
* @param {HTMLElement} element - the element that contains text to highlight.
* @param {MatchLocation[]} matches - the list of matches to highlight.
*/
module.exports = function (element, matches) {