Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View fzakaria's full-sized avatar

Farid Zakaria fzakaria

View GitHub Profile
@fzakaria
fzakaria / yuv2rgb.py
Created April 23, 2012 18:26
A way to convert YUV (NV12) files to RGB (BMP). Requires PIL (Python Image Library)
__author__ = "Farid Zakaria"
__copyright__ = "Copyright 2011, AMD"
__credits__ = ["Sherin Sasidhan (serin.s@gmail.com)"]
__license__ = "GPL"
__version__ = "1.0."
__maintainer__ = "Farid Zakaria"
__email__ = "farid.zakaria@amd.com"
__status__ = "Prototype"
import argparse
### Keybase proof
I hereby claim:
* I am fzakaria on github.
* I am fzakaria (https://keybase.io/fzakaria) on keybase.
* I have a public key whose fingerprint is B99A 67AA F928 5481 A39C 2470 5E4F AAD7 EECE 4B21
To claim this, I am signing this object:
@fzakaria
fzakaria / gist:67f4cc7b36a97627b28c
Created September 23, 2014 21:37
Something like this
//You'd create this helper AuthoratativePropertilesFileAccessor that would wire in
// SqlitePropertiesAccessor. Once it's proven that the test is valid we can simply
// delete this class and wire in immediately SqlitePropertiesAccessor
public AuthoratativePropertilesFileAccessor implements PropertiesFileAccessor {
private final PropertiesFileAccessor authoriative;
private final PropertiesFileAccessor test;
class SqliteModelAccessor<T> implements ModelStoreAccessor<T> {
// Implement interface for a (TEXT, TEXT) SQLite table
}
@Autowired
class SqliteAccessorFactory(ModelResultSetTransformer transformer) {
enum PropertyDatabaseFile {
EPHEMERAL_DATABASE_FILE,
REPLICATED_DATABASE_FILE
}
@fzakaria
fzakaria / lambda_cloudsearch.js
Last active March 13, 2024 19:15
Send CloudTrail events to CloudSearch with AWS Lambda
console.log('Loading event');
var CLOUDSEARCH_ENDPOINT = < INSERT HERE >
var async = require('async');
var jpath = require('json-path')
var zlib = require('zlib');
var aws = require('aws-sdk');
var s3 = new aws.S3({
apiVersion: '2006-03-01'
});
public class SubsetSum {
public static List<List<Integer>> subsetSum( List<Integer> list, int sum) {
List<List<Integer>> solutions = new ArrayList<List<Integer>>();
Stack<Integer> solution = new Stack<Integer>();
subsetSum(list, sum,0, solutions, solution);
return solutions;
}
@fzakaria
fzakaria / dissoc-in.clj
Created December 4, 2015 18:51
dissoc-in that handles vectors
(defn str->int [s]
(when-let [d (re-find #"-?\d+" s)] (Integer. d)))
(defn vec-remove
"remove elem in coll"
[coll pos]
(vec (concat (subvec coll 0 pos) (subvec coll (inc pos)))))
(defn dissoc-in
"The purpose of this method is to handle vector indices as well as maps."
@fzakaria
fzakaria / EchoApplication.java
Created January 18, 2016 19:36
Netty HTTP Echo Server & Client
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
@fzakaria
fzakaria / EchoApplication.java
Created January 18, 2016 19:36
Netty HTTP Echo Server & Client
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
@fzakaria
fzakaria / double_array.go
Created January 21, 2016 18:39
How to iterate over a double array in Cgo
package avformat
//#cgo pkg-config: libavformat
//#include <libavformat/avformat.h>
import "C"
import (
"unsafe"
)
//https://www.ffmpeg.org/doxygen/2.7/structAVFormatContext.html