Skip to content

Instantly share code, notes, and snippets.

View smartkiwi's full-sized avatar

Vladimir Vladimirov smartkiwi

View GitHub Profile
#!/usr/bin/python
"""
Parses Fortran Namelists
based on Fortran Namelist parser for Python prog/scripts by Stephane Chamberland (stephane.chamberland@ec.gc.ca)
http://code.google.com/p/fortran-namelist/
Updated by Volodymyr Vladymyrov (http://stackoverflow.com/users/1296661/vvladymyrov) to parse format presented
in http://stackoverflow.com/questions/14165733/regular-expression-parsing-key-value-pairs-in-namelist-input-file
added support for
1)
$NAMELIST
@smartkiwi
smartkiwi / suds_prevent_parsing
Created March 13, 2013 15:44
Example of using MessagePlugin to prevent suds from parsing response
import suds
__author__ = 'Volodymyr Vladymyrov: smartkiwi@gmail.com'
__doc__ = "Example of using MessagePlugin to prevent suds from parsing response"
class PayloadInterceptor(suds.plugin.MessagePlugin):
def __init__(self, *args, **kwargs):
self.last_payload = None
@smartkiwi
smartkiwi / gist:5459315
Last active December 16, 2015 15:58
posa pa 3
"""
POSA PA 3 program
Echo Server
built and tested using python 2.7.2 and Twisted 12.0.0
"""
import sys
#
# PA 4
#
# based on https://class.coursera.org/posa-001/forum/thread?thread_id=1149
# changes
# + handler run on line sent by client
# + original implementation with endopoint doesn't run on Windows without installing addiotional libs - implemented using reactor.listenTCP
# + added logging
#
#
@smartkiwi
smartkiwi / gist:5485463
Created April 29, 2013 22:54
PA1 python
"""
python 2.7.1 (cpython)
"""
from threading import BoundedSemaphore, Thread
class Png(Thread):
def __init__(self,string,lock1,lock2,times):
super(Png, self).__init__()
import java.util.concurrent.Semaphore;
public class PingPong {
private Semaphore ping_semaphore = new Semaphore(1, true), pong_semaphore = new Semaphore(1, true);
private int maxcount = 100;
class Ping implements Runnable {
@Override
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
/**
* Created with IntelliJ IDEA.
* User: vvlad
* Date: 4/2/13
* Time: 3:21 PM
* To change this template use File | Settings | File Templates.
@smartkiwi
smartkiwi / gist:eb4d29742249a16a0611
Created July 2, 2014 17:35
is this valid avro ?
exception===IndexError('list index out of range',) magnetic_hadoop/streaming/parse_bid_streaming.py:134 Traceback (most recent call last):
File "magnetic_hadoop/streaming/parse_bid_streaming.py", line 164, in <module>
print parse_line(line)
File "magnetic_hadoop/streaming/parse_bid_streaming.py", line 134, in parse_line
d['opt_iponweb_pconv_pv'] = f[61]
IndexError: list index out of range
^^^event_type===error^^^log_line===1377022200{TAB}1234{TAB}72.80.117.250{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}abcdefabcd1377022200{TAB}cba1f490-e5a5-4bda-b8bf-1bafc9fcd70b{TAB}g{TAB}12345{TAB}{TAB}publisher.com{TAB}728x90{TAB}0{TAB}02-05,02-00{TAB}1500000{TAB}4{TAB}2{TAB}123{TAB}{TAB}{TAB}{TAB}1,2{TAB}3,4{TAB}Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36{TAB}http://articles.publisher.com{TAB}0{TAB}750{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}none{TAB}{TAB}{TAB}{TAB}0.0001{TAB}{TAB}{TAB}{TAB
@smartkiwi
smartkiwi / gist:f476b1ecf97d1e3e88eb
Created July 23, 2014 19:19
pypy _cffi_backend
tests/scripts/test1.py:3: in <module>
import gdbm
/usr/lib64/pypy-2.3.1/lib_pypy/gdbm.py:3: in <module>
ffi = cffi.FFI()
/usr/lib64/pypy-2.3.1/site-packages/cffi/api.py:58: in __init__
assert backend.__version__ == __version__
E assert '0.8.2' == '0.8.6'
E + where '0.8.2' = '0.8.2'
E + where '0.8.2' = <module '_cffi_backend' (built-in)>.__version__
@smartkiwi
smartkiwi / gist:3558260348421aa395bc
Created August 28, 2014 15:18
User request histogram.ipynb
{
"metadata": {
"name": "User request histogram-s3-1file"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{