Skip to content

Instantly share code, notes, and snippets.

View Samathy's full-sized avatar

Samathy Barratt Samathy

View GitHub Profile
@Samathy
Samathy / tree.py
Created December 21, 2021 16:44
A Python script which prints a brainfuck program in the shape of an xmas tree, which prints an xmas tree. `python3 tree.py [size of tree e.g 11 ]`
import sys
import io
SPACE = 32
CHAR_X = 88
NEWLINE = 10
def print_tree(s):
lines = []
@Samathy
Samathy / Python_2to3_requirements_check.py
Created June 29, 2020 16:51
Checks requirements.in files for upgradeable packages.
import argparse
import requirements
import requests
import json
# Requires requirements-parser, requests.
class package:
def __init__(self, package):
@Samathy
Samathy / CTFE_ClassName_to_Object_Map.d
Last active May 27, 2020 14:02
Dlang CTFE fun to generate a map of class names, to factories for that class for every class inheriting from given class.
import std.stdio;
class wibble
{
const string name()
{
return typeid(this).name;
}
}
@Samathy
Samathy / automata.py
Created September 9, 2019 08:28
Boilerplate for graphviz for displaying finite automata
import graphviz
class State:
def __init__(self, name, style="solid", color="black"):
self.name = name
self.style = style
self.color = color
self.rendered = False
@Samathy
Samathy / C_keywords.txt
Created March 9, 2019 19:32
Keywords of C
['auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if', 'int', 'long', 'register', 'return', 'short', 'signed', 'sizeof', 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', 'void', 'volatile', 'while']
auto
break
case
char
const
continue
default
do
double
@Samathy
Samathy / constant_confusion.cpp
Created January 16, 2018 12:38
Constant Confusion
int main()
{
char character = 'f'; //A single character
char anotherCharacter = 'b';
static char staticCharacter = 'f'; /* A variable must be static to be evaluated
at compile time. */
static char * cptr = &character; /* A pointer to a character.
One can modify the data,
@Samathy
Samathy / dumppdfcomments.py
Created January 5, 2018 18:50
Python Script to extract highlighted text from PDFs. Uses python-poppler-qt4. Updated [1] to Python 3 [1] https://stackoverflow.com/questions/21050551/extracting-text-from-higlighted-text-using-poppler-qt4-python-poppler-qt4
import popplerqt4
import sys
import PyQt4
def main():
doc = popplerqt4.Poppler.Document.load(sys.argv[1])
total_annotations = 0
for i in range(doc.numPages()):
#include <CapacitiveSensor.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define CAPSENSORPIN 3
#define CAPCPIN 2
#define THERMRESISTORVAL 10000
@Samathy
Samathy / fish_git_prompt_build_status.fish
Created February 24, 2017 11:24
Change the colour of the fish shell git prompt if source files are newer than build files. Set your prompt to fish_git_prompt then. Add this line to the bottom of ~/.config/fish/functions/fish_prompt.fish
 #Tests if source files listed are newer than the build
    set currentTime  0
    set rebuild false
    if test -e (pwd)"/"srcList.fish; and test -e (pwd)"/"buildList.fish
        for file in (strings (pwd)"/"srcList.fish)
@Samathy
Samathy / Arduino_ArchLinux_libtinfo_missing
Last active February 3, 2017 19:35
Fix for -> Uploading a sketch to an Arduino Nano fails on Arch Linux 03.02.2017
Attempting to upload an Arduino sketch to an Arduino Nano fails with the error: 'Failed to find libtinfo.so'
libtinfo is a dependency of avrdude. libtinfo (as far as I can tell) is a depreciated lib who's functionality is now part of, and shipped with, ncurses.
A dependency of Arduino, avrdude, uses the no longer avalible libtinfo.so.
The Arch AUR Package 'libtinfo' symlinks the relevent files, but does not fix the issue.
#Fix
===========
sudo pacman -S avrdude