Skip to content

Instantly share code, notes, and snippets.

View beradrian's full-sized avatar

Adrian Ber beradrian

View GitHub Profile
@beradrian
beradrian / ServletUtils.java
Last active April 18, 2024 23:45
Get baseUrl for a servlet request
String getBaseUrl(HttpServletRequest request) {
String baseUrl = request.getRequestURL().substring(0, request.getRequestURL().length() - request.getRequestURI().length()) + request.getContextPath();
return baseUrl;
}
<?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 / 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 / setproxy
Last active October 10, 2022 17:12
Set proxy for npm and git
# set a proxy
set HTTP_PROXY=
set HTTPS_PROXY=%HTTP_PROXY%
npm config set proxy %HTTP_PROXY%
npm config set https.proxy %HTTPS_PROXY%
npm config set https-proxy %HTTPS_PROXY%
git config --global http.proxy %HTTP_PROXY%
git config --global https.proxy %HTTPS_PROXY%
# unset proxy
@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 / sync-gh-pages
Last active June 8, 2017 19:50
Sync master into gh-pages
git checkout gh-pages
git merge master
git push origin gh-pages
@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;