Skip to content

Instantly share code, notes, and snippets.

@a-rodin
a-rodin / yahoo_currency.py
Created June 23, 2015 20:21
Historical currency conversion rates for Python using Yahoo Converter API
View yahoo_currency.py
from urllib2 import urlopen
import json
import datetime
BASE_URL = 'http://finance.yahoo.com/connection/currency-converter-cache?date='
# Returns price of specified currency at specified date in USD
def get_rate(symbol, date = None):
if symbol == 'USD': return 1.0
if not date:
@a-rodin
a-rodin / unsharp.md
Last active November 9, 2015 09:10
Unsharp mask params relations in pupular softare
View unsharp.md

Unsharp mask params relations in pupular softare

There is correspondence between Unsharp Mask parameters names and scales in widely used graphics software.

Parameter Adobe Photoshop ImageMagick GIMP
Radius 1x 1x 2.5x
Amount 100x 1x 1x
Threshold 1x 1x 1x
View nginx-custom-build.sh
#!/bin/bash
# Author: Alexander Rodin <rodin.alexander@gmail.com>
# License: MIT
BUILD_DIR=build
while getopts "hp:s:r:b:o:c:n" opt; do
case $opt in
h)
echo "Usage: $0 [options]"
@a-rodin
a-rodin / deep-regressor.py
Last active March 21, 2016 07:32
TensorFlow Deep Regressor with sklearn-complatible interface
View deep-regressor.py
import numpy as np
import tensorflow as tf
class DeepRegressor:
def __init__(self, batch_size = None, max_iter = 2001, random_state=0, verbose=False, opt_step = 0.05, C = 0.0):
self.set_params(dict(
batch_size = batch_size,
max_iter = max_iter,
random_state = random_state,
verbose = verbose,
View ubuntu-mbp-hardware.yml
# Ansible role for setting up hardware drivers for Macbook Pro 13" (Early 2015) in Ubuntu 16.04 LTS
# License: GPLv3
# Usage:
# - clone this gist with git
# - go to the gist directory
# - run command `sudo apt-get install ansible && ansible-playbook ubuntu-mbp-hardware.yml`
- name: Setup Macbook hardware
hosts: localhost
become_user: root
View curly.sh
# Colorize and format curl output using pygments and json
# The idea is taken from http://benw.me/posts/colourized-pretty-printed-json-with-curl/
# Dependencies: `npm i -g json && pip install pygments` and w3m text browser from your dist repository.
# Usage: run `source curly.sh`, then use `curly` as plain curl
# It is even possible to even do `alias curl=curly` and use it as a replacement to plain curl.
function curly {
$(which curl) --silent --show-error -i "$@" | (
IFS=$'\n'
PROCESSOR="cat"
View notebook-progress-pytorch.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@a-rodin
a-rodin / robinson.ipynb
Last active July 6, 2020 13:39
Example of Recurrent Highway Networks (https://arxiv.org/abs/1607.03474) with PyTorch
View robinson.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View A better (she|hash)bang for your shell scripts.md

A shebang/hashbang is the first line of an executable script that starts with #!.

Example for an executable shell script:

#!/bin/sh

And here is what I propose to use instead:

View A hack for showing LaTeX formulas in GitHub markdown.md

Problem

A lot of GitHub projects need to have pretty math formulas in READMEs, wikis or other markdown pages. The desired approach would be to just write inline LaTeX-style formulas like this:

$e^{i \pi} = -1$

Unfortunately, GitHub does not support inline formulas. The issue is tracked here.

Investigation