This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing.pool import ThreadPool | |
from os import getpid | |
from time import sleep | |
def fn_sleep(s): | |
sleep(s) | |
return getpid() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $conf; | |
if (!isset($conf)) { | |
$pathTemplate = dirname(__FILE__) . '/conf_%s.php'; | |
$configFile = sprintf($pathTemplate, 'script'); | |
$currentConfigFile = sprintf($pathTemplate, gethostname()); | |
if (file_exists($currentConfigFile)) { | |
$configFile = $currentConfigFile; | |
} elseif (array_key_exists('HTTP_HOST', $_SERVER)) { | |
$currentConfigFile = sprintf($pathTemplate, $_SERVER['HTTP_HOST']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def StrNumberCommaInsert(s): | |
if s.replace('.', '').isdigit(): | |
p = 0 | |
if '.' in s: | |
p = len(s) - (s.index('.') + 1) | |
try: | |
n = int(s) | |
except ValueError: | |
n = float(s) | |
return ("{:,.%sf}" % p).format(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perl_set $request_uuid 'sub { | |
return join "", map{(a..z,A..Z,0..9)[rand 62]} 0..20; | |
}'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/big" | |
"time" | |
) | |
func NewFibonacci() func(x int64) *big.Int { | |
memo := make(map[int64]*big.Int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import logging | |
parent_logger = logging.getLogger("parent") | |
parent_logger.setLevel(logging.DEBUG) | |
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | |
handler = logging.StreamHandler(sys.stdout) | |
handler.setLevel(logging.DEBUG) | |
handler.setFormatter(formatter) | |
parent_logger.addHandler(handler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import contextlib | |
import sys | |
from cStringIO import StringIO | |
def print_error(*args, **kwargs): | |
print(*args, file=sys.stderr, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew tap homebrew/science | |
brew update && brew upgrade | |
# install xquartz for X11 | |
brew cask install xquartz | |
# install gcc for octave | |
brew install gcc | |
brew install octave | |
# install fltk for gnuplot | |
brew install fltk | |
brew install gnuplot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
l1 = [random.randrange(0, 10) for i in range(10)] | |
random.seed(0) | |
l2 = [random.randrange(0, 10) for i in range(10)] | |
print(l1) # [2, 7, 8, 0, 6, 6, 8, 7, 9, 1] | |
print(l2) # [8, 7, 4, 2, 5, 4, 7, 3, 4, 5] always same |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import division | |
import functools | |
import matplotlib.pyplot as plt | |
import pandas as pd | |