Skip to content

Instantly share code, notes, and snippets.

View liluxdev's full-sized avatar

Stefano Gargiulo liluxdev

  • JDK, Lilux.dev
  • Rome, Italy
View GitHub Profile
@liluxdev
liluxdev / how.md
Created January 4, 2023 14:22 — forked from Zemnmez/how.md
L2TP / ipsec VPN, Amazon Linux (EC2)
# adapted from http://spottedhyena.co.uk/centos-67-ipsecl2tp-vpn-client-unifi-usg-l2tp-server/
yum -y install epel # different on amazon linux
sudo yum -y install xl2tpd openswan
systemctl start ipsec.service
service ipsec start

# 'myserver.com' is just to help identify. these are all imported into /etc/ipsec.conf.

vim /etc/ipsec.d/myserver.com.conf # see next...
@liluxdev
liluxdev / tomjn_http2_push.php
Created September 12, 2020 21:08 — forked from tomjn/tomjn_http2_push.php
A naive and incomplete, but functional approach to http2 push
<?php
/**
* Plugin name: HTTP2 Push scripts
* Author: Tom J Nowell
*/
function tomjn_get_dep_url( /*\WP_Dependency*/ $dep ) {
global $wp_version;
$relative = str_replace( site_url(), '', $dep->src );
$ver = $dep->ver;
@liluxdev
liluxdev / mozGetMatchedCSSRules.js
Created August 13, 2016 05:27 — forked from ydaniv/mozGetMatchedCSSRules.js
A Gecko only polyfill for Webkit's window.getMatchedCSSRules
// polyfill window.getMatchedCSSRules() in FireFox 6+
if ( typeof window.getMatchedCSSRules !== 'function' ) {
var ELEMENT_RE = /[\w-]+/g,
ID_RE = /#[\w-]+/g,
CLASS_RE = /\.[\w-]+/g,
ATTR_RE = /\[[^\]]+\]/g,
// :not() pseudo-class does not add to specificity, but its content does as if it was outside it
PSEUDO_CLASSES_RE = /\:(?!not)[\w-]+(\(.*\))?/g,
PSEUDO_ELEMENTS_RE = /\:\:?(after|before|first-letter|first-line|selection)/g;
// convert an array-like object to array
@liluxdev
liluxdev / image_to_data_url.js
Created July 23, 2016 05:12 — forked from HaNdTriX/image_to_data_url.js
Convert an image to base64URL.
/**
* Converts an image to a dataURL
* @param {String} src The src of the image
* @param {Function} callback
* @param {String} outputFormat [outputFormat='image/png']
* @url https://gist.github.com/HaNdTriX/7704632/
* @docs https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement#Methods
* @author HaNdTriX
* @example
*
@liluxdev
liluxdev / image-proxy.conf
Created July 19, 2016 23:37 — forked from tmaiaroto/image-proxy.conf
Nginx Image Filter Resize Proxy Service
# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;
# Gzip was on in another conf file of mine...You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren't overwriting some other setting from another config's http {} section.
@liluxdev
liluxdev / DirectoryWatchService.java
Created July 12, 2016 00:54
Java 1.7+: Watching a Directory for File Changes (Requires Java 1.8+ to run because this code uses some features from Java 8 as well)
package <package>;
import <package>.Service;
import java.io.IOException;
/**
* Interface definition of a simple directory watch service.
*
* Implementations of this interface allow interested parties to <em>listen</em>
From 3a8fe43e9e073f26e44f62ad072079acd8b78de3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Bu=CC=88nemann?= <[email protected]>
Date: Mon, 30 May 2016 00:00:29 +0200
Subject: [PATCH] Add SPDY support back to Nginx with HTTP/2
Ported to 1.9.15 from 1.9.7 patch by Jiale Zhi from CloudFlare with
additional fixes to re-enable deprecated spdy directives and fix
compilation with http_v2 module enabled and spdy disabled.
---
auto/modules | 31 +
@liluxdev
liluxdev / 1. StaticFileHandler.java
Created July 7, 2016 02:59 — forked from Ryan-ZA/1. StaticFileHandler.java
Simple static fileserver for vert.x - uses cached SHA1 hash etags for client caching to ensure that cached files remain correct after redeploys and between servers.
package com.rc;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.vertx.java.core.AsyncResult;
import org.vertx.java.core.Handler;
import org.vertx.java.core.Vertx;
@liluxdev
liluxdev / README.md
Created March 12, 2016 00:42 — forked from imkevinxu/README.md
Time Spent on Page

Javascript code that calculates how much active time is spent on a tab and takes into account changing tabs, switching windows, or leaving the page.

Demo here http://bl.ocks.org/d/4393523/

@liluxdev
liluxdev / stacktrace.cxx
Created March 11, 2016 19:02 — forked from fmela/stacktrace.cxx
A C++ function that produces a stack backtrace with demangled function & method names.
#include <execinfo.h> // for backtrace
#include <dlfcn.h> // for dladdr
#include <cxxabi.h> // for __cxa_demangle
#include <cstdio>
#include <cstdlib>
#include <string>
#include <sstream>
// This function produces a stack backtrace with demangled function & method names.