Skip to content

Instantly share code, notes, and snippets.

View themegabyte's full-sized avatar

Shayan themegabyte

View GitHub Profile
@themegabyte
themegabyte / parser.sh
Created May 28, 2016 10:16
youtube-dl-links-file-parser
#!/bin/bash
IFS=$'\n'
read -d '' -r -a lines < $1
for link in ${lines[@]}
do
if [[ $link == *youtube.com* || $link == *facebook.com* ]]; then
(exec youtube-dl --no-warnings $link)
fi
done
#!/bin/bash
echo -e 'Cleaning up directory'
VAR=`ls -l *.mkv 2>/dev/null | wc -l | tr -d '\n'`
echo "removing $VAR .mkv file(s)"
if [ $VAR ]
then
rm -rf *.mkv
fi
VAR=`ls -l *.mp4 2>/dev/null | wc -l | tr -d '\n'`
for i in *.ogg ; do
ffmpeg -i "$i" -c:a libmp3lame "$(basename "${i/.ogg}").mp3"
sleep 5
done
#!/bin/sh
RED='\033[1;31m'
BLUE='\033[1;34m'
GREEN='\033[1;32m'
NC='\033[0m'
YELLOW='\033[1;33m'
# make sure $VAPIKEY has been exported either through your bash prompt
# or in your .bashrc file inside your home directory. Like so:

Add this to your ./bashaliases or ./bashrc file. You can also enter as a one time on your bash terminal

function gdrive_download () {
  CONFIRM=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$1" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')
  wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$CONFIRM&id=$1" -O $2
  rm -rf /tmp/cookies.txt
}

Usage:

@themegabyte
themegabyte / GetURL.bas
Last active June 13, 2021 13:37
Excel function to extract HyperLinks from linked cell.
Function GetURL(rng As Range) As String
On Error Resume Next
GetURL = rng.Hyperlinks(1).Address
End Function
' Usage: GetURL(Cell Number)
' Output: Associated address with Cell Number
@themegabyte
themegabyte / fix.ps1
Created November 26, 2021 16:31
Fix Permissions for private key in OpenSSH ssh-add for Windows 10
# Courtesy: https://superuser.com/a/1329702
# Set Key File Variable:
New-Variable -Name Key -Value "$env:UserProfile\.ssh\id_rsa"
# Remove Inheritance:
Icacls $Key /c /t /Inheritance:d
# Set Ownership to Owner:
Icacls $Key /c /t /Grant $env:UserName:F
@themegabyte
themegabyte / bookmark.js
Created January 30, 2022 18:55
PTCL Auto Toggle DSL Mode to Reconnect Internet without Rebooting Router.
javascript: (() => {
function checkLogin() {
username = document.getElementById("Frm_Username");
password = document.getElementById("Frm_Password");
loginButton = document.getElementById("LoginId");
if (username == null) {
first();
} else {
if (username.value === "") {
username.value = "admin";
@themegabyte
themegabyte / getQueryVariable.js
Last active February 27, 2022 15:29
Get a variable from the URL parameters, similar to PHP $_GET
function getQueryVariable(variable) {
var svalue = location.search.match(
new RegExp("[?&]" + variable + "=([^&]*)(&?)", "i")
);
return svalue ? svalue[1] : svalue;
}
// ?page=1
getQueryVariable("page"); // 1
@themegabyte
themegabyte / Lookup_concat.vba
Created March 8, 2022 11:58
A function to lookup a value and concatenate all the resulting results. This is useful if you have a list of emails in a row that have a common identifier such as an "account name" and you want to mail merge all of them in the "to" field.
' https://www.get-digital-help.com/excel-udf-lookup-and-return-multiple-values-concatenated-into-one-cell/
' 03/08/2022
' Minor changes to fix my needs.
'Name user defined function and define parameters
Function Lookup_concat(Search_string As String, _
Search_in_col As Range, Return_val_col As Range, delim_in_return As String)
'Dimension variables and declare data types
Dim i As Long