Skip to content

Instantly share code, notes, and snippets.

View thomasfr's full-sized avatar

Thomas Fritz thomasfr

View GitHub Profile
#!/bin/bash
#### SETUP
# 1.) Create a simple point layer
curl -X POST -d '{"layer":"geom","lat":"lat","lon":"lon"}' --header "Content-Type:application/json" http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer
# 2.) Add a spatial index
curl -X POST -d '{"name":"geom","config":{"provider":"spatial","geometry_type":"point","lat":"lat","lon":"lon"}}' --header "Content-Type:application/json" http://localhost:7474/db/data/index/node/
@thomasfr
thomasfr / multi-exec.sh
Last active July 20, 2018 07:56
Execute a SQL Statement in many Databases of one mysql server
#!/bin/bash
user="${1}"
host="${2}"
like="${3}"
all_dbs="$(mysql -u $user -p -h "$host" -Bse 'SELECT SCHEMA_NAME from information_schema.SCHEMATA WHERE SCHEMA_NAME like "${like}"' 2> /dev/null)"
for db in $all_dbs
do
mysql -u $user -p -h "$host" $db -sN -e "SELECT * FROM centerdaten;" 2> /dev/null
@thomasfr
thomasfr / what-changed.sh
Created September 18, 2014 16:04
Recursively compare two directories and print which files have changed. Ignore binary files and do not show non existing files in `dir2`
#!/bin/bash
dir1="/tmp/dir1"
dir2="/tmp/dir2"
IFS=$'\n'
for file in $(grep -Ilsr -m 1 '.' "$dir1"); do diff -q --exclude="cache" "$file" "${file/${dir1}/${dir2}}" 2> /dev/null; done
@thomasfr
thomasfr / test.js
Last active June 22, 2017 13:49
Example for "Extract object structure by usage". This would help refactoring an old code base where the structure of some arguments are not exactly known, or when testing and it is necessary to mock a dependency and you have to pass a object with the same structure for instance
function foo (options, meta, callback) {
console.log(options.propOne)
console.log(options.propTwo[0].foo)
console.log(options.propTwo[0].bar)
console.log(options.propThree.subProp.hello)
meta.foo = 'bar'
}
// A IDE could extract the structure of `options` as JSON
// and copy that structure into the clipboard (functionality could be found in a context menu for example)
@thomasfr
thomasfr / .babelrc.json
Created June 14, 2017 11:55
babelrc with babel-preset-env to just compile necessary ES features for given node version. With support for flow types
{
"presets": [
[
"env",
{
"targets": {
"node": "6.10"
}
}
],
$(function() {
// fileinput bei android deaktivieren
if(!navigator.userAgent.match(/Android/i)) {
$.getScript("/sites/all/themes/fragnebenan/js/fileinput.min.js", function(){
console.log('fileinput laden');
});
}
})
// oder
$(function() {
console.log('ich werde ausgeführt wenn alle DOM ready und alles geladen ist')
function triggerColLeftIcon(){
$('.col-icon-left').css({'display':'none!important'});
$('.col-icon-right').css({'display':'block!important'});
}
function triggerColRightIcon(){
$('.col-icon-right').css({'display':'none!important'});
$('.col-icon-left').css({'display':'block!important'});
}
@thomasfr
thomasfr / test.geojson
Last active January 4, 2016 10:29
GeoJSON Test
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
CREATE (n)-[:hasProperty]-(p{name:"forename",value:"Thomas"}),
n-[:hasProperty]-({name:"surname",value:"Fritz"})