Skip to content

Instantly share code, notes, and snippets.

View h4cc's full-sized avatar

Julius Beckmann h4cc

  • ZENNER IoT Solutions
  • Hamburg, Germany
View GitHub Profile
@h4cc
h4cc / hhvm.config
Created February 5, 2014 12:07
Tiny hhvm JIT profiler test.
Eval {
Jit = true
}
@h4cc
h4cc / loglevels.md
Created March 5, 2014 14:59
Explanation and grouping of loglevels.

Log Levels - RFC 5424.


Internals

This levels only needs to be findable for debugging purposes.

@h4cc
h4cc / phpunit_assertDatesAreEqual.php
Created March 19, 2014 16:18
PHPUnit assertDatesAreEqual assertion.
<?php
/**
* Check if two dates are "almost" equal.
*
* @param \DateTime $date1
* @param \DateTime $date2
* @param int $maxDiffSeconds
*/
public function assertDatesAreEqual(\DateTime $date1, \DateTime $date2, $maxDiffSeconds=59)
@h4cc
h4cc / generate_packages_json.php
Created April 23, 2014 13:22
Redirecting packages.json for Composer/Satis.
<?php
/**
* This file generates a new package.json on STDOUT, that will
* include the other package.json files.
*
* @author Julius Beckmann <beckmann@silpion.de>
*
* Documentation on this:
* https://github.com/composer/composer/blob/c849f7d05d4eb5e585c34c83bd41341bc144f0d0/doc/05-repositories.md
@h4cc
h4cc / pathfinder.hh
Created June 3, 2014 19:04
Solution for the Programmierwetbewerb by Silpion for the Firmenkontaktmesse at FH-Wedel.
<?hh
/**
* Solution for the Programmierwetbewerb by Silpion
* for the Firmenkontaktmesse at FH-Wedel.
*
* @author Julius Beckmann
*
*/
type Point = Pair<int, int>;
@h4cc
h4cc / raw-thumbnails.md
Last active August 29, 2015 14:02
Using ufraw-batch for generating thumbnails in ubuntu.

Install

sudo apt-get install ufraw ufraw-batch

Create config

sudo vim /usr/share/thumbnailers/raw.thumbnailer

with content:

@h4cc
h4cc / apache2-servername-fix.sh
Created June 9, 2014 14:12
How to fix Apache – "Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName" Error on Ubuntu
# Write the ServerName for apache2 in a custom config file:
echo 'ServerName localhost' > /etc/apache2/conf.d/servername
# Restart d'a Server!
service apache2 restart
which smartctl || sudo apt-get -y install smartmontools
which php || sudo apt-get -y install php5-cli
[ -f smart.php ] || wget https://gist.githubusercontent.com/h4cc/a2163b697469d847cd4a/raw/a04e2645d3c5f22625f3efaa28a4f604912b2792/smart.php
for disk in /dev/sd[a-z]
do
echo $disk
sudo smartctl --attributes $disk | php smart.php
done
@h4cc
h4cc / rotate.sh
Created July 14, 2014 21:07
Script for rotating the screen on my Thinkpad X200T.
#!/bin/sh
# Find the line in "xrandr -q --verbose" output that contains current screen orientation and "strip" out current orientation.
rotation="$(xrandr -q --verbose | grep 'connected' | egrep -o '\) (normal|left|inverted|right) \(' | egrep -o '(normal|left|inverted|right)')"
# Using current screen orientation proceed to rotate screen and input devices.
case "$rotation" in
@h4cc
h4cc / handy_commands.sh
Last active August 29, 2015 14:04
Handy Bash commands for every day usage.
# Some handy commands i dont like to google the way down every time:
# List files by changed timestamp in current folder
find . -type f -printf '%T@ %p\n' | sort -n -r | cut -f2- -d" " | sed -e 's,^./,,' | xargs ls -U -l
# Files writeable by "others" in current folder
find . -type d -perm /o+w
# Files writeable by current "group" in current folder
find . -type d -perm /g+w
# Files writeable by current "user" in current folder