Skip to content

Instantly share code, notes, and snippets.

@YakBarber
YakBarber / Main.hs
Last active April 12, 2024 20:23
Tic Tac Toe in Haskell - Barry Van Tassell
module Main (main) where
-- build-depends: base, containers, mtl
import qualified Data.List as L
import Data.Maybe (fromJust)
import Data.Char (digitToInt, toLower)
import qualified Control.Monad.State.Lazy as S
----------------------
@YakBarber
YakBarber / csv_to_latex.py
Created August 2, 2021 04:55
Simple script to format the data in a CSV file (exported from Excel, perhaps) into a copy-pastable LaTeX table. It makes it easy to change the format choices if you want something specific.
### quick 'n' dirty CSV -> LaTeX table output
import csv
###############################
## stuff you should change ##
###############################
# the CSV to be table-ized
IN_FILENAME = "data.csv"
# [Created by task 2.5.0 4/9/2019 13:40:28]
# Taskwarrior program configuration file.
# For more documentation, see http://taskwarrior.org or try 'man task', 'man task-color',
# 'man task-sync' or 'man taskrc'
# Here is an example of entries that use the default, override and blank values
# variable=foo -- By specifying a value, this overrides the default
# variable= -- By specifying no value, this means no default
# #variable=foo -- By commenting out the line, or deleting it, this uses the default
@YakBarber
YakBarber / bright.py
Last active April 19, 2019 16:46
Small script to control brightness on laptop with Intel chipset running Ubuntu. Fn brightness keys and xbacklight stopped working, but this worked. Pass an int between 0 and 100 representing the percent brightness you want. Call without args to get current percentage.
#!/usr/bin/env python3
import os
import sys
import subprocess
from pathlib import Path
if os.geteuid()!=0:
args = ['sudo'] + sys.argv
os.execlp('sudo',*args)
@YakBarber
YakBarber / werkzeug_logging_fix.py
Created February 28, 2018 01:51
Prevent werkzeug from overriding your own logging handlers
#Werkzeug only checks the root logger for user-created handlers before setting its own.
#Since the correct way to create module-wide logging is _not_ with the root logger, this
#causes werkzeug to set its own logger over top of any you may create.
#This can be solved by setting the level of the 'werkzeug' logger to > 0 before werkzeug
#is started. It can also be solved by adding a handler to the root logger. But the consensus
#is that you should not do that. Do this:
import logging
#somewhere before app.run