Skip to content

Instantly share code, notes, and snippets.

@yassine-khachlek
yassine-khachlek / PostgreSQL_timestamp_type_precision_limit.txt
Last active January 22, 2023 20:09
CREATE TABLE mytable (id SERIAL PRIMARY KEY, created_at TIMESTAMP(9) WITH TIME ZONE NOT NULL DEFAULT NOW());
WARNING: TIMESTAMP(9) WITH TIME ZONE precision reduced to maximum allowed, 6
LINE 3: created_at TIMESTAMP(9) WITH TIME ZONE NOT NULL DEFAULT ...
^
WARNING: TIMESTAMP(9) WITH TIME ZONE precision reduced to maximum allowed, 6
CREATE TABLE
Query returned successfully in 42 msec.
[
{
"name": "Worldwide",
"placeType": {
"code": 19,
"name": "Supername"
},
"url": "http:\/\/where.yahooapis.com\/v1\/place\/1",
"parentid": 0,
"country": "",
Obtain a wildcard certificate using Let's Encrypt's new ACMEv2 server
certbot -d *.example.com --preferred-challenges=dns --manual certonly
docker update --restart=no
@yassine-khachlek
yassine-khachlek / nginx.conf
Created October 11, 2018 05:21
/etc/nginx/conf.d
server {
listen 80;
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
server {
listen 80 default_server;
server_name *.example.com;
...
@yassine-khachlek
yassine-khachlek / .htaccess
Created October 10, 2018 17:28
.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
$query = "INSERT INTO table_name (" . implode(',', $columns) . ") VALUES " 
. implode(
    ',',
    array_map(function($data) {
        return "(" . implode(",", array_fill(0, count($data) , '?')) . ")";
    }, $datas)
)
. " ON DUPLICATE KEY UPDATE "
. implode(
function flatten_multidimensional_array($array, $parentKey = NULL, $output = NULL )
{
$parentKey = isset($parentKey) ? $parentKey.'_' : '';
$output = isset($output) ? $output : array();
foreach ($array as $key => $value)
{
switch (gettype($value))
{
case "string":
@yassine-khachlek
yassine-khachlek / gist:adaac618edf00188b2d3
Created March 11, 2016 14:15 — forked from sumardi/gist:3936651
Laravel nginx config
server {
listen 80;
server_name example.com;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
root /var/www/example.com;
index index.php;
var os = require('os');
function loadAvgCpus(){
var cpus = os.cpus();
var total=0;
var idle =0;
for (var i = 0; i<cpus.length ; i++) {