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
@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>]"
@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.

@welll
welll / episode.js
Created January 16, 2017 14:35 — forked from mpj/episode.js
Code from the "Dependency Injection Basics" episode of Fun Fun Function
const assert = require('assert')
function getAnimals(fetch, id) {
return fetch('http://api.animalfarmgame.com/animals/' + id)
.then(response => response.json())
.then(data => data.results[0])
}
describe('getAnimals', () => {
it('calls fetch with the correct url', () => {
@welll
welll / aggregate.js
Created November 1, 2016 04:05
Aggregate data from MongoDB with Node.js and mongoose
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
//Database connection
var uristring = 'mongodb://localhost/test';
var mongoOptions = { };
mongoose.connect(uristring, mongoOptions, function (err, res) {
if (err) {
console.log('Error when connecting to: ' + uristring + '. ' + err);
@welll
welll / enum-access.js
Created November 1, 2016 02:48 — forked from bnoguchi/enum-access.js
How to access enumValues in mongoose from a Model or Document
var mongoose = require('./index')
, TempSchema = new mongoose.Schema({
salutation: {type: String, enum: ['Mr.', 'Mrs.', 'Ms.']}
});
var Temp = mongoose.model('Temp', TempSchema);
console.log(Temp.schema.path('salutation').enumValues);
var temp = new Temp();
console.log(temp.schema.path('salutation').enumValues);
@welll
welll / make-animated-gif.js
Created October 13, 2016 14:56 — forked from AVGP/make-animated-gif.js
Uses three.js, three-software-renderer & omggif to render an animated GIF from a Three.js Scene on the server with node.js
var fs = require('fs'),
omggif = require('omggif'),
THREE = require('three'),
SoftwareRenderer = require('three-software-renderer');
// How many frames and how large shall the GIF be?
var NUM_FRAMES = 200, WIDTH = 500, HEIGHT = 500;
// Our scene, camera and renderer and a box to render
var scene = new THREE.Scene(),
@welll
welll / json_with_cpp.cpp
Created July 22, 2016 16:43 — forked from makomweb/json_with_cpp.cpp
Some fun with JSON serialization/deserialization using C++ REST SDK (Codename "Casablanca").
#include <cpprest/json.h>
#include <sstream>
using namespace std;
typedef web::json::value JsonValue;
typedef web::json::value::value_type JsonValueType;
typedef std::wstring String;
typedef std::wstringstream StringStream;
String JsonValueTypeToString(const JsonValueType& type)
@welll
welll / date_conversion.cpp
Created January 28, 2016 11:58 — forked from st-j/date_conversion.cpp
Convert between boost dates and Unix timestamps (time_t)
#include <ctime>
#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
//==============================================================================
//! Convert date part of Unix timestamp (time_t) to boost date
//!