Skip to content

Instantly share code, notes, and snippets.

View ericchaves's full-sized avatar

Eric Paschoalick Chaves ericchaves

View GitHub Profile
@ericchaves
ericchaves / weird.js
Created April 30, 2012 17:21
instanceof regexp evalutes to false inside a sandbox
var reg = /^[a-z]$/;
console.log('case 01: typeof /^[a-z]$/ returns %s', typeof reg);
console.log('case 02: /^[a-z]$/ instanceof RegExp returns %s', reg instanceof RegExp);
console.log('case 03: /^[a-z]$/.constructor.name === "RegExp" returns %s', reg.constructor.name === 'RegExp');
var util = require('util'),
vm = require('vm'),
sandbox = { u: reg };
@ericchaves
ericchaves / Database.js
Created April 30, 2012 19:50
sandboxed-module TypeError
var settings = require('../config/settings'),
url = require('url'),
mongodb = require("mongodb");
var Database = function(){
this._isConnected = false;
this.uri = url.parse(settings.mongodb, true);
var q = this.uri.query;
this.socketOptions = {
timeout : q.timeout || 0,
@ericchaves
ericchaves / Vagrantfile
Last active August 29, 2015 14:01
Vagrant-coreos looses connection whenever I build a dockerfile
# -*- mode: ruby -*-
# # vi: set ft=ruby :
require 'fileutils'
CLOUD_CONFIG_PATH = "./user-data"
CONFIG= "config.rb"
# Defaults for config options defined in CONFIG
$num_instances = 1
@ericchaves
ericchaves / graphite
Last active August 29, 2015 14:13 — forked from hmmbug/graphite
# goes in /etc/nginx/sites-available & link in ../sites-enabled
upstream graphite {
server unix:///tmp/uwsgi.sock;
}
server {
listen 9002;
server_name localhost;

S3 Website "Index Document"

index.html:

<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
@ericchaves
ericchaves / artboards.sketchpreset
Created November 29, 2015 14:26 — forked from cristianferrarig/artboards.sketchpreset
Custom Sketch Artboards Presets
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>name</key>
<string>Pages</string>
<key>presets</key>
@ericchaves
ericchaves / Instalacao.md
Last active February 15, 2016 23:35
Instalando Arch Linux em um notebook Lenovo G50-80

Arch Linux - Lenovo G50-80 passo-a-passo

Geral

ATENÇÃO

Estas anotações NÃO compõem um script para ser executado, apesar de possuir comandos a ser executados. Use por sua conta e risco. São apenas anotações para meu próprio uso. Use por sua conta e risco. Este é um setup experimental. Use por sua conta e risco. Estes procedimentos irão apagar completamente as partições de seu disco. Use por sua conta e risco. NÃO siga estas instruções caso deseje montar um sistema com dual boot. Use por sua conta e risco.

@ericchaves
ericchaves / data-enrichment.groovy
Created November 18, 2017 19:51
Simple NiFi InvokeScriptedProcessor to enhance JSON data by doing SQL lookups
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import groovy.sql.Sql
import java.nio.charset.StandardCharsets
import org.apache.commons.io.IOUtils
import org.apache.nifi.annotation.behavior.EventDriven
import org.apache.nifi.annotation.documentation.CapabilityDescription
@ericchaves
ericchaves / simple-coroutine.js
Created December 10, 2017 21:32
Poor's man coroutine
/*
* Poor's man coroutine
*/
function co(g) {
return new Promise((resolve, reject)=>{
let it = g(), ret;
(function iterate(val){
ret = it.next(val)
if(ret.done) return resolve(val)
@ericchaves
ericchaves / WhatsApp.java
Created January 5, 2018 18:23 — forked from sjmach/WhatsApp.java
Sample fiile to test whatsapp installation on android device via Appium
package com.sundeepmachado;
import java.io.File;
import java.net.URL;
import junit.framework.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;