Skip to content

Instantly share code, notes, and snippets.

# This snippet is based on http://stackoverflow.com/questions/456649/throttling-with-urllib2
import io
import time
import threading
class TokenBucket(object):
"""An implementation of the token bucket algorithm.
source: http://code.activestate.com/recipes/511490/
@caot
caot / HibernateUtil.java
Created November 28, 2017 17:07 — forked from piyasde/HibernateUtil.java
Multitenancy in Hibernate (with Hibernate 4.3.7 and PostgreSql 9.3.1)
package com.mt;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
@caot
caot / install-comodo-ssl-cert-for-nginx.rst
Created December 12, 2017 17:52 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@caot
caot / glibc-2.17_centos6.sh
Created February 27, 2018 19:17 — forked from harv/glibc-2.17_centos6.sh
update glibc to 2.17 for CentOS 6
#! /bin/sh
# update glibc to 2.17 for CentOS 6
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-common-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-devel-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-headers-2.17-55.el6.x86_64.rpm
sudo rpm -Uvh glibc-2.17-55.el6.x86_64.rpm \
@caot
caot / glibc-check.sh
Created April 26, 2018 13:50 — forked from fasterthanlime/glibc-check.sh
Prints the various glibc versions required by an executable
#!/bin/bash
# This scripts lets you check which minimum GLIBC version an executable requires.
# Simply run './glibc-check.sh path/to/your/binary'
#
# You can set `MAX_VER` however low you want, although I (fasterthanlime)
# feel like `2.13` is a good target (For reference, Ubuntu 12.04 has GLIBC 2.15)
MAX_VER=2.13
SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
@caot
caot / django_model_graph.sh
Created November 12, 2018 20:22 — forked from perrygeo/django_model_graph.sh
Generate UML diagram of django app models
apt-get install python-pygraphviz
pip install django-extensions
# add 'django_extensions' to INSTALLED_APPS in settings.py
python manage.py graph_models trees -o test.png
@caot
caot / nginx.conf
Created December 18, 2018 19:43 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
!function(){
var bP={};
var b=30, bb=150, height=600, buffMargin=1, minHeight=14;
var c1=[-130, 40], c2=[-50, 100], c3=[-10, 140]; //Column positions of labels.
var colors =["#3366CC", "#DC3912", "#FF9900","#109618", "#990099", "#0099C6"];
bP.partData = function(data,p){
var sData={};
sData.keys=[
@caot
caot / nginx.conf
Last active September 18, 2019 15:16 — forked from morhekil/nginx.conf
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
First add the below html code where you want to show in the category.html, product.html and cart.html
<div class="shipping-bar-wrapper" data-coupon-code="{{lang 'freeDelivery'}}"></div>
Add the freeDevlivery(the coupon amount) text to the en.json file in the lang file.
Add this Js code to global.js in the assets/js/theme folder
fetch('/api/storefront/cart', {
credentials: 'same-origin'
})
.then(function(response) {