Skip to content

Instantly share code, notes, and snippets.

View lsongdev's full-sized avatar
👨‍💻

Lsong lsongdev

👨‍💻
View GitHub Profile
@matl33t
matl33t / terminal_productivity.md
Created February 9, 2017 23:22
saving time on the command-line

Terminal Productivity Tricks

Line Editing Motions

  • [C-a] beginning of the line
  • [C-e] end of the line
  • [C-b] back one character
  • [C-f] forward one character
  • [A-b] back one word (Configure alt to +ESC in iterm profile)
  • [A-f] forward one word
@denji
denji / README.md
Last active May 7, 2025 07:38 — forked from Cubixmeister/README.md
Simple Sentry docker-compose.yml
  1. Download docker-compose.yml to dir named sentry
  2. Change SENTRY_SECRET_KEY to random 32 char string
  3. Run docker-compose up -d
  4. Run docker-compose exec sentry sentry upgrade to setup database and create admin user
  5. (Optional) Run docker-compose exec sentry pip install sentry-slack if you want slack plugin, it can be done later
  6. Run docker-compose restart sentry
  7. Sentry is now running on public port 9000
@codeif
codeif / unzip.py
Created April 20, 2017 18:04
unzip.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
解决mac下解压zip文件乱码问题
代码参考:
http://stackoverflow.com/questions/9431918/extracting-zip-file-contents-to-specific-directory-in-python-2-7
http://www.zhihu.com/question/20523036/answer/35225920
http://stackoverflow.com/questions/4917284/extract-files-from-zip-without-keeping-the-structure-using-python-zipfile
编码: https://docs.python.org/2.4/lib/standard-encodings.html
function shuffle(a) {
for (let i = a.length; i; i--) {
let j = Math.floor(Math.random() * i);
[a[i - 1], a[j]] = [a[j], a[i - 1]];
}
}
@riyazpanjwani
riyazpanjwani / snake_game.py
Created September 2, 2017 23:01
Simple implementation of Snake game in python
import curses
from curses import KEY_RIGHT, KEY_LEFT, KEY_DOWN, KEY_UP
from random import randint
WIDTH = 120
HEIGHT = 30
MAX_X = WIDTH - 2
MAX_Y = HEIGHT - 2
SNAKE_LENGTH = 5
@KyonLi
KyonLi / aria2
Last active May 17, 2023 19:11
Aria2 init.d script
#!/bin/sh
### BEGIN INIT INFO
# Provides: Aria2
# Required-Start: $network $local_fs $remote_fs
# Required-Stop:: $network $local_fs $remote_fs
# Should-Start: $all
# Should-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Aria2 - Download Manager
@toioski
toioski / script.applescript
Last active June 5, 2023 01:30
Automatically Open Safari Dev Tools for iOS Simulator
-- `menu_click`, by Jacob Rus, September 2006.
-- Ref: https://stackoverflow.com/questions/14669542/automatically-open-the-safari-debugger-when-the-iphone-simulator-is-launched
on menu_click(mList)
local appName, topMenu, r
-- Validate our input
if mList's length < 3 then error "Menu list is not long enough"
-- Set these variables for clarity and brevity later on
@meletisf
meletisf / openvpn.md
Created July 27, 2018 18:05
Install OpenVPN

Install OpenVPN

apt-get install openvpn

Navigate into the directory

cd /etc/openvpn

Original minified code:

var Stream=require("stream").Stream;module.exports=function(e,n){var i=new Stream,a=0,o=0,u=!1,f=!1,l=!1,c=0,s=!1,d=(n=n||{}).failures?"failure":"error",m={};function w(r,e){var t=c+1;if(e===t?(void 0!==r&&i.emit.apply(i,["data",r]),c++,t++):m[e]=r,m.hasOwnProperty(t)){var n=m[t];return delete m[t],w(n,t)}a===++o&&(f&&(f=!1,i.emit("drain")),u&&v())}function p(r,e,t){l||(s=!0,r&&!n.failures||w(e,t),r&&i.emit.apply(i,[d,r]),s=!1)}function b(r,t,n){return e.call(null,r,function(r,e){n(r,e,t)})}function v(r){if(u=!0,i.writable=!1,void 0!==r)return w(r,a);a==o&&(i.readable=!1,i.emit("end"),i.destroy())}return i.writable=!0,i.readable=!0,i.write=function(r){if(u)throw new Error("flatmap stream is not writable");s=!1;try{for(var e in r){a++;var t=b(r[e],a,p);if(f=!1===t)break}return!f}catch(r){if(s)throw r;return p(r),!f}},i.end=function(r){u||v(r)},i.destroy=function(){u=l=!0,i.writable=i.readable=f=!1,process.nextTick(function(){i.emit("close")})},i.pause=function(){f=!0},i.resume=fu
@phlinhng
phlinhng / a-clash-tproxy-gateway.md
Last active December 30, 2024 10:51
Clash as transparent proxy gateway via TPROXY

Notes

  1. If your local network use public IP ranges instead of private ones, make sure to add respecive RETURN rules to iptables to prevent looping issue
  2. Set clash as DHCP's only DNS server to allow domain-based filter (shunting) rules work
  3. Use lsof -i udp:53 to check if clash's DNS module work fine, otherwise you may have to kill systemd-resolved and any other processes occupying the UDP 53 port
  4. The given scripts will NOT hangle the traffic of gateway itself since it is not recommend to do so. If you want to redirect the egress traffic of the gateway, the following material may be useful

Reference