Skip to content

Instantly share code, notes, and snippets.

# auto detects a good number of processes to run
worker_processes auto;
#Provides the configuration file context in which the directives that affect connection processing are specified.
events {
# Sets the maximum number of simultaneous connections that can be opened by a worker process.
worker_connections 8000;
# Tells the worker to accept multiple connections at a time
multi_accept on;
}
@hakansakalli
hakansakalli / ubuntu-dell-g3.md
Created November 30, 2020 08:56 — forked from douglasmiranda/ubuntu-dell-g3.md
Ubuntu 16.04 Dell G3 series setup

Nested Routers in Express.js

Express makes it easy to nest routes in your routers. But I always had trouble accessing the request object's .params when you had a long URI with multiple parameters and nested routes.

Let's say you're building routes for a website www.music.com. Music is organized into albums with multiple tracks. Users can click to see a track list. Then they can select a single track and see a sub-page about that specific track.

At our application level, we could first have a Router to handle any requests to our albums.

const express = require('express');
@hakansakalli
hakansakalli / KeycloakClientAuthExample.java
Created February 28, 2019 13:33 — forked from thomasdarimont/KeycloakClientAuthExample.java
Retrieve and verify AccessToken with Keycloak Client.
package de.tdlabs.keycloak.client;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.keycloak.OAuth2Constants;
import org.keycloak.RSATokenVerifier;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.KeycloakBuilder;
import org.keycloak.common.VerificationException;
import org.keycloak.jose.jws.JWSHeader;
import org.keycloak.representations.AccessToken;
@hakansakalli
hakansakalli / App.java
Created February 28, 2019 12:31 — forked from thomasdarimont/App.java
Simple Spring Boot App protected by Keycloak with initial roles from Keycloak and additional hierarchical app Internal roles. Supports fine grained permission checks, where the permissions are derived from roles.
package demo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
OpenIDConnectAuth.discover(
vertx,
new OAuth2ClientOptions()
.setClientID("<your google auth client id>")
.setClientSecret("<your google auth client secret>")
.setSite("https://accounts.google.com")
.setTokenPath("https://www.googleapis.com/oauth2/v3/token")
.setAuthorizationPath("/o/oauth2/auth"),
res -> {
@hakansakalli
hakansakalli / cqlsh-linux-cassandra.md
Created February 13, 2019 11:07 — forked from diegopacheco/cqlsh-linux-cassandra.md
How to install cqlsh only on Linux?
pip3 install cqlsh==4.1.1
cqlsh --version
# or...
sudo su root
pip install cqlsh==4.1.1
cqlsh --version
@hakansakalli
hakansakalli / backends.py
Created March 12, 2018 13:30 — forked from monkut/backends.py
django (1.8) python3 LDAP (via ldap3) Authentication backend
"""
django (1.8) python3 LDAP (via ldap3) Authentication backend
Assumes 'AUTH_INFORMATION' is defined in settings.py in the form:
AUTH_INFORMATION = { 'LDAP'{
'USERNAME_SEARCH_FILTER': <ldap search filter, for example, '(uid={})'>,
'HOST': <ldap server host>,
'PORT': <ldap server port (integer)>,
'BASE_DN': <ldap base DN>,
@hakansakalli
hakansakalli / gist:a834fcfc510cba4d98fc1dedd5b9af35
Created February 16, 2018 13:18 — forked from ichord/gist:9808444
demo of using pdf.js to extract pages to images
<script src="http://cdnjs.cloudflare.com/ajax/libs/processing.js/1.4.1/processing-api.min.js"></script><html>
<!--
Created using jsbin.com
Source can be edited via http://jsbin.com/pdfjs-helloworld-v2/8598/edit
-->
<body>
<canvas id="the-canvas" style="border:1px solid black"></canvas>
<input id='pdf' type='file'/>
<!-- Use latest PDF.js build from Github -->
@hakansakalli
hakansakalli / gist:3c8124ea5c42759bc7729976fa9bdca4
Created November 13, 2017 17:12 — forked from lost-theory/gist:3925738
different delimiters in jinja2 + flask
from flask import Flask, render_template_string, request
class CustomFlask(Flask):
jinja_options = Flask.jinja_options.copy()
jinja_options.update(dict(
block_start_string='<%',
block_end_string='%>',
variable_start_string='%%',
variable_end_string='%%',
comment_start_string='<#',