Skip to content

Instantly share code, notes, and snippets.

How to install and run Headless nightmare.js based scripts in Ubuntu.
Steps:
1. Spin Ubuntu 16.04 x64 server
2. Run: apt-get update
3. Run: apt-get upgrade
4. Run: apt-get install -y libgtk2.0-0 libgconf-2-4 libasound2 libxtst6 libxss1 libnss3 xvfb
5. Install Node.js 6+. See: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
You can then run your script using this command:
@nolanlawson
nolanlawson / protips.js
Last active February 4, 2024 18:06
Promise protips - stuff I wish I had known when I started with Promises
// Promise.all is good for executing many promises at once
Promise.all([
promise1,
promise2
]);
// Promise.resolve is good for wrapping synchronous code
Promise.resolve().then(function () {
if (somethingIsNotRight()) {
throw new Error("I will be rejected asynchronously!");
@marcelofabri
marcelofabri / xopen
Last active July 11, 2016 21:34
Open .xcworkspace file if exists or .xcodeproj otherwise. Useful for CocoaPods users. Found it elsewhere, but I can't find it anymore.
#!/usr/bin/env ruby
require 'shellwords'
proj = Dir['*.xcworkspace'].first
proj = Dir['*.xcodeproj'].first unless proj
if proj
puts "Opening #{proj}"
`open #{proj}`
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"