Skip to content

Instantly share code, notes, and snippets.

@Khalefa
Khalefa / pipe1.py
Created April 5, 2018 22:09
Data virtualization layer
import asyncio
import binascii
def print_data(x):
try:
print (binascii.hexlify(x))
print (binascii.hexlify(x).decode('ascii'))
except:
pass
@Khalefa
Khalefa / psql-srv.py
Last active July 21, 2022 17:28 — forked from matteobertozzi/psql-srv.py
python 3 (should works)
# th30z@u1310:[Desktop]$ psql -h localhost -p 55432
# Password:
# psql (9.1.10, server 0.0.0)
# WARNING: psql version 9.1, server version 0.0.
# Some psql features might not work.
# Type "help" for help.
#
# th30z=> select foo;
# a | b
# ---+---
@Khalefa
Khalefa / xmltodataframe.py
Created April 5, 2018 02:58
Does not work for large xml file
import xml.etree.ElementTree as ET
import pandas as pd
class XML2DataFrame:
def __init__(self, xml_data):
self.root = ET.parse(xml_data).getroot()
def parse_root(self, root):
return [self.parse_element(child) for child in iter(root)]
const_iterator (node *n=nullptr):current{n}{}
//recusive
node* min(node* r){
if(r==nullptr) return nullptr;
if(r->left==nullptr)
return r;
return min(r->left);
<?xml version="1.0" encoding="UTF-8" ?><gpx version="1.0" creator="GPSLogger 91 - http://gpslogger.mendhak.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"><time>2018-02-06T08:23:58.000Z</time><trk><trkseg><trkpt lat="38.21493833333333" lon="-85.76218333333333"><ele>148.3</ele><time>2018-02-06T08:23:58.000Z</time><course>1.33</course><speed>10.928067</speed><geoidheight>-33.2</geoidheight><src>gps</src><hdop>0.98</hdop><vdop>0.85</vdop><pdop>1.29</pdop></trkpt>
<trkpt lat="38.215055" lon="-85.76217833333334"><ele>147.8</ele><time>2018-02-06T08:23:59.000Z</time><course>358.81</course><speed>10.421581</speed><src>gps</src></trkpt>
<trkpt lat="38.215151666666664" lon="-85.762175"><ele>147.4</ele><time>2018-02-06T08:24:00.000Z</time><course>358.69</course><speed>8.865576</speed><src>gps</src></trkpt>
<trkpt lat="38.215235" lon="-85.76216666666666"><ele>146.9</ele><t
@Khalefa
Khalefa / Computation.java
Last active November 2, 2017 04:45
Bedia
package badia;
import org.apache.giraph.edge.Edge;
import org.apache.giraph.edge.EdgeFactory;
import org.apache.giraph.graph.BasicComputation;
import org.apache.giraph.graph.Vertex;
import org.apache.giraph.io.VertexReader;
import org.apache.giraph.io.formats.GeneratedVertexInputFormat;
import org.apache.giraph.io.formats.TextVertexOutputFormat;
import org.apache.hadoop.io.FloatWritable;
import h5py
import sys
def visitor_func(name, node):
if isinstance(node, h5py.Dataset):
print "<Dataset name=\""+name+ ">"
print "</Dataset>"
elif isinstance(node, h5py.Group):
print "<Group name=\""+name+"\" >"
node.visititems(visitor_func)
@Khalefa
Khalefa / fig1.24.cpp
Created August 30, 2017 23:13
Function Operator
#include <iostream>
#include <strings.h>
#include <vector>
using namespace std;
template <typename Object, typename Compartor>
const Object& findMax(const vector<Object> &arr, Compartor cmp){
int maxIndex=0;
for(int i=1;i<arr.size();i++){
MERGE (_1:`Namespace` {`prefix`: 'wsdl', `_uuid`: '2f60c83d-b86c-5995-9a0e-92bf1ce5b525', `uri`: 'http://schemas.xmlsoap.org/wsdl/'})
;
MERGE (_2:`Namespace` {`prefix`: 'dc', `_uuid`: '11af3748-d2b3-529f-becb-89fe5bde5876', `uri`: 'http://purl.org/dc/elements/1.1/'})
;
MERGE (_3:`Namespace` {`prefix`: 'html', `_uuid`: 'b5c309ec-3a93-549f-8f28-6d75cea3ce1b', `uri`: 'http://www.w3.org/1999/xhtml'})
;
MERGE (_4:`Namespace` {`prefix`: 'rdf', `_uuid`: '53017ca4-785d-5ebc-ab8a-fc7d30f8608a', `uri`: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'})
;
MERGE (_5:`Namespace` {`prefix`: 'xs', `_uuid`: '936afb92-6c30-52cd-a10a-2e22a2684cc6', `uri`: 'http://www.w3.org/2001/XMLSchema'})
;
This file has been truncated, but you can view the full file.
MERGE (_1:`Namespace` {`prefix`: 'wsdl', `_uuid`: '2f60c83d-b86c-5995-9a0e-92bf1ce5b525', `uri`: 'http://schemas.xmlsoap.org/wsdl/'})
;
MERGE (_2:`Namespace` {`prefix`: 'dc', `_uuid`: '11af3748-d2b3-529f-becb-89fe5bde5876', `uri`: 'http://purl.org/dc/elements/1.1/'})
;
MERGE (_3:`Namespace` {`prefix`: 'html', `_uuid`: 'b5c309ec-3a93-549f-8f28-6d75cea3ce1b', `uri`: 'http://www.w3.org/1999/xhtml'})
;
MERGE (_4:`Namespace` {`prefix`: 'rdf', `_uuid`: '53017ca4-785d-5ebc-ab8a-fc7d30f8608a', `uri`: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'})
;
MERGE (_5:`Namespace` {`prefix`: 'xs', `_uuid`: '936afb92-6c30-52cd-a10a-2e22a2684cc6', `uri`: 'http://www.w3.org/2001/XMLSchema'})
;