Skip to content

Instantly share code, notes, and snippets.

Docker Completion for Zsh (Official)

  • mkdir -p ~/.oh-my-zsh/plugins/docker/
  • curl -fLo ~/.oh-my-zsh/plugins/docker/_docker https://raw.githubusercontent.com/docker/cli/master/contrib/completion/zsh/_docker
  • Add docker to plugins section in ~/.zshrc
  • exec zsh
@jakiro2017
jakiro2017 / remove_accents.py
Created February 24, 2021 01:52 — forked from J2TEAM/remove_accents.py
Remove Vietnamese Accents - Xoá dấu tiếng việt in Python
s1 = u'ÀÁÂÃÈÉÊÌÍÒÓÔÕÙÚÝàáâãèéêìíòóôõùúýĂăĐđĨĩŨũƠơƯưẠạẢảẤấẦầẨẩẪẫẬậẮắẰằẲẳẴẵẶặẸẹẺẻẼẽẾếỀềỂểỄễỆệỈỉỊịỌọỎỏỐốỒồỔổỖỗỘộỚớỜờỞởỠỡỢợỤụỦủỨứỪừỬửỮữỰựỲỳỴỵỶỷỸỹ'
s0 = u'AAAAEEEIIOOOOUUYaaaaeeeiioooouuyAaDdIiUuOoUuAaAaAaAaAaAaAaAaAaAaAaAaEeEeEeEeEeEeEeEeIiIiOoOoOoOoOoOoOoOoOoOoOoOoUuUuUuUuUuUuUuYyYyYyYy'
def remove_accents(input_str):
s = ''
print input_str.encode('utf-8')
for c in input_str:
if c in s1:
s += s0[s1.index(c)]
else:
s += c
@jakiro2017
jakiro2017 / Mac SSH Autocomplete
Created August 24, 2020 10:18 — forked from aliang/Mac SSH Autocomplete
Add auto complete to your ssh, put into your .bash_profile
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
sed -e s/,.*//g | \
grep -v ^# | \
uniq | \
grep -v "\[" ;
@jakiro2017
jakiro2017 / State.js
Created June 11, 2020 09:17 — forked from m1nd/State.js
State pattern
/*
Состояние — это поведенческий паттерн проектирования, который позволяет объектам менять поведение в зависимости
от своего состояния. Основная идея в том, что программа может находиться в одном из нескольких состояний, которые
всё время сменяют друг друга. Набор этих состояний, а также переходов между ними, предопределён и конечен.
Находясь в разных состояниях, программа может по-разному реагировать на одни и те же события, которые происходят с ней.
Такой подход можно применить и к отдельным объектам. Например, объект Документ может принимать три состояния: Черновик,
Модерация или Опубликован. В каждом из этих состоянии метод опубликовать будет работать по-разному.
*/
class TrafficLight {
@jakiro2017
jakiro2017 / stateful.js
Last active June 11, 2020 10:31 — forked from foca/stateful.js
Stateful is a simple implementation of the State Pattern for JavaScript.
function Stateful(object, initialState, interfaces, onInitialize) {
var currentState;
this.interfaces = interfaces = interfaces || object.constructor.States;
if (typeof interfaces == "undefined") {
throw "An object with the set of interfaces for each state is required";
}
function trigger() {
if (typeof object.trigger == "function") {
exports.RunObserver = () => {
/**
* Subject could be anything, Whatsapp group, Circket feed, news letter
* notification
*/
var Subject = function () {
//List of subscribers
this.observers = [];
return {
@jakiro2017
jakiro2017 / Observer.js
Created June 11, 2020 08:31 — forked from nishanbajracharya/Observer.js
Simple observer pattern with example
class Observer {
constructor(state) {
this.state = state;
this.subscribers = [];
}
get() {
return this.state;
}
@jakiro2017
jakiro2017 / observer.js
Created June 11, 2020 08:28 — forked from emosher/observer.js
A simple implementation of the Observer pattern in Javascript.
/**
* Observer.js
* This is a program to implement the Observer pattern in JavaScript.
*/
/**
* The Subject "class" constructor.
*/
var Subject = function () {
@jakiro2017
jakiro2017 / github_webhooks.py
Created February 28, 2020 11:31 — forked from vitorfs/github_webhooks.py
Handling GitHub Webhooks Using Django
import hmac
from hashlib import sha1
from django.conf import settings
from django.http import HttpResponse, HttpResponseForbidden, HttpResponseServerError
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from django.utils.encoding import force_bytes
import requests