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
SELECT | |
(CASE | |
WHEN i.income < 5000 THEN '- £5000' | |
WHEN i.income BETWEEN 5000 AND 20000 THEN '£5,000 - £20,000' | |
WHEN i.income BETWEEN 20000 AND 30000 THEN '£20,000 - £30,000' | |
WHEN i.income BETWEEN 30000 AND 50000 THEN '£30,000 - £50,000' | |
WHEN i.income > 50000 THEN '+ £5000' | |
ELSE 'other' | |
END) AS income, | |
COUNT(*) AS users |
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
// Show the details of installed software, in this instance, Firefox | |
sudo apt-cache show firefox | |
sudo apt-cache show apache2 | |
// Change the name of a file in a directory, using sudo because the directory is www | |
sudo mv alan_test.tx alan.txt | |
// Switch to root user |
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 | |
if( strpos( $_SERVER['REQUEST_URI'], 'my-url' ) !== false ) { | |
// Do something | |
} |
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 | |
// Define postcode | |
$postcode = "BA6 5TY"; | |
// Isolate first two characters of the postcode and replace any integer with nothing | |
$postcode_area = preg_replace("/[0-9]/","",substr($postcode, 0, 2)); |
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
SELECT date1, date2, date3 | |
FROM dates AS d | |
WHERE GREATEST(IFNULL(d.date1,MAKEDATE(2099,365)), | |
IFNULL(d.date2,MAKEDATE(2099,365)), | |
IFNULL(d.date3,MAKEDATE(2099,365))) <= '2013-06-03 16:08:46' | |
AND | |
LEAST(IFNULL(d.date1,MAKEDATE(1900,365)), | |
IFNULL(d.date2,MAKEDATE(1900,365)), | |
IFNULL(d.date3,MAKEDATE(1900,365))) >= '2008-04-01 16:08:46' |
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 | |
// Function to walk through a multidimensional array and remove any successive duplicates based on an index | |
function stripDuplicateHeader(&$stripArray, $index){ // Pass a reference of the array to be processed and the index to check | |
$newArr = array(); // Create an array in which to populate the processed arrays | |
foreach (array_reverse($stripArray) as $val) { // walk through the array to be processed backwards | |
$newArr[$val[$index]] = $val; //populate | |
} | |
$stripArray = array_reverse(array_values($newArr)); // remove duplicates | |
return $stripArray; // Return array | |
} |
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 | |
$dbh = dbconnect(); // open db conn | |
$tblupdatedetailsql = array(); // define $tblupdatedetailsql array | |
foreach ($adGroups as $adGroup) { // populate new sql array using content array | |
$tblupdatedetailsql[] = '('.$tblupdateid.', 0, "'.mysql_real_escape_string($adGroup->name).'")'; | |
} | |
// insert in the db using the implode function and the array | |
$insert = "INSERT INTO tbl (id,type,desc) VALUES".implode(',', $tblupdatedetailsql); | |
$statement = $dbh->prepare($insert); //prepare |
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 | |
//Indexed arrays without key | |
$array = array("foo", "bar", "hallo", "world"); | |
var_dump($array); | |
/* | |
Will output the following: |
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
a { | |
color: #A32713; | |
text-decoration: none; | |
-webkit-transition: color .4s; | |
-moz-transition: color .4s; | |
-ms-transition: color .4s; | |
-o-transition: color .4s; | |
transition: color .4s; | |
} |
NewerOlder