Skip to content

Instantly share code, notes, and snippets.

@sourrust
sourrust / FLAC Benchmark 2016-06-11.md
Last active June 12, 2016 05:19
Comparing my project FLAC (v0.4.0) decoder to the newer one with bound checking disabled on arrays.

FLAC (v0.4.0)

File Name: 01 GATE ~Sore wa Akatsuki no you ni~.flac
Size: 32.4 MB
Block size: 4096 samples
Frame size: 14 - 14926 bytes
Sample rate: 44100 Hz
Number of channels: 2
Bits per samples: 16

Total samples: 10053036

@sourrust
sourrust / visibleOnScreen.js
Created April 6, 2016 05:36
Loads in images when the image is in the viewport of the screen
(function() {
'use strict';
var images, win;
win = window;
images = document.querySelectorAll('img');
function isElementInView(el) {
var rect = el.getBoundingClientRect();
@sourrust
sourrust / decode.c
Last active January 9, 2016 20:34
Comparing the reference decoder of FLAC to my implementation in Rust
#include <stdio.h>
#include <stdlib.h>
#include <FLAC/stream_decoder.h>
uint64_t _total_samples = 0;
uint64_t total_samples = 0;
static FLAC__StreamDecoderWriteStatus write_callback(
const FLAC__StreamDecoder* decoder,
const FLAC__Frame* frame,
@sourrust
sourrust / PrefixFix.js
Last active December 28, 2015 11:29
Script used to replace all the class references, in highlight.js, with a prefix of `hljs-`. The prefixes will be in (most likely 8.0) highlight.js, but I thought I would put this up for the curious.
// Basic instruction on using this script are (after downloading and unzip):
//
// 1. cd into the gist's directory
// 2. run "npm install"
// * to get the packages that are being used by this script
// 3. run "node PrefixFix.js [/path/to/highlight.js]"
// * if you don't specify the directory that highlight.js is in, the
// script assumes that it is right outside of it (aka it is just "node
// PrefixFix.js highlight.js")
'use strict';
@sourrust
sourrust / keyit.user.js
Last active September 30, 2015 01:58
Inspired by <http://siasia.github.com/backbone-reddit/>, keyboard shortcuts for reddit.com itself with a GreaseMonkey script.
// ==UserScript==
// @name Keyit
// @description Keyboard based navigation for reddit
// @include http*://www.reddit.com/
// @include http*://www.reddit.com/r/*
// ==UserScript==
// Keyboard shortcuts:
//
// j => move down
@sourrust
sourrust / dos2unix.sh
Created November 1, 2010 03:20
Might work for other things, but mainly for Minecraft DOS-style saves
#!/bin/sh
#
# This mainly for turning Minecraft DOS(Windows) file saves into
# Unix(Mac and Linux) file saves.
# Put the directory where the saves are into the first param
# the dos one:
# ie. /path/to/Minecraft-save
cd $1
@sourrust
sourrust / ChromeDev.sh
Created October 13, 2010 05:29
Most of the time the dev auto-updater never works for me, so I made this script to make updating easier or just as easy as the auto-updater.
#!/bin/sh
#
# Downloads the latest Chrome developer version
URL="http://dl.google.com/chrome/mac/dev/GoogleChrome.dmg"
CHROME="$HOME/Downloads/GoogleChrome.dmg"
PROCESS=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
CHANGELOG="http://googlechromereleases.blogspot.com/search/label/Dev%20updates"
# Parse the arguements