Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 torch | |
import torch.nn as nn | |
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence | |
seqs = ['gigantic_string','tiny_str','medium_str'] | |
# make <pad> idx 0 | |
vocab = ['<pad>'] + sorted(set(''.join(seqs))) | |
# make model |
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/python | |
import os, sys, gzip | |
from StringIO import StringIO | |
from datetime import datetime | |
def readByte(f): | |
return ord(f.read(1)) | |
def readInt(f): | |
l = 0 |
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 datetime import datetime | |
import string | |
from nltk.stem.lancaster import LancasterStemmer | |
from nltk.corpus import stopwords | |
#Gets the tweet time. | |
def get_time(tweet): | |
return datetime.strptime(tweet['created_at'], "%a %b %d %H:%M:%S +0000 %Y") |
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
""" | |
The most simple DNS client written for Python with asyncio: | |
* Only A record is support (no CNAME, no AAAA, no MX, etc.) | |
* Almost no error handling | |
* Doesn't support fragmented UDP packets (is it possible?) | |
""" | |
import asyncio | |
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
# this script has been tested and worked in a freshly installed Ubuntu 16.04 and 16.10 | |
# it assumes that you are running airflow in a private netowrk and no need to be worry about outside access | |
# if that's not the case, the lines for PostgreSQL and Redis in this script need to be updated accordingly | |
# run as root | |
sudo su | |
# initial system updates and installs | |
apt-get update && apt-get upgrade -y && apt-get autoremove && apt-get autoclean | |
apt-get -y install build-essential binutils gcc make git htop nethogs tmux |
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 random import random | |
# function to optimize: takes in a list of decision variables, returns an objective value | |
# this is the Rosenbrock function: http://en.wikipedia.org/wiki/Rosenbrock_function | |
# the global minimum is located at x = (1,1) where f(x) = 0 | |
def my_function(x): | |
return (1-x[0])**2 + 100*(x[1] - x[0]**2)**2 | |
# function to perform (a very crude, stupid) optimization | |
# bounds = lower and upper bounds for each decision variable (2D list) |
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 __future__ import print_function | |
from itertools import starmap | |
import tensorflow as tf | |
import random | |
from tensorflow.python.ops import rnn | |
import math | |
flags = tf.flags |
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 | |
""" | |
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction. | |
""" | |
from __future__ import print_function, division | |
import numpy as np | |
from keras.layers import Convolution1D, Dense, MaxPooling1D, Flatten | |
from keras.models import Sequential |