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 / ytgrep.go
Last active November 3, 2019 20:55
YouTube search result scraper that doesn't rely on an html parser. Runs in O(len(ResponseBody)).
//
//=======================================================================
// NOTICE -- this program has stopped working, please refer to this gist:
// https://gist.github.com/sug0/79680851924800d24f393978a08e9bc7
//=======================================================================
//
package main
import (
@sug0
sug0 / net.c
Last active February 10, 2019 15:58
Go style networking in C
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <goio.h>
@sug0
sug0 / sched.c
Last active February 19, 2019 03:01
Cron alternative that will run in your shitter.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/wait.h>
/* configurable constants */
#define TIME_MAX 2
@sug0
sug0 / pattern-match.lsp
Created February 25, 2019 04:40
newLISP pattern matching akin to Haskell
(define-macro (pattern-match expr)
(local (e u m p)
(setq e (eval expr))
(dolist (pat (args) (!= u nil))
(setq p (pat 0))
(setq m (pat 1))
(setq u (unify p e)))
(if (!= u nil)
(eval (list
'let
@sug0
sug0 / arp_poison.go
Created April 8, 2019 00:41
ARP poisoning in Go
package main
import (
"net"
"log"
"flag"
"github.com/mdlayher/arp"
)
@sug0
sug0 / Schema.pm
Last active May 20, 2019 23:54
Perl JSON validator
package JSON::Schema;
use strict;
use warnings;
use Scalar::Util qw(looks_like_number);
use Exporter;
# inherit this package
our @ISA = qw(Exporter);
@sug0
sug0 / trip.go
Last active November 4, 2021 13:16
Collaborative OSM based road trip planner in Go
package main
import (
"os"
"os/signal"
"syscall"
"net/http"
"context"
"sync"
"time"
@sug0
sug0 / cat.rs
Last active June 20, 2019 17:27
Micro cat clone in Rust
use std::io::{self, Read, Write};
use std::fs;
use std::env;
use std::process;
enum Input {
Stdin(io::Stdin),
File(fs::File),
}
@sug0
sug0 / farbfeld.rs
Created June 18, 2019 02:18
Write farbfeld with Rust
use std::mem;
use std::slice;
use std::io::{self, Write};
macro_rules! to16 {
($n:expr) => (
(($n as u16) << 8) | (($n as u16) & 0xff)
);
}
@sug0
sug0 / pipe.py
Last active June 1, 2020 19:43
Convert NewPipe playlists from SQLite to JSON
import sqlite3
import json
if __name__ == '__main__':
with sqlite3.connect('newpipe.db') as conn:
c = conn.cursor()
playlists = { id:{'name':name, 'tracks':[]} for id, name, _ in \
c.execute('select * from playlists') }