Skip to content

Instantly share code, notes, and snippets.

View dylnmc's full-sized avatar

dylnmc dylnmc

View GitHub Profile
@dylnmc
dylnmc / README.md
Last active September 24, 2020 05:35
Map Meta Keys in Vim!

Meta Sequences in Vim

Terminals are weird. If you type read -r in a shell then hold Alt and tap a, you may be surprised to see ^[a glaring at you.

Why?

Your terminal encodes Alt-a (referred to as <m-a> in vim) as two bytes: Escape (referred to as <esc> in vim) followed by a. This encoding scheme has been used for decades and allows your terminal to send escape sequences like

@dylnmc
dylnmc / vulpo.txt
Created August 21, 2020 20:28
vulpo color palette
0: #303030
1: #d75f5f
2: #5f875f
3: #d7875f
4: #5f87af
5: #875faf
6: #008787
7: #d7d7af
8: #585858
" v!autocmd (:
augroup Vimrc " (:
autocmd!
" vim shenanigans
autocmd WinEnter,BufWinEnter $HOME/simplevimrc.vim call <sid>setupVimFile()
autocmd BufWinLeave $HOME/simplevimrc.vim call <sid>cleanupVimFile()
autocmd BufRead,TextChanged,FileChangedShellPost,FileReadPost,FilterReadPost,ShellFilterPost $HOME/simplevimrc.vim call <sid>computeFirstFolds()
@dylnmc
dylnmc / rgb2hex.py
Last active October 14, 2017 20:13
convert rgb to hex from cli
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main(rgb):
if len(rgb) != 3 and len(rgb) != 4:
from sys import stderr, exit
stderr.write('expected either "r g b" or (r,g,b) as input\n')
exit(2)
print("#"+("{:02x}"*3).format(*rgb[:3]))
#!/bin/sh
# view here:
# https://i.stack.imgur.com/OK3po.png
e=$'\e['
for n in {0..7}; do
printf "${e}"'38;05;'"${n}"'m%-6s' '('"$n"') '
done
@dylnmc
dylnmc / scrambledEggs.py
Last active September 1, 2016 04:11
Hungry? Have some scrambled eggs!
#!/usr/bin/env python3
if __name__ == '__main__':
from sys import platform
if not platform.startswith('linux'):
from sys import stderr
print('Sorry; this only works in Linux!', file=stderr)
exit(1)
from os import system
from random import randint
@dylnmc
dylnmc / pi.py
Created April 14, 2015 16:09
Pi py - simple pi calculation in python
#! /usr/bin/env python
__author__ = "dylnmc"
def main():
from decimal import Decimal, getcontext
from os import nice
getcontext().prec = 100
two = Decimal("2.0")
@dylnmc
dylnmc / TicTacToe.c
Last active December 24, 2018 12:31
Best Tic-Tac-Toe game in C for Unix - use the arrow keys to navigate and Space or Enter to select
/*
This game is for Unix only.
It is a simple yet easily navigable Tic-Tac-Toe game for the Unix terminal. To run this file, go
to your awesome Unix terminal (after you have downloaded this text file, of course) and
navigate to this file. Then, compile and link the program with your handy compiler (which will
almost definitely be installed unless you have removed it) using the command 'gcc TicTacToe.c'.
This creates an executeable. To run it, you can simply type './a.out'. If you want to have a more
memorable file and/or prevent conflicts, simply change the name with the 'mv' tool
('mv a.out TicTacToe') or use the '-o' ("output file") when compiling
@dylnmc
dylnmc / cursors.py
Last active August 29, 2015 14:10
Cursors
#! /usr/bin/env python
"""
View all of the cursors for your operating system and their names in a nice Tkinter-based Python script.
"""
__author__ = "dylnmc"
from Tkinter import *
# All of the cursors I could find - ordered very nicely for you :)
@dylnmc
dylnmc / bubbles.py
Last active January 2, 2023 12:05
tkinter bubble
#! /usr/bin/env python2
"""
This is a very bubbly yet simple animation in python's Tkinter.
A lot of turquoise circles start positioned at the bottom of the Tkinter panel when
it opens. Then, on a blue background, The bubbles float fall upwards. Depending on their
size, the rise at different speeds: the bigger the faster. When they reach the top, they
apparently disappear and start back below the bottom of the screen and float back into
view. It's really fun to watch it for a minute or so.