Skip to content

Instantly share code, notes, and snippets.

View sancau's full-sized avatar

Alexander Tatchin sancau

View GitHub Profile
@sancau
sancau / pipeline.py
Created March 22, 2017 16:46
Simple class for building async / blocking execution pipelines
# coding=utf-8
"""
Minimalistic util for building async pipelines of functions in Python
(c) github.com/sancau
"""
from multiprocessing.dummy import Pool as ThreadPool
from multiprocessing import Pool as ProcessPool
@sancau
sancau / animated_3d_histogram.py
Created February 7, 2017 13:59
Example of building animated 3D histogram with Python (Python 3.6 used)
# coding=utf-8
# github.com/sancau
from collections import Counter
from collections import namedtuple
from random import randint
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as p3
@sancau
sancau / cx_oracle.md
Last active February 6, 2017 12:21 — forked from kimus/cx_oracle.md
Installing python cx_oracle on Ubuntu

First of all, it just seems like doing anything with Oracle is obnoxiously painful for no good reason. It's the nature of the beast I suppose. cx_oracle is a python module that allows you to connect to an Oracle Database and issue queries, inserts, updates..usual jazz.

Linux

Step 1:

sudo apt-get install build-essential unzip python-dev libaio-dev

Step 2. Click here to download the appropriate zip files required for this. You'll need:

@sancau
sancau / dbms_interaction.py
Created January 20, 2017 09:40
DBMS interaction cases (ORACLE, POSTGRESQL, SQLACLHEMY)
# RAW CX_ORACLE
import cx_Oracle
import os
DB_USERNAME = '...'
DB_PASSWORD = '...'
DB_SID = '...' # basicaly a schema
DB_IP = '...'
DB_PORT = int
@sancau
sancau / excel_series_to_datetime.py
Last active October 31, 2016 13:49
Parsing excel timestamp format with Python
EXCEL_TIME = 42607.5234143519
# way 1
import datetime
def xldate_as_datetime(xldate, datemode):
# datemode: 0 for 1900-based, 1 for 1904-based
return (
datetime.datetime(1899, 12, 30)
+ datetime.timedelta(days=xldate + 1462 * datemode)
)
@sancau
sancau / MongoDB.md
Last active October 14, 2016 12:01

Mongo dump

mongodump -d database name -o target directory

You have to mount your folder on your VM.

First you need to install Guest Additions (although I already did this during the installation).

Start your VM Devices > Insert Guest Additions CD image... I had to manually mount the CD: sudo mount /dev/cdrom /media/cdrom Install the necessary packages: sudo apt-get install make gcc linux-headers-$(uname -r) Install the Guest Additions: sudo /media/cdrom/VBoxLinuxAdditions.run Now you can mount your share using:

@sancau
sancau / chrome.md
Created August 5, 2016 07:00
Disable CORS in Google Chrome

Disables CORS in Chrome

google-chrome --disable-web-security --user-data-dir=/home/sancau/temp (some directory)

@sancau
sancau / redux-basics.js
Last active August 4, 2016 11:00
Basic redux actions handling with multiple reducers
import { applyMiddleware, combineReducers, createStore } from 'redux';
//////////////////////////////////////////////////////
const userReducer = (state={}, action) => {
switch (action.type) {
case 'CHANGE_NAME': {
return {...state, name: action.payload}
}
case 'CHANGE_AGE': {

some usefull docker stuff

One liner to stop / remove all of Docker containers:

docker stop $(docker ps -a -q)

docker rm $(docker ps -a -q)

move files from host to container and overwise