Skip to content

Instantly share code, notes, and snippets.

View pcan's full-sized avatar
🕳️
down the white rabbit hole

Pierantonio Cangianiello pcan

🕳️
down the white rabbit hole
View GitHub Profile
@pcan
pcan / SelfExpiringHashMap.java
Last active April 21, 2024 14:18
SelfExpiringHashMap - a Java Map which entries expire automatically after a given time; it uses a DelayQueue internally.
/*
* Copyright (c) 2019 Pierantonio Cangianiello
*
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@pcan
pcan / typescript-types-test.ts
Last active January 5, 2017 15:46
A test of type serialization tool for TypeScript language.
class ClassTypeImpl implements reflect.ClassType {kind='class'}
class InterfaceTypeImpl implements reflect.InterfaceType {kind='interface'}
let node_modules = {
typescript : {
lib : {
lib.core.d : {
PropertyDescriptor : new InterfaceTypeImpl(),
PropertyDescriptorMap : new InterfaceTypeImpl(),
Object : new InterfaceTypeImpl(),
ObjectConstructor : new InterfaceTypeImpl(),
@pcan
pcan / gai_strerror_shim.c
Created January 6, 2017 10:01
gai_strerror Shim for Luasocket static lib (compiled with MinGW)
/*
Specify the following options for the linker:
-Wl,--enable-stdcall-fixup
*/
#include "ws2tcpip.h"
char *
gai_strerrorA(
_In_ int ecode)
@pcan
pcan / gist:46da4decce64798737a458d5b3c9421c
Created January 17, 2017 21:20 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.

Using self-signed certificate.

Create a Certificate Authority root (which represents this server)

Organization & Common Name: Some human identifier for this server CA.

openssl genrsa -des3 -out ca.key 4096
openssl req -new -x509 -days 365 -key ca.key -out ca.crt
@pcan
pcan / README.md
Last active April 17, 2024 01:45
Node.js plain TLS Client & Server, 2-way Cert Auth

Node.js TLS plain TLS sockets

This guide shows how to set up a bidirectional client/server authentication for plain TLS sockets.

Newer versions of openssl are stricter about certificate purposes. Use extensions accordingly.

Prepare certificates

Generate a Certificate Authority:

@pcan
pcan / DynamicServiceActivator.java
Created March 25, 2017 09:13 — forked from arthurtsang/DynamicServiceActivator.java
Create a Spring Integration Channel programatically and register that as a Spring bean
private SubscribableChannel createInputChannel(String inputChannelName) {
PublishSubscribeChannel channel = new PublishSubscribeChannel();
channel.setBeanName(inputChannelName);
channel.setBeanFactory(applicationContext);
//channel.setApplySequence(true);
((ConfigurableApplicationContext)applicationContext).getBeanFactory().registerSingleton(inputChannelName, channel);
return channel;
}
@pcan
pcan / README.md
Created April 3, 2017 09:16
Compile Redis with Cygwin

Prerequisites

Install Cygwin with make, gcc & g++. Download Redis tar.gz package, unpack it.

Patch

Edit deps/hiredis/net.c and add the following lines just after the include directives:

@pcan
pcan / README.md
Last active August 6, 2020 07:03
Redis test cluster without ruby

These scripts let you run Redis in cluster mode (only for testing/dev purpose), without using the redis-trib script (written in Ruby! who wants it!?). The create-cluster has been modified to assign cluster slots after creation.

@pcan
pcan / main.js
Last active April 26, 2017 07:30
NodeJS script for Nexus 3 massive artifact deletion
var server = 'localhost:8081';
var client = new NexusClient(server);
client.login('user', 'password')
.then(() => client.deleteArtifacts('maven-releases', 'it.pcan.test', '0.10.0').then(response => console.log(response.body)))
.then(() => client.deleteArtifacts('maven-releases', 'it.pcan.test', '0.10.1').then(response => console.log(response.body)))
.then(() => client.deleteArtifacts('maven-releases', 'it.pcan.test', '0.10.2').then(response => console.log(response.body)));
// The contents of this file are subject to the Mozilla Public License
// Version 1.1 (the "License"); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://www.mozilla.org/MPL/
//
// Software distributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//