Home » Archive

Articles in the Coding Category

Coding »

[24 May 2014 | No Comment | ]

As you may know i am relatively new to Ruby on rails and i am currently working on a project where i need a simple captcha.
And simple_captcha is pretty simple and exactly what i need, however i came upon a weird bug.
In the signin_controller i use simple_captcha_valid? and sometimes it works properly and sometimes not, and i hate inconsistent bugs it was almost showing randomly.
After more than an hour of debugging i realized the problem was in simple_captcha_valid? it’s self-destructing after the first use, converting from true to false
So if …

Coding, Tools »

[23 May 2012 | 5 Comments | ]

I was thinking about wordpress version enumeration and while the meta generator tag is very explicit but it’s not always showing since some (most?) public/custom themes don’t show that meta tag.
So while playing with wordpress i discovered a way of enumerating the version.
If you request domain.com/wp-login.php you will get this in the HTML response:
<link rel=’stylesheet’ id=’colors-fresh-css’ href=’ $ DOMAIN/wp-admin/css/colors-fresh.css?ver= $VERSION ‘ type=’text/css’ media=’all’ />
(or in older versions)
<link rel=’stylesheet’ id=’login-css’ href=’$DOMAIN/wp-admin/css/login.css?ver=$VERSION’ type=’text/css’ media=’all’ />

Each $VERSION relates to a different wordpress version.

With the help of core.svn.wordpress.org/tags/2.7/wp-includes/script-loader.php
(2.8/wp-includes/script-loader.php.. etc) i made a list

WP-version $colors_version
2.7 …

Coding »

[10 May 2012 | No Comment | ]

After trying this script that i wrote yesterday [PHP] MySQL result to JSON – For mongoDB found out it’s not very useful if the MySQL result is big (like in my case) and 570MB of JSON encoded data is not very practical to upload and import.
So instead i wrote another little script to export a table and push it to the new mongo collection (table).

//mysql_query(“SET NAMES ‘utf8’;”);

$m = new Mongo(“mongodb://HOST:PORT”);
// If mongoDB is on the same box then use $m = new Mongo();
$db = $m->local; // “local” is the name …

Coding »

[9 May 2012 | No Comment | ]

So today i tested mongoDB and i wanted some rows from an existing database but it had to be in JSON format so i wrote this little script to port it.

mysql_query(“SET NAMES ‘utf8’;”);
$m = mysql_query(‘SELECT * FROM `table` LIMIT 0,100;’);
$json = “”;
$i = 0;
while($rows[] = mysql_fetch_assoc($m)){
$json .= json_encode($rows[$i]);
$json .= “\n”;
$fp = fopen(‘data.json’, ‘a+’);
fwrite($fp, $json);

Coding, Miscellaneous »

[12 Aug 2011 | 20 Comments | ]

When running CLI PHP on windows i got that error:
The program can’t start because php_mbstring.dll is missing from your computer
PHP The program can’t start because dll is missing from your computer. Try reinstalling the program to fix this problem.
And i’ve verified the file is there and the version is correct.

Also another error was:
PHP Warning: PHP Startup: Unable to load dynamic library ‘F:/AppServ\php5\ext\p
hp_exif.dll’ – The specified module could not be found.

Anyway thanks to wez’s solution here, i fixed it.
In php.ini this line:
Was before this one

I switched them and it’s working …

Coding »

[31 Mar 2011 | No Comment | ]

Can be used like this:
<a href=”<?PHP echo get_category_link_by_name(‘my category’); ?>”>My category link</a>
And change “my category” to whatever you want.
Put this in functions.php

function get_category_link_by_name($cat){
//By http://0xA.li
$cat_ID = get_cat_ID($cat);
$cat_link = get_category_link($cat_ID);
$return $cat_link;
print $return;