Skip to content

Instantly share code, notes, and snippets.

@mindc
mindc / ping_parallel_threads.pl
Created April 18, 2017 08:36
Parallel pings using threads
#!/usr/bin/perl
use strict;
use warnings;
use threads;
use threads::shared;
use Thread::Queue;
use JSON::XS;
use Net::Ping;
use Data::Dumper;
@mindc
mindc / until-logged-in.js
Last active July 18, 2017 08:03
Javascript Promise - run stuff until user is logged in - mixin Promises with API code
isLoggedIn().then(main); // run main() when user logged in
let jsonrpc = new JSONRPC(); // JSONRPC client, Promise based
function isLoggedIn() {
return jsonrpc.call('User.isLoggedIn').catch(showLoginForm);
}
function logIn(args) {
return jsonrpc.call('User.logIn', args).catch(showLoginForm);
@mindc
mindc / README.md
Last active August 18, 2017 23:11
Custom Tomcat ErrorPage for Apache FOP and PHP

Custom Tomcat ErrorPage for Apache FOP and PHP

Custom ErrorPage at webapps/fop/Error.jsp

<%@ page isErrorPage="true" %><%

boolean handled = false; // Set to true after handling the error

 // Get the PageContext
@mindc
mindc / README.md
Last active August 21, 2017 07:18
Lighttpd and Certbot (automated)

Lighttpd and Certbot

/etc/letscrypt/cli.ini

sa-key-size = 4096
authenticator = webroot
webroot-path = /home/certbot
renew-hook = /home/certbot/renew-hook.sh
post-hook = /home/certbot/post-hook.sh
@mindc
mindc / line-thrift.pl
Created August 21, 2017 07:35
LINE instant messenger protocol in Perl
#!/usr/bin/perl
package customHttpClient;
use base qw(Thrift::HttpClient);
sub setCustomHeader {
my $self = shift;
push @{$self->{'customHeaders'}},[@_];
}
@mindc
mindc / FopServlet.diff
Created August 21, 2017 07:39
Custom userconf.xml for Apache FOP on Tomcat
--- FopServlet.java.org 2010-07-12 21:34:45.000000000 +0200
+++ FopServlet.java 2011-04-06 19:00:01.639060332 +0200
@@ -44,6 +44,10 @@ import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.MimeConstants;
+import org.xml.sax.SAXException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
@mindc
mindc / OrderThroughRelationTrait.php
Last active September 11, 2017 06:17
Laravel QueryBuilder and augmented orderBy - order through relations
<?php
use Illuminate\Database\Eloquent\Relations\HasOneOrMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
trait OrderThroughRelationTrait {
/**
* Add an "order by" clause to the query and handles relations if specified.
*
@mindc
mindc / stunnel.pl
Last active September 19, 2017 10:39
Perl version of stunnel, using IO::Async
#!/usr/bin/perl
=pod
=encoding utf8
=head1 AUTHOR
Paweł Feruś <null@mindc.net>
@mindc
mindc / netmap.conf
Created January 11, 2019 08:55
VMWare Bridge interface naming
#This file is automatically generated.
# Hand-editing this file is not recommended.
network0.name = "Bridged [ens6f1]"
network0.device = "vmnet0"
network1.name = "HostOnly"
network1.device = "vmnet1"
network2.name = "NAT"
network2.device = "vmnet8"
network3.name = "Bridged [ens6f0.39]"
3fec
<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="https://webapi.allegro.pl/service.php" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="service" targetNamespace="https://webapi.allegro.pl/service.php"><types><xsd:schema targetNamespace="https://webapi.allegro.pl/service.php" elementFormDefault="qualified" attributeFormDefault="unqualified"><xsd:complexType name="PackageInfoStruct"><xsd:all><xsd:element name="operatorId" type="xsd:int"/><xsd:element name="packageId" type="xsd:string"/><xsd:element name="operatorName" type="xsd:string" minOccurs="0"/></xsd:all></xsd:complexType><xsd:complexType name="ArrayOfPackageinfostruct"><xsd:sequence><xsd:element name="item" type="tns:PackageInfoStruct" minOccurs="0" maxOccurs="unbounded"/></xsd:sequence></xsd:complexType><xsd:element name="DoAddPackageInfoToPostBuyFormRequ