Skip to content

Instantly share code, notes, and snippets.

@6ui11em
6ui11em / array_duplicates.js
Created April 20, 2018 07:18
Javascript remove duplicates from array #javascript #array
var data = [
{
name: 'Kyle',
occupation: 'Fashion Designer'
},
{
name: 'Liza',
occupation: 'Web Developer'
},
{
@6ui11em
6ui11em / migration.sh
Last active May 31, 2018 09:54
Laravel migratin, model and controller command #laravel #migration #controller #model #artisan #command
php artisan make:model Todo -mcr
php artisan migrate
@6ui11em
6ui11em / matchmedia.js
Created May 8, 2018 09:36
Magento 2 responsive javascript #magento2 #javascript #responsive #matchmedia
define([
'jquery',
'matchMedia',
'domReady!'
], function ($, mediaCheck) {
'use strict';
/*...*/
mediaCheck({
media: '(min-width: 768px)',
// Switch to Desktop Version
@6ui11em
6ui11em / git_add_commit_all.sh
Created May 11, 2018 22:24
Git add & commit all changes #git #commit
git add -A && git commit -m "Your Message"
@6ui11em
6ui11em / m2_install_command.sh
Created May 11, 2018 22:41
Magento 2 install command #magento2 #install #command
php bin/magento setup:install --base-url={base_url} \
--db-host=localhost --db-name={db_name} --db-user={db_username} --db-password={db_password} \
--admin-firstname={name} --admin-lastname={lastname} --admin-email={email} \
--admin-user=admin --admin-password={admin_pass} --language=es_ES \
--currency=EUR --timezone=Europe/Madrid --use-rewrites=1
@6ui11em
6ui11em / input_date_support_check.js
Created May 23, 2018 17:14
Javascript check input date browser supports #javascript #js #vanilla #data #browser
var isDateSupported = function () {
var input = document.createElement('input');
var value = 'a';
input.setAttribute('type', 'date');
input.setAttribute('value', value);
return (input.value !== value);
};
if (isDateSupported()) {
// Browser native date pickers are supported!
@6ui11em
6ui11em / force_unlock_tables.sql
Created May 29, 2018 11:39
MySQL force unlock tables. #mysql
mysql -u your_user -p
mysql> show open tables where in_use>0;
mysql> show processlist;
mysql> kill put_process_id_here;
@6ui11em
6ui11em / allow_invalid_dates.sql
Created May 29, 2018 14:28
MySQL allow invalid dates. #mysql #date
SET SQL_MODE='ALLOW_INVALID_DATES';
@6ui11em
6ui11em / shuffle_array.js
Created June 14, 2018 09:08
Javascript shuffle array. #javascript #js #shuffle #array
/**
* Randomly shuffle an array
* https://stackoverflow.com/a/2450976/1293256
* @param {Array} array The array to shuffle
* @return {String} The first item in the shuffled array
*/
var shuffle = function (array) {
var currentIndex = array.length;
var temporaryValue, randomIndex;
@6ui11em
6ui11em / is_out_viewport.js
Created June 18, 2018 20:37
Javascritp check if element is outside the viewport #javascript #js #ouside #viewport
/*!
* Check if an element is out of the viewport
* (c) 2018 Chris Ferdinandi, MIT License, https://gomakethings.com
* @param {Node} elem The element to check
* @return {Object} A set of booleans for each side of the element
*/
var isOutOfViewport = function (elem) {
// Get element's bounding
var bounding = elem.getBoundingClientRect();