Skip to content

Instantly share code, notes, and snippets.

View lipelopeslage's full-sized avatar

Felipe Lopes Lage lipelopeslage

View GitHub Profile
@lipelopeslage
lipelopeslage / JUnitTestCaseOne.java
Created December 26, 2016 20:06
Simple unit testing with JUnit and Mockito
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.Mockito.mock;
@lipelopeslage
lipelopeslage / promisse_chaining_example.js
Created June 29, 2016 14:48
ES2015 Promise - Simple chaining example
var ajax = (str)=>{
return new Promise(function(resolve, reject){
$.get(str).success(resolve).fail(reject);
})
};
ajax('https://httpbin.org/get').then(function(res){
// primeiro then fitra valor
return res.url;
}).then(function(res){
@lipelopeslage
lipelopeslage / promisse_example.js
Created June 28, 2016 02:40
Ajax example with Promisse.
function asyncFunc() {
return new Promise(
function (resolve, reject) {
$.get('https://httpbin.org/geta', function(res){
resolve(res);
}).fail(function(res){
reject(res.responseText);
});
});
}
@lipelopeslage
lipelopeslage / utils.styl
Created June 22, 2016 18:51
Stylus aux functions
roundborder(x)
-moz-border-radius x
-webkit-border-radius x
border-radius x
unselectable()
-moz-user-select -moz-none
-khtml-user-select none
-webkit-user-select none
@lipelopeslage
lipelopeslage / url-css-loader-workaround.js
Created April 17, 2016 14:51
A url workaround in CSS image paths using webpack.
/*
USAGE:
webpack.config.js:
[..] loaders:{
{ test: /\.(png|jpg)$/, loader: 'url-css-loader-workaround?relativePath=./../..&name=[path][name].[ext]' }
}
*/
var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: {
main: './js/main.js',
ignore: ['./stylus/style.styl']
},
output: {
path: '../build/js',
@lipelopeslage
lipelopeslage / freebase_sitcom.js
Last active January 31, 2016 18:12
Freebase AJAX sitcom query
var query = [{
"type": "/tv/tv_program",
"name": null,
"id": null,
"genre": "sitcom",
"/common/topic/image": [{
"id": null
}],
"/common/topic/subjects": [],
"program_creator": [],
@lipelopeslage
lipelopeslage / ex1.html
Last active November 22, 2015 16:08
Resolução simulado P2 - Javascript
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Ex.01</title>
<script src="jquery-1.11.3.min.js"></script>
</head>
<body>
seletores:
tr:odd - ímpar (vermelho)
@lipelopeslage
lipelopeslage / resolucao_joao.html
Last active October 6, 2015 03:24
resolucao_joao.html
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
n1: <input id="n1" type="text"><br>
n2: <input id="n2" type="text"><br>
<ul>
@lipelopeslage
lipelopeslage / exercicio01.html
Last active October 4, 2015 21:24
Gabarito - Simulado P1 [Javascript]
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Exercício 1</title>
</head>
<body>
<script>