Skip to content

Instantly share code, notes, and snippets.

View ilyakamens's full-sized avatar

Ilya Kamens ilyakamens

View GitHub Profile
@ilyakamens
ilyakamens / cache.js
Created March 14, 2019 15:06
Simplified version of using cached promise
const axios = require('axios');
let cache;
async function foo(x) {
if (cache) {
console.log('using cache', x);
return cache;
}
cache = axios.get('https://jsonplaceholder.typicode.com/users').then((resp) => resp.data[0].name);
@ilyakamens
ilyakamens / appcast_location_test_1.py
Created April 5, 2018 04:20
Appcast location test with city and state
from pprint import pprint
import requests
if __name__ == '__main__':
pprint(requests.get('https://api.appcast.io/search', params={
'token': '<token>',
'city': 'New York',
'state': 'NY',
'r': '1miles',
@ilyakamens
ilyakamens / scraper.py
Last active November 16, 2017 04:36
Scrape event info from http://www.nihon-kankou.or.jp/
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
1. Open Terminal
2. sudo easy_install pip
3. pip install --user requests
4. pip install --user requests_threads
5. pip install --user beautifulsoup4
6. pip install --user --upgrade pyopenssl
#####
# The sum of the middle two digits is a Square Number.
# The sum of the middle four digits is a Cube number
# The net difference between the first and tenth digit is 2
# The net difference between the second and ninth digit is 3
# The net difference between the third and eighth digit is 4
# The sum of the first five digits is a Prime number
# The sum of the last five digits is a Triangular number
# The sum of the digits in odd positions (first, third, fifth, seventh and ninth digits) is an Odd number
# The digit 4 is in first 5 positions
├─┬ autoprefixer-loader@3.2.0
│ ├─┬ autoprefixer@6.3.3
│ │ ├── browserslist@1.1.3
│ │ ├── caniuse-db@1.0.30000431
│ │ ├── normalize-range@0.1.2
│ │ ├── num2fraction@1.2.2
│ │ └── postcss-value-parser@3.3.0
│ ├─┬ loader-utils@0.2.12
│ │ ├── big.js@3.1.3
│ │ └── json5@0.4.0
@ilyakamens
ilyakamens / trie-autocomplete.py
Created November 17, 2015 02:22 — forked from quiver/trie-autocomplete.py
trie-based autocomplete using redis/python
# vim: set fileencoding=utf8
'''
References
- http://stackoverflow.com/a/1966188
- http://en.wikipedia.org/wiki/Tree_(data_structure)
$ python suggest.py prefix
'''
import sys
import redis