Skip to content

Instantly share code, notes, and snippets.

@lestoni
lestoni / gist:5f7e4fa3794db843a999
Last active August 29, 2015 14:02
Pre-Pro Fn invocation
function func(fn, beforeFn, afterFn /*, thisArgs*/){
var context = arguments.length === 4 ? arguments[3] : null;
var queue = [beforeFn, fn, afterFn];
return function(){
var args = [].slice.call(arguments);
queue.forEach(function(fn, index){
index === 1 ? fn.apply(context,args) : fn.apply(context);
});
};
@lestoni
lestoni / gist:cc02e429400463b45e88
Last active August 29, 2015 14:03
Cruncher.js
function cruncher(fn, context){
if(typeof fn !== 'function'){
return new Error('Expected ' + fn + ' to be a function');
}
var _slice = [].slice,
memo = [];
function ingest(){
memo.push(fn.apply(context || null, _slice.call(arguments)));
#canvas {
border: 1px solid #ccc;
}
@lestoni
lestoni / gist:426b251c3cf68c2c7b42
Created August 8, 2014 15:31
some momentum core:FTW
@media only screen and (max-width: 480px) and (min-width: 320px) {
/*==========================================
Get rid of the H6 it is not necessary.
Giving the heading some whitespace provides
a good visual view.
=========================================*/
.heading h2 {
font-size: 1.1em;
width: 100%;
padding: 5px;
@lestoni
lestoni / activeingredient.json
Created September 10, 2015 16:48
active-ingredient
{
"_id": "55ee9d3faf18e05d4ce2f540",
"active_ingredient_interaction": "Currently updating...",
"breast_feeding_advisory": "Manufacturer advises that the drug should be avoided during breastfeeding as there is no adequate information on safety of the drug to the child",
"contra_indications": "Severe ulcer, gastrointestinal bleeding, and hypersensitivity",
"dosage": "100mg BD",
"generic": "",
"indication": "Inflammation and pain in rheumatoid arthritis, osteoarthritis and alkylosing spondylitis.",
"name": "Aceclofenac",
"picture_url": "",
@lestoni
lestoni / gist:2c60a1fe894936e8de21
Last active September 17, 2015 22:57 — forked from anildigital/gist:862675ec1b7bccabc311
Remove dangling docker images
docker rmi $(docker images -q -f dangling=true)
  • What do Etcd, Consul, and Zookeeper do?
    • Service Registration:
      • Host, port number, and sometimes authentication credentials, protocols, versions numbers, and/or environment details.
    • Service Discovery:
      • Ability for client application to query the central registry to learn of service location.
    • Consistent and durable general-purpose K/V store across distributed system.
      • Some solutions support this better than others.
      • Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
  • Centralized locking can be based on this K/V store.
@lestoni
lestoni / sort.js
Last active January 30, 2018 13:44
Ranking sorting and Average
// Sort Arr by Ranking
function sortByRanking(arr) {
let compare = function (a,b) {
if (a.ranking < b.ranking) {
return -1;
} else if (a.ranking > b.ranking) {
return 1;
} else {
return 0;
}
@lestoni
lestoni / index.js
Created August 13, 2018 05:45
Word Occurence
'use strict';
/**
* Get Scores of the amount of space the occurring words take up in a comment.
*
* @param {Array} comments Comments Collection
* @param {Object} categories Categories to Score
*
* @return {void}
@lestoni
lestoni / gist:8c74da455cce3d36eb68
Last active April 12, 2024 18:15
vim folding cheatsheet

via (https://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun)

  • zf#j creates a fold from the cursor down # lines.
  • zf/string creates a fold from the cursor to string .
  • zj moves the cursor to the next fold.
  • zk moves the cursor to the previous fold.
  • zo opens a fold at the cursor.
  • zO opens all folds at the cursor.
  • zm increases the foldlevel by one.
  • zM closes all open folds.