This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// pdo | |
$params = array(':username' => 'John', ':email' => $mail ); | |
$pdo->prepare(' | |
SELECT * FROM users | |
WHERE username = :username | |
AND email = :email'); | |
$pdo->execute($params); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// pdo | |
$pdo = new PDO("mysql:host=localhost;dbname=database", "username", "password"); | |
// mysqli, oo way | |
$mysqli = new mysqli('localhost', 'username', 'password', 'database'); | |
// mysqli, procedural | |
$mysqli = mysqli_connect('localhost', 'username', 'password', 'database'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data:text/html, <style%20type%3D"text%2Fcss">%23e%7Bposition%3Aabsolute%3Btop%3A0%3Bright%3A0%3Bbottom%3A0%3Bleft%3A0%3B%7D<%2Fstyle><div%20id%3D"e"><%2Fdiv><script%20src%3D"http%3A%2F%2Fd1n0x3qji82z53.cloudfront.net%2Fsrc-min-noconflict%2Face.js"%20type%3D"text%2Fjavascript"%20charset%3D"utf-8"><%2Fscript><script>var%20e%3Dace.edit("e")%3Be.setTheme("ace%2Ftheme%2Fmonokai")%3Be.getSession().setMode("ace%2Fmode%2Fphp")%3B<%2Fscript> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class InvalidIpFormatException extends \InvalidArgumentException {} | |
class InvalidIpRangeException extends \InvalidArgumentException {} | |
class IpV4Validator | |
{ | |
private $_ip; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// custom error handler to suppress errors | |
function exception_error_handler($errno, $errstr, $errfile, $errline ) { | |
return ''; | |
} | |
set_error_handler('exception_error_handler'); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class IpV4Validator | |
{ | |
private $_ip; | |
public function __construct( $ipAddr ) { | |
$this->_ip = $ipAddr; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Duck typing | |
class Car | |
{ | |
public function run() { | |
return 'car is running'; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import subprocess | |
devs = {} | |
devs['jayzeng'] = 'jayzeng' | |
devs['davidremm'] = 'davidremm' | |
devs['beau'] = 'beauhoyt' | |
devs['yanmei'] = 'wyiemay' | |
devs['niek'] = 'nieksand' | |
devs['lee'] = 'leehasoffers' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/telnet' | |
cache_dump_limit = 100 | |
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3) | |
slab_ids = [] | |
localhost.cmd("String" => "stats items", "Match" => /^END/) do |c| | |
matches = c.scan(/STAT items:(\d+):/) | |
slab_ids = matches.flatten.uniq | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* SplClassLoader implementation that implements the technical interoperability | |
* standards for PHP 5.3 namespaces and class names. | |
* | |
* http://groups.google.com/group/php-standards/web/final-proposal | |
* | |
* // Example which loads classes for the Doctrine Common package in the | |
* // Doctrine\Common namespace. |