Skip to content

Instantly share code, notes, and snippets.

@werty1st
werty1st / filter url slash.php
Created October 10, 2014 13:33
filter url slash reverse string replace for slash and apos to find items which include such char.
File:
contao3/system/modules/metamodels/MetaModels/ItemList.php
public function setFilterParameters($arrPresets, $arrValues)
{
...
foreach ($arrProcessed as $key => $value) {
$value = str_replace(array('-slash-', '-apos-'), array('/', '\''), $value);
$arrProcessed[$key] = $value;
@werty1st
werty1st / FormMetaModelNotelist.php
Last active August 29, 2015 14:07
save notelist items as raw array to store items in db on processFormData hook
contao3/system/modules/metamodelsattribute_notelist/FormMetaModelNotelist.php
Zeile 272
...
$arrNotelist = $arrTmp;
unset($arrTmp);
//aufbereiten um als array verfügbar zu halten
@werty1st
werty1st / pam adb sudo auth
Created November 14, 2014 16:41
use android device to authenticate
common_auth:
auth sufficient pam_exec.so quiet /root/pam.py
pam.py:
#!/usr/bin/python2.7
from subprocess import Popen, PIPE
import re
import string
from array import array

Recently I was asked to generate PDF invoices for an online shop. I looked at various PHP PDF generators, but wasn't particularly impressed with any of them.

Then I found (via Stack Overflow) a command-line HTML-to-PDF convertor called wkhtmltopdf, which uses WebKit (the same layout engine as Safari and Google Chrome) and therefore is very accurate.

There is a class for PHP integration on the Wiki, but I found it overly complicated and it uses temp files which aren't necessary. This is the code I wrote instead.

I used Smarty for generating the HTML for the PDF, but you can use any template engine, or pure PHP if you prefer.

Note: I originally tried to install wkhtmltopdf from source, but it's much easier to use the static binary instead.

@werty1st
werty1st / synclient Logitech
Last active August 29, 2015 14:15
Linux Tk820 Logitech working like apple magix trackpad
Rechts Tap aus:
synclient TapButton2=3
Rechts Click Button aus:
synclient RightButtonAreaLeft=0
synclient RightButtonAreaRight=0
synclient RightButtonAreaTop=0
synclient RightButtonAreaBottom=0

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"
@werty1st
werty1st / modemswitch
Last active August 29, 2015 14:24
umts modem 3g at command
apt-get install usb-modeswitch-\*
/usr/sbin/usb_modeswitch -v 12d1 -p 1446 -t option-zerocd
#dann neu reinstecken
udev erstellen:
/etc/udev/rules.d/70-usb-modeswitch.rules
# eigene udev-Regeln für UMTS-Sticks
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1446", RUN+="/usr/sbin/usb_modeswitch -v 12d1 -p 1446 -M '55534243123456780000000000000011062000000100000000000000000000'"
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1001", RUN+="/bin/bash -c 'modprobe option && echo 12d1 1001 > /sys/bus/usb-serial/drivers/option1/new_id'"
function insertScript(url) {
scriptEl = document.createElement('script');
scriptEl.type = 'text/javascript';
scriptEl.async = true;
scriptEl.src = url;
document.getElementsByTagName('head')[0].appendChild(scriptEl);
}
function loadScript(url,callback,args) {
scriptEl = document.createElement('script');
scriptEl.type = 'text/javascript';
scriptEl.async = true;
scriptEl.src = url;
if (typeof(callback) === 'function'){
if ("onload" in scriptEl){
scriptEl.onload = function(){
@werty1st
werty1st / gist:2647f12f355d5e5f8b98
Last active November 19, 2015 10:38 — forked from jamesmr89/gist:77851acecda208ecc780
pfSense 1to1 NAT OpenVPN setup
Goal of this document is to describe how to setup a vpn tunnel with two pfSense boxes
having the same LAN subnet, for the purpose of this doc we'll use 192.168.1.1/24 on
both firewalls LAN interfaces
We have to make some dummy networks here to NAT to so as far as Site A will be concerned,
site B will be 192.168.2.0/24, and as far as Site B is concerened site A will be 192.168.3.0/24
SiteA (LAN 192.168.1.1)
OpenVPN Server:
Standard Setup and we'll use 10.0.1.0/24 as the Tunnel Network (I can elaborate here later)