Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

m.l cundi

🎯
Focusing
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
mikeckennedy / switch_in_python_example.py
Last active Aug 21, 2019
Could we easily add switch to the Python language? I think the answer is maybe yes!
View switch_in_python_example.py
# Here is an example of some syntax I'm proposing:
# See the github repo at https://github.com/mikeckennedy/python-switch
def test_switch():
num = 7
val = input("Enter a key. a, b, c or any other: ")
with Switch(val) as s:
s.case('a', process_a)
s.case('b', process_b)
@paulirish
paulirish / what-forces-layout.md
Last active Oct 21, 2019
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

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.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
View design.py
# -*- 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
mattfahrner / python-paged-ldap-snippet-2.4.py
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.
View python-paged-ldap-snippet-2.4.py
#! /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
soheilhy / nginxproxy.md
Last active Oct 19, 2019
How to proxy web apps using nginx?
View nginxproxy.md

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 example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

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

@dangtrinhnt
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
keo / bootstrap.sh
Last active Oct 14, 2019
Setup encrypted partition for Docker containers
View bootstrap.sh
#!/bin/sh
# Setup encrypted disk image
# For Ubuntu 14.04 LTS
CRYPTFS_ROOT=/cryptfs
apt-get update
apt-get -y upgrade
apt-get -y install cryptsetup
@dengshuan
dengshuan / ckedit.py
Last active Jan 14, 2019 — forked from mrjoes/ckedit.py
Apply ckeditor(WYSIWYG rich text editor) to flask-admin textarea
View ckedit.py
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
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
fqrouter / worker nginx conf
Last active Jul 24, 2019
Youtube Reverse Proxy
View worker nginx conf
resolver 8.8.8.8;
location /video/ {
if ($request_uri ~ "^/video/(.+?)/.+") {
set $upstream_host $1.googlevideo.com;
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.