Skip to content

Instantly share code, notes, and snippets.

View ourway's full-sized avatar
🏆

Farshid Ashouri ourway

🏆
View GitHub Profile
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A basic example using multiple processes
We spawn 4 processes. Each process is made to draw N/4 random
integers from 1 to 10, for some fixed large N.
Then the processes adds up its list of numbers, passes it into a queue,
and the main program adds up the subtotals to get a grand total.
@ourway
ourway / multiprocessing.py
Created May 23, 2020 02:48 — forked from thorsummoner/multiprocessing.py
python multiprocessing example
#!/usr/bin/env python3
""" Example multiprocess based python file
"""
import multiprocessing
import argparse
import itertools
ARGP = argparse.ArgumentParser(
@ourway
ourway / gist:889e77f506aaa3f4b55c88a5a1170e94
Created May 23, 2020 02:47 — forked from axolx/gist:3068001
Python multiprocessing example: run a function 7 times on a 5 process pool
import multiprocessing
import time
from random import randint
PROCESSES = 5
WORKER_CALLS = 7
def worker(num):
"""worker function"""
print 'Starting worker', num
@ourway
ourway / dialogflow_post_entities.py
Created April 30, 2020 01:22 — forked from mil06/dialogflow_post_entities.py
Posting new entities to dialog flow
# from __future__ import print_function
# import httplib2
# import os
# from apiclient import discovery
# from oauth2client import client
# from oauth2client import tools
# from oauth2client.file import Storage
import urllib.request as urllibReq
"""
For more information regarding DialogFlow SDK see:
* https://github.com/googleapis/dialogflow-python-client-v2
* https://dialogflow-python-client-v2.readthedocs.io/en/latest/
* https://cloud.google.com/dialogflow/docs/reference/rest/v2/projects.agent.sessions/detectIntent
"""
import dialogflow_v2 as dialogflow
@ourway
ourway / celery.sh
Created April 13, 2020 00:27 — forked from amatellanes/celery.sh
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
# ZIPLINE IMPORTS
import pandas as pd
import numpy as np
import re
import scipy
from collections import OrderedDict
from cvxopt import solvers, matrix, spdiag
import talib
from zipline.api import attach_pipeline, pipeline_output, get_datetime
@ourway
ourway / check_balance.py
Created January 21, 2018 10:46 — forked from talesa/check_balance.py
Script to check balances across exchanges implemented in `ccxt`
import asyncio
import ccxt.async as ccxt
from collections import defaultdict
exchanges = list()
exchanges.append(('binance', apiKey, secret))
exchanges.append(('livecoin', apiKey, secret))
tasks = list()
tasks += [ccxt.coinmarketcap({'timeout':100000}).fetch_tickers(params={'limit':0})]
@ourway
ourway / 50m_lakes_subset.geojson
Created January 21, 2018 10:32 — forked from mattmakesmaps/50m_lakes_subset.geojson
Created from Natural Earth dataset `50_m_lakes_utf8.shp`. SHP loaded into QGIS 2.1.0, Exported as GeoJSON by right-clicking layer in TOC, and selecting `Save As...`
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ourway
ourway / .screenrc
Created October 7, 2017 19:13 — forked from joaopizani/.screenrc
A killer GNU Screen Config
# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off