Skip to content

Instantly share code, notes, and snippets.

View JoeyTeng's full-sized avatar

Joey Teng JoeyTeng

View GitHub Profile
@timstclair
timstclair / dynamic_select_test.go
Created September 3, 2015 18:12
Select from a dynamic list of channels
package scratch
import (
"reflect"
"testing"
)
/*
Results with Go1.5 on a 6 core Xeon CPU E5-1650 0 @ 3.20GHz
This file has been truncated, but you can view the full file.
../eyyxo.torrent:
Name: Hacked Team
Size: 415768052618 (387G)
Announce: udp://coppersurfer.tk:6969/announce
Files:
Amministrazione/01 - CLIENTI/1 - Commesse/1 - Commesse 2011/Commessa001.2011 Royal.xls 59392 (58K)
Amministrazione/01 - CLIENTI/1 - Commesse/1 - Commesse 2011/Commessa002.2011 Royal.xls 59392 (58K)

A Quick and Dirty Lens primer

Why does Lens exist? Well, Haskell records suck, for a number of reasons. I will enumerate them using this sample record.

data User = User { login    :: Text
                 , password :: ByteString
                 , email    :: Text
                 , created  :: UTCTime
 }
@akorn
akorn / rsync_parallel.sh
Last active January 26, 2024 08:18 — forked from rcoup/rsync_parallel.sh
This script can transfer large directory structures with parallel rsync workers. Example command line: `rsync_parallel . -- -aHSAX --exclude '*13' . /tmp/2/.`
#!/bin/zsh
#
# Copyright (c) 2014, 2020 by Dr. András Korn. Implements the basic idea of a similar script by Robert Coup (2013).
# License: GPLv3
function usage() {
echo 'Usage:
rsync_parallel [--parallel=N] <args to find(1) to generate list of stuff to transfer> -- <args to rsync>
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Math.md
Last active April 15, 2024 20:34
GLSL Math functions

Trigonometry

const float PI = 3.1415926535897932384626433832795;
const float PI_2 = 1.57079632679489661923;
const float PI_4 = 0.785398163397448309616;

float PHI = (1.0+sqrtf(5.0))/2.0;
@xf1
xf1 / remux
Created April 29, 2014 04:41
Remuxing with eac3to
Remuxing
Why Remux Blu-rays?
-You use MPC-HC (or similar DShow players) and standard filters for playback. You can also use better quality renderers like Haali, EVR and madVR.
-You get the ease of playback of a re-encode without the quality loss. A double click off the .mkv will start the movie - no annoying warnings, loading screens, previews and setup menus.
-You don't have to deal with horribly bloated, unstable and expensive PowerDVD or Arcsoft playback software.
-You don't have to mess with ISO creation, correct BD folder structure, UDF and SPTD drivers, and image mounting every time you want to watch a movie.
-You never have to worry about the region code setting of a disc.
-You never have to worry about HDCP or PAP content protection.
-You never have to worry about your software player downsampling your audio - get full bit-depth and frequency resolution, 24bit/96kHz or higher, not 16/48.
@aras-p
aras-p / preprocessor_fun.h
Last active April 28, 2024 15:25
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@isnowfy
isnowfy / dft.py
Last active July 5, 2019 04:29
dft
# Example usage
# $ python dft.py | gnuplot
# 9
# 0 0
# 1 1
# 2 2
# 0 2
# 1 1
# -1 1
# 0 2
@msg555
msg555 / gist:5418199
Last active October 30, 2021 19:27
Stack Switching
#include <stdio.h>
#include <stdlib.h>
#define STACK_SIZE (1 << 26)
#define STACK_PAD 128
int rec(int n) {
return n == 0 ? 0 : rec(n - 1) + 1;
}
@rcoup
rcoup / rsync_parallel.sh
Created April 10, 2013 21:52
Parallel-ise an rsync transfer when you want multiple concurrent transfers happening,
#!/bin/bash
set -e
# Usage:
# rsync_parallel.sh [--parallel=N] [rsync args...]
#
# Options:
# --parallel=N Use N parallel processes for transfer. Defaults to 10.
#
# Notes: