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
@Sanix-Darker
Sanix-Darker / answerfile
Created October 29, 2023 21:32 — forked from oofnikj/answerfile
Install Docker on Termux
KEYMAPOPTS="us us"
HOSTNAMEOPTS="-n alpine"
INTERFACESOPTS="auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
hostname alpine
"
TIMEZONEOPTS="-z UTC"
@Sanix-Darker
Sanix-Darker / postgres-cheatsheet.md
Created August 12, 2023 09:46 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Sanix-Darker
Sanix-Darker / raffle.vim
Created May 15, 2023 08:46
random pick name from buffer with vimScript on vim
" vimScript
" -- On dailies, for random choice on given buffer with names
function! StringInLine(line_number, search_string)
let line_text = getline(a:line_number)
let match_position = match(line_text, a:search_string)
return match_position >= 0
endfunction
function! Raffle()
let total_lines = line('$')
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 && \