Skip to content

Instantly share code, notes, and snippets.

@sguzman
sguzman / Cmake.txt
Created June 23, 2018 07:32
A cmake build file linking to cheerp tool chain
cmake_minimum_required(VERSION 3.11)
project(out.js)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-Wall -target cheerp")
set(CMAKE_CXX_COMPILER "/Applications/cheerp/bin/clang++")
set(CMAKE_LINKER "/Applications/cheerp/bin/llvm-link")
set(CMAKE_AR "/Applications/cheerp/bin/llvm-ar")
set(CMAKE_NM "/Applications/cheerp/bin/llvm-nm")
set(CMAKE_OBJDUMP "/Applications/cheerp/bin/llvm-objdump")
@sguzman
sguzman / main.rs
Created June 29, 2018 19:44
A simple example using html5ever to modify html data
extern crate html5ever;
use html5ever::{ParseOpts, parse_document};
use html5ever::tree_builder::TreeBuilderOpts;
use html5ever::rcdom::RcDom;
use html5ever::rcdom::NodeEnum::Element;
use html5ever::serialize::{SerializeOpts, serialize};
use html5ever::tendril::TendrilSink;
fn main() {
@sguzman
sguzman / ffmpeg.sh
Created June 30, 2018 14:19
Create a black video with an added mp3 track
ffmpeg -s 640x480 -f rawvideo -pix_fmt rgb24 -r 25 -i /dev/zero -i music.mp3 -vcodec libx264 -preset medium -tune stillimage -crf 24 -acodec copy -shortest output.mkv
@sguzman
sguzman / main.rs
Created July 1, 2018 00:28
A simple example involving raw pointers, padding, structs, byte addressing and stuff
pub fn main() {
struct Lel {
ch: char,
num: u64
}
struct Yip {
lel: Lel,
b: bool
}
@sguzman
sguzman / python-async-print.py
Created October 9, 2018 05:34
Be able to print in a multi-threaded env with a simple call to asyncio
async def print_async(*args):
print(*args)
def p(*args):
asyncio.run(print_async(*args))
p('It works')
p('Still works')
@sguzman
sguzman / Dockerfile
Created November 1, 2018 00:35
A good image for building golang static executables then tranferring executable to alpine
FROM golang as base
RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN go get -u "github.com/gin-gonic/gin"
RUN go get -u "github.com/lib/pq"
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s -extldflags -static" -o main .
@sguzman
sguzman / kube.sh
Created November 4, 2018 20:31
Script to run on kubernetes worker node to get to join
#!/bin/sh
apt-get update \
&& apt-get install -qy docker.io
apt-get update && apt-get install -y apt-transport-https \
&& curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
@sguzman
sguzman / Dockerfile
Created November 4, 2018 20:33
Dockerfile for rustup with building deps first
FROM liuchong/rustup:musl AS base
RUN mkdir app
WORKDIR ./app
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
RUN rustup target add x86_64-unknown-linux-musl
RUN rustup install nightly
RUN cargo install cargo-build-deps --verbose --color always
@sguzman
sguzman / bytes_split.go
Created April 22, 2019 16:28 — forked from xlab/bytes_split.go
Golang split byte slice in chunks sized by limit
func split(buf []byte, lim int) [][]byte {
var chunk []byte
chunks := make([][]byte, 0, len(buf)/lim+1)
for len(buf) >= lim {
chunk, buf = buf[:lim], buf[lim:]
chunks = append(chunks, chunk)
}
if len(buf) > 0 {
chunks = append(chunks, buf[:len(buf)])
}
@sguzman
sguzman / YouTubeURLFormats.txt
Created May 21, 2019 21:12 — forked from rodrigoborgesdeoliveira/ActiveYouTubeURLFormats.txt
Example of the various YouTube url formats
http://www.youtube.com/watch?v=-wtIMTCHWuI
http://www.youtube.com/v/-wtIMTCHWuI?version=3&autohide=1
http://youtu.be/-wtIMTCHWuI
http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch?v%3D-wtIMTCHWuI&format=json
http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare