A simple command line script to grab screenshots of a URL in multiple screen widths (desktop, tablet, mobile, or Twitter Bootstrap breakpoints) using PhantomJS. Useful for quickly generating images of websites or in-the-browser design processes to share with team members of a client.
var data = {} | |
, fields = [ | |
'earth[africa][sudan][lion]' | |
, 'earth[africa][sudan][girafe]' | |
, 'earth[africa][sudan][monkeys][lemur]' | |
, 'earth[africa][zimbabwee][elephants]' | |
, 'earth[africa][zimbabwee][elephants]' | |
, 'earth[africa][zimbabwee][elephants]' | |
, 'earth[europe][switzerland][chocolate]' | |
, 'pluto[isnt][a][planet]' |
addressbook_autocomplete: function() { | |
if ($('input[data-bind="addressbook-autocomplete"]').length > 0) { | |
$('input[data-bind="addressbook-autocomplete"]').autocomplete('destroy'); | |
$('input[data-bind="addressbook-autocomplete"]').show(); | |
function aao_handle_select(that, label, address) { | |
var div = document.createElement('div'); | |
$('div[data-handle-for="' + $(that).attr('name') + '"]').remove(); |
FormHelper = { | |
getFormData: function(event, allowEmpty) { | |
var allowEmpty = 'boolean' === typeof allowEmpty ? allowEmpty : true; | |
var form = event.target ? $(event.target) : event; | |
var data = {}; | |
form.find('input[type="hidden"][name], input[type="text"][name], input[name]:checked, textarea[name], select[name]').each(function(i) { | |
var keys = $(this).attr('name').replace(/\]/g, '').split('['); | |
var marker; | |
for (var i = 0; i < keys.length; i++) { |
var glob = require('glob') | |
, fs = require('fs') | |
, cheerio = require('cheerio') | |
, _ = require('lodash') | |
, contentful = require('contentful') | |
, htmlFilePath = './page.html' | |
, htmlFile = fs.readFileSync(htmlFilePath); | |
; |
test: | |
override: | |
- mkdir -p $CIRCLE_TEST_REPORTS/reports | |
- eslint --format junit src/ > $CIRCLE_TEST_REPORTS/reports/eslint.xml | |
- ava --tap | tap-xunit > $CIRCLE_TEST_REPORTS/reports/ava.xml |
'use strict' | |
require('./buffer-polyfill') | |
const childProcess = require('child_process') | |
const os = require('os') | |
const path = require('path') | |
const cdp = require('chrome-remote-interface') | |
const get = require('got') |
I hereby claim:
- I am adieuadieu on github.
- I am adieuadieu (https://keybase.io/adieuadieu) on keybase.
- I have a public key ASDyGEeNbQQjhYFD1N9_2CKP7uyRpsays3yRE7UeQfJ8VAo
To claim this, I am signing this object:
/* | |
Grabs all SVGs matching a query selector from a webpage's | |
DOM and converts them to a raster format (PNG), then downloads them. | |
I wanted to grab an <svg /> from a webpage. | |
Then, I realised I wanted it as a PNG. | |
So I wrote this script. Paste it into your browser's console. | |
*/ | |
((svgQuerySelector = 'svg', saveType = 'image/png', saveQuality = 1) => { | |
const svgElements = document.querySelectorAll(svgQuerySelector) |
CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.
In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.
First, let's illustrate the 3 styles by implementing