Skip to content

Instantly share code, notes, and snippets.

Adrian Ber beradrian

Block or report user

Report or block beradrian

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@beradrian
beradrian / proxy.js
Created Jan 18, 2018
CORS proxy with node-http-proxy
View proxy.js
/** If you want to use the local development environment with the dev backend,
* this will create a proxy so you won't run into CORS issues.
* It accepts the following command line parameters:
* - port the port where the proxy will listen
* - target the DEV backend target to contact.
* Example: If you set the port to 3000 and target to https://dev.nibo.ai then
* your actual "resourceBaseUrl" in NiboSettings should be http://localhost:3000/api/v1
*/
// Define the command line options
const optionDefinitions = [
@beradrian
beradrian / log.js
Last active Nov 21, 2017
Log from JS to Fluentd/Logstash
View log.js
var log4js = require('log4js');
// Use as host
// - 192.168.99.100 as host for local Docker or the IP provided by `docker-machine ip default`
// var host = '192.168.99.100';
var host = 'localhost';
console.log("Using central log host " + host);
console.log("Configure log4js ...");
@beradrian
beradrian / App.config
Created Oct 13, 2017
Logstash NLog Target
View App.config
<target name="logstash" xsi:type="Network" address="tcp://host:port" newLine="true">
<layout xsi:type="JsonLayout" includeAllProperties="false">
<attribute name="@timestamp" layout="${date:format=yyyy-MM-ddTHH\:mm\:ss.fffZ}" />
<attribute name="level" layout="${level:upperCase=true}"/>
<attribute name="category" layout="${logger}" />
<attribute name="message" layout="${message}" />
<attribute name="environment" layout="production" />
<attribute name="extra" layout="value" />
</layout>
</target>
@beradrian
beradrian / chronos.docker-compose.yml
Last active May 25, 2017
docker-compose.yml samples
View chronos.docker-compose.yml
version: '3'
services:
zk1:
image: zookeeper
restart: always
ports:
- "2181:2181"
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zk1:2888:3888
@beradrian
beradrian / build.gradle
Last active May 25, 2017 — forked from xconnecting/build.gradle
Gradle: Using jdbc in build script
View build.gradle
import groovy.sql.Sql
// more information at http://docs.groovy-lang.org/latest/html/api/groovy/sql/Sql.html
apply plugin: 'groovy'
apply plugin: 'eclipse'
apply plugin: 'maven'
repositories { mavenCentral() }
configurations { driver }
View FineTuneCache.nginx.conf
# https://www.nginx.com/blog/nginx-caching-guide/
proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g
inactive=60m use_temp_path=off;
server {
...
location / {
proxy_cache my_cache;
View jmeter-results-to-junit.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/testResults">
<testsuites>
<testsuite>
<xsl:for-each select="*">
<testcase>
<xsl:attribute name="classname"><xsl:value-of select="name()"/></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="@lb"/></xsl:attribute>
@beradrian
beradrian / .travis.yml
Last active Jun 23, 2016
Karma with Chrome and FF on Travis
View .travis.yml
language: node_js
node_js:
- stable
before_install:
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sudo apt-get update
- sudo apt-get install -y libappindicator1 fonts-liberation
- sudo apt-get upgrade libstdc++6 lsb-base
View WebsocketsConfig.java
package com.stefisoft.webchat;
import java.util.HashSet;
import java.util.Set;
import javax.websocket.Endpoint;
import javax.websocket.server.ServerApplicationConfig;
import javax.websocket.server.ServerEndpointConfig;
import org.slf4j.Logger;
@beradrian
beradrian / DistanceTest.java
Created Dec 3, 2015
Distance between two geographical points
View DistanceTest.java
package org.bar;
import org.geotools.referencing.GeodeticCalculator;
import java.awt.geom.Point2D;
/**
* How far is NY from London ?
*/
public class DistanceTest {
You can’t perform that action at this time.