Skip to content

Instantly share code, notes, and snippets.

View acdcjunior's full-sized avatar
🌘
It's been a hard day's night

Antônio "acdc" Jr. acdcjunior

🌘
It's been a hard day's night
View GitHub Profile
@acdcjunior
acdcjunior / cli.js
Created May 22, 2018 00:30
websocket express server client example
const WebSocket = require('ws');
const ws = new WebSocket('ws://localhost:3000/');
ws.on('open', function open() {
ws.send('sent by client');
});
ws.on('message', function incoming(data) {
console.log('received @client', data);
@acdcjunior
acdcjunior / VerPropriedade.java
Created March 22, 2018 20:19
Ver propriedade/debugar spring
/*
Adicione no CONFIG: @EnableScheduling
*/
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Scheduled;
/*!
* Vue.js v2.5.16-4
* (c) 2014-2018 Evan You
* Released under the MIT License.
*/
! function(e, t) {
"object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : e.Vue = t()
}(this, function() {
"use strict";
var y = Object.freeze({});
pragma solidity ^0.4.11;
/// @title Catalogo de Ouvidorias para o Barramento de Ouvidorias
/*
Cada ouvidoria somente pode autorizar uma vez.
*/
contract CatalogoOuvidorias {
uint constant NUMERO_DE_AUTORIZACOES_EXIGIDAS_PARA_UMA_NOVA_OUVIDORIA_PODER_CADASTRARSE = 3;
0x1750dd0f8cd22ee9d849ab11ebc62adb37ffc10a
@acdcjunior
acdcjunior / Banco.js
Last active July 5, 2017 22:59
Banco.js
var Banco = (function () {
function Banco(nomeBanco) {
if (nomeBanco === void 0) { nomeBanco = 'testes'; }
this.checkEhString(nomeBanco);
this.db = new PouchDB(nomeBanco);
}
Banco.prototype.checkEhString = function (id) {
if (typeof id !== 'string') {
throw new Error('Argumento deve ser uma string e nao um objeto! Recebido: '
+ JSON.stringify(id));
@acdcjunior
acdcjunior / parsing brackets.md
Created February 21, 2016 06:43
Parsing brackets using JavaScript (with PEG.js, not regex)

GO TO

  http://pegjs.org/online

Paste in the grammar:

  Expression
        = head:Factor tail:Factor* {
              return head + tail.join("");

}

@acdcjunior
acdcjunior / Dummies.java
Created January 23, 2016 23:36
Mockito: create a mock object that throws exception at any method call (so... a Dummy object, not a mock)
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import static org.mockito.Mockito.mock;
public class Dummies {
private static class NoMethodShouldBeCalledAnswer implements Answer<Object> {
private String className;
@acdcjunior
acdcjunior / MockitoVsHandBuiltDoublesTest.java
Created January 23, 2016 22:16
Mockito vs. Hand-built test doubles (Mocks) small performance test
import org.junit.Test;
import org.mockito.Mockito;
import org.openqa.selenium.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@acdcjunior
acdcjunior / SeleniumFileDownloadFirefox.java
Created June 30, 2015 18:00
Selenium Automatic File download using Firefox
FirefoxProfile fxProfile = new FirefoxProfile();
fxProfile.setPreference("browser.download.folderList",2);
fxProfile.setPreference("browser.download.manager.showWhenStarting",false);
fxProfile.setPreference("browser.download.dir","c:\\mydownloads");
fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv");
WebDriver driver = new FirefoxDriver(fxProfile);
driver.navigate().to("http://www.foo.com/bah.csv");