Skip to content

Instantly share code, notes, and snippets.

View alanxoc3's full-sized avatar

Alan Morgan alanxoc3

View GitHub Profile
@alanxoc3
alanxoc3 / wbxdv.conf
Last active January 10, 2022 04:40
An fcitx wubi (五笔) table mapping for dvorak. This basically just makes wubi normal if your main keyboard layout is dvorak. Convert to a '.mb' file with 'mb2txt' and place it in /usr/share/fcitx/table.
[CodeTable]
UniqueName=wubidv
Name=Wubidv
Name[ca]=Wubidv
Name[da]=Wubidv
Name[de]=Wubidv
Name[ja]=Wubidv
Name[ko]=Wubidv
Name[ru]=Уби (Wubidv)
Name[zh_CN]=五笔字型dv
@alanxoc3
alanxoc3 / repolink
Last active November 25, 2020 20:53
A cli based approach to sharing files on your git hosting service.
@alanxoc3
alanxoc3 / _compiled_mapbuilder_dev.lua
Created April 17, 2020 04:27
Pico8 0.2.0b Include Memory Bug
g_gunvals_raw=[[
0#{x=0,y=0,w=12,h=10},
{x=12,y=0,w=12,h=10},
{x=0,y=10,w=12,h=10},
{x=12,y=10,w=12,h=10},
{x=0,y=20,w=12,h=12},
{x=12,y=20,w=12,h=12},
{x=24,y=0,w=8,h=8},
{x=24,y=8,w=8,h=8},
{x=24,y=16,w=8,h=8},
@alanxoc3
alanxoc3 / combine_monitors.sh
Created January 17, 2020 21:36
Combines two monitors into one.
#!/bin/bash
# Make your desktop environment treat two monitors as only one.
xrandr --output DP-1 --rotate left
xrandr --output DP-2 --rotate right
xrandr --output DP-2 --right-of DP-1 --auto
xrandr --setmonitor combined auto DP-1,DP-2
@alanxoc3
alanxoc3 / gun_vals.lua
Created December 14, 2019 04:15
Storing a table inside a string in PICO-8 lua.
function nf() end
-- Recursively copies table attributes.
function tabcpy(src, dest)
dest = dest or {}
for k,v in pairs(src or {}) do
if type(v) == 'table' and not v.is_tabcpy_disabled then
dest[k] = tabcpy(v)
else
dest[k] = v
@alanxoc3
alanxoc3 / railway_cipher.py
Last active December 15, 2018 09:03
A space efficient implementation of the Railway Cipher.
#!/usr/bin/env python3
# Railway Cipher, without a multidimensional array.
# Author: Alan Morgan
def get_rail_len(h): return 2*(h+1)-2
def get_level_len(level, fence_height, s):
rail_length = get_rail_len(fence_height)
rem = len(s) % rail_length - 1
level_len = len(s) // rail_length
@alanxoc3
alanxoc3 / dmenu_alias
Created April 10, 2018 08:56
Dmenu alias integration with xterm!
#!/usr/bin/bash
# By: Alan Morgan
# Don't you love my obfuscated perl code?
perl -e '
sub uniq { my %seen; grep !$seen{$_}++, @_; }
$dmenu=`dmenu_path`;
@dmenu=split "\n", $dmenu;
$aliases=`bash -i -c alias`;
@aliases = $aliases =~ /^alias ([^\=]+)\=.*$/mg;
%aliases = map { $_ => 1 } @aliases;
@alanxoc3
alanxoc3 / xtermcmd
Created April 10, 2018 08:54
A simple script that opens up xterm with a command or an alias!!!
#!/bin/bash
# For running commands on xterm startup.
# The newline is needed, because bash does weird things with aliases. Bash
# needs a line before the shopt command takes effect. That was a wild goose
# chase!
# http://www.delorie.com/gnu/docs/bash/bashref_72.html
xtermcmd() {
xterm -e "bash --rcfile <(echo -e \"shopt -s expand_aliases; . ~/.bashrc;\n$*\")"
@alanxoc3
alanxoc3 / .c
Created February 26, 2018 04:46
Almost Thread Safe C Increment example.
// Thread demo by Alan Morgan.
// Empirically, this example seems thread safe.
// But, it may be possible for 2 children to exit the while loop at the same time.
// Thus I must ask the question. Is true thread safety even possible!!!
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <string.h>
#include <unistd.h>