Skip to content

Instantly share code, notes, and snippets.

View tosiara's full-sized avatar

tosiara

View GitHub Profile
@tosiara
tosiara / 99-nordvpn.sh
Created December 13, 2023 11:41
conditional routing of guest network
#!/bin/sh
table=nordvpn
wifi=wlan1-2
wifi_if=nordvpn
wg=wg0
if [ "$INTERFACE" == "$wg" ]; then
if [ "$ACTION" == "ifup" ]; then
logger "NORDVPN: $INTERFACE $ACTION"
@tosiara
tosiara / tensorflow.md
Last active April 5, 2023 07:00
Build tensorflow without cpu optimizations
apt-get update
apt install apt-transport-https curl gnupg patchelf -y
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor >bazel-archive-keyring.gpg
mv bazel-archive-keyring.gpg /usr/share/keyrings
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/bazel-archive-keyring.gpg] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list

apt-get update
apt-get install bazel=5.3.0
@tosiara
tosiara / icalendar.py
Created January 2, 2023 11:04
Parse ical Google Calendar export
from icalendar import Calendar, Event
g = open("sun.ics","rb")
gcal = Calendar.from_ical(g.read())
for component in gcal.walk():
if component.name == "VEVENT":
print(component.get('summary'), component.get('dtstart').dt)
g.close()
@tosiara
tosiara / patch.md
Created December 29, 2021 12:14
Patch for sshd: Authentication refused: bad ownership or modes for directory /data

You may not connect to sshd on LineageOS because of wrong /data permissions:

sshd: Authentication refused: bad ownership or modes for directory /data
  1. Navigate to your LineageOS 14.1 source dir
  2. Open file external/openssh/misc.c
  3. Find function safe_path and comment out this code block:
@tosiara
tosiara / valgrind_motion_fuzz_double_free.md
Created December 13, 2021 07:59
motion valgrind report (double free)
==401159== Memcheck, a memory error detector
==401159== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==401159== Using Valgrind-3.19.0.GIT and LibVEX; rerun with -h for copyright info
==401159== Command: /home/user/git/motion/src/motion -c /home/user/git/motion-fuzzing.conf -n -d 7
==401159== 
[0:memcheck-amd64-] [NTC] [ALL] conf_load: Processing thread 0 - config file /home/user/git/motion-fuzzing.conf
[0:memcheck-amd64-] [NTC] [ALL] motion_startup: Logging to file (/dev/null)
==401159== Thread 4 ml1:
==401159== Invalid free() / delete / delete[] / realloc()
@tosiara
tosiara / valgrind_motion_fuzz_no_crash.md
Created December 10, 2021 10:55
motion valgrind report
==227091== 
==227091== HEAP SUMMARY:
==227091==     in use at exit: 179,801,253 bytes in 116,355 blocks
==227091==   total heap usage: 16,254,781 allocs, 16,138,453 frees, 117,125,828,652 bytes allocated
==227091== 
==227091== Thread 1:
==227091== 12 bytes in 3 blocks are possibly lost in loss record 13 of 326
==227091==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==227091==    by 0x13D021: mymalloc (util.c:180)
@tosiara
tosiara / android-wireguard-tools.md
Last active October 21, 2022 12:04
Cross compile wireguard-tools for Android
  1. Install NDK (side by side)
  2. Add NDK compiler to the PATH (select architecture accordingly, ex, x86_64):
export PATH=$PATH:/home/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin
export CC=x86_64-linux-android27-clang
  1. cd wireguard-tools/src
  2. make
@tosiara
tosiara / openwrt_login_curl.md
Last active October 20, 2021 09:52
OpenWRT login curl

Login using curl:

curl -sw '%{http_code}' -o /dev/null -X POST -F "luci_username=root" -F "luci_password=root" http://192.168.1.1/cgi-bin/luci

The result will be 403 if the password is incorrect, or 302 in case of success

The session cookie looks like:

@tosiara
tosiara / ruby_wtf.rb
Created October 11, 2021 09:53
Ruby WTF
def a; end
def b; end
puts "Before patching:"
print a
print b
a = {}
b {}
@tosiara
tosiara / rename_jpegs_by_exif_date
Created August 20, 2021 10:37
Rename jpeg photo by its exif date
for i in *; do mv $i `exif $i 2> /dev/null | grep Date | grep Orig | awk '{ print $4 }' | awk -F '|' '{ print $2 }' | tr ':' '-'`_.jpg; done