$ids = DB::table('service')
->select(DB::raw('DISTINCT label_id AS cat_label_id'))
->whereNull('deleted_date')
->lists('cat_label_id');
$ids will be an array.
$ids = DB::table('service')
->select(DB::raw('DISTINCT label_id AS cat_label_id'))
->whereNull('deleted_date')
->lists('cat_label_id');
$ids will be an array.
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^(192\.168\.56\.1|192\.168\.56\.2)$
RewriteCond %{REQUEST_URI} (/login.*|/node.*|/welcome.*) [NC]
RewriteRule ^(.*)$ index.php [F,L]
## | |
## Server-Pool Size Regulation (MPM specific) | |
## | |
# prefork MPM | |
# implements a non-threaded, pre-forking web server (isolating each request) | |
# physical RAM hungry, maxclients is important | |
# StartServers: number of server processes to start | |
# MinSpareServers: minimum number of server processes which are kept spare |
mysql -h<hostname> -u<user> -p<password> <database> < example.sql
gz'ed dumpfile
gunzip < .sql.gz | mysql -h -u -p
use the average aggregate function of a count query:
SELECT AVG (sender_count)
FROM (
SELECT COUNT(sender_mail) AS sender_count
FROM event
) AS event
I can't remember rewrite rules:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.your-domain\.com [NC]
RewriteRule (.*) http://www.your-domain.com/$1 [L]
RewriteCond %{HTTP_HOST} !^www\.other-domain\.com [NC]
RewriteRule (.*) http://www.other-domain.com/$1 [L]
SSH_ENV=$HOME/.ssh/environment | |
# start the ssh-agent | |
function start_agent { | |
echo "Initializing new SSH agent..." | |
# spawn ssh-agent | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" | |
echo succeeded | |
chmod 600 "${SSH_ENV}" | |
. "${SSH_ENV}" > /dev/null |
// DateTime API | |
$dateTime = new DateTime('2014-06-23'); | |
echo $dateTime->format('U'); | |
echo $dateTime->getTimestamp(); | |
// or | |
$dateTime = DateTime::createFromFormat('!d-m-Y', '23-06-2014'); | |
// or IntlDateFormatter API | |
$fmt = new IntlDateFormatter( |
# Forward Proxy | |
<VirtualHost *:80> | |
ServerAdmin admin@localhost | |
RewriteEngine On | |
ProxyPreserveHost On | |
RewriteRule ^/(.*) http://<HOST-OR-IP>/$1 [P] | |
<Proxy *> | |
Order allow,deny | |
Allow from all | |
</Proxy> |
//fork a CLI script from a webserver PHP script using the popen() function | |
//This allows to nicely transfer parameters to the new script instance like this: | |
$bgproc = popen('php "/my/path/my-bckgrnd-proc.php"', 'w'); | |
if($bgproc===false){ | |
die('Could not open bgrnd process'); | |
}else{ | |
// send params through stdin pipe to bgrnd process: | |
$p1 = serialize($param1); | |
$p2 = serialize($param2); | |
$p3 = serialize($param3); |