Skip to content

Instantly share code, notes, and snippets.

View jayantbh's full-sized avatar
🟣
Building middlewarehq.com

Jayant Bhawal jayantbh

🟣
Building middlewarehq.com
View GitHub Profile
@jayantbh
jayantbh / exec_family_and_printing.c
Last active April 27, 2016 15:54
Exec family of functions usage demo.
//exec() family of functions
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv){
pid_t id;
id = vfork();
if(id == 0){
@jayantbh
jayantbh / js_utility_functions.js
Created April 3, 2016 14:02
Some commonly used JS utility functions I use regularly.
Array.prototype.getItemCount = function (val) {
var count = 0, i = -1;
while ((i = this.indexOf(val, i + 1)) != -1) {
count++;
}
return count;
};
Array.prototype.sortObjectsWithSingleKeyByValue = function (isAscending) {
return (isAscending) ? this.sort((a, b) => a[Object.keys(a)[0]] - b[Object.keys(b)[0]]) : this.sort((a, b) => b[Object.keys(b)[0]] - a[Object.keys(a)[0]]);