Skip to content

Instantly share code, notes, and snippets.

@salehjg
salehjg / build.gcc142.src.sh
Last active January 14, 2025 22:23
Building GCC from source.
#!/bin/bash
# Check if an argument was provided
if [ -z "$1" ]; then
echo "Usage: $0 <install dir>"
exit 1
fi
# Assign the first argument to a variable
installdir="$1"
@salehjg
salehjg / aws.ami.f1.setup.xfce.sh
Last active January 6, 2025 13:56
My AWS F1 Setup Script
#!/bin/bash
echo "Dont forget to allow TCP port 5901 in your instance's security group. You have to add it manually to the inbound rules."
echo "This script is tested on Amazon Linux 2"
echo "You have to use a VNC client to connect to your server. You can use Vinagre for example."
# Detect the current user
USER=$(whoami)
echo "Detected user: $USER"
[Temperatures_CPU]
> 0x6A 0x37
> 0x6B 0x3D
> 0x6C 0x43
> 0x6D 0x49
> 0x6E 0x4F
> 0x6F 0x4F
> 0x70 0x64
[FanSpeeds_CPU]
@salehjg
salehjg / Android-Studio-use-libopencv.so.md
Last active March 25, 2023 15:24
Android Studio+NDK+OpenCV shared library (tested on Android Studio 2022.1, SDK 33, NDK 21, and Device API 26)
  1. Follow this gist to build OpenCV shared library for Android.
  2. Create a new project, Java, MinSDK API26.
  3. In Project Side Bar, right click on App and select New -> Folder -> JNI Folder.
  4. Check the Change Folder Location check box and rename the last part of the path from src/main/jni/ to src/main/jniLibs/ .
  5. Go to your OpenCV/01_ndk_outputs/sdk/native/libs source directory and select all the folders and copy them into jniLibs of your Android Studio project.
  6. It is assumed that your phone is a arm64-v8a.
  7. Open your app's build.gradle and add this to defaultConfig entry:
externalNativeBuild{
            cmake{
@salehjg
salehjg / OpenCV-NDK-Build.md
Last active March 10, 2023 19:58
How to build OpenCV for NDK from source.

Pre Requisities

  1. Use a Linux OS. It is assumed that Arch Linux is used.
  2. Install the latest version of Android Studio.
  3. Use SDK Manger of Android Studio to install your SDK 25, NDK 21.4.7075529, and BuildTools 25.0.3 of your choice.
  4. Install the packages that we are going to need on your linux: sudo pacman -S cmake git aria2 ant unzip ant
  5. Make sure you have a suitable python2, python3, and jdk

OpenCV Versions

If you need the cv1 interface of OpenCV, you should use version < 4. Versions>=4 only have the cv2 interface. We are going to use OpenCV 3.4.16 .

@salehjg
salehjg / vpn-hotspot.sh
Created January 4, 2023 21:03 — forked from ShapeShifter499/vpn-hotspot.sh
vpn hotspot script
#!/storage/xbin/bash
# This script should help forward VPN over any tethered connection on a Android device. Turn on tethering, then enable VPN, then run this script.
# Inital variable setup
tethering=0
# Setup iptables before forwarding VPN
iptables -A POSTROUTING -o tun0 -j MASQUERADE -t nat
@salehjg
salehjg / non-adb-root.sh
Last active January 3, 2023 22:53
An ADB script to share the VPN on an android device with its hotspot USB/WIFI
echo "RUN AS ROOT ON THE ANDROID DEVICE (TERMUX: SU: NEXT LINE)"
ip rule show | grep 'iif rndis0 lookup tun0' || ip rule add from all iif rndis0 lookup tun0 pref 17999; iptables -n -v -L natctrl_FORWARD | grep 'ACCEPT all -- rndis0 tun0' || iptables -I natctrl_FORWARD 4 -i rndis0 -o tun0 -j ACCEPT; iptables -n -v -L natctrl_FORWARD | grep 'ACCEPT all -- tun0 rndis0' || iptables -I natctrl_FORWARD 4 -i tun0 -o rndis0 -m state --state RELATED,ESTABLISHED -j ACCEPT
@salehjg
salehjg / Springer.CSSP.bst
Created August 28, 2022 13:25
BibTeX Style File for Springer CSSP (Journal) - Unofficial - Use it at your own risk
%%
%% This is file `spbasic.bst',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% merlin.mbs (with options: `ay,nat,seq-lab,vonx,nm-rvx,ed-rev,jnrlst,dt-beg,yr-par,yrp-x,yrpp-xsp,note-yr,jxper,jttl-rm,thtit-a,pgsep-c,num-xser,ser-vol,jnm-x,btit-rm,bt-rm,pre-pub,doi,edparxc,blk-tit,in-col,fin-bare,pp,ed,abr,mth-bare,ord,jabr,xand,eprint,url,url-blk,em-x,nfss,')
%% ----------------------------------------
%%
%%********************************************************************************%%

Setup Canon LBP-6030B on ArchLinux

  1. Install $ sudo pacman -S ghostscript
  2. Install $ yay -S cups
  3. Enable its service $ sudo systemctl enable cups.service
  4. Restart the service $ sudo systemctl restart cups.service
  5. Check its status $ sudo systemctl status cups.service
  6. Install $ yay -S cnrdrvcups-sfp
  7. BE AWARE THAT LBP-6030B is a UFRII-LT printer with sfp. Only use cnrdrvcups-lb package if your printer is LBP6030 (white version, USA)!!
  8. Open http://localhost:631/ in Chrome.
  9. Go to Administration and then click on Add Printer