Skip to content

Instantly share code, notes, and snippets.

View AndreasMattsson's full-sized avatar

Andreas Mattsson AndreasMattsson

View GitHub Profile
@dweekly
dweekly / mp3acm.c
Created October 19, 2010 00:45
Windows Snippet To Use Built-in ACM MP3 Decoder
#include <windows.h>
#include <stdio.h>
#include <assert.h>
#include <mmreg.h>
#include <msacm.h>
#define MP3_BLOCK_SIZE 522
#define SOURCE_MP3 "C:\\audiograbber\\At The Club Last Night\\At_The_Club_Last_Night_-_Haven't_You_Heard.mp3"
#define OUTPUT_PCM_FILE "c:\\dump.pcm"
@granoeste
granoeste / gist:870440
Created March 15, 2011 07:57
[Android] Modify contrast using a ColorMatrix
ColorMatrixColorFilter setContrast(float contrast) {
float scale = contrast + 1.f;
float translate = (-.5f * scale + .5f) * 255.f;
float[] array = new float[] {
scale, 0, 0, 0, translate,
0, scale, 0, 0, translate,
0, 0, scale, 0, translate,
0, 0, 0, 1, 0};
ColorMatrix matrix = new ColorMatrix(array);
ColorMatrixColorFilter filter = new ColorMatrixColorFilter(matrix);
@kbarros
kbarros / FFTW3Library.java
Created December 4, 2011 00:30
Automatically generated Java FFTW wrapper
//
// Java wrapper for FFTW3 using Java Native Access (JNA)
// Author: Kipton Barros
//
package fftw3;
// This file was automatically generated with JNAerator the command:
// java -jar jnaerator-0.9.7.jar -library FFTW3 /usr/local/include/fftw3.h -o . -v -noJar -noComp -noPrimitiveArrays -noMangling -structsInLibrary -runtime JNA -sizeAsLong -Dfftw_complex=double -Dfftwf_complex=float
// I made some small manual modifications, essentially to remove unneeded JNAerator dependencies
@jl2
jl2 / readaudio.c
Created January 26, 2012 06:33
Use ffmpeg's libavcodec and libavformat to decode an audio file into an output buffer.
/*
readmp3.c
Copyright (c) 2012, Jeremiah LaRocco jeremiah.larocco@gmail.com
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
@Alexis-D
Alexis-D / consumer.c
Created February 11, 2012 15:51
Producer / Consumer / Conditions variables / pthreads
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define BUF_SIZE 5
// the buffer works like a stack for
// the sake of simplicity, if needed
// we may implement a queue
@harningt
harningt / SimpleCrypto.java
Created September 22, 2012 19:00
Simple Android Stream Crypto
package us.eharning.android.cryptosample;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.KeySpec;
@mbinna
mbinna / podforceupdate.sh
Created December 4, 2012 09:43
Clear CocoaPods cache, re-download and re-install all pods
#!/usr/bin/env bash
rm -rf "${HOME}/Library/Caches/CocoaPods"
rm -rf "`pwd`/Pods/"
pod update
@chadmaughan
chadmaughan / pre-commit.sh
Last active November 25, 2022 00:38
A git pre commit hook that runs the test task with the gradle wrapper
#!/bin/sh
# this hook is in SCM so that it can be shared
# to install it, create a symbolic link in the projects .git/hooks folder
#
# i.e. - from the .git/hooks directory, run
# $ ln -s ../../git-hooks/pre-commit.sh pre-commit
#
# to skip the tests, run with the --no-verify argument
# i.e. - $ 'git commit --no-verify'
@adammw
adammw / gist:6257550
Last active June 3, 2024 13:21
HLS / M3U8 Downloader for AES-128 Encrypted Streams
#!/usr/bin/env node
// M3U8 Downloader (not working)
var fs = require('fs');
var http = require('http');
var https = require('https');
var crypto = require('crypto');
var program = require('commander');
var ee = require('streamee');
@mattpodwysocki
mattpodwysocki / eventsource.js
Last active September 23, 2019 15:34
Adding support for server-sent events for RxJS
if (!!root.EventSource) {
/**
* This method wraps an EventSource as an observable sequence.
* @param {String} url The url of the server-side script.
* @param {Observer} [openObserver] An optional observer for the 'open' event for the server side event.
* @returns {Observable} An observable sequence which represents the data from a server-side event.
*/
dom.fromEventSource = function (url, openObserver) {
return new AnonymousObservable(function (observer) {