Skip to content

Instantly share code, notes, and snippets.

@binary10ve
binary10ve / simple-pagination.js
Created March 7, 2022 18:31 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
const getAppEnv = (function(){
class AppEnv{
constructor(platform, buildVersion){
this.platform = platform;
this.buildVersion = buildVersion;
this.cacheEnabled = false;
}
enableCache(){
class Phone{
backup(){
console.log("Applying default backup strategy")
}
}
function googleBackup(phone){
const _backup = phone.backup;
module GoogleBackUp
def backup
puts("Back Up with Google")
super
end
end
@binary10ve
binary10ve / README.md
Created July 11, 2018 11:24 — forked from magnetikonline/README.md
NSSM - the Non-Sucking Service Manager cheatsheet.
@binary10ve
binary10ve / docker-cleanup-resources.md
Created December 19, 2017 11:50 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@binary10ve
binary10ve / adapter.py
Created November 10, 2017 13:40 — forked from pazdera/adapter.py
Example of `adapter' design pattern in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of `adapter' design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@binary10ve
binary10ve / redis_cheatsheet.bash
Created November 9, 2017 12:40 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@binary10ve
binary10ve / python_decorator_guide.md
Created October 17, 2017 20:49 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

function LinkedList(){
this.head = null;
}
LinkedList.prototype.append = function(data){
var newNode = {
data : data,
next : this.head // Since the new node is going to be the head, assigning existing head reference to next property
}
this.head = newNode;