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 | |
/** | |
* SQL base class, extends MySQLi | |
* | |
*/ | |
class Sql extends MySQLi{ | |
/** | |
* MySQLi __construct override with autoconnect | |
* | |
* @return void |
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
SELECT SUM(TIME_TO_SEC(TIMEDIFF(`to`,`from`))) as `spent` FROM `intervals` GROUP BY `id`; |
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
exec('/sbin/udevadm info --query=property --name=sda',$arr,$out); | |
$dopts = array(); | |
foreach($arr as $item){ | |
$parts = explode('=',$item); | |
$dopts[$parts[0]] = $parts[1]; | |
} | |
print_r($dopts); |
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/bash | |
if [ -z "$1" ]; then | |
echo "No start revision" | |
exit 1; | |
fi | |
if [ -z "$2" ]; then | |
echo "No end revision" | |
exit 1; | |
fi |
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
#!/usr/bin/php | |
<?php | |
function progress($i, $total, $label = null, $end=null){ | |
$percent = ceil(($i / $total) * 100); | |
$barSize = ceil($percent/2); | |
$blankSize = 50 - $barSize; | |
if(($blankSize + $barSize) < 50){ | |
$blankSize += (50 - ($blankSize + $barSize)); | |
} |
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/bash | |
echo "Source database name:" | |
read sourceDb | |
if [ -z "${sourceDb-unset}" ] | |
then | |
echo "Your mission, should you choose to accept it is to enter a source database name..." | |
exit 1 | |
fi |
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
## Editor>File and Code Templates>Code>PHP Setter Method | |
#set($typeHintText = "$TYPE_HINT ") | |
## First we check against a blacklist of primitive and other common types used in documentation. | |
#set($nonTypeHintableTypes = ["", "string", "int", "mixed", "number", "void", "object", "real", "double", "float", "resource", "null", "bool", "boolean"]) | |
#foreach($nonTypeHintableType in $nonTypeHintableTypes) | |
#if ($nonTypeHintableType == $TYPE_HINT) | |
#set($typeHintText = "") | |
#end | |
#end | |
## Make sure the type hint actually looks like a legal php class name(permitting namespaces too) for future proofing reasons. |
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 | |
/** | |
* I would rather solve this problem by having a Entity, a dumb business model that contains | |
* all the data, is dumb (yep), has no logic and represents a data type. | |
* | |
* Populate it once and reuse the type where applicable, as it will give many advantages against | |
* having to juggle around bazillion of separate variables. | |
* | |
* a) your business logic and data will be clearly separated - SOC; | |
* b) KISS DRY; |
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
namespace Hello.World | |
import Iterator | |
import List | |
import LinkedList as BaseList | |
import Map | |
import OtherInterface | |
Main | |
const EXCL_MARK is '!' |
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
var inputUsername | |
var inputPassword | |
user = retrieve from storage with matching inputUsername | |
if user not exists | |
return 'No matching user' | |
if user.password not match hash(inputPassword) | |
return 'No matching user' |
OlderNewer