Skip to content

Instantly share code, notes, and snippets.

View wolkym's full-sized avatar

Woldemar XmbIpoB wolkym

View GitHub Profile
@wolkym
wolkym / Numpy_by_reference.py
Created February 25, 2015 10:39
I am building data simulation framework with numpy ORM, where it is much more convenient to work with classes and objects instead of numpy arrays directly. Nevertheless, output of the simulation should be numpy array. Also blockz is quite interesting as a backend here. I would like to map all object attributes to numpy arrays. Thus, numpy arrays…
a = np.arange(10)
class Case():
def __init__(self, gcv_pointer):
self.gcv = gcv_pointer
def gcv(self):
return(self.gcv)
def gcv_set(self, value):
self.gcv[:] = value
@wolkym
wolkym / books.py
Last active August 29, 2015 14:16 — forked from kennethlove/books.py
class Book:
title = ''
pages = 0
def __init__(self, title='', pages=0):
self.title = title
self.pages = pages
def __add__(self, other):
"""Control adding two Books together or a Book and a number"""
@wolkym
wolkym / objects_memory.R
Last active August 29, 2015 14:21
R memory consumption by objects
# http://stackoverflow.com/questions/1395270/determining-memory-usage-of-objects
sort( sapply(ls(),function(x){object.size(get(x))}))
print(object.size(x=lapply(ls(), get)), units="Mb")
@wolkym
wolkym / orientdb_tests.java
Last active August 29, 2015 14:22
Tests of OrientDB inserts
//delete from Case unsafe
package pocOrientDB;
//import com.orientechnologies.*;
//import java.io.Console;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
<h3>Date Formats</h3>
<table style="width: 100%px;">
<tbody>
<tr>
<td>Conversion specification</td>
<td>Description</td>
<td>Example</td>
</tr>
<tr>
<td>%a</td>
@wolkym
wolkym / timing.scala
Created July 31, 2015 14:18
timing scala execution
def time[R](block: => R): R = {
val t0 = System.nanoTime()
val result = block // call-by-name
val t1 = System.nanoTime()
println("Elapsed time: " + (t1 - t0) + "ns")
result
}
// Now wrap your method calls, for example change this...
val result = 1 to 1000 sum
@wolkym
wolkym / hbase-rest-examples.sh
Last active September 8, 2015 16:13 — forked from karmi/hbase-rest-examples.sh
Experiments with the HBase REST API
#!/usr/bin/env bash
#
# ===================================
# Experiments with the HBase REST API
# ===================================
#
# <http://hbase.apache.org/docs/r0.20.4/api/org/apache/hadoop/hbase/rest/package-summary.html>
#
# Usage:
#
@wolkym
wolkym / examples
Last active September 14, 2015 13:12 — forked from tariqmislam/examples
HBase | REST | JSON
Taken from Karmi via Gist @ gist: 1218928
#!/usr/bin/env bash
#
# ===================================
# Experiments with the HBase REST API
# ===================================
#
# <http://hbase.apache.org/docs/r0.20.4/api/org/apache/hadoop/hbase/rest/package-summary.html>
#
@wolkym
wolkym / rotated.scala
Last active October 28, 2015 17:17
Rotated
package leonteq
object FindInRotated {
def find(x: Int, arr: Array[Int])/*: Option[Int]*/ = {
val splitPoint: Vector[Int] = ((1 to (arr.size - 1)).toVector dropWhile { case i => !(arr(i) < arr(i - 1) | arr(i) == x )})
if (splitPoint.isEmpty) None
else {
val arrZ = arr.zipWithIndex
val headed = arrZ.drop(splitPoint.head)
/* This demonstrates a trigger for denormalizing a join table into an array.
Hasn't really been tested much, but seems to work.
Will put it into production tomorrow and see!
Maybe PostgreSQL 9.4 will come with arrays of foreign keys. That will remove a lot of the
need for simple join tables.
http://blog.2ndquadrant.com/postgresql-9-3-development-array-element-foreign-keys didn't
make it into 9.3.