This file contains hidden or 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
| #!/usr/bin/env python3 | |
| #this file create a freq dict of text | |
| import re | |
| import os | |
| import sys | |
| import uu | |
| import operator | |
| class FrequencyDict(): |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import argparse | |
| def parse_args(): | |
| """ Process command line arguments. """ | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("-c", "--column", type=int, | |
| default=0, |
This file contains hidden or 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
| #!/bin/sh | |
| # chkconfig: - 95 95 | |
| ### BEGIN INIT INFO | |
| # Provides: someservice | |
| # Required-Start: $ALL | |
| # Required-Stop: | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: | |
| # X-Interactive: false | |
| # Short-Description: someservice |
This file contains hidden or 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
| #!/usr/bin/env python2 | |
| # -*- coding: utf-8 -*- | |
| """ """ | |
| from jinja2 import Template | |
| # python3 | |
| def render_jinja(template: str, parameters: dict) -> str: | |
| """ |
This file contains hidden or 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 pandas as pd | |
| from joblib import Parallel, delayed | |
| data = [] | |
| func = None | |
| def process_chunk(chunk_size, num): | |
| res = data[chunk_size * num: chunk_size * (num + 1)].apply(func) | |
| return res |
This file contains hidden or 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
| # How to execute ipython | |
| ipython nbconvert --to=html --ExecutePreprocessor.enabled=True test_notebook.ipynb |
This file contains hidden or 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
| #!/bin/bash | |
| # runs ipython notebook by cron | |
| # Add to cron | |
| # 42 14 * * * /home/user/cron_ipython_runner.sh | |
| source $HOME/.profile | |
| WORKDIR=/var/local/ | |
| RUNNERLOG=/tmp/recomm_runner.log |
This file contains hidden or 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
| # Postgres | |
| from sqlalchemy import create_engine | |
| engine = create_engine('postgresql://USER:PASS@HOST/') | |
| engine.execute('select 1').fetchall() | |
| # Vertica | |
| import pyodbc | |
| conn_string = 'DSN=Vertica;' | |
| con = pyodbc.connect(conn_string) |
This file contains hidden or 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 import Process | |
| from time import sleep | |
| import pandas as pd | |
| series = pd.Series(range(100)) | |
| data = series[:3] | |
| def process_chunk(chunk_id, chunk_size): | |
| local_data = data[chunk_id * chunk_size: (chunk_id + 1) * chunk_size] | |
| for x in local_data: |
This file contains hidden or 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 decor(func): | |
| def wrap(*args, **kwargs): | |
| print('before a') | |
| print(args) | |
| args[0].log() | |
| res = func(*args, **kwargs) | |
| print('after a') | |
| return wrap | |
| def param_decor(param1): |
OlderNewer