Categories
Technical

My Cronjob (restart database and apache clean logs cronjob configuration)

Find below cronjob that restart apache server, mysql server and clean httpd logs

 SHELL=/bin/bash
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 MAILTO=root
 HOME=/
 

 # For details see man 4 crontabs
 

 # Example of job definition:
 # .---------------- minute (0 - 59)
 # |  .------------- hour (0 - 23)
 # |  |  .---------- day of month (1 - 31)
 # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
 # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
 # |  |  |  |  |
 # *  *  *  *  * user-name command to be executed
   */30  *  *  *  *       root /etc/init.d/httpd restart > /dev/null 2>&1
   */30  *  *  *  *       root /etc/init.d/mysqld restart > /dev/null 2>&1
   */30  *  *  *  *       root /bin/find  /var/log/httpd/*.log -mtime +7 -exec rm -f {} \; 
Categories
MySql SqLite

SQLITE – update a column from another table

SQLITE – update a column from another table while concatenating a string

UPDATE table1
SET table1.businessOwner =  table1.prenom1UniteLegale || ' ' || table1.nomUniteLegale, 
BusinessNameDavid = table1.denominationUniteLegale ,
BusinessAddressDavid = table1.numeroVoieEtablissement || ' ' || table1.typeVoieEtablissement || ' ' || table1.libelleVoieEtablissement 
from table2 
WHERE table1.siren = table1.siren 
Categories
Laravel MySql

LARAVEL – auto increment a column with mysql – upsert

see example below of an upsert

Polls::updateOrInsert(['business_id'=> $business_id],
    [
        "$vote_value" => DB::raw('$vote_value + 1'),
        'polls_name' => $theBusiness->BUSINESSNAME,
        'source' => env('APP_CODE'),
        'updated_at' => $lastupdated
    ]);
Categories
Laravel SqLite

SQLITE – Auto-increment a column with Laravel

Example : for SQLITE the double quote is critical to make it work

Polls::updateOrInsert(['business_id'=> $business_id],
    [
        "$vote_value" => DB::raw('"$vote_value" + 1'),
        'polls_name' => $theBusiness->BUSINESSNAME,
        'source' => env('APP_CODE'),
        'updated_at' => $lastupdated
    ]);
Categories
General

SQL Table Creation Concept – Practical

 CREATE TABLE api.m2_track_file_submission_to_windsurfer (
 id serial NOT NULL,
 ...
 ...
 ...
 ...
 created_at timestamp(0) NULL,
 updated_at timestamp(0) NULL,
 deleted_at timestamp(0) NULL
 ); 

Categories
Laravel

Laravel Eloquent SQL query compare insensitive string

'ilike' or 'not ilike'
return $query->where('api_call', 'not ilike', '%TEST%');
Categories
Satori Architect

Error:80040419 Satori (SORTING) STO2=2 Satori (Dosort) output MRE1=54 -2147220455 CallDoProcess() failed. (error 80040419) Satori

Error:80040419 Satori (SORTING) STO2=2 Satori (Dosort) output MRE1=54 -2147220455 CallDoProcess() failed. (error 80040419) Satori

Not enough pieces

Categories
General

Mac Tips

defaults write -g InitiaKeyRepeat -int 10
defaults write -g KeyRepeat -int 1

Categories
Continuous Integration/Development Programming

SENIOR MOTTO

  • Is it going to fix something or make it more performant?
  • Can we afford it breaking what’s already working?
  • Does it require rewriting a lot of tests?
  • Do we really need to make that change?

From Mohamed Said – Laravel Team

Categories
javascript

PHP JSON Merge

This code is used to merge given two JSON objects

<?php
$json1 = '{
	"id": "#001",
    "username": "Tom",
    "type": "admin",
    "status": "active"   
}';

$json2 =  '{
    "id": "#002",
    "username": "Jerry",
    "type": "user",
    "status": "Inactive"
}';
$user[] = json_decode($json1,true);
$user[] = json_decode($json2,true);
$json_merge = json_encode($user);
?>

<h4>Given JSON String:</h4> 
<p>
<div>$json1 = <?php echo $json1; ?></div>
<div>$json2 = <?php echo $json2; ?></div>
</p>
<h4>Output:</h4> 
<div><?php echo $json_merge; ?></div>