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
var gulp = require('gulp');
var browserify = require('browserify');
var notify = require('gulp-notify');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
var plumber = require('gulp-plumber');
var less = require('gulp-less');
var csso = require('gulp-csso');
var watch = require('gulp-watch');
var envify = require('envify');
@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 / 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 / README.md
Created November 6, 2018 08:30 — forked from datchley/README.md
Micro templating library for javascript

Micro-Template: README.md

Valid template expressions:

  • expressions can reference any property on the passed in context, including nested properties and indexed access to array properties.
     {{ name }}
 {{ obj.name }}
@laphilosophia
laphilosophia / what-forces-layout.md
Created February 15, 2019 07:20 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@laphilosophia
laphilosophia / js-turkish-to-english.js
Created February 25, 2019 11:36 — forked from enginkartal/js-turkish-to-english.js
Javascript Turkish character to english characters change
String.prototype.turkishtoEnglish = function () {
return this.replace('Ğ','g')
.replace('Ü','u')
.replace('Ş','s')
.replace('I','i')
.replace('İ','i')
.replace('Ö','o')
.replace('Ç','c')
.replace('ğ','g')
.replace('ü','u')
@laphilosophia
laphilosophia / axios.js
Created November 6, 2019 19:57 — forked from wooooodward/axios.js
Axios plugin example with request interceptor that adds JWT token to the auth header and 401 response interceptor to refresh token
import Vue from 'vue'
import axios from 'axios'
import store from '../store'
import { TokenService } from '../services/storage.service'
// Full config: https://github.com/axios/axios#request-config
let config = {
baseURL:
process.env.baseURL ||
@laphilosophia
laphilosophia / http2.js
Created November 26, 2019 21:06 — forked from davidgilbertson/http2.js
HTTP2 server with compression and caching
const http2 = require('http2');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const brotli = require('brotli'); // npm package
const PORT = 3032;
const BROTLI_QUALITY = 11; // slow, but we're caching so who cares
const STATIC_DIRECTORY = path.resolve(__dirname, '../dist/');
const cache = {};