Skip to content

Instantly share code, notes, and snippets.

Yassine Khachlek yassine-khachlek

Block or report user

Report or block yassine-khachlek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:bb40033471aee7c2279494044fb71fe1
Obtain a wildcard certificate using Let's Encrypt's new ACMEv2 server
certbot -d *.example.com --preferred-challenges=dns --manual certonly
View nginx.conf
server {
listen 80;
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
server {
listen 80 default_server;
server_name *.example.com;
...
View .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]
View Laravel MySQL INSERT ON DUPLICATE KEY UPDATE.md
$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(
View Flatten a multidimensional array
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":
View gist:adaac618edf00188b2d3
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;
View cpu.js
var os = require('os');
function loadAvgCpus(){
var cpus = os.cpus();
var total=0;
var idle =0;
for (var i = 0; i<cpus.length ; i++) {
@yassine-khachlek
yassine-khachlek / gist:671991bb95e5cb432130
Created Apr 17, 2015
Smooth Scrolling To Internal Links With jQuery
View gist:671991bb95e5cb432130
$(document).ready(function(){
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash;
var $target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top
}, 900, 'swing', function () {
You can’t perform that action at this time.