Skip to content

Instantly share code, notes, and snippets.

@ldotlopez
ldotlopez / ps1.sh
Last active April 19, 2024 11:31
ps1 bash module
#!/usr/bin/env bash
#
# Copyright (C) 2024 Luis López <luis@cuarentaydos.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@ldotlopez
ldotlopez / sqlite3-csv
Created September 12, 2023 08:23
sqlite3-csv
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
# shellcheck disable=SC2034
__FILE__="$(realpath -- "${BASH_SOURCE[0]}")"
__DIR__="$(dirname -- "$__FILE__")"
__NAME__="$(basename -- "$__FILE__")"
import os
import sys
def is_utf_8(s):
try:
return s.encode("utf-8").decode("utf-8") == s
except (UnicodeEncodeError, UnicodeDecodeError):
return False
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
YT_VIDEO="https://www.youtube.com/watch?v=ydYDqZQpim8"
YT_URL="$(youtube-dl --get-url "$YT_VIDEO")"
OUTF="$HOME/.local/share/namibia/background.png"
mkdir -p "$(dirname -- "$OUTF")"
#!/usr/bin/env python3
import argparse
import logging
import subprocess
from pprint import pprint as pp
import boto3
logging.basicConfig()
@ldotlopez
ldotlopez / bash-strict-mode.sh
Last active September 8, 2020 10:19
Unofficial bash "strict" mode
#!/usr/bin/env bash
### Bash Environment Setup
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
# set -o xtrace
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
@ldotlopez
ldotlopez / reeina.py
Created August 16, 2020 19:15
Micro prototype of Eina in python - github.com/ldotlopez/eina
import gi
gi.require_version('Gst', '1.0')
gi.require_version('Gtk', '3.0')
gi.require_version('GLib', '2.0')
import os
from urllib import parse
from gi.repository import (
import audioop
import time
import pyaudio
from typing import List
class settings:
FORMAT = pyaudio.paInt16
function color_get_ps1 {
local hostname="${1:-$(hostname)}"
hostname="${hostname/.*/}"
if [[ "$(uname -s)" == "Darwin" ]]
then
hashfunc=$(type -p md5)
else
hashfunc=$(type -p md5sum)
@ldotlopez
ldotlopez / motion-photos-tool.py
Created January 31, 2020 18:44
Android motion photos tool
#!/usr/bin/env python
TOKEN = b"\x00\x00\x00MotionPhoto_Data\x00\x00\x00"
def _load(filepath):
with open(filepath, "rb") as fh:
return fh.read()