Skip to content

Instantly share code, notes, and snippets.

@kitsaels
kitsaels / build.xml
Created May 25, 2020 13:57
Java ant build.xml example
<project default="jar" xmlns:jacoco="antlib:org.jacoco.ant">
<property name="build.sysclasspath" value="ignore"/>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="lib/jacoco/jacocoant.jar"/>
</taskdef>
<target name="clean">
<delete dir="build"/>
</target>
@kitsaels
kitsaels / getFilename.php
Last active March 18, 2021 21:12
Get Filename from HTTP header Content-Disposition
<?php
function getFilename($header) {
if (preg_match('/Content-Disposition:.*?filename="(.+?)"/', $header, $matches)) {
return $matches[1];
}
if (preg_match('/Content-Disposition:.*?filename=([^; ]+)/', $header, $matches)) {
return rawurldecode($matches[1]);
}
throw new Exception(__FUNCTION__ .": Filename not found");
@kitsaels
kitsaels / LdapEntry.php
Last active May 22, 2019 13:30
Listing AD User accounts
<?php
class LdapEntry {
function __construct(array $entry) {
$this->entry = $entry;
}
function getAttribute($attribute, $default="") {
if (empty($this->entry['samaccountname'][0])) {
return $default;