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
@datchley
datchley / README.md
Last active March 23, 2019 21:00
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 }}
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');
@loveencounterflow
loveencounterflow / benchmarks-raw.coffee
Created February 23, 2020 11:11
JavaScript Performance Benchmarks: Looping with `for` and `yield`
'use strict'
############################################################################################################
log = console.log
warn = console.warn
fn = ( new Intl.NumberFormat 'en-US' ).format
@PaulKinlan
PaulKinlan / detect.js
Created March 5, 2015 16:29
Detect unknown content injection
var detectInjection = function(knownHostsArray) {
var requests = window.performance.getEntriesByType("resource");
var unknownHosts = [];
var knownHosts = {};
var foundHosts = {};
for (var knownHost in knownHostsArray) {
knownHosts[knownHostsArray[knownHost]] = true;
}
@chendo
chendo / _document.js
Last active June 2, 2022 02:54
Server side rendering (SSR) in Next.js with styled-components, styled-jsx, and emotion.
import Document, { Head, Main, NextScript } from 'next/document'
import { renderToString } from 'react-dom/server'
import { extractCritical } from 'emotion-server'
import { ServerStyleSheet } from 'styled-components'
import flush from 'styled-jsx/server'
export default class MyDocument extends Document {
static async getInitialProps(ctx) {
const styledComponentsSheet = new ServerStyleSheet()
@davidgilbertson
davidgilbertson / http2.js
Last active October 9, 2023 06:09
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 = {};
/*!
* jQuery JavaScript Library v2.1.1pre
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
@pbojinov
pbojinov / README.md
Last active December 8, 2023 21:09
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@nrollr
nrollr / MySQL_macOS_Sierra.md
Last active January 31, 2024 14:45
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 :

@CrocoDillon
CrocoDillon / cookies.js
Last active February 11, 2024 22:42
Export your awesome module using AMD, CommonJS, Node.js or just as global.
/*
* Inspiration (well… copy pasting more or less) from:
* https://github.com/ScottHamper/Cookies/blob/0.3.1/src/cookies.js#L127-L140
*
* Thanks Scott!
*/
(function (global) {
'use strict';
var MyModule = function () {