Skip to content

Instantly share code, notes, and snippets.

View mgermain's full-sized avatar

Mathieu Germain mgermain

  • horoma AI
  • Montreal
View GitHub Profile
#!/bin/bash
source scl_source enable devtoolset-3
@mgermain
mgermain / validate_emails.py
Last active April 15, 2018 18:44
Validate that emails are valid on SMTP server.
#!/usr/bin/env python3
# Dependencies python3 and dnspython
import os
import re
import sys
import csv
import time
import string
import random
import smtplib
from __future__ import print_function
import re
import ijson.backends.yajl2 as ijson
with open("movies_rule_agent/actors.txt", "r") as f_actors:
actors = [re.sub(r'\n', '', entry).lower() for entry in f_actors.readlines()]
with open("movies_rule_agent/actor_qids.txt", "w") as f_actor_qids:
with open('wikidata_json_dump/latest-all.json', "r") as f_wiki:
for obj in ijson.items(f_wiki, 'item'):
import os
import requests
from bs4 import BeautifulSoup
class GSheet(object):
base_sheet_url = 'https://spreadsheets.google.com/feeds/worksheets/{0}/private/full'
list_worksheet_url = 'https://spreadsheets.google.com/feeds/list/{0}/{{}}/private/full'
cell_worksheet_url = 'https://spreadsheets.google.com/feeds/cells/{0}/{{}}/private/full'
HTTPheaders = {'content-type': 'application/atom+xml'}
@mgermain
mgermain / test_io_write_vs_append.py
Last active August 29, 2015 14:17
Compare the speed of appending to a file VS reading everything in memory appending there then rewriting everything.
"""
## RESULTS ##
# Windows 8.1 + NTFS + SSD:
read_write 6.81500005722
append 6.42299985886
# LinuxMint 15 + ext4 witout journaling + HD
read_write 0.222398996353
append 0.00950384140015
"""
@mgermain
mgermain / gist:2ceba111d93cdb717b28
Last active August 29, 2015 14:08
Theano MRG_RandomStreams backup test
import numpy as np
from theano.sandbox.rng_mrg import MRG_RandomStreams
rng = MRG_RandomStreams(seed=1234)
mult = rng.multinomial(pvals=[[.3,.3,.3]])
# Backup random state
rst = rng.rstate.copy()
rst_upd = [s[0].get_value() for s in rng.state_updates]