Skip to content

Instantly share code, notes, and snippets.

View woffleloffle's full-sized avatar

Willem Labuschagne woffleloffle

View GitHub Profile
@woffleloffle
woffleloffle / AppDelegate.m.diff
Last active March 7, 2022 14:03
Silence "nw_connection_get_connected_socket" warnings in React Native (expo)
...
#if RCT_DEV
[bridge moduleForClass:[RCTDevLoadingView class]];
+
+ NSURL * jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
+ [[RCTBundleURLProvider sharedSettings] setJsLocation:jsCodeLocation.host];
#endif
...
@woffleloffle
woffleloffle / random-number-game.py
Created October 20, 2021 18:09
Guess the random number
# Random number game
from random import randint
minimum = 1
maximum = 100
guesses = 10
print("Let's play a game!")
print("..but first...\n")
@woffleloffle
woffleloffle / db_dump_all.sh
Created March 22, 2021 14:27
Dump every database on a MySQL server
#/bin/sh
mysql -u root -pPASSWORD -e 'show databases' | tail -n +2 | while read DB
do
mysqldump -u root -pPASSWORD "$DB" > "/path/to/your/backup/$DB.sql"
done
@woffleloffle
woffleloffle / keep-awake.ps1
Created March 7, 2021 09:33
Script to keep a PC alive, will prevent screen lock and sleep.
clear host
#
# Script to keep the PC alive, will prevent screen lock and sleep.
#
# Works by pressing Print Screen every 60 seconds
# side effect is that a screenshot will overwrite the clipboard contents
#
$opt = (Get-Host).PrivateData
$opt.WarningBackgroundColor = "DarkCyan"
save = !sh -c 'export PREV=$(git symbolic-ref HEAD|cut -d/ -f3-) && git checkout -b "$1" && git commit -am "$1" && git checkout "$PREV"' -
@woffleloffle
woffleloffle / sysctl.conf
Created February 21, 2019 16:50
Speed up shared network server on Mac OS X
## Add the contents below to /etc/sysctl.conf
kern.ipc.maxsockbuf=4194304
kern.ipc.somaxconn=2048
kern.ipc.nmbclusters=2048
net.inet.tcp.rfc1323=1
net.inet.tcp.win_scale_factor=4
net.inet.tcp.sockthreshold=16
net.inet.tcp.sendspace=1042560
net.inet.tcp.recvspace=1042560
@woffleloffle
woffleloffle / OS X
Created December 3, 2018 19:50
Recursively delete all node_modules folders
find . -name "node_modules" -exec rm -rf '{}' +
@woffleloffle
woffleloffle / bucket-size.sh
Created February 27, 2018 13:49
Count the size of an S3 Bucket (or sub-path) in Gigabytes
aws --profile {PROFILE} s3 ls s3://{BUCKET_NAME}/{PATH_NAME} --recursive | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024/1024" GB"}'
@woffleloffle
woffleloffle / toggle hidden folders
Created February 22, 2018 17:52
Your RC alias to show and hide hidden folders in OS X
# Hidden Folders in Finder
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
@woffleloffle
woffleloffle / flushdns
Created February 22, 2018 17:51
Your RC file alias to clear your DNS Cache
# Flush DNS Cache
alias flushdns="sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder && echo 'DNS Cache cleared!'"