Skip to content

Instantly share code, notes, and snippets.

View JustusAdam's full-sized avatar

Justus Adam JustusAdam

View GitHub Profile
@JustusAdam
JustusAdam / imgsort.py
Last active October 19, 2015 08:26
Sort images into directories by date taken/modified
#!/usr/bin/env python3
import pathlib
import sys
import exifread
from datetime import datetime
from itertools import count
image_exts = [
".jpg",
<html>
<head>
<script src="main.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
function reset_geschlecht () {
var frau_input = document.getElementById("frau-input");
var mann_input = document.getElementById("mann-input");
frau_input.labels[0].style.color = "black";
mann_input.labels[0].style.color = "black";
@JustusAdam
JustusAdam / StripDirPrefixes.hs
Last active April 13, 2017 11:18
Renames all direcories in the working directory by stripping a prefix. Leaves those who dont match the prefix unchanged.
-- Renames all direcories in the working directory by stripping a prefix
-- Leaves those who dont match the prefix unchanged.
import System.Directory
import Data.List
import System.Environment
import Control.Monad.Extra
main = getArgs >>= \[prefix] ->
listDirectory "." >>= filterM doesDirectoryExist >>= mapM_ (maybe (return()) (renameDirectory <$> (prefix++) <*> id) . stripPrefix prefix)
@JustusAdam
JustusAdam / Watch.hs
Last active April 19, 2017 14:56
Watch a shake project for changes and recompile on change
{-# LANGUAGE BangPatterns #-}
import Control.Concurrent
import Control.Monad
import Data.Foldable
import qualified Data.HashSet as HS
import System.Directory
import System.Environment
import System.FilePath
import System.FSNotify
@JustusAdam
JustusAdam / PlistToYaml.hs
Last active May 17, 2017 20:40
Read a plist file and convert it into Yaml
-- Reads a plist file and converts it into Yaml
-- it might not support all plist elements
-- it supports 'dict', 'array', 'integer' and 'string'
-- dependencies:
-- - base
-- - aeson
-- - xml
-- - yaml
-- - unordered-containers
@JustusAdam
JustusAdam / GenPW.hs
Last active June 26, 2020 14:08
A simple('ish) and transparent password generator
-- A one-file Haskell password generator file.
--
-- has two generation methods
-- chars which works simply by generating random characters
-- dict which selects words from a dictionary.
--
-- The `dict` generation method needs `aspell` to be installed on the system (as
-- it uses the `aspell` wordlists). The language argument to the `dicts` method
-- must be a valid `aspell` language identifierm with the default being 'en'.
--
@JustusAdam
JustusAdam / gen_ghci_conf.hs
Created August 3, 2018 12:07
I'm weird, so I made a haskell script to generate my ghci config.
#!stack runhaskell
import Data.Monoid
import Text.Printf
data ExtsHelper
= Prefixed String
[ExtsHelper]
| Values [String]
exts :: [ExtsHelper]
@JustusAdam
JustusAdam / lc.hs
Last active November 11, 2019 14:44
A simple line counting tool
{-# LANGUAGE NoImplicitPrelude, GADTs, FlexibleContexts #-}
import Control.Arrow ((***))
import qualified Data.Char as C
import qualified Data.HashMap.Strict as Map
import Data.List (partition)
import System.Directory
import System.FilePath
import Text.Printf
import Universum
class Ref:
sentinel = object()
def __init__(self):
self._val = self.sentinel
def set(self, val):
self._val = val
def get(self):
t = self._val
self._val = self.sentinel
return t
interrupt_handler = lambda _: None
def foo():
global interrupt_handler
# also could be something like write to a channel, opened only locally in foo
def h(x):
print(x)
interrupt_handler = h
for i in bar():