Skip to content

Instantly share code, notes, and snippets.

View ahmedbaig's full-sized avatar
♠️
Hacking & Improvising

Ahmed Baig ahmedbaig

♠️
Hacking & Improvising
View GitHub Profile
@ahmedbaig
ahmedbaig / ngrok.yml
Created September 4, 2022 05:58
Runner cron script for Pi Surveillance Camera
authtoken: secret_key
region: au
tunnels:
ssh:
addr: 22
proto: tcp
web:
addr: 80
proto: http
ssl:
@ahmedbaig
ahmedbaig / Battery_Charge_Notification.sh
Created September 3, 2022 05:00
Batter Charge Notification Maker
#!/bin/bash
# Description: Display notification if battery is about to charge or discharge fully.
# upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state|to\ full|percentage" ; --- There are different ways we get battery status - this is no 1
# upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state|to\ full|percentage" | awk '/perc/{print $2}' --- There are different ways we get battery status - this is no 2
# $ find /sys/class/power_supply/BAT0/ -type f | xargs -tn1 cat --- There are different ways we get battery status - this is no 3
# $ cat /sys/class/power_supply/BAT0/status --- There are different ways we get battery status - this is no 4
# $ cat /sys/class/power_supply/BAT0/capacity --- There are different ways we get battery status - this is no 5
# we will try to use 4th & 5th ; as only these gives one letter / number as output. Rest gives long string and also baterry % in long string , cannot be used to compare arithmatically
@ahmedbaig
ahmedbaig / installation.md
Last active November 9, 2021 09:03
Installing MobilityDB on Postgres 13 Postgis 3

Add PostgreSQL 13 repository to Ubuntu 20.04

sudo apt update
sudo apt -y upgrade
sudo apt -y install vim bash-completion wget
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

You can now add the repository to your source list

// Dynamic Flags
let args = {};process.argv.forEach(function (val, index, array) {let valsplit = val.split("=");args[valsplit[0]] = valsplit[1]});
// Speedometer
function formatBytes(a,b=2,k=1024){with(Math){let d=floor(log(a)/log(k));return 0==a?"0 Bytes":parseFloat((a/pow(k,d)).toFixed(max(0,b)))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][d]}}
var fs = require('fs');
var AWS = require('aws-sdk');
const StreamSpeed = require('streamspeed');
// File
@ahmedbaig
ahmedbaig / Jenkins
Created August 26, 2021 14:15
CI/CD Codes
#!groovy
/*
The MIT License
Copyright (c) 2015-, CloudBees, Inc., and a number of other of contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is

Keybase proof

I hereby claim:

  • I am ahmedbaig on github.
  • I am ahmedbaig (https://keybase.io/ahmedbaig) on keybase.
  • I have a public key ASAlJjl7gvCd1Unz12knYOt1hq-ekHYt7_qCt0r64kyOIAo

To claim this, I am signing this object:

@ahmedbaig
ahmedbaig / README.md
Created July 9, 2021 15:04
Docker XMPP Postgresql setup and API Collections

XMPP eJabberd Server

  • Initialize Server on docker

docker run --name ejabberd -d -p 5222:5222 ejabberd/ecs

  • Start with your configuration and database
mkdir database
@ahmedbaig
ahmedbaig / app.ts
Created June 4, 2021 13:33
Alternative to multer file uploader using busboy-body-parser in Typescript
// Server Code ...
const busboyBodyParser = require('busboy-body-parser');
// Express TCP requests parsing
app.use(busboyBodyParser({ limit: '10mb', multi:true }));
// Some more server code ...