Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@heiglandreas
heiglandreas / create_annotation.php
Created March 4, 2013 07:03
Create a PDF-File with Annotations showing up in Adobe Reader with a checked checkbox in the Annotation-List.
<?php
// Requires PDFlib >= 8.0.0
header('Content-Type: application/pdf');
$pdf = new PDFlib();
$pdf->begin_document('','');
$pdf->begin_page_ext(100,100,'');
$pdf->create_annotation(10,40,20,50, 'text', 'contents={testcontent} name=1 title={foo} popup=2 annotcolor={rgb 1 1 0}');
$pdf->create_annotation(10,40,20,50, 'popup', 'name=2 parentname=1');
$pdf->create_annotation(10,40,20,50,'text','contents={Marked festgelegt von foo} name=3 custom={{key=State type=string value=Marked} {key=StateModel type=string value=Marked}} title={foo} popup=4 inreplyto=1 annotcolor={rgb 1 1 0}');
$pdf->create_annotation(10,40,20,50, 'popup', 'name=4 parentname=3');
@heiglandreas
heiglandreas / ldap_auth.php
Last active April 15, 2024 06:46
LDAP-Authentication
<?php
/**
* This gist expects the following parameters
*
* @param string $ldapURI The LDAP-Uri. Something like ldaps://example.com:636 or ldap://example.com/396
* @param string|null $rdnUsername The DN of a user with read-credentials to the LDAP. Not necessary for anonymous bind.
* @param string|null $rdnPassword THe password of the $rdnUsername
* @param string|null $filter THe filter to be used to find the user in the LDAP
*/
foreach (explode(' ', $text) as $i => $token) {
$textflow = $pdf->add_textflow($textflow, $token, 'matchbox={name={' . $i . '}}');
$textflow = $pdf->add_textflow($textflow, ' ', 'matchbox=end');
}
# Setting up a local solr instance on a mac
# install solr with homebrew
brew install solr
# create the base solr index directory
sudo cp -r /usr/local/opt/solr/libexec/example/multicore/* /Library/Solr/
# make sure you can write to the solr logs
sudo chown -R `whoami` /usr/local/Cellar/solr/
@heiglandreas
heiglandreas / keybase.md
Created September 18, 2014 05:43
keybase.md

Keybase proof

I hereby claim:

  • I am heiglandreas on github.
  • I am heiglandreas (https://keybase.io/heiglandreas) on keybase.
  • I have a public key whose fingerprint is 967C CFA5 0DFF EE03 BB8B F5F2 CA92 13C7 5BFC E472

To claim this, I am signing this object:

@heiglandreas
heiglandreas / ldapConvert
Created October 21, 2014 20:17
Convert an LDAP-Result into a somewhat more usable array
function convertLdapArray($resultArray)
{
$attributes = array();
foreach ($resultArray as $key => $value) {
if (! is_String($key)) {
continue;
}
// This is an integer key
if (! isset($resultArray[$value]) {
$resultArray[$value] = array();
@heiglandreas
heiglandreas / ext-ldap-test-provisioner.sh
Last active August 29, 2015 14:24
Provision test-ldap for ext-ldap-tests
#!/bin/bash
#
# Provision a Vagrant Box containing an OpenLDAP-Server to execute
# tests for PHPs ext-ldap against
apt-get update
DEBIAN_FRONTEND=noninteractive aptitude install -q -y slapd ldap-utils
export SLAPPASS=`slappasswd -s password`
@heiglandreas
heiglandreas / Vagrantfile
Created July 6, 2015 08:44
ext_ldap-Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.provision "shell", path: "https://gist.githubusercontent.com/heiglandreas/10e1c7dd80d6e058faae/raw/ext-ldap-test-provisioner.sh"
end
@heiglandreas
heiglandreas / gist:9a4133e3d3f8bada3a27
Last active August 28, 2015 10:04
How to describe needed information for a method
<?php
class TestAction implements GenericAction
/**
* How would I describe that this method required the 'test'-parameter to be set?
*
* It shouldn't be @param as it's not a parameter to the method. An inline/embedded PHPDoc-comment
* wouldn't work as there's nothing I could add it to.
*
* I would have expected something like @requires or @expects to define that like so:
*
/**
* Always return false
*
* @return false
*/
public function returnFalse()
{
return true;
}