Skip to content

Instantly share code, notes, and snippets.

Avatar

Toubi AntoineToubhans

View GitHub Profile
@AntoineToubhans
AntoineToubhans / check-git-branch-before-deploy.js
Created May 31, 2018
A tiny serverless plugin to check the current branch before deploy
View check-git-branch-before-deploy.js
const exec = require('child_process').exec;
class CheckGitBranchBeforeDeploy {
constructor (serverless, options) {
this.commands = {
deploy: {
lifecycleEvents: [
'resources',
]
View MongoTs_data_ingestion.py
import mongots
from datetime import datetime
from csv import DictReader
temperature_collection = mongots.MongoTSClient().ClimaticDataDb.temperatures
with open('./weather_data.csv') as file:
reader = DictReader(file, delimiter=';')
failed = 0
View gist:c38bd2d91087ae6da47c0f1c2e899cd3
```
| datetime | city | temperature |
|---------------------|-------|-------------|
| 1996-07-01 02:00:00 | paris | 15.0 |
| | | |
| | | |
```
View Prêt.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View py-time-tracker-code-example-3.py
def _log(message):
print('[BetterTimeTracker] {function_name} {total_time:.3f} {partial_time:.3f}'.format(**message))
@better_time_tracker(_log)
def load():
df = pd.read_csv('/home/toubi/Works/sicara/h3/HyperCube/App/Demo/Demo/Titanic.csv', delimiter=';')
return df
@better_time_tracker(_log)
View py-time-tracker-better-time-tracker.py
import time
from functools import wraps
_total_time_call_stack = [0]
def better_time_tracker(log_fun):
def _better_time_tracker(fn):
@wraps(fn)
def wrapped_fn(*args, **kwargs):
global _total_time_call_stack
View py-time-tracker-code-example-2.py
def _log(message):
print('[SimpleTimeTracker] {function_name} {total_time:.3f}'.format(**message))
@simple_time_tracker(_log)
def load():
df = pd.read_csv('/home/toubi/Works/sicara/h3/HyperCube/App/Demo/Demo/Titanic.csv', delimiter=';')
return df
@simple_time_tracker(_log)
View py-time-tracker-simple-decorator.py
from time import time
from functools import wraps
def simple_time_tracker(log_fun):
def _simple_time_tracker(fn):
@wraps(fn)
def wrapped_fn(*args, **kwargs):
start_time = time()
try:
View py-time-tracker-cprofile-result-partial.txt
8347 function calls (8300 primitive calls) in 0.012 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
6 0.000 0.000 0.000 0.000 <frozen importlib._bootstrap>:402(parent)
55 0.000 0.000 0.000 0.000 <frozen importlib._bootstrap>:989(_handle_fromlist)
1 0.000 0.000 0.005 0.005 <ipython-input-119-9a494182bfd0>:11(normalize_ticket_price_per_class)
1309 0.000 0.000 0.000 0.000 <ipython-input-119-9a494182bfd0>:13(<lambda>)
1 0.000 0.000 0.011 0.011 <ipython-input-119-9a494182bfd0>:15(run)
View gist:2e874516ac8dccf1448f4a1f26cfd45e
4145 function calls (4134 primitive calls) in 0.008 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
6 0.000 0.000 0.000 0.000 <frozen importlib._bootstrap>:402(parent)
51 0.000 0.000 0.000 0.000 <frozen importlib._bootstrap>:989(_handle_fromlist)
1 0.000 0.000 0.007 0.007 <ipython-input-1-0a0672299ac8>:11(run)
1 0.000 0.000 0.006 0.006 <ipython-input-1-0a0672299ac8>:3(load)
1 0.000 0.000 0.001 0.001 <ipython-input-1-0a0672299ac8>:8(normalize_ticket_price_per_class)
You can’t perform that action at this time.