Skip to content

Instantly share code, notes, and snippets.

@saeed-abdullah
saeed-abdullah / timezone.patch
Created November 26, 2019 00:22
MailParser timezone parsing patch
diff --git mailparser/utils.py mailparser/utils.py
index f44139c..797f218 100644
--- mailparser/utils.py
+++ mailparser/utils.py
@@ -345,7 +345,7 @@ def convert_mail_date(date):
log.debug("Date parsed in timestamp: {!r}".format(t))
date_utc = datetime.datetime.utcfromtimestamp(t)
timezone = d[9] / 3600 if d[9] else 0
- timezone = "{:+.0f}".format(timezone)
+ timezone = "{:+.2f}".format(timezone)
@saeed-abdullah
saeed-abdullah / cites.py
Created March 28, 2016 01:31
Citation parsing from aux files
from collections import Counter
import re
import sys
cite_re = re.compile(r'\\citation\{(.+)\}', re.MULTILINE)
def get_all_cites(aux):
"""
Retrives all cites from a given aux file.
@saeed-abdullah
saeed-abdullah / mctq-reader.py
Last active December 24, 2015 12:59
Qualtics data extractor tool.
def read_mctq_data(input_file):
"""
Read MCTQ data from Qualtrics web survey tool.
:param input_file: Path to the CSV file exported from the survey tool
:return:: Pandas DataFrame object.
"""
table = pd.read_csv(input_file, skiprows=[1],
usecols=['Q50','Q51', 'Q52_1', 'Q56_1', 'Q58_1', 'Q59_1_TEXT', 'Q60_1', 'Q61', 'Q63_1_TEXT',
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sklearn
from sklearn import tree, metrics, cross_validation
from sklearn.feature_extraction.text import CountVectorizer
def get_data_from_arxiv(arxiv_data, key):
row_doc = []
label = []
for index, (k, v) in enumerate(arxiv_data.iteritems()):
for d in v:
label.append(index)
# -*- coding: utf-8 -*-
"""
trigram.py
~~~~~~~~~~
Assignment 1 for Info 6010:
https://courses.cit.cornell.edu/info6010/assignment1.html
"""
@saeed-abdullah
saeed-abdullah / gist:2474808
Created April 24, 2012 00:04
Gzip file reader for NLP QA.
import gzip
def get_gzip_data(filename):
"""Read daa from gzip file.
param
----
filename: Input gzip file.
"""
with gzip.open(filename, "rb") as f:
@saeed-abdullah
saeed-abdullah / ex.py
Created November 1, 2011 14:00
Info 6307 --- Nov 1.
import numpy as np
import sys
import matplotlib.pyplot as plt
from sklearn import linear_model
def read_data_file(filename):
"""Reads data file in comma separated format.
@saeed-abdullah
saeed-abdullah / build_network.py
Created October 4, 2011 13:58
GitHub Follower Network
from github2.client import Github
import networkx as nx
def build_follower_network(users):
follower_list = []
github = Github(requests_per_second=1)
for user in users:
try:
follower_list.append((user, github.users.followers(user)))
except RuntimeError: