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 / asyncio_django_view.py
Created November 26, 2020 17:06
asyncio + django
def _fetchImageSizes(self, images: list):
TIMEOUT_CONNECT = 2
async def fetchImage(image: dict):
ctx = ssl.create_default_context()
ctx.set_ciphers('DEFAULT@SECLEVEL=0')
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
timeout = aiohttp.ClientTimeout(total=TIMEOUT_CONNECT)
@ledil
ledil / gist:4332335f17b80ae9b87c680d1d9f3748
Created November 22, 2019 10:09
Find largest object within git
git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| sed -n 's/^blob //p' \
| sort --numeric-sort --key=2 \
| cut -c 1-12,41- \
| $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
@ledil
ledil / show_big_files.sh
Created November 22, 2019 10:07
Show you the largest objects in your repo pack file
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field separator to line break, so that we can iterate easily over the verify-pack output
@ledil
ledil / test
Created November 30, 2018 14:45
<script language="Javascript1.1" type="text/javascript">
var ftClick = getRequestParameter('target',location.href);
var ftExpTrack_3096092 = "";
var ftX = "";
var ftY = "";
var ftZ = "";
var ftOBA = 1;
var ftContent = "";
var ftCustom = "";
var ft1920x1080_OOBclickTrack = "";
@ledil
ledil / gist:b23eadaf16ed4fd80bed2809689cd8ea
Created February 7, 2018 22:25
haproxy + letsencrypt
# first haproxy entry
frontend fe-scalinglaravel
bind *:80
acl letsencrypt-acl path_beg /.well-known/acme-challenge/
use_backend letsencrypt-backend if letsencrypt-acl
default_backend test
@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 / Readme.md
Last active July 21, 2017 10:22
Cloud9 upgrade npm and install react via create-react-app

install latest version of node

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
nvm install v6.11

install latest version of npm

@ledil
ledil / extj
Created July 12, 2017 07:46
extjs grid store abort
Ext.define('Ext.enhance.data.Store', {
override: 'Ext.data.Store',
constructor: function(config) {
var me = this;
me.callParent([config]);
me.on({
'beforeload': function(store, operation) {
// keep the operation which has request object
store.lastOperation = operation;
}