Skip to content

Instantly share code, notes, and snippets.

View Akamaozu's full-sized avatar

Uzo Olisemeka Akamaozu

View GitHub Profile
@Akamaozu
Akamaozu / log_parser.js
Last active August 1, 2020 22:33
node.js streaming log parser
var chunks_received = 0,
lines_parsed = 0,
server_logs = [],
started = Date.now();
process.stdin.on( 'readable', function(){
var received_buffer = process.stdin.read();
if( ! received_buffer ) return;
chunks_received += 1;
@Akamaozu
Akamaozu / exclusive_executor.js
Created November 17, 2016 21:57
Make sure a callback is triggered only once
function exclusive_execute( real_callback ){
var triggered_callback = false;
return function(){
if( triggered_callback ) return;
triggered_callback = true;
real_callback();
}
@Akamaozu
Akamaozu / id-gen.js
Last active July 10, 2016 00:34
Generate Unique IDs, Release It When Consumed
function id_generator(){
var store = {};
function release_id( id ){
delete store[ id ];
}
function generate_unique_id(){
@Akamaozu
Akamaozu / payback.js
Last active August 29, 2015 14:19
Refactored Payback.js
$(document).ready(function(){
// required vars
var accessToken = window.location.hash.split("=")[1];
var userID = accessToken.split(".")[0];
// step 1: get users followed
getFollowedUsers(userID, accessToken, function(followed_users){
// step 2a: check for non-mutual follows
@Akamaozu
Akamaozu / indescribable.js
Created May 28, 2013 23:09
Indescribable by Chris Tomlin. In Javascript.
// The lyrics of Chris Tomlin
// in the eyes of a Programmer
// Best read while listening to the song
// (http://www.youtube.com/watch?v=7PTvr755V8s)
// Enjoy!
var highest_of_highs = earth.getMountainByName("Everest").getTop();
var depths_of_the_sea = earth.getOceanByName("Artic").getBottom();
foreach ( creation in earth ) {