Beanstalk delete the job

1. telnet localhost 11300
2. use mytube
3. peek-ready or peek-delayed
4. kick or delete

Running cron job every 5 minutes

1. Go to editor: crontab -e

2. */5 * * * * /usr/bin/curl https://www.natality-dating.com/1/bulkmailer/1 2>/dev/null >/dev/null

3. Check the result: crontab -l

4. Check if cron is running: ps -aef | grep cron

Git changing remote url

1. git remote set-url origin https://username@hostname:port/project.git
2. check the result by typing git remote -v

PHP Laravel Redis caching examples

1. Directly with Redis class
config/app.php

‘providers’ => array(
‘Illuminate\Redis\RedisServiceProvider’,
),
‘aliases’ => array(
‘Redis’ => ‘Illuminate\Support\Facades\Redis’,
),

config/database.php

‘redis’ => array(
‘cluster’ => false,
‘default’ => array(
‘host’ => ‘127.0.0.1’,
‘port’ => 6379,
‘database’ => 0,
),
),

PHP code will look like this
$redis = \Redis::connection();
if ($redis->exists($cacheKey)) {
$results = json_decode($redis->get($cacheKey),true);
}
else {
$results =select_array_from_mysqldb( $dblink );
$redis->set($cacheKey,json_encode($results));
}

2. Through Cache class
config/cache.php

return array(
‘driver’ => ‘redis’,

‘prefix’ => ‘kleidoo’,
);

PHP code will look like this
$minutes = 60;
if (\Cache::has($cacheKey)) {
$results = json_decode(\Cache::get($cacheKey),true);
}
else {
$results =select_array_from_mysqldb( $dblink );
\Cache::put($cacheKey,json_encode($menutags),$minutes);
}

PHP enable debug

error_reporting(-1);
ini_set(‘display_errors’, ‘On’);

PHP SoapClient enable debug

1. Add trace attribute to SoapClient when intialize it.
$soapclient = new SoapClient( $soapurl, array(‘trace’ => 1) );

2. Add the following 2 methods after making a soap call
echo $soapclient->__getLastRequest();
echo $soapclient->__getLastResponse() ;

stdClass or Array ?

The usual approach is

Use objects when returning a defined data structure with fixed branches:

$person
-> name = “John”
-> surname = “Miller”
-> address = “123 Fake St”

Use arrays when returning a list:

“John Miller”
“Peter Miller”
“Josh Swanson”
“Harry Miller”

Use an array of objects when returning a list of structured information:

$person[0]
-> name = “John”
-> surname = “Miller”
-> address = “123 Fake St”

$person[1]
-> name = “Peter”
-> surname = “Miller”
-> address = “345 High St”

Objects are not suitable to hold lists of data, because you always need a key to address them. Arrays can fulfill both functions – hold arbitrary lists, and a data structure.

Therefore, you can use associative arrays over objects for the first and third examples if you want to. I’d say that’s really just a question of style and preference.

how-to get current hostname in javascript

window.location.host or document.location.host : you’ll get sub.domain.com:8080 or sub.domain.com:80
window.location.hostname or document.location.hostname: you’ll get sub.domain.com
window.location.protocol or document.location.protocol: you’ll get http:
window.location.port or document.location.port: you’ll get 8080 or 80
window.location.origin or document.location.origin: you’ll get http://sub.domain.com *

Free DNS Servers List
208.67.220.220
67.138.54.100
207.225.209.66

display parameter

display: block
comment: for example <div> element takes the whole line as 100% width.

display: inline
comment: for example <div> element takes only own length and leave rest of the line to next elements