Skip to content

Instantly share code, notes, and snippets.

View s4y's full-sized avatar

Sidney San Martín s4y

View GitHub Profile
# Reference: https://github.com/macvim-dev/macvim/wiki/building
class Macvim < Formula
desc "GUI for vim, made for macOS"
homepage "https://github.com/macvim-dev/macvim"
head "https://github.com/s4y/macvim.git", :branch => "stateful-render"
depends_on :xcode => :build
depends_on "cscope"
depends_on "lua"
depends_on "python"
@s4y
s4y / unbak.py
Created March 7, 2019 08:09
Recover data from Apple backup files
#!/usr/bin/env python3
# See https://www.downtowndougbrown.com/2013/06/legacy-apple-backup-file-format-on-floppy-disks/
import os
import pathlib
import struct
import sys
f = open(sys.argv[1], 'rb')
#!/bin/bash
if [[ $# < 1 ]]; then
echo "usage: $0 input.mov [ffmpeg_opts]..." 1>&2
exit 1
fi
infile="$1"
shift
outfile="${infile%.*}.mp4"
@s4y
s4y / ac3_downmix.txt
Last active January 9, 2019 09:22
Convert mkv to mp4, downmix audio to stereo, keep original audio as second track
for f in *.mkv; do ffmpeg -hide_banner -y -i "$f" -c copy -c:s mov_text -map 0:v -map 0:a -map 0:a -map s -ac:a:0 2 -c:a:0 aac -disposition:a:0 none -disposition:a:1 default -movflags +faststart "${f%.mkv}.mp4" || break; done
@s4y
s4y / 4chan_archive.py
Created November 12, 2018 15:31
4chan thread archiver. Old project; not maintained.
#!/usr/bin/env python3
from urllib.request import urlopen, urlretrieve
from urllib.error import HTTPError
import json
import os
import sys
import time
def update(thread):
youtube-dl -o htba VaL-KP6QOUI && (textargs='borderw=3:font=Arial Black:fontcolor=white:fontsize=40:x=40:y=h-lh-20' ; ffmpeg -ss 38 -t 2.85 -i htba.* -lavfi 'scale=502:-1 , drawtext='"$textargs"':enable=between(t\,1.5\,1.8):text=I , drawtext='"$textargs"':enable=between(t\,1.8\,2.1):text=I RESPECT , drawtext='"$textargs"':enable=gte(t\,2.1):text=I RESPECT WOMEN , split=3[mp4out][s1][s2] ; [s1]palettegen[p], [s2]fifo[s2], [s2][p]paletteuse[gifout]' -map '[mp4out]' -pix_fmt yuv420p -map 0:1 i_respect_women.mp4 -map '[gifout]' i_respect_women.gif)
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/IOKitLib.h>
typedef struct {
char key[4];
char ignored[24];
uint32_t size;
char ignored2[10];
char cmd;
char ignored3[5];
#include <inttypes.h>
#include <stdlib.h>
typedef enum {
UTF8_OK = 0,
UTF8_ERROR = 4,
} utf8_decode_state_t;
typedef struct {
utf8_decode_state_t state;
@s4y
s4y / maybe_a_shell.c
Last active September 13, 2017 03:21
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main() {
for (;;) {
char* line = NULL;
size_t cap;
ssize_t sz;
@s4y
s4y / naive_utf8.c
Last active October 15, 2017 09:28
A simple UTF-8 parser that happens to be fast.
#include <inttypes.h>
typedef enum {
UTF8_OK = 0,
UTF8_ERROR = 4,
} utf8_decode_state_t;
typedef struct {
utf8_decode_state_t state;
uint32_t codepoint;