Skip to content

Instantly share code, notes, and snippets.

View Sanix-Darker's full-sized avatar
🐼
coding in the dark...

darker Sanix-Darker

🐼
coding in the dark...
View GitHub Profile
git_open_link(){
# $1 can be 'origin' or 'dev' depending on the source
remote_link=$(git remote get-url $1)
browser=firefox
CURL_CHECK="curl --head --silent --fail"
if $CURL_CHECK "$remote_link" &> /dev/null; then
$browser $remote_link;
else
built_link=$(echo "https://$(echo $remote_link | sed -e 's/git@//' | sed -e 's/:/\//')")
if $CURL_CHECK "$built_link" &> /dev/null; then
#include <stdio.h>
#include <string.h>
const char *MORSE_TABLE[] = {
".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..",
".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.",
"...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."};
int main() {
char word[100];
#!/bin/bash
# run a command again and again only if the standard output hash change by a single bit
# _inf git status
_inf(){
echo "Executing '$@' until the output change or you quit:"
# we source our alias first
PREVIOUS_HASH=""
while true; do
CURRENT_HASH=$($(echo "${@}") | md5sum)
if [ "$CURRENT_HASH" != "$PREVIOUS_HASH" ]; then
#!/bin/bash
# a confirm check before executing anything
# _confirm "your message" your command there
_confirm(){
args=("${@}")
if [[ $NOTINTERACTIVE = "1" ]]; then
echo -e "\n$BLUE[+] ${args[0]} $COLOROFF"
callback=${args[@]:1}
$callback
else
#!/bin/bash
# _sleep 10
_sleep(){
seconds=$1
start="$(($(date +%s) + $seconds))"
while [ "$start" -ge `date +%s` ]; do
time="$(( $start - `date +%s` ))"
printf '%s\r' "$(date -u -d "@$time" +%H:%M:%S)"
done
}
_ps_per_mem(){
while true; do
clear
ps -eo pid,%mem,cmd --sort=-%mem | head -n 10
sleep 100
done
}
#!/bin/bash
clean_volumes(){
# List all volumes from docker volume
# then remove the first line
# sed to delete "local " from the /tmp/volumes
# and then apply the docker volume rm on each lines from that file
docker volume ls > /tmp/volumes && \
tail -n +2 /tmp/volumes && \
sed -i 's/local //g' /tmp/volumes && \
@Sanix-Darker
Sanix-Darker / .bash_aliases
Last active March 20, 2023 04:00
note: a simple command line for fast todo topic oriented
#!/bin/bash
# To take note about something really quickly
# Requirements : fzf and ag
#
# $ note topic note to my self... # will add a new note for the topic
# $ note topic # will seach for notes on this topic
# $ note # will list for you all notes taken globally
note(){
NOTES_DIR=$HOME/notes/
#!/bin/bash
# this small scrip combine audio streams from a running instance of pulseaudio
# and creates a new virtual input
f_log() {
echo "[+] $0 -> $*"
}
function usage () {
@Sanix-Darker
Sanix-Darker / main.js
Last active April 2, 2023 06:39
Trigger emoji box on :: from the tweet modal text input.
// hit :: two times to have emoji popup open
let keystrokes = [];
const TARGET_EMOJI_POPUP_ON = ['::']
const LETTERS = [
'A', 'B', 'C', 'D',
'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X',