Skip to content

Instantly share code, notes, and snippets.

View welll's full-sized avatar
🏠
Working from home

Wellington Soares welll

🏠
Working from home
View GitHub Profile
import express from 'express';
import React from 'react';
import { renderToString } from 'react-dom/server';
const app = express();
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
@welll
welll / click.m
Created February 27, 2021 19:52 — forked from eddiekaiger/click.m
Programmatically move/click mouse on macOS
// Found on: http://hints.macworld.com/article.php?story=2008051406323031
// File:
// click.m
//
// Compile with:
// gcc -o click click.m -framework ApplicationServices -framework Foundation
//
// Usage:
// ./click -x pixels -y pixels
@welll
welll / package-locker.sh
Created August 3, 2018 23:10 — forked from maxdanilov/package-locker.sh
Lock versions in package.json from package-lock.json or npm-shrinkwrap.json
#!/bin/sh
set -e
PACKAGE_JSON="package.json"
PACKAGE_JSON_NEW="package.new.json"
PACKAGE_LOCK="package-lock.json" # default. when shrinkwrap used, is npm-shrinkwrap.json
function usage() {
echo "Usage: ${0} -d=<abs-path-to-dir-with-package.json> [-lf=<name-of-the-lock-file>]"
let myAsyncFunctionThatReturnsPromise = new Promise((resolve, reject) => {
setTimeout(function(){
resolve("Success!")
}, 2500)
})
let foo1 = Promise.resolve()
.then(function(){ callUndefinedFunction() })
.catch((e)=> console.log(`Error: ${e}`))
@welll
welll / https-server.py
Created November 28, 2017 21:10
Python - HTTPS Server
#!/usr/bin/env python3
import BaseHTTPServer, SimpleHTTPServer
import urlparse
import ssl
# update these vars
cert='/path-to-cert.pem'
key='/path-to-private-key.pem'
bindHost='0.0.0.0'
@welll
welll / headless.md
Created July 20, 2017 21:51 — 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.

node debug $(which gulp) taskName
@welll
welll / global-value.js
Created March 15, 2017 15:40
AvenueCode - Blog Post
global.myNumber = 5; //Global variable initialized to value 5.
@welll
welll / checking-image.js
Created March 14, 2017 16:12
Checking if the image was loaded
function checkIfImageExist(src, cb) {
var img = new Image();
img.onload = function() {
cb(null)
}
img.onerror = function(e) {
@welll
welll / missing-return.js
Created March 14, 2017 09:22
AvenueCode - Blog Post
/* missing a RETURN statement */
fs.readFile(`${filePath}`, (err, data) => {
if (err) {
console.log(`Error reading file: ${filePath}`)
}
//...
//code
//...