Skip to content

Instantly share code, notes, and snippets.

@Benoss
Benoss / gist:8277602
Created January 6, 2014 03:05
Python pool multi thread/process example
import time, random
PROCESS = True
JOB_POOL_SIZE = 10
DATABASE_POOL_SIZE = 5
def apply_job(arg):
r = random.random() *10
time.sleep(r)
return (arg, r)
@Benoss
Benoss / config_local.py
Created March 17, 2014 01:09
Django add Debug Toolbar for non HTML response ex: Json rest response
DEBUG=True
SOUTH_TESTS_MIGRATE = True
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'geo', # Or path to database file if using sqlite3.
'USER': 'postgres', # Not used with sqlite3.
'PASSWORD': 'postgres', # Not used with sqlite3.
'HOST': '127.0.0.1', # Set to empty string for localhost. Not used with sqlite3.
@Benoss
Benoss / .bash_aliases
Last active August 29, 2015 14:01
Bash Alias
alias ll='ls -lah --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias la='ls -A'
alias l='ls -CF'
alias upgrade='sudo apt-get update && sudo apt-get dist-upgrade -V && sudo pip install --upgrade pip virtualenv virtualenvwrapper fabric && sudo npm update -g'
alias h='history | grep $1'
alias psg='ps -ef | grep $1'
alias ..='cd ..'
function my_ip() # get IP adresses
{
@Benoss
Benoss / designer.html
Last active August 29, 2015 14:07
designer
<link rel="import" href="../core-ajax/core-ajax.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<link rel="import" href="../paper-tabs/paper-tab.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: relative;
@Benoss
Benoss / designer.html
Last active August 29, 2015 14:07
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
@Benoss
Benoss / 0_reuse_code.js
Last active August 29, 2015 14:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#/usr/bin/sh
sudo apt-get update
sudo apt-get --yes install python-pip
sudo apt-get --yes install vim
sudo apt-get --yes install htop
sudo apt-get --yes install ncdu
sudo pip install --upgrade 'pip<7'
sudo pip install --upgrade ansible
sudo pip install --upgrade virtualenv virtualenvwrapper
sudo apt-get dist-upgrade -V
<?php
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$IParray=array_values(array_filter(explode(',',$_SERVER['HTTP_X_FORWARDED_FOR'])));
$_SERVER['REMOTE_ADDR'] = reset($IParray);
}
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){
$_SERVER['REQUEST_SCHEME'] = 'https';
$_SERVER['HTTPS']='on';
# -*- coding: utf-8 -*-
import pip, os
from pip.commands.list import ListCommand
from pip.req import parse_requirements
import re
import argparse
class MyListCommand(ListCommand):
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
rm get-pip.py
sudo pip install virtualenv
#virtualenv --no-site-packages my_virtualenv_name
mkdir .virtualenvs
sudo pip install virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/git