Skip to content

Instantly share code, notes, and snippets.

View smartkiwi's full-sized avatar

Vladimir Vladimirov smartkiwi

View GitHub Profile
@smartkiwi
smartkiwi / init_pyspark.py
Created December 11, 2014 21:01
run pyspark in standalone module without bin/pyspark
import os
import sys
# Set the path for spark installation
# this is the path where you have built spark using sbt/sbt assembly
os.environ['SPARK_HOME'] = "/Users/vvlad/spark/spark-1.0.2"
# Append to PYTHONPATH so that pyspark could be found
sys.path.append("/Users/vvlad/spark/spark-1.0.2/python")
sys.path.append("/Users/vvlad/spark/spark-1.0.2/python/lib/py4j-0.8.1-src.zip")
from cffi import FFI
# create ffi wrapper object
ffi = FFI()
ffi.cdef('''
void* VW_InitializeA(char *);
void* VW_ReadExampleA(void*, char*);
@smartkiwi
smartkiwi / gist:b4b67002905a7882febf
Created September 3, 2014 01:29
valgrind sample_gcc
valgrind ./sample_gcc
==15743== Memcheck, a memory error detector
==15743== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==15743== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==15743== Command: ./sample_gcc
==15743==
this is a native c program calling vw
can't open: , error = Success
terminate called after throwing an instance of 'std::exception'
what(): std::exception
@smartkiwi
smartkiwi / gist:573d0173839c8c2e5972
Created September 3, 2014 01:27
vw ./c_test/sample_gcc valgrind -v info
[vagrant@localhost c_test]$ valgrind -v ./sample_gcc
==15733== Memcheck, a memory error detector
==15733== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==15733== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==15733== Command: ./sample_gcc
==15733==
--15733-- Valgrind options:
--15733-- -v
--15733-- Contents of /proc/version:
--15733-- Linux version 2.6.32-279.el6.x86_64 ([email protected]) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Fri Jun 22 12:19:21 UTC 2012
@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": [
{
@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: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
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.
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
@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__()