Skip to content

Instantly share code, notes, and snippets.

View beradrian's full-sized avatar

Adrian Ber beradrian

View GitHub Profile
@beradrian
beradrian / diagram.mermaid
Last active December 20, 2023 20:12
timeouts
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@beradrian
beradrian / proxy.js
Created January 18, 2018 18:11
CORS proxy with node-http-proxy
/** 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 November 21, 2017 13:26
Log from JS to Fluentd/Logstash
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 / chronos.docker-compose.yml
Last active May 25, 2017 13:38
docker-compose.yml samples
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 13:32 — forked from xconnecting/build.gradle
Gradle: Using jdbc in build script
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 }
@beradrian
beradrian / FineTuneCache.nginx.conf
Created May 19, 2017 10:41
Nginx configuration
# 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;
<?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 June 23, 2016 15:29
Karma with Chrome and FF on Travis
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
@beradrian
beradrian / WebsocketsConfig.java
Created June 15, 2016 08:46
Websockets config
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 December 3, 2015 14:41
Distance between two geographical points
package org.bar;
import org.geotools.referencing.GeodeticCalculator;
import java.awt.geom.Point2D;
/**
* How far is NY from London ?
*/
public class DistanceTest {