Skip to content

Instantly share code, notes, and snippets.

View sug0's full-sized avatar
💭
debugging

Tiago Carvalho sug0

💭
debugging
View GitHub Profile
@sug0
sug0 / paste.c
Last active July 14, 2017 15:36
libmill based pastebin clone
// build: $ cc -o paste paste.c -lmill
// run: $ ./paste &; disown
// use: $ alias pastebin="nc localhost 6969"
// $ echo wat up pimp | pastebin
// $ pastebin < source_code.c
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
@sug0
sug0 / pomf.ps1
Created August 10, 2017 10:38
Pomf uploading util for PowerShell
# this snippet of code needs `curl` and `jq`, which you
# can grab from you favorite package manager, or directly
# from their respective websites
# $URL is the API URL of your preferred pomf clone
# ex: https://mixtape.moe/upload.php
Function Pomf-Upload($URL)
{
foreach ($File in $Args) {
$FullPath = (Get-Item $File).FullName
@sug0
sug0 / hash.c
Last active August 12, 2017 18:38
Fixed size hash table implementation, based on https://www.youtube.com/watch?v=qTZJLJ3Gm6Q
#include "hash.h"
struct _lst {
void *e;
uint64_t hash;
struct _lst *next;
};
/*
* Adapted sdbm hashing function
@sug0
sug0 / zippy.sh
Created September 3, 2017 13:40
ZippyShare commandline tool
zippyshare() {
curl -f -\# -F upload_form=@"$@" http://www20.zippyshare.com/upload | html2text
}
@sug0
sug0 / youtubeAutoplay.js
Last active September 20, 2017 16:25
Userscript to disable the stupid youtube autoplay
// ==UserScript==
// @name YouTube Autoplay
// @namespace https://gandas.us.to/
// @version 0.4
// @description Disable the stupid youtube autoplay
// @author sugoiuguu
// @match http://www.youtube.com/watch*
// @match https://www.youtube.com/watch*
// ==/UserScript==
@sug0
sug0 / DFA.hs
Last active January 17, 2018 11:50
[DFA] Deterministic Finite Automata in Haskell
module DFA where
import Data.Maybe (fromJust)
data Transition i a = Transition a (State i a)
deriving (Show, Read, Eq)
data State i a = State
{ identifier :: i
, isFinalState :: Bool
@sug0
sug0 / monad.py
Last active January 25, 2018 04:16
Monads in Python
from functools import reduce as _reduce
from random import random as _random
from sys import version_info as _version, stdout as _stdout, stdin as _stdin
# version specific code
_input = None
if _version[0] < 3:
_input = raw_input
else:
@sug0
sug0 / func.sh
Created February 12, 2018 23:37
Toy functional tools for the shell
#!/bin/sh
lambda() {
if [ ! $__lambda ]; then
__lambda=`printf "lambda_%s" $(date +%s)`
eval " \
$__lambda() { \
$1; \
};"
fi
@sug0
sug0 / zipper.go
Created February 17, 2018 04:34
A Zipper in Go using "container/list" | https://en.wikipedia.org/wiki/Zipper_(data_structure)
package zipper
import l "container/list"
type Zipper struct {
nzip int
list *l.List
back *l.Element
sel *l.Element
front *l.Element
@sug0
sug0 / minmax.hs
Last active March 12, 2018 01:04
Tic-Tac-Toe MinMax in Haskell
module MinMax where
import Data.List (minimumBy)
-- a game of tic-tac-toe
--- load this file in ghci, and enter
--- 'ticTacToe' in the prompt
type Token = Char