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
# @see /usr/include/asm-generic/errno-base.h
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
@Sanix-Darker
Sanix-Darker / mno.json
Created June 12, 2024 10:02 — forked from Jspascal/mno.json
Africa Mobile Phone Number regex
{
"om_cmr": "/^6(5[5-9]|9|8[5-9])/",
"momo_cmr": "/^6(5[1-4]|7|8[1-4])/",
"momo_civ": "/^(05)/",
"om_civ": "/^(07)/",
"moov_civ": "/^(01)/",
"wave_civ": "/^(0[157])/",
"moov_ben": "/^(9[4589]|6[03458]|5[58])/",
"moov_tgo": "/^(9[6-9]|79)/",
"tmoney": "/^(70|9[0-3])/",
@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
}