Skip to content

Instantly share code, notes, and snippets.

function printf(s,...) print(s:format(...)) end
function fastExportImage()
-- whether the pohtoshop is in focus
local window = hs.window.focusedWindow()
local app = window:application()
local title = app:title()
local isPhotoshop = title:find("Photoshop CC")
if( not isPhotoshop ) then
@BigSully
BigSully / toggle system proxy by hammerspoon shortcuts in macos
Last active January 17, 2020 15:22
toggle system proxy by hammerspoon shortcuts in macos
1. set the ip and port of http and https proxy manually for the first time, which can be accomplished in command line though.
networksetup -setwebproxy "Wi-fi" 127.0.0.1 8080
networksetup -setsecurewebproxy "Wi-fi" 127.0.0.1 8080
2. add the following shell function to your ~/.profile
toggleProxy() {
e=$(networksetup -getwebproxy wi-fi | grep "No")
ns=wi-fi
status=''
@BigSully
BigSully / DNS over TLS for unbound
Last active June 3, 2024 09:57
DNS over TLS configuration for unbound, including Google DNS, Cloudflare DNS and Quad9 DNS
server:
logfile: ""
# verbosity: 2
username: "nobody"
interface: 0.0.0.0
access-control: 0.0.0.0/0 allow
prefetch: yes
# include: "/opt/unbound/local.conf"
# include: "/opt/unbound/customize.conf"
@BigSully
BigSully / async await in chrome extension
Last active March 19, 2024 20:59
async await in chrome extension
/**
* Usage:
* let cookies = await asyncfy(chrome.cookies.getAll)({ url })
* let tabs = await asyncfy(chrome.tabs.query)({active: true, currentWindow: true})
*
* @param fn A function that takes one or more parameters, and the last parameter is a callback which has one or more parameter. The simplest one is chrome.management.getSelf
* @returns {function(...[*]): Promise<any>} Return one value if the results array has only one element, else return the whole results array
*/
let asyncfy = fn => (...args) => {
return new Promise((resolve, reject) => {
@BigSully
BigSully / raspberry pi wireless AP
Last active May 2, 2020 14:19
Setting up a Raspberry Pi 3B plus as a routed wireless access point
## set up the raspberry pi 3B+ as a wifi AP ( a wireless router )
## suppose etho is your wan interface name, and wlan0 is your lan interface name
# https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md
# https://thepi.io/how-to-use-your-raspberry-pi-as-a-wireless-access-point/
# https://www.shellvoide.com/wifi/setup-wireless-access-point-hostapd-dnsmasq-linux/
## install softwares
apt install -y hostapd
apt install -y dnsmasq
DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent
# testing ps -ef | grep hostapd
@BigSully
BigSully / start mitmproxy in background programmatically
Last active March 30, 2024 21:33
start mitmproxy in background programmatically
from mitmproxy.options import Options
from mitmproxy.proxy.config import ProxyConfig
from mitmproxy.proxy.server import ProxyServer
from mitmproxy.tools.dump import DumpMaster
import threading
import asyncio
import time
class Addon(object):
@BigSully
BigSully / Javascript ISO country code to country name conversion
Created July 24, 2020 13:03 — forked from maephisto/Javascript ISO country code to country name conversion
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function.
var isoCountries = {
'AF' : 'Afghanistan',
'AX' : 'Aland Islands',
'AL' : 'Albania',
'DZ' : 'Algeria',
'AS' : 'American Samoa',
'AD' : 'Andorra',
'AO' : 'Angola',
'AI' : 'Anguilla',
'AQ' : 'Antarctica',
@BigSully
BigSully / obfuscate.gradle
Last active September 9, 2020 16:25 — forked from lucacesari/obfuscate.gradle
Obfuscate a jar with Gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'net.sf.proguard:proguard-gradle:5.3.3'
}
}
ext {
@BigSully
BigSully / compile nginx on macos
Created October 26, 2020 21:27
compile nginx on macos
OPTS=''
## nginx
curl -OL http://nginx.org/download/nginx-1.19.3.tar.gz
tar -xf nginx-*.tar.gz
## pcre
curl -OL https://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
tar -xf pcre-*.tar.gz
OPTS="$OPTS --with-pcre=../pcre-8.44/"
@BigSully
BigSully / gcc compiler optimization for arm systems.md
Created February 18, 2021 18:20 — forked from fm4dd/gcc compiler optimization for arm systems.md
GCC compiler optimization for ARM-based systems

GCC compiler optimization for ARM-based systems

2017-03-03 fm4dd

The gcc compiler can optimize code by taking advantage of CPU specific features. Especially for ARM CPU's, this can have impact on application performance. ARM CPU's, even under the same architecture, could be implemented with different versions of floating point units (FPU). Utilizing full FPU potential improves performance of heavier operating systems such as full Linux distributions.

-mcpu, -march: Defining the CPU type and architecture

These flags can both be used to set the CPU type. Setting one or the other is sufficient.