Skip to content

Instantly share code, notes, and snippets.

@iacchus
iacchus / colors.muttrc
Created September 6, 2019 01:34 — forked from LukeSmithxyz/colors.muttrc
Mutt example colors
# vim: filetype=neomuttrc
# Default index colors:
color index yellow default '.*'
color index_author red default '.*'
color index_number blue default
color index_subject cyan default '.*'
# For new mail:
color index brightyellow black "~N"
color index_author brightred black "~N"
@iacchus
iacchus / widen_ascii.py
Created April 14, 2018 21:21
widen_ascii.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
WIDE_MAP = dict((i, i + 0xFEE0) for i in range(0x21, 0x7F))
WIDE_MAP[0x20] = 0x3000
def widen(s):
"""
Convert all ASCII characters to the full-width counterpart.
@iacchus
iacchus / python3-ascii-to-full-width.MD
Last active December 10, 2017 18:52
Python 3 ASCII to Full Widh chars

Snippet to convert ascii chars to full-width characters

First one:

>>> def widen_str(string):
...     return(''.join([chr(0xFEE0 + ord(char)) for char in string]))
...
>>> widen_str('Hello, World!')
'Hello,\uff00World!'
@iacchus
iacchus / logwatcher.py
Created December 5, 2017 16:14
Simple logwatcher in python3. Watchs a log file for a line with a stiing, then runs an executable with the line as arguments.
#!/usr/bin/env python3
# usage
#
# 1. Make the above script executable:
# chmod +x logwatcher.py
#
# 2. Add a cronjob to start it after reboot like:
# @reboot /home/YOURUSERNAME/logwatcher.py "/var/log/auth.log" "session opened for user" "/sbin/myscript.sh"
#
# arguments are:
@iacchus
iacchus / simple-python-pushover.py
Created December 5, 2017 15:50
Simple Python Pushover Script using Requests to Send Message
#!/usr/bin/env python3
# 1. Just fill 'app token' and 'user key' below,
# 2. make the script executable: chmod +x simple-python-pushover.py
# 3. run in command line.
# Dependencias are python3 and `requests` lib
APP_TOKEN = ''
USER_KEY = ''
import requests as r
@iacchus
iacchus / center.python3
Created October 14, 2017 21:22
Center fortunes in terminal
#!/usr/bin/env python3
import sys, os
linelist = list(sys.stdin)
# gets the biggest line
biggest_line_size = 0
for line in linelist:
line_lenght = len(line.expandtabs())
@iacchus
iacchus / .bashrc
Created July 4, 2017 19:41
make tmux behave well in ssh (append to .bashrc)
if [[ -z "$TMUX" ]] && [ "$SSH_CONNECTION" != "" ]; then
tmux attach-session -t "$USER" || tmux new-session -s "$USER"
fi
#!env ruby
#
# brew install sox
#
def play(note, octave=1)
"play -q -n synth sq #{note}#{octave} remix - fade 0 .6 .1 norm; "
end
song_notes = %w(B A G A B B B A A A G D D B A G A B B B B A A B A G)
@iacchus
iacchus / play_notes.py
Created April 20, 2017 12:42 — forked from eliasdorneles/play_notes.py
Playing notes with sox
import subprocess
import time
def wait(seconds):
time.sleep(seconds)
def play_note(note='C', duration=4, delay=0):
# requires sox to be installed
@iacchus
iacchus / gist:9c25a370dd533e523348d1b6fa535697
Created April 3, 2017 03:38
Embed abcjs in vanilla forums pre elements if they are ABC
<script src="https://rawgit.com/paulrosen/abcjs/master/bin/abcjs_plugin_3.1.1-min.js"></script>
<script>
abcjs_plugin_autostart = false;
window.ABCJS.plugin.auto_render = false;
ABCJS.plugin.hide_abc = true;
ABCJS.plugin.render_options = {
scale: 1,
staffwidth:700,
paddingtop: 0,