Skip to content

Instantly share code, notes, and snippets.

View ivanistheone's full-sized avatar

Ivan Savov ivanistheone

View GitHub Profile
@ivanistheone
ivanistheone / gist:4249353
Created December 10, 2012 08:35
Parsing access log and collecting sessions
#!/usr/bin/env python
import re
from collections import defaultdict, namedtuple
import datetime
f = open("access.log")
logfiles_list = [ f.readlines() ]
@ivanistheone
ivanistheone / simple_chef_with_logging.py
Created April 2, 2020 14:08
Demo of common use of config.LOGGER in ricecooker for testing new colorlogs
#!/usr/bin/env python
from ricecooker.chefs import SushiChef
from ricecooker.classes.nodes import ChannelNode, TopicNode, DocumentNode
from ricecooker.classes.files import DocumentFile
from ricecooker.classes.licenses import get_license
from ricecooker.config import LOGGER
(venv) probook:kiwix-build ivan$ ./kiwix-build.py --target-platform native_dyn
WARNING: kiwix-build has not been tested on MacOS platfrom.
Tests, bug reports and patches are welcomed.
[INSTALL PACKAGES]
- autoconf : SKIP
- automake : SKIP
- libtool : SKIP
- cmake : SKIP
- pkg-config : SKIP
SKIP, No package to install.
@ivanistheone
ivanistheone / README.md
Last active May 26, 2017 21:53
Proof of concept for combining command line arguments.

Combining argparse parsers

This is a proof of concept for a command line interface (CLI) that is subclassable. TO use, create an instance of the class (or subclass) and call it's main method.

The only tricky part is that subclasses need to pass add_parser_help=False when calling the BaseCLI's __init__ method.

Using base.py by itself

@ivanistheone
ivanistheone / README.md
Last active March 29, 2017 00:18 — forked from GGulati/Jarvis.py
Code that goes with blog post https://ggulati.wordpress.com/2016/02/24/coding-jarvis-in-python-3-in-2016/ —with modifications for Mac OS X.
@ivanistheone
ivanistheone / Intro to Python for people who know Java.md
Created March 28, 2017 20:17
A few tips for people interested in learning Python

Python for Java programmers

Part of what makes python readable is the absence of type information, the indentation-based block structure for code, and a few Python idioms, also known as "syntax sugar" if you will.

This tutorial assumes the reader is familiar with other programming languages like Java and shows some examples of Python coolness.

Keybase proof

I hereby claim:

  • I am ivanistheone on github.
  • I am ivansavov (https://keybase.io/ivansavov) on keybase.
  • I have a public key whose fingerprint is 8CBB AA5B CDA6 A50D 4B2E F9BD 2A72 2D82 C0D3 4F08

To claim this, I am signing this object:

#!/usr/bin/env python
"""
Simple DB server (key value store) that works over HTTP on localhost.
- GET /set?<key>=<value> Sets <key> to <value>
- GET /get?key=<key> Gets the value for key <key>
Usage:
dbserver.py [--port=<int>]
Options:
@ivanistheone
ivanistheone / README.md
Created January 11, 2016 22:05
Simple DB server
@ivanistheone
ivanistheone / heart_beat_diagram.js
Created July 22, 2013 16:40
I would like to make a ECG-like hear-beat diagram, but the default x-sampling rate shows a gap in the graph. Paste this into http://graphie-to-png.khanacademy.org/ to see the results. Any suggestions are welcome.
// X and Y ranges of the graph
var X_RANGE = [-2, 10];
var Y_RANGE = [-35, 100];
// Width of the graph in pixels
// Let's use 400 for "normal" graphs and 170 for "small" graphs
var SIZE = 400;
var xScale;
var yScale;