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 gcd(m,n): | |
while m % n != 0: | |
oldm = m | |
oldn = n | |
m = oldn | |
n = oldm % oldn | |
return n | |
class Rational: | |
def __init__(self, n, d): |
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
[<__main__.Sub object at 0x1f44250>, <__main__.Sub object at 0x1f44390>, <__main__.Sub object at 0x1f44350>] | |
[u'a', u'b', u'c'] | |
pre commit | |
------ | |
ok | |
after commit | |
------ |
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 airflow import DAG | |
from airflow.operators.bash_operator import BashOperator | |
from airflow.operators.python_operator import PythonOperator | |
from datetime import datetime, timedelta | |
# default arguments for each task | |
default_args = { | |
'owner': 'nthomas', |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <time.h> | |
/* ========================================================================== | |
* COMPARATORS | |
* ========================================================================== */ |
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 s3_to_pandas(client, bucket, key, header=None): | |
# get key using boto3 client | |
obj = client.get_object(Bucket=bucket, Key=key) | |
gz = gzip.GzipFile(fileobj=obj['Body']) | |
# load stream directly to DF | |
return pd.read_csv(gz, header=header, dtype=str) | |
def s3_to_pandas_with_processing(client, bucket, key, header=None): |
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 numpy as np | |
import tensorflow as tf | |
from tensorflow.contrib import learn | |
from tensorflow.contrib.learn.python.learn.estimators import model_fn as model_fn_lib | |
tf.logging.set_verbosity(tf.logging.INFO) | |
def cnn_model_fn(features, labels, mode): |
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
/* | |
This a header file that includes every standard library. | |
You can use it to save time. | |
NOTE: This header file may not be recognized by compilers | |
other than gcc. | |
*/ | |
#include <bits/stdc++.h> | |
/* | |
//Use this if the above header file doesn't work. |
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 collections import OrderedDict | |
import datetime | |
from typing import Iterator, List, Sized, Union | |
import numpy as np | |
import pandas as pd | |
from psycopg2.extensions import QuotedString | |
from sqlalchemy import and_, exists, MetaData, Table, Column as SAColumn | |
import logging |
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
# Note: it is a copy of great answer by "mgoldwasser" from Stackoverflow | |
# Check the original answer here: http://stackoverflow.com/a/26018934/1032439 | |
# Imagine that post1, post5, and post1000 are posts objects with ids 1, 5 and 1000 respectively | |
# The goal is to "upsert" these posts. | |
# we initialize a dict which maps id to the post object | |
my_new_posts = {1: post1, 5: post5, 1000: post1000} | |
for each in posts.query.filter(posts.id.in_(my_new_posts.keys())).all(): |
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
#!/usr/bin/env python | |
import wx | |
from wx import EVT_CLOSE | |
import wx.grid as gridlib | |
EVEN_ROW_COLOUR = '#CCE6FF' | |
GRID_LINE_COLOUR = '#ccc' | |
class PandasTable(wx.Frame): |
OlderNewer