Skip to content

Instantly share code, notes, and snippets.

View laphilosophia's full-sized avatar
🖖
live long and prosper

Erdem Arslan laphilosophia

🖖
live long and prosper
View GitHub Profile
@laphilosophia
laphilosophia / sass-icon-list.scss
Last active October 26, 2017 14:53
Sass each sample
@mixin size($width, $height: $width) {
width: $width;
height: $height;
}
@mixin display($display, $align: false) {
display: $display;
@if $align {
vertical-align: $align;
}
@laphilosophia
laphilosophia / tips.js
Created October 30, 2017 10:35
Performance Tips.
// Browser loading time
let calc = () => {
const domint = window.performance.timing.domInteractive;
const reqstr = window.performance.timing.requestStart;
return domint - reqstr;
}
// Resource timing
let perf = () => {
return window.performance.getEntriesByType('resource') || [];
@laphilosophia
laphilosophia / content_editable.js
Created January 30, 2018 11:14 — forked from rafaelsq/content_editable.js
Vue ContentEditable
export default {
name: 'content_editable',
template: '<div ref="element" v-html="text"></div>',
props: {
text: [String],
customTag: [String],
},
mounted: function() {
let newElement = document.createElement(this.customTag || 'div')
@laphilosophia
laphilosophia / vuex-state-reset.js
Last active February 27, 2018 06:35
vuex state reset
export const RESET_STATES = 'resetStates'
function resetState (state, moduleState) {
const mState = state[moduleState]
if (mState.initState && typeof mState.initState === 'function') {
const initState = mState.initState()
for (const key in initState) {
mState[key] = initState[key]
@laphilosophia
laphilosophia / MySQL_macOS_Sierra.md
Created April 2, 2018 08:51 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

@laphilosophia
laphilosophia / IndexedDB101.js
Created July 24, 2018 14:20 — forked from JamesMessinger/IndexedDB101.js
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
@laphilosophia
laphilosophia / cookies.js
Created October 4, 2018 17:09 — forked from arozwalak/cookies.js
Javascript: Cookies set/get/delete
function getCookie(c_name) {
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1) {
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1) {
c_value = null;
}
else {
@laphilosophia
laphilosophia / message-api.js
Created November 5, 2018 12:09
Message API
// Instantiate the Channel
const channel = new MessageChannel()
// Sending Messages Through the Channel
const data = {
color: 'blue',
title: 'Lorem ipsum dolor',
number: '000998909874564781',
content: 'Lorem ipsum dolor sit amet. Consectetur adicisping alet.',
}
@laphilosophia
laphilosophia / cache-api.js
Created November 5, 2018 12:09
Cache API
// https://alligator.io/js/cache-api/
if ('caches' in window) {
const cacheName = 'sample-caches'
const url = '/resource'
caches.open(cacheName).then(cache => {
return console.log(cache)
})
@laphilosophia
laphilosophia / currying.js
Created November 5, 2018 12:10
Javascript Currying and Partial Application Examples
// Javascript Currying and Partial Application Examples
const multiplier = x => {
return (y, z) => {
return z * y * z
}
}
const mult = multiplier(10) // x
mult(20, 30) // y, z