Skip to content

Instantly share code, notes, and snippets.

View andrewvmail's full-sized avatar

momoterraw andrewvmail

View GitHub Profile
var request = require('request');
var async = require('async');
async.parallel(
{
data1: function(callback) {
request('someUrl', function (error, response, body) {
callback(error, body);
});
},
@icebob
icebob / merge.js
Created July 29, 2016 08:19
Merge GraphQL schemas & resolvers in modules
let moduleQueries = [];
let moduleTypeDefinitions = [];
let moduleMutations = [];
let moduleResolvers = [];
let files = config.getGlobbedFiles(path.join(__dirname, "**", "*schema.js"));
// Load schema files
files.forEach((file) => {
let moduleSchema = require(path.resolve(file));
@andrewvmail
andrewvmail / perf-snippet.js
Created October 18, 2018 21:20
performance snippets
let toggle = false
const attachHandler = () =>
document
.getElementById("message-composer-input")
.addEventListener("change", function() {
if(!toggle) {
@chrisjhoughton
chrisjhoughton / bootstrap.js
Created August 14, 2014 10:56
SailsJS Geo-encoding and lookup
module.exports.bootstrap = function (cb) {
// Ensure we have 2dsphere index on Property so GeoSpatial queries can work!
sails.models.YOURMODEL.native(function (err, collection) {
collection.ensureIndex({ coordinates: '2dsphere' }, function () {
// It's very important to trigger this callack method when you are finished
// with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap)
cb();
@tprochazka
tprochazka / build.gradle
Last active July 3, 2019 01:14
Smart versionName and versionCode for android Gradle build evaluation
/**
* Will return version from properties file and replace -SNAPSHOT by GIT commit hash
* to recognize origin commit for the every build.
*/
project.ext.evalVersionName = {
def ideBuild = project.properties['android.injected.invoked.from.ide']
if (ideBuild) {
logger.info("IDE build");
return "dev"
} else if (project.VERSION.toUpperCase().contains("SNAPSHOT")) {
#!/bin/sh
# Usage:
# ./clone.sh TESTENV_TO_CLONE_DIR NEW_TEST_ENV_DIR
# ./clone.sh TESTENV08-HOST TESTENV03-HOST
# The above will clone 08 to 03 and register the vm
#
# * Do not end the argument directories with a slash!
# Date: Mar 10, 2015
DIR_DS=$(pwd)
@marcotrosi
marcotrosi / log-minimal-demo.lua
Created July 8, 2015 08:22
Lua - automatic logging idea
-- load the log module
local log = require("log")
-- some function for demo
function add(a, b)
return a+b
end
-- wrap the main script in a main function
function main()
@bitjockey42
bitjockey42 / 00_OSX_Docker_Machine_Setup.md
Last active November 9, 2020 13:49 — forked from andystanton/Start up local Docker Machine on OSX automatically.md
Use native virtualization on OS X docker with xhyve

What this?

So one of the painful points of using docker on OS X is that you need to run a virtualbox VM, which often suffers from performance issues. With xhyve, a OS X virtualization system, and docker-machine-xhyve you can now have docker use the native OS X hypervisor to run containers.

No more dealing with virtualbox shenanigans!

In this script, I've also set up a way to autoconfigure terminal sessions to load docker's environment vars (dependent on docker-machine) so you do not have to run eval $(docker-machine env whatever) every time you open a new terminal window.

Requirements

@munhitsu
munhitsu / gist:1034876
Last active November 29, 2020 09:10
python 2.7.5 install on OSX (10.8+) using brew (pip, easy_install, virtualenv, virtualenvwrapper)
# In case you had some strange python installation
# NOTE: .pydistutils.cfg seems to be not compatible with brew install python
# areas I needed to clean before installation
# clean up ~/Library/Python
# clean up .local
# preconditions:
# xcode with command line tools installed
xcode-select --install
@justindmyers
justindmyers / server.js
Created January 17, 2016 12:13
https with Ionic
var fs = require('fs');
var httpProxy = require('http-proxy');
var http = require('http');
var https = require('https');
var express = require('express');
var app = express();
app.use(function (req, res, next) {
console.log(req);
if (req.url === '/') {