Skip to content

Instantly share code, notes, and snippets.

View mniip's full-sized avatar
😼

mniip mniip

😼
View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/hidraw.h>
type MLens m s t a b = forall f. Traversable f => (a -> Compose m f b) -> s -> Compose m f t
mlens :: Monad m => (s -> m a) -> (s -> b -> m t) -> MLens m s t a b
mlens get set h s = Compose $ get s >>= getCompose . h >>= traverse (set s)
type MGetting m r s a = (a -> Compose m (Const r) a) -> s -> Compose m (Const r) s
mview :: Applicative m => MGetting m a s a -> s -> m a
mview l s = fmap getConst . getCompose $ l (\a -> Compose (pure (Const a))) s
@mniip
mniip / LC.hs
Last active October 30, 2018 14:00
{-# OPTIONS_GHC -fno-warn-tabs -Wno-missing-fields #-}
import Control.Applicative
import Control.Monad
import Control.Monad.Yoctoparsec
import Data.Char
import Data.List
import qualified Data.Map as M
import Data.Maybe
import qualified Data.Set as S
import System.Environment
typedef struct { int ix; char const *str; } entry;
entry list_class[] = {
{ELFCLASSNONE, "ELFCLASSNONE"},
{ELFCLASS32, "ELFCLASS32"},
{ELFCLASS64, "ELFCLASS64"},
{0, 0}
};
entry list_data[] = {
CC= gcc
CFLAGS= -g
CPPFLAGS=
LINKFLAGS=
SOURCE=resizexfs.c
EXE=resizexfs
all: $(EXE)
@mniip
mniip / isbanned.py
Last active November 5, 2017 03:10
A freenode-specific hexchat script that checks whether someone is banned on some channel. For irssi version see https://gist.github.com/mniip/66a16b6da65d6deda9bc
__module_name__ = "isbanned"
__module_author__ = "mniip"
__module_version__ = "0.6"
__module_description__ = "freenode-specific module that checks whether someone is banned on some channel"
"""
Commands:
/isbanned <channel> <user>
Check whether <user> is banned on <channel>
/ismuted <channel> <user>
{-# LANGUAGE TypeOperators, KindSignatures, DataKinds, PolyKinds, GADTs, RankNTypes, StandaloneDeriving, InstanceSigs, ScopedTypeVariables #-}
module GHC.TypeLits.Singletons
(
NatSingleton(..),
NatIsZero(..), induceIsZero,
NatUnary(..), induceUnary,
NatTwosComp(..), induceTwosComp,
NatBaseComp(..), induceBaseComp,
@mniip
mniip / timer.c
Last active December 31, 2016 05:04
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <string.h>
#include <signal.h>
#include <curses.h>
void quit()
{
endwin();
@mniip
mniip / 2048.sh
Created March 25, 2015 02:33
A 2048 clone for those who can't afford a desktop environment. Runs in sh!
#!/bin/sh
print_cell()
{
if [ "$1" = 0 ]; then
echo -en " "
else
if [ "$1" -ge 128 ]; then
echo -en '\x1B[33m'
elif [ "$1" -ge 16 ]; then
echo -en '\x1B[31m'
@mniip
mniip / tracer.c
Last active August 31, 2016 18:23
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <signal.h>
#include <limits.h>
#include <errno.h>
#include <pthread.h>