Skip to content

Instantly share code, notes, and snippets.

View kunle's full-sized avatar

Kunle kunle

  • Canada
  • 14:35 (UTC -04:00)
View GitHub Profile
@kunle
kunle / rubocop.md
Created March 9, 2022 19:17 — forked from stungeye/rubocop.md
Installing and Running Rubocop

Installing Rubocop

Install Rubocop by adding it to your Gemfile:

gem 'rubocop'
gem 'rubocop-rails'

And running:

bundle install

@kunle
kunle / k8s.yaml
Created December 17, 2019 13:51
K8s cheat sheet
###
# Statefulset
###
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: [STATEFULSET_NAME]
spec:
serviceName: [SERVICE_NAME]
replicas: 3
@kunle
kunle / docker-scratch.sh
Last active August 8, 2019 20:41
Some docker commands
#list all volumes with detail information, helpful to know when to remove or prune unused volumes
docker volume inspect $(docker volume ls | awk '{print $2}' | paste -sd " " -)
#
@kunle
kunle / basicQueryStringParser.js
Last active July 31, 2017 18:09
Basic Query String parser
const getQueryObject = (queryString) => {
const queries = queryString ? queryString.split('&').map((e)=>{ var v = e.split('='); var n = {}; n[v[0]] = v[1]; return n}) : [];
const o = queries.reduce((p,c)=>{
return Object.assign(p,c);
},{});
return o;
}
@kunle
kunle / separate.ts
Last active July 31, 2017 18:36
Separates given string into groups separated by the separator provided
export const separate = (value: string, groupCount: number, separator = ' ') => {
if ((value === undefined || value === null) || (groupCount === null || groupCount === undefined)) {
throw new Error('value and groupCount are required');
}
let reuslt = '';
value.split('').forEach((c, i) => {
const currentPos = i + 1;
let isSeparatable = currentPos % groupCount === 0 && currentPos !== value.length;
if (isSeparatable) {
reuslt = `${reuslt}${c}${separator}`;
@kunle
kunle / loggerWrapper.js
Created July 4, 2017 20:34
Wrapper for Logging service calls
let wrapper = function (bb, context) {
this.doWrap(bb, context);
};
wrapper.prototype.doWrap = function(bb, context) {
for(let key in bb){
if(typeof bb[key] === 'function') {
wrapper.prototype[key] = function() {
console.log('before', context);
bb[key].apply(null,arguments);
@kunle
kunle / index.html
Created April 21, 2017 18:07
JS Bin Async parallel loop // source https://jsbin.com/tepufik
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Async parallel loop">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://rawgit.com/caolan/async/v1.5.2/dist/async.min.js"></script>
@kunle
kunle / gist:b7145831c13063f8d8d2
Created October 9, 2015 14:41
Javascript template engine
var templateEngine = function(html, options) {
var re = /<%(.+?)%>/g,
reExp = /(^( )?(var|if|for|else|switch|case|break|{|}|;))(.*)?/g,
code = 'with(obj) { var r=[];\n',
cursor = 0,
result;
var add = function(line, js) {
js? (code += line.match(reExp) ? line + '\n' : 'r.push(' + line + ');\n') :
(code += line != '' ? 'r.push("' + line.replace(/"/g, '\\"') + '");\n' : '');
return add;
function doIt(someArray){
var result = [];
var realResult = [];
someArray.forEach(function(ele){
result.push(doPromise(ele))
});
function doPromise(element){
return new Promise(function(resolve, reject){
if(element == null)reject('Dont send me garbage');