Skip to content

Instantly share code, notes, and snippets.

@ptisserand
ptisserand / getit.py
Last active May 5, 2021
Python code to retrieve gateway IP
View getit.py
def get_default_gateway():
try:
hip = None
with open("/proc/self/net/route") as routes:
for line in routes:
parts = line.split('\t')
if '00000000' == parts[1]:
hip = parts[2]
if hip is not None and len(hip) == 8:
@ptisserand
ptisserand / add_timestamp.sh
Created Apr 10, 2020
Add timestamp with ffmpeg
View add_timestamp.sh
ffmpeg -i INPUT.mp4 -vf "drawtext=fontfile=/usr/share/fonts/TTF/Roboto-Medium.ttf:fontsize=22:fontcolor=yellow:box=1:boxcolor=black:x=(W-tw)/2:y=H-th-10:text='%{pts\:hms} %{frame_num}'" OUTPUT.mp4
@ptisserand
ptisserand / Vagrantfile
Created Apr 8, 2020
Using HTTP proxy for vagrant
View Vagrantfile
Vagrant.configure("2") do |config|
if Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = "http://192.168.0.110:3128/"
# config.proxy.https = "http://192.168.0.2:3128/"
# config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
end
# ... rest of the configurations
end
@ptisserand
ptisserand / start-docker-cache.bash
Created Mar 26, 2020
Start a proxy to speed up docker build
View start-docker-cache.bash
#!/bin/bash
CACHE_DIR=/srv/squid/cache
echo "Starting squid container"
docker run --rm --net host -v ${CACHE_DIR}:/var/cache/squid3 -d jpetazzo/squid-in-a-can
echo "Setup iptables"
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 3129 -w
@ptisserand
ptisserand / docker-compose.yml
Created Feb 14, 2020
docker-compose to run mitmproxy with web interface using docker volume
View docker-compose.yml
version: '3.4'
services:
app:
image: mitmproxy/mitmproxy
ports:
- 8080:8080
- 8081:8081
volumes:
- mitmproxy:/home/mitmproxy/.mitmproxy
@ptisserand
ptisserand / gist:29dd8d4643c67fad47599d77a1198b25
Created Jul 18, 2019
Q&D workaround patch for cordova-plugin-background-geolocation ITMS-90338
View gist:29dd8d4643c67fad47599d77a1198b25
diff --git a/ios/CDVBackgroundGeolocation/CocoaLumberjack.h b/ios/CDVBackgroundGeolocation/CocoaLumberjack.h
index 32a4deb..c384e25 100644
--- a/ios/CDVBackgroundGeolocation/CocoaLumberjack.h
+++ b/ios/CDVBackgroundGeolocation/CocoaLumberjack.h
@@ -739,7 +739,6 @@ NSString * DDExtractFileNameWithoutExtension(const char *filePath, BOOL copy);
* This protocol describes a dynamic logging component
*/
@protocol DDRegisteredDynamicLogging
-
/**
@ptisserand
ptisserand / gist:25cd1153715e8731a23c95d548748215
Created Oct 2, 2017
shell script to use wakeonlan image docker
View gist:25cd1153715e8731a23c95d548748215
#!/bin/bash -e
NAS_MAC="00-11-32-44-A5-AF"
WAKE_IMG="ptisserand/wakeonlan"
docker run --rm --net=host -t ${WAKE_IMG} ${NAS_MAC}