Skip to content

Instantly share code, notes, and snippets.

View wjandrea's full-sized avatar

William Andrea wjandrea

  • Montreal, QC
View GitHub Profile
#!/usr/bin/env python3
"""
Use Unicode flag emoji homoglyphs to re-encode UTF-8.
To encode, a string is first encoded as UTF-8, then each byte is
broken down into bits, and each bit is encoded as a flag:
The more well-known country flag in each pair represents 0, and the
less well-known one represents 1. Pairs are cycled through.
There are 8 pairs total, which is the most I could find without repeats.
@wjandrea
wjandrea / sieve.py
Last active January 17, 2022 05:47
"sieve" iterative, not recursive, based on https://www.youtube.com/watch?v=5jwV3zxXc8E
def sieve(s):
seen = []
for i in s:
if any(i%n == 0 for n in seen): # If "i" is divisible by any previous numbers
continue
yield i
seen.append(i)
from itertools import count # Don't reinvent the wheel ("nats")
@wjandrea
wjandrea / solarized_dark_custom.sh
Last active April 11, 2023 21:24
My custom Solarized Dark theme for Xterm-like terminals. Note that I'm not a graphic designer.
# Solarized was created Ethan Schoonover. https://ethanschoonover.com/solarized/
# Original
base03="002b36"
base02="073642"
base01="586e75"
base00="657b83"
base0="839496"
base1="93a1a1"
base2="eee8d5"
@wjandrea
wjandrea / dircolors
Last active May 29, 2023 16:11
My custom dircolors. This is based on the default dircolors in Ubuntu 14.04, I think.
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
#
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copying and distribution of this file, with or without modification,
# are permitted provided the copyright notice and this notice are preserved.
#
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
@wjandrea
wjandrea / alert.sh
Last active January 23, 2019 16:48
Ubuntu "alert" alias as function
#!/bin/bash
# You can source this script to get the "alert" function.
function alert {
# Alert after a long running command.
# Use like so: "sleep 2; alert"
local exit=$? # Must go first!
local img=terminal
local msg="$(fc -nl -1 | sed -e 's/^\s\+//; s/\s*[;&|]\s*alert$//')"
@wjandrea
wjandrea / setup.ubuntu.solarize.sh
Last active February 20, 2017 19:57 — forked from t-mart/setup.ubuntu.solarize.sh
Simplify hex codes, better palette for gnome-terminal, fix fg color, add darker bg color
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
# Note about the palette: I am not a graphic designer.
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "#073642:#D30102:#859900:#B58900:#268BD2:#D33682:#2AA198:#EEE8D5:#002B36:#CB4B16:#4E9A06:#C4A000:#6C71C4:#75507B:#46B46C:#EEE8D5"
# If you want a darker background:
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "#001B26"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "#93A4A6"