Skip to content

Instantly share code, notes, and snippets.

@designeng
designeng / gist:feb653aad8442d3969e34fd929766c87
Created April 14, 2018 21:14 — forked from chadhutchins/gist:1440602
Tarjan's strongly connected components algorithm in Javascript - followed pseudocode from http://en.wikipedia.org/wiki/Tarjan%E2%80%99s_strongly_connected_components_algorithm
window.onload = function() {
var v0 = new Vertex("0");
var v1 = new Vertex("1");
var v2 = new Vertex("2");
var v3 = new Vertex("3");
var v4 = new Vertex("4");
var v5 = new Vertex("5");
var v6 = new Vertex("6");
var v7 = new Vertex("7");
@designeng
designeng / gist:b6610ff59ce36cef9dd919f416c73348
Created April 14, 2018 21:14 — forked from chadhutchins/gist:1440602
Tarjan's strongly connected components algorithm in Javascript - followed pseudocode from http://en.wikipedia.org/wiki/Tarjan%E2%80%99s_strongly_connected_components_algorithm
window.onload = function() {
var v0 = new Vertex("0");
var v1 = new Vertex("1");
var v2 = new Vertex("2");
var v3 = new Vertex("3");
var v4 = new Vertex("4");
var v5 = new Vertex("5");
var v6 = new Vertex("6");
var v7 = new Vertex("7");
@designeng
designeng / Gulpfile.js
Created July 23, 2019 13:22 — forked from webdesserts/Gulpfile.js
Automatically reload your node.js app on file change with Gulp (https://github.com/wearefractal/gulp).
// NOTE: I previously suggested doing this through Grunt, but had plenty of problems with
// my set up. Grunt did some weird things with scope, and I ended up using nodemon. This
// setup is now using Gulp. It works exactly how I expect it to and is WAY more concise.
var gulp = require('gulp'),
spawn = require('child_process').spawn,
node;
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
@designeng
designeng / hidden-classes-in-js-and-inline-caching.md
Created February 22, 2020 19:52 — forked from twokul/hidden-classes-in-js-and-inline-caching.md
Hidden classes in JavaScript and Inline Caching

Hidden classes in JavaScript and Inline Caching

Knowing how internals work is always a good. Pretty much for everything. Cars, trains, computers, you name it. It gives you an insight on what happens under the hood. You also act/react differently based on this knowledge.

As you might have guessed, it’s also true for web development. Knowledge of CSS transitions allows you to achieve better performance and not to use JavaScript in most cases. Knowledge of V8 internals allows you to write more performant JavaScript code. So let’s talk about V8 a little.

A little about V8

V8 is a JavaScript engine built by Google. Firefox built SpiderMonkey, Opera built Carakan and Microsoft built Chakra. One very important difference between V8 and other JavaScript engines is that V8 doesn’t generate any intermediate code. It compiles JavaScr

@designeng
designeng / gist:660d298d706e7750a86e4d219f20bcee
Created September 10, 2020 08:52
Docker remove stopped containers & dangling images
# Remove all stopped containers:
docker rm $(docker ps -a -q)
# Remove all dangling Docker images:
docker rmi $(docker images -f "dangling=true" -q)
@designeng
designeng / blueGreenDeployment.js
Created September 22, 2020 18:08 — forked from brandonros/blueGreenDeployment.js
node.js + nginx + PM2 rolling release/blue green deployments (zero downtime)
const Promise = require('bluebird');
const fs = require('fs');
const execa = require('execa');
class BlueGreenDeployment {
constructor({appName, blueProxyPassPattern, greenProxyPassPattern, nginxConfigFile}) {
this.appName = appName;
this.blueProxyPassPattern = blueProxyPassPattern;
this.greenProxyPassPattern = greenProxyPassPattern;
this.nginxConfigFile = nginxConfigFile;
@designeng
designeng / MANUAL.md
Created January 28, 2021 12:27 — forked from kimyvgy/MANUAL.md
Deploy nodejs app with gitlab.com and pm2

Deploy nodejs app with gitlab.com and pm2

This manual is about setting up an automatic deploy workflow using nodejs, PM2, nginx and GitLab CI. It is tested on:

  • Target server: Ubuntu 16.04 x64. This is suitable for Ubuntu 14.x.
  • Windows 10 on my PC to work.
@designeng
designeng / parse_gist.js
Created September 20, 2021 21:33 — forked from tchittick/parse_gist.js
Recursion through a Cheerio.js object and writing to .CSV
/*An object created to parse through a large number of HTML
blocks quickly. Used with cheerio.js. Begin via:
parse.run($('some-div')[0])
*/
var fs = require('fs'),
cheerio = require('cheerio');
var Parse = function(block) {
@designeng
designeng / Form.vue
Last active November 29, 2021 08:18
Emit event on selector option click
<!-- parent form component -->
<template>
<form>
<FormSelector
:options="users"
:selected="currentUser"
@change="onUserChange($event)"
/>
</form>
@designeng
designeng / git-cheat-sheet.md
Created December 22, 2021 16:38
Git Cheat Sheet

Git Cheat Sheet

Although there are enough resources on the web about Git, I will keep this one for my own reference. Minimal Git version required 1.7.2.

TOC