Skip to content

Instantly share code, notes, and snippets.

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 / 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

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 / 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
@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 / 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;
cat /etc/usbpower
#!/bin/bash
# This script attempts to read /sys/devices/ and identify usb ports and devices
# that can be toggled to enable wakeup from sleep.
#
# Version: 2.0
# Date written: August 20, 2012
#
# Copyright (C) 2012 danomac @ gentoo forums
var style = '.videoWrapper { position: relative; padding-bottom: 56.25%; /* 16:9 */ padding-top: 50px; height: 0;} .videoWrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:none;}';
var htmlDiv = document.createElement('style');
htmlDiv.innerHTML = style;
document.getElementsByTagName('head')[0].appendChild(htmlDiv);
String.prototype.toDOM=function(){
var d=document
,i
,a=d.createElement("div")
@werty1st
werty1st / SUM_if_join_AS.sql
Created July 24, 2014 18:10
mysql join IF sum
SELECT ci.inventory_id, ci.inventory_quantity, cd.reservations, (ci.inventory_quantity + cd.reservations) as gesamt
FROM catalog_inventory ci
JOIN
(SELECT cd.documentation_inventory_nr, SUM(IF(cd.documentation_on >= UNIX_TIMESTAMP(NOW()),cd.documentation_quantity,0)) as reservations
FROM
catalog_documentation cd
GROUP BY cd.documentation_inventory_nr) as cd
ON cd.documentation_inventory_nr=ci.inventory_id
GROUP BY ci.inventory_id
apt-get install ifenslave
echo "bonding" >> /etc/modules
cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo eth0 wlan0 bond0
iface lo inet loopback
# Do not receive dhcp on eth0
iface eth0 inet manual