Skip to content

Instantly share code, notes, and snippets.


m.l cundi

Block or report user

Report or block cundi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mikeckennedy /
Last active Aug 21, 2019
Could we easily add switch to the Python language? I think the answer is maybe yes!
# Here is an example of some syntax I'm proposing:
# See the github repo at
def test_switch():
num = 7
val = input("Enter a key. a, b, c or any other: ")
with Switch(val) as s:'a', process_a)'b', process_b)
paulirish /
Last active Oct 21, 2019
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.


Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'design.ui'
# Created: Wed May 27 16:39:17 2015
# by: PyQt4 UI code generator 4.11.3
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
mattfahrner /
Last active Sep 4, 2019
This snippet allows you to do a Python LDAP search with paged controls. The latest version now supports Python "ldap" 2.4. Many thanks to Ilya Rumyantsev for doing the 2.4 legwork.
#! /usr/bin/python
import sys
import ldap
from ldap.controls import SimplePagedResultsControl
from distutils.version import LooseVersion
# Check if we're using the Python "ldap" 2.4 or greater API
LDAP24API = LooseVersion(ldap.__version__) >= LooseVersion('2.4')
soheilhy /
Last active Oct 19, 2019
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for,, and on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

dangtrinhnt / server-vars.yml
Last active Sep 5, 2019
Open edX server-vars.yml variables
View server-vars.yml
# variables common to the lms role, automatically loaded
# when the role is included
# These are variables that default to a localhost
# setup and are meant to be overwritten for
# different environments.
# Variables in all caps are environment specific
# Lowercase variables are internal to the role
keo /
Last active Oct 14, 2019
Setup encrypted partition for Docker containers
# Setup encrypted disk image
# For Ubuntu 14.04 LTS
apt-get update
apt-get -y upgrade
apt-get -y install cryptsetup
dengshuan /
Last active Jan 14, 2019 — forked from mrjoes/
Apply ckeditor(WYSIWYG rich text editor) to flask-admin textarea
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext import admin
from wtforms import TextAreaField
from wtforms.widgets import TextArea
from flask.ext.admin.contrib.sqla import ModelView
app = Flask(__name__)
app.config['SECRET_KEY'] = '123456790'
tamoyal / gist:10441108
Created Apr 11, 2014
Create super user and database user in Mongo 2.6
View gist:10441108
# Create your superuser
$ mongo
> use admin
> db.createUser({user:"someadmin",pwd:"secret", roles:[{role:"root",db:"admin"}]})
> exit
# Alias for convenience (optional and at your own risk)
$ echo 'alias mongo="mongo --port 27017 -u someadmin -p secret --authenticationDatabase admin"' >> ~/.bash_profile
$ source ~/.bash_profile
fqrouter / worker nginx conf
Last active Jul 24, 2019
Youtube Reverse Proxy
View worker nginx conf
location /video/ {
if ($request_uri ~ "^/video/(.+?)/.+") {
set $upstream_host $;
add_header Content-Disposition "attachment; filename=video.mp4;";
rewrite /video/.+?/(.+)$ /$1 break;
proxy_buffering off;
proxy_pass https://$upstream_host;
proxy_set_header Host $upstream_host;
You can’t perform that action at this time.