Skip to content

Instantly share code, notes, and snippets.

View chaudum's full-sized avatar
🏠
Working from home

Christian Haudum chaudum

🏠
Working from home
View GitHub Profile
package io.crate.metadata.settings;
import com.google.common.collect.Sets;
import org.junit.Test;
import static org.junit.Assert.*;
public class CrateSettingsTest {
@Test
OsService osService = mock(OsService.class);
OsStats osStats = mock(OsStats.class);
OsStats.Mem mem = mock(OsStats.Mem.class);
when(osStats.mem()).thenReturn(mem);
when(mem.actualFree()).thenReturn(byteSizeValue);
when(mem.actualUsed()).thenReturn(byteSizeValue);
when(mem.usedPercent()).thenReturn((short) 22);
when(mem.freePercent()).thenReturn((short) 78);
bind(OsService.class).toInstance(osService);
...
childImplementations.put(FREE, new MemoryExpression(FREE) {
@Override
public Long value() {
return osService.stats().mem().actualFree().bytes();
}
});
childImplementations.put(USED, new MemoryExpression(USED) {
@Override
public Long value() {
@chaudum
chaudum / gist:39373c14cf7f89e0c808
Last active March 25, 2016 05:30
At the moment, Crate does not have a builtin concept of ACL or user permissions, but there are several ways to secure a cluster and prevent it from unauthorized access. However, sometimes you want make your cluster just read-only and people have been asking us about that. — https://crate.io/blog/readonly-crate-with-nginx-and-lua/
upstream crate {
server 10.0.0.101:4200;
server 10.0.0.102:4200;
server 10.0.0.103:4200;
}
server {
listen 4220;
location = /_sql {
@chaudum
chaudum / Berlin.json
Last active July 2, 2019 11:09
12 districts of Berlin, JSON object per line so it can be easily imported into Crate.IO
{"geometry": {"type": "MultiPolygon", "coordinates": [[[[13.1865954, 52.489298], [13.1875725, 52.491232], [13.1895918, 52.4929407], [13.1894319, 52.4949858], [13.1898203, 52.4975432], [13.1917093, 52.4986912], [13.1952155, 52.4997414], [13.1981897, 52.499792], [13.1990817, 52.499888], [13.2051704, 52.5013633], [13.2097274, 52.5029098], [13.2093457, 52.5043024], [13.2087621, 52.5050455], [13.2093301, 52.5058751], [13.2104999, 52.5072015], [13.2110126, 52.5085223], [13.2118605, 52.509347], [13.2120085, 52.5093064], [13.2123221, 52.5092443], [13.2124329, 52.5092366], [13.2127884, 52.5091866], [13.2128017, 52.5092091], [13.2130117, 52.5091619], [13.2132311, 52.5090972], [13.2139232, 52.5090727], [13.2139789, 52.5090954], [13.2140851, 52.509101], [13.2141573, 52.5091212], [13.2142409, 52.5091502], [13.2144632, 52.5092745], [13.2145174, 52.509327], [13.2145456, 52.5093678], [13.2155819, 52.5091595], [13.2156956, 52.5093652], [13.2149809, 52.5095096], [13.2151045, 52.5096504], [13.2155245, 52.5102731], [13.2158675,
@chaudum
chaudum / convert.py
Last active December 18, 2015 07:19
This script converts the countries.geo.json from https://github.com/johan/world.geo.json/blob/master/countries.geo.json> into JSON that can be imported into Crate.IO. You could actually use it with any country in this repository, such as Austria (AUT, https://github.com/johan/world.geo.json/blob/master/countries/AUT.geo.json)
# -*- coding: utf-8; -*-
# vi: set encoding=utf-8
import sys
import json
def main(source):
with open(source) as fp:
d = json.load(fp)
@chaudum
chaudum / php-5.6.3.txt
Created January 12, 2016 07:38
crate-pdo: PHP 5.6.3 vs. 7.0.2
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ./vendor/bin/phpunit --coverage-html ./report
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
Runtime: PHP 5.6.3 with Xdebug 2.3.3
Configuration: /vagrant/phpunit.xml.dist
............................................................... 63 / 128 ( 49%)
............................................................... 126 / 128 ( 98%)
..
@chaudum
chaudum / php-5.6.3.txt
Created January 12, 2016 09:09
crate-dbal: PHP 5.6.3 vs. 7.0.2
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ./vendor/bin/phpunit --coverage-html ./report
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
Runtime: PHP 5.6.3 with Xdebug 2.3.3
Configuration: /vagrant/phpunit.xml.dist
............................S.S.S.SS........................... 63 / 153 ( 41%)
........SSSSSSSSSS................S.................SS........S 126 / 153 ( 82%)
SS.........................
@chaudum
chaudum / salt-minion.yml
Created February 11, 2016 09:37
salt-minion on CentOS 7.1 / Azure Cloud
# file: /etc/salt/minion
# We had problems that the salt minions that run on Azure (CentOS 7.1) disconnected all the time.
# The problem was solved by configuring the TCP keepalive settings instead of using the OS defaults:
# ... your configuration here ...
# loglevel info for more information about connectivity problems
log_level: info
# keepalive is set default to True but in the config shipped with the package it is commented out
tcp_keepalive: True
@chaudum
chaudum / bootstrap.py
Created February 24, 2016 21:09
Installing azure package fails
##############################################################################
#
# Copyright (c) 2006 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS