Skip to content

Instantly share code, notes, and snippets.

View lee-pai-long's full-sized avatar
💭
Work In Progress

Saïdina MOHAMED ALI lee-pai-long

💭
Work In Progress
  • Marseille (France)
View GitHub Profile
@lee-pai-long
lee-pai-long / yourapp
Created March 14, 2017 10:23 — forked from leplatrem/yourapp
gunicorn virtualenv init.d script (could be simpler with upstart)
#! /bin/bash
### BEGIN INIT INFO
# Provides: yourapp
# Required-Start: nginx
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: The main django process
# Description: The gunicorn process that receives HTTP requests
# from nginx
@lee-pai-long
lee-pai-long / post-provisioning-mount_vagrant.md
Last active September 5, 2017 13:33
Vagrant mount folder post provisioning

[Vagrant] Post provisioning mount

config.vm.share_folder "ganja", "/test", "/test"
config.vm.provision :shell do |shell|
  shell.inline = "sudo mount -t vboxsf -o uid=`id -u apache`,gid=`id -g apache` test /test"
end
@lee-pai-long
lee-pai-long / vagrant_ssh_with_another_user.md
Last active September 5, 2017 13:33
How to use the vagrant ssh command with another user than vagrant.

[VAGRANT] Vagrant ssh connect with another user

Requirement: The other user must be provisioned at boot

Then In the Vagrantfile:

...
VAGRANT_COMMAND = ARGV[0]
...
# source: http://stackoverflow.com/questions/32557920/what-are-type-hints-in-python-3-5
def check_type_hinter(function):
"""
Make sure you follow what you said.
How to use:
@check_type_hinter
def length(arg: str) -> int:
return len(arg)
@lee-pai-long
lee-pai-long / gist:1ed12786328d1fc960f5ae97181ca1fc
Created May 25, 2016 09:30 — forked from telent/gist:9742059
12 factor app configuration vs leaking environment variables
App configuration in environment variables: for and against
For (some of these as per the 12 factor principles)
1) they are are easy to change between deploys without changing any code
2) unlike config files, there is little chance of them being checked
into the code repo accidentally
3) unlike custom config files, or other config mechanisms such as Java
@lee-pai-long
lee-pai-long / beautiful_idiomatic_python.md
Created April 29, 2016 16:37 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:

[PYTHON] Virtualenvwrapper for python 3

Install Virtualenvwrapper

$ [sudo -H] pip[3] install virtualenvwrapper

Create virtualenv home directory

[SED] Remove comments and empty lines from file

$ sed \
> -e '/^<comment_character>/d' \
> -e '/^$/d' \
> -i <file>

[LINUX MINT 17.2] Mouse middleclick paste keybinding

Install xdotool

$ [sudo] apt-get update -qq && \
> [sudo] apt-get install -yqq xdotool

[LINUX MINT 17.2] Install UNetbootin

$ sudo add-apt-repository ppa:gezakovacs/ppa && \
> sudo apt-get update && \
> sudo apt-get install unetbootin extlinux