Looking to duplicate a table into a new table – it is very simple:
CREATE TABLE `high_risk_old` LIKE high_risk; INSERT INTO `high_risk_old` SELECT * FROM `high_risk`;
Looking to duplicate a table into a new table – it is very simple:
CREATE TABLE `high_risk_old` LIKE high_risk; INSERT INTO `high_risk_old` SELECT * FROM `high_risk`;
Here it is, an ad for a front-end developer/designer on Seek.
Since putting up the ad we have received some brillant and some terrible resumes.
This has lead me to think that web developers need some guidelines when they are seeking a new job.
I have been build some background apps recently which need to do a lot of repetitions (think 100,000 times the same task which takes about 0.25 to 1 second to execute, of which most of it is waiting for the remote server to respond). Since these are daily and are not that server intensive it made sense to run them concurrently so instead of taking the good part of the day it just takes a few hours. I noticed on the proc_open page there was a very nice solution by Matou Havlena of havlena.net.
Continue reading “PHP Multi-thread Asynchronous Process Manager”
Basic hashing of passwords is poor. LinkedIn should have expected that one day that their password list would be stolen and when that happened it should have been hashed better so a standard dictionary could not reverse the passwords. Tthe LinkedIn passwords were leaked all over internet and with the help of crowd-sourced hackers the passwords were easily reversed back from SHA-1 hashes substrings to the plain text passwords. With tools like John the Ripper social hackers like Francois Pesce was able to reverse over 2 million LinkedIn passwords.
I found a strange bug/feature in MySQL which means that if you do a select statement using a INT against a VARCHAR column in matches all of the values in the column which do not start with a number. MySQL claim this is a normal.
The other day the new developer in my office wanted to get a directory listing using PHP as he was writting a new plugin for WordPress. To his surprise this is really easy with the glob() function:
<?php foreach (glob("*") as $filename) { echo $filename . 'size ' . filesize($filename) . 'n'; }
Glob allows you to use patterns similar to those when you are using the ls command in Terminal and returns the file list as an array.
Quick tip: if you want to get the HTML for any web page you can use the PHP function file_get_contents(). To see the HTML in your web browser wrap the htmlentities function around the file_get_contents() function.
<?php echo htmlentities(file_get_contents('http://example.com'));
Which returns:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>IANA — Example domains</title> <!-- start common-head --> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="/_css/2008.1/reset-fonts-grids.css" /> <link rel="stylesheet" type="text/css" media="screen" href="/_css/2008.1/screen.css" /> <link rel="stylesheet" type="text/css" media="print" href="/_css/2008.1/print.css" /> <link rel="shortcut icon" type="image/ico" href="/favicon.ico" /> <script type="text/javascript" src="/_js/prototype.js"></script> <script type="text/javascript" src="/_js/corners.js"></script> <script type="text/javascript" src="/_js/common.js"></script> <!-- end common-head --> </head> <body> <!-- start common-bodyhead --> .... <!-- end common-bodytail --> </body> </html>
This is my own opinion of the keys to give you a leg up when creating a new PHP/MySQL site:
With these tools you can get started on your next site in hours.
Today I needed to run a some code that did a lot of heavy lifting and kept having the error below:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 71 bytes) in /Applications/MAMP/htdocs/test_memory.php on line 46
The solution is to override the memory limit set by PHP.ini:
<?php ini_set('memory_limit','64M');
Check out PHP.Net’s ini_set documentation for more details.
Notes:
If you are looking for a fast way to URL shorten with CodeIgniter you are in luck.
Basically you set your routes (application->config->routes.php) $route[‘404_override’] to point to the controller and action which directs shorten URLs
e.g. in you routes file:
$route['404_override']='short_links/retrive';
Then short_links has a function retrive
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Short_links extends CI_Controller { function retrive() { $this->load->model('shorten_urls');//load the model which looks after the URLs $url = $this->uri->segment(1);//get the URL segment e.g. abc redirect($this->shorten_urls->get_url($url)); //lookup the original URL and redirect } }