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 / braille.go
Last active August 1, 2020 18:04
Image to braille art converter
// $ mkdir braille
// $ cd braille
// $ go mod init braille
// $ <... copy this file into main.go>
// $ go build
// $ curl -sf <some image> | ./braille -width 100 -height 100 -lum 128
package main
import (
@sug0
sug0 / xshot.sh
Last active March 8, 2023 22:12
Upload screenshots to IPFS
#!/bin/sh
# xshot.sh
# by sugo/vim
usage() {
echo Usage: $0 [-h] "[-select|-full|-edit|-upload]"
}
get_image() {
@sug0
sug0 / heatmap.go
Last active May 16, 2020 03:08
Generate go package heatmap
package main
import (
"os"
"fmt"
"sort"
"sync"
"runtime"
"go/token"
"go/parser"
@sug0
sug0 / sin.rs
Last active February 16, 2022 09:57
Constant function sin table in Rust
#![feature(const_fn)]
#![feature(const_raw_ptr_deref)]
fn main() {
const SIN_90: f32 = SINTAB[90];
println!("{}", SIN_90);
}
const fn to_radians(x: f64) -> f64 {
x * (std::f64::consts::PI / 180.0)
@sug0
sug0 / switch.rs
Created April 26, 2020 19:32
C style switch in Rust
macro_rules! switch {
($( $cond:expr => $result:expr ),+ $(,)?) => {
match true {
$( _ if $cond => $result ),+,
_ => unreachable!(),
}
}
}
fn main() {
@sug0
sug0 / diamonds.sc
Created April 21, 2020 14:22
Scarpet script to manage a diamond bank
__command() -> usage();
usage() -> (
'/diamonds consult\n' +
'/diamonds deposit <amount>\n' +
'/diamonds withdraw <amount>\n' +
'/diamonds sacrifice <amount>\n' +
'/diamonds transfer <target-user> <amount>'
);
@sug0
sug0 / inddownload.go
Created April 5, 2020 22:49
Downloader for Adobe InDesign's online reader
// This is targeting windows specifically, because I made this for my brother.
// If you need to use this abomination yourself, be sure to edit the code accordingly.
package main
import (
"os"
"log"
"fmt"
"sync"
"bufio"
@sug0
sug0 / history.py
Last active March 16, 2020 20:22
How I lost my mind looking for a techno song
# Let us write some code to snoop up our firefox history database file...
# This is when hoarding browser history links is actually useful!
# Never nuke your browser history, kids! :^)
import re
import sqlite3
from contextlib import closing
from sys import argv
@sug0
sug0 / discord_recover.go
Created December 28, 2019 21:28
Download discord channel messages
package main
import (
"os"
"encoding/gob"
"compress/gzip"
"fmt"
"github.com/bwmarrin/discordgo"
)
@sug0
sug0 / co.rs
Created December 1, 2019 18:57
Rust coroutines based around setjmp/longjmp... Why has God abandoned us?!
use std::ffi::c_void;
use std::os::raw::c_int;
extern "C" {
fn setjmp(env: *mut c_void) -> c_int;
fn longjmp(env: *mut c_void, val: c_int);
}
const JMP_BUF_SIZ: usize = 512;