Skip to content

Instantly share code, notes, and snippets.

View ldong's full-sized avatar
❤️
Love & Peace

Alan Dong ldong

❤️
Love & Peace
  • Sunnyvale, CA
View GitHub Profile
@ldong
ldong / max_fullscreen.md
Created May 14, 2017 06:18
max full screen

Maximize full screen

function toggleFullscreen(e) {
  var d = document, done;
  e = e || d.documentElement;
  '-frsexit ms-FRsExit moz-FRSCancel webkit-FRsExit'.replace(/(\w*)-(f)(r)(s)(\w+)/gi, function(_, p, f, r, s, c) {
    if (!done) {
      s = 'ull' + s + 'creen';
 if (d[p + f + s + 'Element'] && d[c = p + c + 'F' + s]) {
@ldong
ldong / gamma.py
Created April 30, 2017 04:44
Gamma python version
#!/usr/bin/env python
import math
def gamma(a):
# special case
if int(a) == 1:
return 0
ind = (int)(math.floor(math.log(a*1.0)/math.log(2.0)))
first = ind * '1' + '0'
size = ((int)(math.pow(2, (int)(math.floor(math.log(a*1.0)/math.log(2.0))))))

Nginx

Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo.

nginx will load all files in /usr/local/etc/nginx/servers/

  • Tips -
@ldong
ldong / LICENSE.txt
Created April 7, 2017 16:50 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@ldong
ldong / ubuntu_16.04_vagrantfile
Created March 2, 2017 04:20
ubuntu/xenial64
# -*- mode: ruby -*-
# vi: set ft=ruby :
file_location = '~/VMs/src'
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

Question

Why would ember append application.hbs to the document.body?

First paragraph states of Ember Doc

By default, your application will render the application template and attach it to the document's body element.

But why, though?

@ldong
ldong / apache_server.conf.md
Created February 27, 2017 04:16
Apache Server Config
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
 
@ldong
ldong / deepClone.md
Last active February 22, 2017 09:46
deep clone javascript object
function cloneObject(obj) {
  const clone = Object.keys(obj).reduce((acc, prop) => {
  	acc[prop] = obj[prop] === Object(obj[prop]) ? cloneObject(obj[prop]) : obj[prop];
    return acc;
  }, {});

  return clone;
};
@ldong
ldong / deepClone.md
Created February 22, 2017 09:35
deep clone
function cloneObject(obj) {
  const clone = Object.keys(obj).reduce((acc, prop) => {
  	acc[prop] = obj[prop] === Object(obj[prop]) ? cloneObject(obj[prop]) : obj[prop];
    return acc;
  }, {});

  return clone;
};
@ldong
ldong / mysql_notes.md
Created February 21, 2017 06:53
MySQL Notes