Skip to content

Instantly share code, notes, and snippets.

@xsurge83
xsurge83 / lambda_function.py
Created March 8, 2022 19:36 — forked from psa-jforestier/lambda_function.py
AWS Lambda function to gzip compress file when upload to S3 (will replace original file with gz version)
###
### This gist contains 2 files : settings.json and lambda_function.py
###
### settings.json
{
"extensions" : ["*.hdr", "*.glb", "*.wasm"]
}
### lambda_function.py
@xsurge83
xsurge83 / README.md
Last active February 8, 2016 05:00
fresh block
function requestApi() {
return $q.when();
}
var wrapApi = lastPromise(requestApi)
.then(function() {
// we are done here
});
function lastPromise(fn) {
@xsurge83
xsurge83 / gist:48f3b5ceaca904ea51cf
Created May 10, 2014 08:47
Distribution Probability
function randomProb(hash, n){
var bucketHash = {}, bucketHash, index, key,
sum=0, results =[], randValue, curBucketValue;
for(key in hash){
sum += hash[key];
bucketHash[key] = sum;
}
for (var index = 0; index < n; index++) {
randValue = Math.random();
@xsurge83
xsurge83 / gist:bf35b6ea76625bc0c7fa
Last active August 29, 2015 14:01
Aggregate in Sync order
var ids = [1,2,3];
var aggregateIds = function(ids, obj, callback){
var id;
if(!obj){
obj = {};
}
if(ids.length){
setTimeout(function(){
var id = ids.shift();
@xsurge83
xsurge83 / index.coffee
Created April 1, 2014 05:24
Read directory with git folder and copy to destination
#
#Todo:
#1. read args for source and destination directories
#2. read all folder in source directory
#3. read all package.json and get repo url
#4. for each url execute git clone
#
fs = require('fs')
{exec} = require('child_process')
@xsurge83
xsurge83 / myArray.js
Created March 10, 2014 04:06
Sub class array
function _bindArrayMethod(name, obj) {
obj.prototype[name] = function () {
return Array.prototype[name].apply(this, arguments);
};
}
function subClassArray(obj) {
var index;
for (index = 0; index < methods.length; index++) {
_bindArrayMethod(methods[index], obj);
<html ng-app="Test" >
<head>
<title>Field splitter directive - Demo page</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
<script type="text/javascript" src="angular-field-splitter.js" ></script>
<script type="text/javascript">
angular.module('Test', ['fieldSplitter']);
@xsurge83
xsurge83 / gist:5993045
Created July 14, 2013 03:11
BinarySearch
array = [1,4,5,6,10,13]
class BinarySearch
constructor:(@elems)->
@len = @elems.length
midPoint = (start, end)->
((end - start)/2) + start
find : (value, start=0, end =-1)->
exports.trace = function(label) {
// TODO probably can to do this better with V8's debug object once that is
// exposed.
var err = new Error;
err.name = 'Trace';
err.message = label || '';
Error.captureStackTrace(err, arguments.callee);
console.error(err.stack);
};