This file contains 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
DROP PROCEDURE IF EXISTS pivot_user_preferences; | |
DELIMITER $$ | |
CREATE PROCEDURE pivot_user_preferences(IN user_id INT) | |
BEGIN | |
DECLARE done INT DEFAULT FALSE; | |
DECLARE definition_label CHAR(255); | |
DECLARE label_cursor CURSOR FOR SELECT DISTINCT label FROM example_db.user_preferences; | |
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; |
This file contains 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 | |
function errorAndDie($message) { | |
echo $message . PHP_EOL; | |
die(1); | |
} | |
$url = 'https://api.github.com/user/starred'; | |
do { |
This file contains 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 | |
function date_iso($format, $timestamp = null) | |
{ | |
if ($timestamp === null) { | |
$timestamp = time(); | |
} | |
$convert = array( | |
'a' => 'A' , 'B' => 'B', 'D' => 'z', 'ddd' => 't', 'dd' => 'd', 'd' => 'j', |
This file contains 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
#!/bin/sh | |
# Usage: convert_assertions.sh file1 file2 ... | |
perl -i -p \ | |
-e 's/assertEquals?/assertEquals/g;' \ | |
-e 's/assertNotEquals?/assertNotEquals/g;' \ | |
-e 's/assertPattern/assertRegExp/g;' \ | |
-e 's/assertIdentical/assertSame/g;' \ | |
-e 's/assertNotIdentical/assertNotSame/g;' \ | |
-e 's/assertNoPattern/assertNotRegExp/g;' \ | |
-e 's/assertReference/assertSame/g;' \ |
This file contains 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
OPTIONS="--quiet -f /etc/mongod.conf" |
This file contains 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 | |
defined('TIDYDIR_EXTENSION') || define('TIDYDIR_EXTENSION', 'html'); | |
function tidyDir($directory) { | |
$htmlFiles = glob($directory.DIRECTORY_SEPARATOR.'*.'.TIDYDIR_EXTENSION); | |
$filenameRegEx = '#^(.+?)\.([^\.]+?)$#'; | |
$htmlTidy = new tidy(); | |
foreach ($htmlFiles as $entry) { | |
if (preg_match($filenameRegEx, $entry, $matches)) { | |
$filename = $matches[1]; | |
$extension = $matches[2]; |
This file contains 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 | |
$myConn = new PDO( | |
'mysql:host=localhost;dbname=dbname', | |
'username', | |
'password' | |
); | |
$myConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$multiSqlStatement = ' | |
INSERT INTO users (username) VALUES (:username); |
NewerOlder