Skip to content

Instantly share code, notes, and snippets.

View vertexvaar's full-sized avatar

Oliver Eglseder vertexvaar

View GitHub Profile
@vertexvaar
vertexvaar / sortArrayByArray.php
Last active November 29, 2016 23:19
Array sorting functions written a long time ago, don't know why... Maybe to find the ugliest possible way.
<?php
$array = [
9843 => [
'name' => 'Bob',
'order' => '2',
],
98723 => [
'name' => 'Creg',
'order' => '1',
],

Keybase proof

I hereby claim:

  • I am vertexvaar on github.
  • I am vertexvaar (https://keybase.io/vertexvaar) on keybase.
  • I have a public key whose fingerprint is EEF4 0FBF 8132 DC7F F9D7 BD2F F721 B4E3 95B7 911C

To claim this, I am signing this object:

@vertexvaar
vertexvaar / connect.php
Last active November 29, 2016 23:17
How to establish a SSH local forward with PHP and connect to a remote DB afterwards
<?php
$proc = new \Symfony\Component\Process\Process(
'\\ssh -i ' . $pk . ' -NL 3307:' . $dbServ . ':3306 ' . $sshUsr . '@' . $sshHst . ' sleep 10 >> logfile'
);
$proc->start();
// wait until connection is established
sleep(1);
$dataBase = new \mysqli('127.0.0.1', $dbUsr, $dbPwd, $dbName, 3307);
$result = false;
@vertexvaar
vertexvaar / locker.php
Last active June 26, 2017 11:48
Deprecate $GLOBALS access
<?php
class DeprecationLogger implements ArrayAccess
{
protected $values = [];
/**
* DeprecationLogger constructor.
*
* @param array $values
@vertexvaar
vertexvaar / pre-receive
Created November 21, 2017 20:34
git pre-receive hook to decline non-signed commits
#!/bin/sh
status=0
while read oldrev newrev refname
do
git verify-commit "$newrev" 2>&- >&-
if [ $? -ne 0 ]; then
echo "[GPG] Missing signature"
<?php
class Accessor
{
public static function getLinkedStaticPropertyIterator($class, $property): \Iterator
{
return (\Closure::bind(
function () use ($class, $property) {
foreach ($class::${$property} as $logger) {
yield $logger;
}
<?php
/**
* http://www.termsys.demon.co.uk/vtansi.htm#cursor
*
* Class Cursor
*/
class Cursor
{
/**
@vertexvaar
vertexvaar / git.sh
Created August 12, 2018 11:55
Git actions for merging repos together
# Move all commits in subfolder
git filter-branch -f --tree-filter 'mkdir -p $target; for node in ./*; do if [ "$node" != "./app" ];then mv $node $target; fi; done'
# Sign all commits
git filter-branch -f --commit-filter 'git commit-tree -S "$@"'
@vertexvaar
vertexvaar / regex.md
Last active November 19, 2021 15:08
key - label - XML to XLIFF RegEx

\t\t\t<label index="(.*?)">(.*?)</label>\n \t\t\t<trans-unit id="$1">\n\t\t\t\t<source>$2</source>\n\t\t\t</trans-unit>\n

@vertexvaar
vertexvaar / Dockerfile
Created October 15, 2018 10:33
Dockerfile wget run progress bar
RUN wget --progress=bar:force:noscroll https://...