For the bad guy, contempt feeds his actions, penalty fits them.
But the narrow-minded guy, punishment feeds his narrowness, shame fits him.
Author: uda
Bash A to Z and 0 to 9
When you run a bash command, e.g. grep, and you need to take in account the letters A to Z and 0 to 9, you can use the following syntax:
for i in {{a..z},{A..Z},{0..9}}; do echo $i; done
From here you can take it further.
It came in hand when I was searching for a value in the session directory and the grep could not accept the * value because there were too many files, so I ran this:
for i in {{a..z},{0..9}}; do grep "something" sess_$i*; done
And I got my results as expected.
Installing ODBTP on Linux with PHP 5.4
- ODBTP installation instructions: http://odbtp.sourceforge.net/install.html
- fix ZVAL_ADDREF: http://sourceforge.net/p/odbtp/patches/2/
- fix function_entry: https://bugs.php.net/bug.php?id=60680
Apache and mime types
A few days ago I started a project of upgrading a CRM system written in PHP.
Now, the current server is using Apache 1.3.33 and PHP 5.1.6, old, right?, and, hold on, the server has a dual core x86 CPU, 4Gb of memory, which holds it for day to day use, but starts to squeak every now and then.
The new server has 8 cores, 8Gb of memory which can be upgraded since it is a Virtual Machine, a 64bit version of gentoo linux installed, and it runs Apache 2.2.24 with PHP 5.4.13 as a mod and is constantly updated.
I thought that the PHP syntax and function changes would be a pain, apparently that was nothing, Apache upgrade and non-planned configurations in the php code and file namings, they made the transfer more difficult.
The problem was that one specific file, a JS dictionary file with the name dict.hebrew.utf-8.js was being served with the encoding iso-8859-8 (Visual Hebrew), what made all the content seem like gibberish, funny, hu?
Snooping and searching the web, I tried simply setting the AddDefaultCharset UTF-8, but that did nothing, so I looked at my wall and saw the page saying RTFM, and so I did…
http://httpd.apache.org/docs/2.2/mod/mod_mime.html
Then it hit me, the setting AddCharset iso-8859-8 .hebrew is set before AddCharset UTF-8 .utf8 .utf-8 (I added the last one for compatibility) so I commented out the utf8 line and copied it to be the first AddCharset line, and WALLA, it did it.
So, to conclude my messy post… Remember Remember
- First come first served
- Name static files with language or encoding names thoughtfully
- Try and read what the plans are for the technologies you are using for the system you are building
- If your system has some hiccups, try to RTFM
- The fifth of November
Yehuda
Drupal form ajax & Zurb Foundation3
A few months ago I embedded the Foundation3 Framework into Drupal as the base of a theme for an intra-net system.
At first I found some issues with loading both jquery.js and foundation.js, so I loaded the minimized foundation.js instead of jquery.js and all worked fine.
Last week i added a form to one of the modules that uses AJAX refresh, and here I bumped into a tough one, I received an error stating that handleError is not defined (actualy, it was: function [something] has no method handleError).
So as usual, I snooped around the Internet, and of course, jQuery deprecated handleError, so some suggested to add the function in the page before the triggering function is called, it only helped me see the error, not prevent it from being raised.
So I realized, that the reason the handleError is even called is because it depends on an old jQuery version, and with foundation I'm using a newer one.
In short, I added the latest jquery.form.js from malsup's website to the theme, and in template.php replaced misc/jquery.form.js with the new one, like this:
function THEMENAME_js_alter(&$js) { if (isset($js['misc/jquery.form.js'])) { $path = drupal_get_path('theme', 'THEMENAME') . '/js/jquery.form.js'; $js[$path] = $js['misc/jquery.form.js']; $js[$path]['version'] = '3.27'; $js[$path]['data'] = $path; unset($js['misc/jquery.form.js']); } }
Enjoy
pygobject-2.0
If you get here, you probably searched for pygobject-2.0.
I’ve searched the internet upside down, downside up, and did not find how to install this package (I’m trying to install nemo-python).
The solution is: you have to install python-gobject-2-dev.
Enjoy
Piwik 1.8.4 upgrade – empty data
I use Piwik for analytics, on my sites and my clients, it is a great open source tool, like really great.
Recently I updated a self hosted Piwik by one of my clients, and since the update the “Crunched” data would not appear, empty graphs and empty bars.
The weird thing was that raw data was coming in, and the visitor log was active.
So I looked around, I did not want to do something that might make it worse, and I found this FAQ, and option 4 did the trick 🙂
I guess this is sort of an FYI post, enjoy and spread open-source.
Yehuda
PHP sleep2next function
I had a project done for a client, where I needed a code to run again every second, since cron-tabs work every minute I use an inner function to keep the code running.
I did it for them before, I used the simple sleep function, but this code needed a more precise timing, i can’t miss a second of data.
So I came up with a simple function that solves it:
function sleep2next() { usleep( intval( ( ( time() + 1 ) - microtime(true) ) * 1000000 ) ); }
The code calculates the miliseconds until next round second and pauses the code for that period of time, the further code will now start as soon as possible after the next second.
Notice: on windows platforms it might act somewhat strange.
Chrome Pre-Install cleaning
I stumbled into Google Chrome extensions made by various providers, that viciously use the Pre-Install option in order to stay even when the user uninstalls it, every user will get highly annoyed by this “Feature”.
After getting annoyed myself by one of them (Shameless mako.co.il) I looked it up.
Apparently, the pre-install keys exist under this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\Extensions
Or here for 64bit operating system
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Google\Chrome\Extensions
Since I provide technical support for people, I needed a tool to automate the removal action, so I created a REG file to remove this registry key.
Notice: This file cleans up every extension registered to be pre-installed, but it doesn’t remove them.
No free source allowed!!! OK, what else is new?
I guess that by now you already heard, read or any way else got to know about the weird terms Microsoft puts in front of application developers for Windows Phone. if not, read about it at Jan Wildeboer.
Here is the highlight: Microsoft says no to open source licenses or programs based on libraries that are under open source licenses. and they even mentioned GPLv3 as an example.
Well, my first move reading this was to share it with friends and use the old mantra “Microsoft is evil…”, at second thought, they may be, but what exactly are we doing to stop feeding them?
All we do is cry and weep how Microsoft behaves, how they corrupted the regular users with dummy interfaces, and flashy processor eating applications, yeah, they did, so what, they are a business after all, they have to feed their children, right?
So instead of complaining how M$ is trying to push away Open Source, and how Apple is going in their way and vice versa, lets make some better Linux Distributions for Dummies, some greater User Interfaces that people can do things also without a command line, cause using “ls -l” is cool for me, but my dad just wants to read his damn email and some news.
Lets not make it worth for cellphone companies to use Windows as an OS, lets not make it worth for M$ to disallow Open Source applications.