Skip to content

Instantly share code, notes, and snippets.

View coconut49's full-sized avatar
🐰
Focusing

49 coconut49

🐰
Focusing
View GitHub Profile
@coconut49
coconut49 / retry.py
Last active December 15, 2017 15:22
def ignore_error_and_retry(times=3):
def real_decorator(fn):
def warpper(*args, **kwargs):
try:
fn(*args, **kwargs)
except Exception as e:
print(str(e))
if not hasattr(warpper, "counter"):
warpper.counter = 1
else:
@coconut49
coconut49 / timeout.py
Last active December 15, 2017 15:22
直接用,但不会抛异常,稳如狗
from contextlib import contextmanager
import signal
@contextmanager
def timeout(seconds=3):
class TimeoutError(Exception):
pass
def handler(*args,**kwargs):
print("[-] Timeout!")
raise TimeoutError
@coconut49
coconut49 / gpg-agent-forward.sh
Created May 15, 2017 07:10 — forked from dtaylor84/gpg-agent-forward.sh
Cygwin GPG Agent Forwarding Script (for use with Gpg4Win 3, requires openssh and ssh-pageant)
#!/bin/bash -e
remote="$1@$2"
echo -ne '\e]0;wait... '"$remote"'\a'
eval $(/usr/bin/ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME")
localdir="$(cygpath -u "$APPDATA")/gnupg"
extrasock="$localdir/S.gpg-agent.extra" # file containing "PORT\nNONCE"
rdir='$HOME/.gnupg' # remote prefix
rinsock="$rdir/S.gpg-agent" # listen on this socket on server
@coconut49
coconut49 / bird.conf
Created October 24, 2017 13:56
school ospf bird
router id 33.44.0.1;
protocol device {
scan time 10;
}
protocol kernel {
metric 64; # Use explicit kernel route metric to avoid collisions
# with non-BIRD routes in the kernel routing table
import none;
@coconut49
coconut49 / 85-yubikey-screen-lock.rules
Last active November 4, 2017 18:19
a tiny script to auto lock and unlock gnome session
SUBSYSTEM=="usb", ACTION=="remove", ENV{ID_VENDOR_ID}=="1050", ENV{ID_MODEL_ID}="0407", RUN+="/usr/local/bin/yubikeylocker.sh"
SUBSYSTEM=="usb", ACTION=="add", ENV{ID_VENDOR_ID}=="1050", ENV{ID_MODEL_ID}=="0407", RUN+="/usr/local/bin/yubikeylocker.sh"
@coconut49
coconut49 / SimpleHTTPServerWithUpload.py
Created September 9, 2018 09:54 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@coconut49
coconut49 / main.go
Created August 21, 2019 03:23
Golang SSL Pinning
package main
import (
"context"
"crypto/sha256"
"crypto/tls"
"crypto/x509"
"encoding/pem"
"errors"
"fmt"