Skip to content

Instantly share code, notes, and snippets.

View futurist's full-sized avatar

James Yang futurist

  • China
View GitHub Profile
@futurist
futurist / open-finder.el
Created April 18, 2016 23:01 — forked from hidsh/open-finder.el
Mac: open folder by Finder from Emacs
(defun open-finder-1 (dir file)
(let ((script
(if file
(concat
"tell application \"Finder\"\n"
" set frontmost to true\n"
" make new Finder window to (POSIX file \"" dir "\")\n"
" select file \"" file "\"\n"
"end tell\n")
(concat
@futurist
futurist / introrx.md
Created June 18, 2016 09:03 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@futurist
futurist / cors.js
Created July 2, 2016 14:14 — forked from balupton/cors.js
Acheiving CORS via a Node HTTP Server
// Create our server
var server;
server = http.createServer(function(req,res){
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
res.setHeader('Access-Control-Allow-Headers', '*');
if ( req.method === 'OPTIONS' ) {
res.writeHead(200);
@futurist
futurist / change_case.el
Created October 22, 2016 07:23 — forked from dbrady/change_case.el
emacs lisp defuns to change the case (camelCase <-> snake_case) of the word under cursor, or an entire region if selected. NOTE: the snake-case defuns do not work, they just camelCase. Ooops.
;; Grateful thanks are given to Brian Marick (@marick) for helping me
;; write these. I got the original idea while reading through
;; http://xahlee.org/emacs/elisp_idioms.html, but couldn't work out
;; the elisp regexes. Brian Marick (@marick) stepped in and helped. He
;; took my tortured and broken camelcase-region and turned it into
;; something that actually worked. I then created
;; camelcase-word-or-region. I then wrote the snakecase versions but I
;; see now that all I did was copy the camelcase defuns over and,
;; meaning to go back and finish them Real Soon Now, forgot all about
;; them. I've had a quick look (2011-02-27) but elisp regexes are

What is Critical Rendering Path

The Critical Rendering Path is the sequence of steps the browser goes through to convert the HTML, CSS and JavaScript into actual pixels on the screen. If we can optimize the critical rendering path, we can make our pages faster.

Constructing the DOM

When you type an URL and hit enter, the browser sends a request to the server. The server returns a response with the HTML to the browser, which somehow needs to convert the markup into something that we can see on the screen.

The browser follows a well defined set of steps and it all starts with processing the HTML and building the DOM.

@futurist
futurist / bongo.sh
Created February 10, 2017 10:08 — forked from smashew/bongo.sh
This one works... Tested
LOADING=false
usage()
{
cat << EOF
usage: $0 [options] dbname
OPTIONS:
-h Show this help.
-l Load instead of export
@futurist
futurist / bongo.sh
Last active February 11, 2018 14:56 — forked from nhoening/bongo.sh
Allowing to pass a query for exporting specific data. Added a LIMIT option to limit the number of returned results. Added a debug switch to see errors.
#!/bin/bash
LOADING=false
DEBUG=/dev/null
usage()
{
cat << EOF
usage: $0 [options] <DBNAME>
@futurist
futurist / back_forward.js
Created March 2, 2017 12:25 — forked from sstephenson/back_forward.js
How to detect whether a hash change came from the Back or Forward button
var detectBackOrForward = function(onBack, onForward) {
hashHistory = [window.location.hash];
historyLength = window.history.length;
return function() {
var hash = window.location.hash, length = window.history.length;
if (hashHistory.length && historyLength == length) {
if (hashHistory[hashHistory.length - 2] == hash) {
hashHistory = hashHistory.slice(0, -1);
onBack();
@futurist
futurist / gist:0ba49fe408f6d345e220421e6d24955e
Last active March 13, 2017 03:12
Remove Sendmail from Ubuntu

Remove Sendmail from Ubuntu

This should help you completely uninstall Sendmail and all that comes with it.

First, stop the service (assuming it's running).

sudo /etc/init.d/sendmail stop

Uninstall sendmail and sendmail-bin

@futurist
futurist / headless.md
Created June 29, 2017 05:33 — forked from addyosmani/headless.md
So, you want to run Chrome headless.

Update May 2017

Eric Bidelman has documented some of the common workflows possible with headless Chrome over in https://developers.google.com/web/updates/2017/04/headless-chrome.

Update

If you're looking at this in 2016 and beyond, I strongly recommend investigating real headless Chrome: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md

Windows and Mac users might find using Justin Ribeiro's Docker setup useful here while full support for these platforms is being worked out.