Skip to content

Instantly share code, notes, and snippets.

@ledil
ledil / state.js
Created January 9, 2024 16:59 — forked from dbisso/state.js
Simple state management in vanilla JS
function State() {
this.actions = {};
this.subscriptions = [];
this.history = [];
}
State.prototype.subscribe = function(element, action, callback) {
this.subscriptions[action] = this.subscriptions[action] || [];
this.subscriptions[action].push(function(data) {
callback.apply(element, data);
@ledil
ledil / ab.sh
Created September 28, 2017 08:15 — forked from brentertz/ab.sh
Apache Bench - Load test a protected page
#!/bin/bash
COOKIE_JAR="ab-cookie-jar"
COOKIE_NAME="_myapp_session"
USERNAME="foo@bar.com"
PASSWORD="password"
LOGIN_PAGE_URI="http://localhost:3000/users/sign_in"
TEST_PAGE_URI="http://localhost:3000/dashboard"
echo "Logging in and storing session id."
@ledil
ledil / makecert.sh
Last active September 12, 2017 08:34 — forked from richieforeman/makeauthority.sh
Issue Your Own Self-Signed S/MIME Certs with OpenSSL
openssl genrsa -des3 -out smime.key 4096
openssl req -new -key smime.key -out smime.csr
openssl x509 -req -days 3650 -in smime.csr -CA ca.crt -CAkey ca.key -set_serial 1 -out smime.crt -addtrust emailProtection -addreject clientAuth -addreject serverAuth -trustout -extfile smime.cnf -extensions smime
openssl pkcs12 -export -in smime.crt -inkey smime.key -out smime.p12 -chain -CAfile ca.crt
@ledil
ledil / idle.sh
Created July 5, 2017 12:29 — forked from ikbear/idle.sh
Docker image entrypoint idle script
#!/bin/bash
echo "This is a idle script (infinite loop) to keep container running."
echo "Please replace this script."
cleanup ()
{
kill -s SIGTERM $!
exit 0
}
@ledil
ledil / haproxy.cfg
Created January 30, 2017 12:51 — forked from tikenn/haproxy.cfg
Let's Encrypt Auto-Renewal script for HAProxy
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 2048
#!/usr/bin/env python
# coding=utf-8
#
# @file gevent_zmq_redis_demo.py
# @author kaka_ace <xiang.ace@gmail.com>
# @date Tue Oct 14 2014
"""
fetures: there are two concurrent tasks
1. From Redis server, Getting the notify msg with BLPOP operation,