Skip to content

Instantly share code, notes, and snippets.

View IftiMahmud's full-sized avatar

Ifti Mahmud IftiMahmud

View GitHub Profile
<?php
//Bad Email...
$badEmail = "bad@email";
//Run the email through an email validation filter.
if( !filter_var($badEmail, FILTER_VALIDATE_EMAIL) ){
echo "Email is no good.";
}else{
echo "Nice email.";
}
<?php
// basic email validation, needs to be updated to support new longer domains
$email = '[email protected]';
$regex = "/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/i";
$valid = preg_match( $regex, $email ) ? 'yes' : 'no';
?>
<strong>Email:</strong> <?php echo $email ?><br />
<strong>Valid:</strong> <?php echo $valid ?>
<?php
#!/usr/bin/env php
//usage: php envato-screenshots-downloader.php /path/to/save/screenshots http://url/to/screenshots/page
set_time_limit(0);
$dir = $argv[1];
$source = $argv[2];
print_r($argv);
mkdir ($dir);
$src = file_get_contents($source);
$pattern = '/src="(https:\/\/0.s3[a-zA-Z0-9_\-\.\/%]+)"/i';

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@IftiMahmud
IftiMahmud / http_pool.php
Last active August 29, 2015 14:27 — forked from phpfour/http_pool.php
Concurrent requests using pecl_http
<?php
$endpoint = "http://api.someservice.com";
$userId = 101;
$urls = array(
$endpoint . '/profile/' . $userId,
$endpoint . '/orderHistory/' . $userId,
$endpoint . '/currentBalance/' . $userId
);