Skip to content

Instantly share code, notes, and snippets.

@cryptogun
cryptogun / fork_as_private_repo.md
Last active June 26, 2024 23:39
Fork as private repository while benefiting from future updates form the remote public repo.
for i in `seq 255`
do
{
ping -c 2 192.168.1.$i -W 500 > /dev/null
if [ $? -eq 0 ]; then
echo 192.168.1.$i is ok >> ip.txt
fi
}
done
@cryptogun
cryptogun / linux-kill-pts.md
Created June 5, 2024 18:31 — forked from holmberd/linux-kill-pts.md
Kill tty/pts sessions in Linux

Kill user tty/pts sessions in Linux

Commands

  • w: show who is logged on and what they are doing
  • who: show who is logged on
  • tty: show current users pseudo terminal
  • ps -ft pts/1: get process id for the pseudo terminal
  • pkill: signal process based on name and other attributes
@cryptogun
cryptogun / adb.conf
Created January 12, 2024 02:28
adblock + remaining direct access in Shadowrocket format, suitable for Spectre use.
This file has been truncated, but you can view the full file.
[Rule]
DOMAIN-SUFFIX,ad.12306.cn,REJECT
@cryptogun
cryptogun / default.custom.yaml
Created July 21, 2018 05:10
Rime. Press left shift to commit chars and switch to english mode.
patch:
ascii_composer:
switch_key:
Shift_L: commit_code
@cryptogun
cryptogun / draw_big_O.py
Created October 26, 2017 10:37
Draw performance line (e.g. big O) for x, y inputs.
import tkinter as tk
x = [2, 100, 1000, 10000, 100000, 1000000]
y = [0, 0, 0.0055, 31.250, 562.51, 62600]
WIDTH = 700
HEIGHT = 600
xy = list(map(lambda x, y: [x, y], x, y))
MINX = min(x)
import tkinter as tk
import tkinter.messagebox as tkMessageBox
import threading
from queue import Queue
# Thread-safe version.
# Tkinter functions are put into queue and called by prompt_thread_loop
# in the main thread.
messagebox_queue = Queue()
#!/usr/bin/python
try:
import SimpleHTTPServer
except:
import http.server as SimpleHTTPServer
try:
import SocketServer
except:
import socketserver as SocketServer
PORT = 8000
import tkinter as tk # python 3.x
# import Tkinter as tk # python 2.x
class Example(tk.Frame):
def __init__(self, parent):
tk.Frame.__init__(self, parent)
# valid percent substitutions (from the Tk entry man page)
import tkinter as tk
import sys
class ExampleApp(tk.Tk):
def __init__(self):
tk.Tk.__init__(self)
toolbar = tk.Frame(self)
toolbar.pack(side="top", fill="x")
b1 = tk.Button(self, text="print to stdout", command=self.print_stdout)