So recently I’ve not been able to connect to the eduroam WiFi at the Technische Universität München in Garching Forschungszentrum. I’m guessing the RBG is running some specialized DHCP server that is not compatible with the newest NetworkManager version in Arch Linux. So to fix this, edit the file “/etc/NetworkManager/Networkmanager.conf” and comment out this file like so: #dhcp=internal Credits to Philipp and Simon, for saving me lots of headaches.
Codeschnippsel
“libGL error: unable to load driver: i965_dri.so” fix
So I actually rarely encounter any problems with my Arch Linux, but sometimes they just want to see the world burn. Apparently after updating the mesa driver, so library got lost.
Easy fix:
# Arch Linux mv ~/Android/Sdk/tools/lib64/libstdc++/libstdc++.so.6{,.bak} mv ~/Android/Sdk/tools/lib64/libstdc++/libstdc++.so.6.0.18{,.bak} ln -s /usr/lib/libstdc++.so ~/Android/Sdk/tools/lib64/libstdc++/
Thanks to proft.me for providing this!
Git command of the day: git remote prune
In this series of posts I’ll document useful git commands ready to copy&paste which nobody knows by heart but you need once in a while. Today:
git remote prune <name>
From the docs:
prune
Deletes all stale remote-tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in “remotes/<name>”.
With
--dry-run
option, report what branches will be pruned, but do not actually prune them.
Very useful when working with Github and you just merged a PR then usually you also delete the branch on the remote immediately after. This does not however delete the branch from your local repository and over time it can get messy. With this simple command you delete all local references tracking upstream branches which were deleted on the server. If your remote is called origin then just type enter it like so::
git remote prune origin
PHP: Dump _ALL_ the data to the browser
Sometimes its useful to show data received / processed through PHP in the browser for debugging purposes. Yes you can use Firebug or some of those fancy debugging classes, but maybe you just want to view that damn array quickly 🙂 Use this: function dumpMe($arr) { echo str_replace(array(“\n”, ‘ ‘), array(‘ ‘, ‘ ‘), print_r($arr, true)) . ‘ ‘; }
PHPs http_response_code – 5.3 compatibility snippet
The Api of PHP just rocks, easy to use for the things you need. Sometime compatibility is an issue though. Many webhosters didn’t upgrade yet from 5.3 to anything reasonable, so I might as well keep this snippet here for future reference: if (!function_exists(‘http_response_code’)) { function http_response_code($newcode = NULL) { static $code = 200; if ($newcode !== NULL) { header(‘X-PHP-Response-Code: ‘ . $newcode, true, $newcode); if (!headers_sent()) { $code = $newcode; } } return $code; } }
Format a PHP Timestamp to Mysql Datetime/Timestamp
Useful when converting between those two formats often: function formatDateMysql($timestamp = false) { if ($timestamp === false) { $timestamp = time(); } return date(‘Y-m-d H:i:s’, $timestamp); } in the other direction you can use the mighty strtotime function, o god I love PHP so much <3 (Yes Java, your Date object is a mess!)
Better SPAM protection with Postfix
In order to use RBL lists on your postfix setup to block spam replace this line in main.cf: smtpd_sender_restrictions = check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf with: smtpd_sender_restrictions = reject_rbl_client sbl-xbl.spamhaus.org, reject_rbl_client cbl.abuseat.org, reject_non_fqdn_sender, reject_unknown_sender_domain, check_sender_access mysql:/etc/postfix/mysql-virtual_sender.cf You can copy and paste the line with any ISPConfig setup. If you don’t use mysql to authenticate your users then you might need to adapt parts of this setting.
PHP: Get maximum upload filesize
When handling file uploads its handy to check beforehand if the file fits insides the restrictions PHP sets in its ini file. To determine these the following functions are really handy:
Java: Statischer vs. Dynamischer Typ
Beim Thema Vererbung ist man schnell mal verwirrt, vor allem wenn sich da auch Statische Methoden reinmischen. Zur klarstellung sollte man sich verdeutlichen, was der Unterschied zwischen dem statischen und dem dynamischen Datentypen einer Variable ist.
PHP Foreach über zwei Arrays
Wenn man zwei symmetrische Arrays (Gleiche Anzahl von Elementen) hat und man möchte über diese gleichzeitig iterieren, dann wird das mit einem normalen Foreach nicht funktionieren. Man kann hier allerdings ein bisschen tricksen und die Funktion nützen, dass man sowohl über Key als auch den Wert des Arrays verfügen kann. < ?php foreach (array_combine($name, $value) as $n => $v){ //double Iteration $sql.=$n.’=’.$v.’, ‘; } Ganz nützlich, wenn man sich SQL Statements zusammenbaut.