Skip to content

Instantly share code, notes, and snippets.

View imankulov's full-sized avatar

Roman Imankulov imankulov

View GitHub Profile
@imankulov
imankulov / so_survey.ipynb
Last active June 19, 2018 10:55
Linear regresssion to explore the dependency of job satisfaction from the language used
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@imankulov
imankulov / so_survey.ipynb
Created June 16, 2018 11:16
StackOverflow survery playground
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@imankulov
imankulov / craziness.py
Created April 7, 2018 15:41
Telegram chat bot replying with random "Trump-alike" messages to anything you write
import json
import glob
import requests
import markovify
from tqdm import tqdm
TELEGRAM_TOKEN = os.environ['TELEGRAM_TOKEN']
@imankulov
imankulov / pycoffee-2018-02-28.ipynb
Last active February 25, 2018 12:25
PyCoffee 2018-02-28 (Trump tweets / Bitcoin price correlation)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@imankulov
imankulov / pycoffee.py
Last active January 24, 2018 10:13
Print the date of the next PyCoffee meetup in Porto
from dateutil.rrule import rrule, WEEKLY
from datetime import datetime as dt
r = rrule(WEEKLY, interval=2, dtstart=dt(2018, 1, 27, 10))
print(r.after(dt.utcnow()).strftime('%A, %d %B at %H%p'))
@imankulov
imankulov / babel_example.py
Last active October 4, 2017 07:29
Sample script to convert timezone names to localized city names
from babel import Locale
es = Locale('es')
pt = Locale('pt')
ru = Locale('ru')
print es.time_zones['America/New_York']['city']
print pt.time_zones['America/New_York']['city']
print ru.time_zones['America/New_York']['city']
@imankulov
imankulov / browser_utils.py
Last active May 28, 2019 08:53
A MacOS python script to run Google Chrome or Firefox instance with given timezone settings. Requires pytz
import pytz
import os
def guess_timezone(city):
"""
Take the city name and try to guess the timezone
"""
tz_map = {tz.split('/')[-1].lower(): tz for tz in pytz.all_timezones}
try:
@imankulov
imankulov / chrome_moscow.sh
Created April 5, 2017 16:00
How to run a Google Chrome under Mac OS with a different timezone
#!/bin/bash
export TZ='Europe/Moscow'
exec open -na "Google Chrome" --args "--user-data-dir=$HOME/chrome-profile"
@imankulov
imankulov / timezone.php
Created March 1, 2017 14:35
Timezone magic to find the boundaries of the day
<?
$utc = new DateTimeZone('UTC');
$user_tz = new DateTimeZone('Europe/Moscow');
// current time in UTC
date_default_timezone_set('UTC');
$datetime = new DateTime();
// convert current time to user's local time
$datetime->setTimezone($user_tz);
@imankulov
imankulov / bitmapist_workaround.py
Created February 23, 2017 19:13
Workaround for broken "foo AND NOT bar" logic in bitmapist
>>> bitmapist.mark_unique('foo', 1)
>>> bitmapist.mark_unique('foo', 1000)
>>> bitmapist.mark_unique('bar', 1)
>>> list(bitmapist.UniqueEvents('foo') & ~bitmapist.UniqueEvents('bar'))
[]
>>> list(bitmapist.UniqueEvents('foo') ^ bitmapist.UniqueEvents('bar') & bitmapist.UniqueEvents('foo'))
[1000]