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
try { | |
$category->delete(); | |
} | |
catch (\Illuminate\Database\QueryException $e) { | |
if($e->getCode() == "23000"){ //23000 is sql code for integrity constraint violation | |
// return error to user here | |
} | |
} |
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
1. Add dynamic css, js | |
https://github.com/ericf/express-handlebars/issues/15 | |
https://stackoverflow.com/questions/25300017/how-to-ensure-the-javascript-is-at-the-bottom-of-the-code-in-express-handlebars |
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
Generate ssh in web server | |
go to /var/www | |
sudo -u www-data ssh-keygen | |
sudo cat .ssh/id_rsa.pub | |
set this in gitlab deployment keys | |
sudo -u www-data mkdir xxxxxx |
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
https://8degreethemes.com/wordpress-themes/ | |
https://www.navthemes.com/free-wordpress-theme/constra/ | |
http://demo.navthemes.com/?demo=plain-blog-theme | |
http://demo.navthemes.com/?demo=truewest-free-multipurpose-wordpress-theme&c=rsOSrXFBK | |
http://demo.mysterythemes.com/owner/ |
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
Format date time using Carbon | |
\Carbon\Carbon::createFromFormat($from, $value)->format($to); | |
\Carbon\Carbon::createFromFormat('Y-m-d H:i:s', '2017-12-10 01:00:00')->format('d/m/Y H:i') | |
Validate & format Carbon date | |
if (! function_exists('carbon_date_or_null_if_zero')) { | |
function convert_datetime_to_carbon($value, $from = 'Y-m-d H:i:s', $to = 'd/m/Y H:i') | |
{ | |
if(empty($value)){ | |
return null; |
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
LOAD DATA LOCAL INFILE "C:/Users/xxx/e7849261fe2785926565f6c9c4dea6e957c3c837.csv" | |
INTO TABLE contacts | |
FIELDS TERMINATED BY ',' | |
ENCLOSED BY '"' | |
LINES TERMINATED BY '\n' | |
IGNORE 1 ROWS |
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
Manage Security | |
1.Allow HTTP Service theough firewall | |
Open Predefined Service | |
https://www.rootusers.com/how-to-open-a-port-in-centos-7-with-firewalld/ | |
2. Change SSH Port | |
https://www.globo.tech/learning-center/change-ssh-port-centos-7/ | |
3. Disable Root Login | |
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-centos-7 |
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
require_once( 'wp-load.php' ); | |
global $wpdb; | |
$sql_1 = "DELETE FROM ".$wpdb->prefix."term_relationships WHERE object_id IN (SELECT ID FROM ".$wpdb->prefix."posts WHERE post_type = 'product');"; | |
$sql_2 = "DELETE FROM ".$wpdb->prefix."postmeta WHERE post_id IN (SELECT ID FROM ".$wpdb->prefix."posts WHERE post_type = 'product');"; | |
$sql_3 = "DELETE FROM ".$wpdb->prefix."posts WHERE post_type = 'product';"; | |
$sql_4 = "DELETE relations.*, taxes.*, terms.* | |
FROM ".$wpdb->prefix."term_relationships AS relations |
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
https://htmlpdfapi.com/blog/free_html5_invoice_templates | |
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
use Symfony\Component\HttpFoundation\StreamedResponse; | |
$response = new StreamedResponse(function() use ($request, $data) { | |
while (true) { | |
echo 'data: ' . json_encode(['data' => $data]) . "\n\n"; | |
ob_flush(); | |
flush(); | |
usleep(10000000); | |
} | |
}); |