Skip to content

Instantly share code, notes, and snippets.

View B-Stefan's full-sized avatar

Stefan Bieliauskas B-Stefan

View GitHub Profile
@B-Stefan
B-Stefan / knockout.googleAdressAutocomplete.js
Created April 11, 2013 13:45
custom binding for a google maps autocomplete geocoder
define(['knockout', 'jquery', 'gmaps'], function (ko, $, gmaps) {
ko.bindingHandlers.googleAdressAutocomplete = {
init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
var self = element
var allBindings = allBindingsAccessor()
var position = new gmaps.maps.LatLng(allBindings.lat(), allBindings.lng());
/**
* Define geocode function for update and init
*/
@B-Stefan
B-Stefan / hipchat.coffee
Created September 15, 2014 19:47
Angular-Hipchat-Directive
define ['./directives'], (module)->
module.directive "hipchat", ($window) ->
(scope, element, attrs) ->
console.log(arguments)
options = {
url: attrs.url ? "www.hipchat.com/gk2Lvjf6Y"
timezone: attrs.hipchatTimezone ? 'Europe/Berlin'
showButton: attrs.hipchatShowButton ? false
@B-Stefan
B-Stefan / staticInclude.coffee
Created September 15, 2014 19:52
An Angular-Directive to import a template and maintain the Scope
define ['./directives'], (module)->
module.directive 'staticInclude', ($http, $templateCache, $compile)->
(scope, element, attrs)->
templatePath = attrs.staticInclude ? attrs.src;
$http.get(templatePath, { cache: $templateCache }).success (response)->
contents = element.html(response).contents();
$compile(contents)(scope)
@B-Stefan
B-Stefan / sumByKey.coffee
Created September 15, 2014 19:54
Angular sum filter for tables
define ['./filters'], (filters)->
filters.filter 'sumByKey', [-> (data, key) ->
return 0 if typeof (data) is "undefined" or typeof (key) is "undefined"
sum = 0
i = data.length - 1
while i >= 0
sum += parseInt(data[i][key])
@B-Stefan
B-Stefan / VisibilitySensor.ts
Created March 30, 2015 11:59
Alternative visibility sensor for react.js
/** @jsx React.DOM */
'use strict';
import React = require('react');
export interface VisibilitySensorProps{
active:boolean
delay: number
onChange(isVisible:boolean):void
children:any[] | string
}
@B-Stefan
B-Stefan / gist:581a065d5f15bc44da56
Created November 28, 2015 14:20 — forked from wimleers/gist:702387
How to convert from a custom date format into a UTC string using Qt.
QDateTime timeConvertor;
QString customDateString = "14-Nov-2010 05:27:03 +0100";
QString dateTime = customDateString.left(20).trim();
int timezoneOffset = customDateString.right(5).left(3).toInt();
timeConvertor = QDateTime::fromString(dateTime, "dd-MMM-yyyy HH:mm:ss");
// Mark this QDateTime as one with a certain offset from UTC, and set that
// offset.
timeConvertor.setTimeSpec(Qt::OffsetFromUTC);
@B-Stefan
B-Stefan / prov_utils.py
Created November 4, 2016 10:58
Prov documents unified function, modified to check if a record is already in the document
from prov.model import ProvEntity,ProvDocument,ProvBundle
from prov.constants import PROV_TYPE, PROV_BUNDLE
def create_records_for_bundles(prov_document):
for bundle in prov_document.bundles:
already_existing = prov_document.get_record(bundle.identifier)
if len(already_existing) is 0:
bundle_entity = ProvEntity(bundle=prov_document, identifier=bundle.identifier, attributes={PROV_TYPE: PROV_BUNDLE})

Keybase proof

I hereby claim:

  • I am B-Stefan on github.
  • I am stefan125 (https://keybase.io/stefan125) on keybase.
  • I have a public key whose fingerprint is 26C8 B3F6 8A33 199E B4E7 2815 3E55 324C D327 015D

To claim this, I am signing this object:

LOAD CSV into Neo4j quickly and successfully

Since version 2.1 Neo4j provides out-of-the box support for CSV ingestion. The LOAD CSV command that was added to the Cypher Query language is a versatile and powerful ETL tool. It allows you to ingest CSV data from any URL into a friendly parameter stream for your simple or complex graph update operation, that …​ conversion.

document
prefix ex <http://example.com>
wasGeneratedBy(ex:Ingredients, ex:Buy, -)
wasGeneratedBy(ex:Cake, ex:Bake, -)
activity(ex:Buy, -, -)
activity(ex:Bake, -, -)
entity(ex:Cake)
entity(ex:Ingredients)
agent(ex:Bob)