Skip to content

Instantly share code, notes, and snippets.

@mailightkun
mailightkun / multiFilter.js
Created February 20, 2019 02:09 — forked from jherax/filterArray.js
Filters an array of objects with multiple criteria.
/**
* Filters an array of objects with multiple criteria.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria as the property names
* @return {Array}
*/
function multiFilter(array, filters) {
const filterKeys = Object.keys(filters);
// filters all elements passing the criteria
@mailightkun
mailightkun / my.cnf
Created June 7, 2018 05:28 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on Ubuntu, CentOS etc. servers)
# Optimized my.cnf configuration for MySQL/MariaSQL
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# === Updated May 2018 ===
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have less or more resources available you should adjust accordingly to save CPU,
# RAM and disk I/O usage.
# The settings marked with a specific comment or the word "UPD" after the value
@mailightkun
mailightkun / openssl_encrypt_decrypt.md
Created April 6, 2018 04:44
Replace mcrypt_encrypt with openssl_encrypt

Replace mcrypt_encrypt with openssl_encrypt

If you switch from PHP 5.x to 7.1 you will get the following message:

"Function mcrypt_encrypt() is deprecated"

Now it is the right time to refactor this old function :-)

function encrypt(string $data, string $key, string $method): string
@mailightkun
mailightkun / ubuntu-server-setup-16.04-LAMP.md
Created November 16, 2017 03:28 — forked from Otienoh/ubuntu-server-setup-16.04-LAMP.md
LAMP Server setup for Ubuntu 16.04 on Digital Ocean

Server setup for Ubuntu 16.04 on Digital Ocean

The setup installs the following software:

The setup installs the following software:

  • Apache
  • MySQL
  • PHP
  • Node
@mailightkun
mailightkun / ubuntu-server-setup-16.04.md
Created November 16, 2017 03:28 — forked from marcuslilja/ubuntu-server-setup-16.04.md
Server setup for Ubuntu 16.04 on Digital Ocean

Server setup for Ubuntu 16.04 on Digital Ocean

The setup installs the following software:

  • Nginx
  • MySQL
  • PHP
  • Node
  • Composer
@mailightkun
mailightkun / UpgradeTimestamps.php
Created April 19, 2017 02:26 — forked from wayneashleyberry/UpgradeTimestamps.php
Laravel Artisan command to upgrade timestamp columns for MySQL 5.7 strict mode.
<?php
namespace App\Console\Commands;
use DB;
use Illuminate\Console\Command;
class UpgradeTimestamps extends Command
{
/**
@mailightkun
mailightkun / CronRunCommand.php
Created August 11, 2016 23:58 — forked from sisou/CronRunCommand.php
Cron job command for Laravel 4.2
<?php
# Cron job command for Laravel 4.2
# Inspired by Laravel 5's new upcoming scheduler (https://laravel-news.com/2014/11/laravel-5-scheduler)
#
# Author: Soren Schwert (GitHub: sisou)
#
# Requirements:
# =============
# PHP 5.4
@mailightkun
mailightkun / nginx.default.conf
Created April 22, 2016 14:28 — forked from santoshachari/nginx.default.conf
PHP5.6 and NGINX: Install PHP56-FPM, Nginx & MySQL on EC2 with Amazon Linux AMI
# Install linux update, followed by GCC and Make
sudo yum -y update
sudo yum install -y gcc make
# Install Nginx and php56-FPM
sudo yum install -y nginx php56-fpm
# Install php56 extensions
sudo yum install -y php56-devel php-mysql php56-pdo php56-pear php56-mbstring php56-cli php56-odbc php56-imap php56-gd php56-xml php56-soap
@mailightkun
mailightkun / gist:27a4c24c7b227460b677
Created November 17, 2015 05:07 — forked from ghinda/gist:6036998
local/session storage polyfill (@Rem's version + with support for opera mini)
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@mailightkun
mailightkun / git-commit-csv-export.sh
Created November 17, 2015 05:07 — forked from ghinda/git-commit-csv-export.sh
git csv export of commits in the last month
git log --since='last month' --pretty=format:'%h;%an;%ad;%s' --author='Ionut Colceriu' > ~/log.csv