Skip to content

Instantly share code, notes, and snippets.

@willmendesneto
willmendesneto / Interface.js
Created March 31, 2014 18:02
Interface example in Javascript
// INTERFACE "X"
var X = {
share: function(clientEmail, email ){}
};
// LIB "A"
var A = {
type: 'facebook'
};
// LIB "B"
var B = {
@willmendesneto
willmendesneto / print-by-divisors.js
Last active August 29, 2015 14:01
PrintByDivisors: my resolution for FizzBuzz problem
var PrintByDivisors = {
opts: {
begin: 1,
end: 100,
numbers: [15, 3, 5],
outputs: ['SouDev', 'Sou', 'Dev']
},
extend: function(target, source) {
target = target || {};
@willmendesneto
willmendesneto / Gruntfile.js
Last active August 29, 2015 14:01
Files requireds for create a project for create angular modules using Grunt task manager
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
// OBS:
// Replace the string with informations
@willmendesneto
willmendesneto / jogos.js
Last active August 29, 2015 14:02
World Cup in six lines of Javascript based in @fmasanori jogos.py. Zepto/Jquery dependency
// Example in http://codepen.io/willmendesneto/pen/Iguor
$.get('http://worldcup.sfg.io/matches', function(data){
data.forEach(function(item){
if (item.status === 'completed') {
console.log(item.home_team.country + ' ' + item.home_team.goals + ' x ' + item.away_team.country + ' ' + item.away_team.goals);
}
});
}, 'json');
@willmendesneto
willmendesneto / Vagrantfile
Last active August 29, 2015 14:04
Vagrantfile based in Vaprobash project
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Config Github Settings
github_username = "fideloper"
github_repo = "Vaprobash"
github_branch = "1.0.1"
github_url = "https://raw.githubusercontent.com/#{github_username}/#{github_repo}/#{github_branch}"
# Server Configuration
@willmendesneto
willmendesneto / gist:622aa25cf9bc6fcb81cf
Last active August 29, 2015 14:12
CLI: Funções e Alias

Algumas informações para inserirmos algumas funções e aliases no ambiente CLI. Como utilizo o oh-my-zsh, carrego alguns plugins por padrão:

plugins=(git rails ruby frontend-search nvm rvm vagrant)

É sempre uma boa prática modularizar os arquivos. Para isto criaremos 2 arquivos:

  • .functions: arquivo onde ficarão as funções;
  • .aliases: arquivo onde ficarão os atalhos/aliases;
@willmendesneto
willmendesneto / solarized-dark.css
Created January 4, 2015 22:13
Solarized Dark highlight for Jekyll blogs/websites
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
@willmendesneto
willmendesneto / .functions
Last active August 29, 2015 14:15
.functions
# Simple calculator
function calc() {
local result="";
result="$(printf "scale=10;$*\n" | bc --mathlib | tr -d '\\\n')";
# └─ default (when `--mathlib` is used) is 20
#
if [[ "$result" == *.* ]]; then
# improve the output for decimal numbers
printf "$result" |
sed -e 's/^\./0./' `# add "0" for cases like ".5"` \
@willmendesneto
willmendesneto / protractor_conf.js
Created February 15, 2015 12:26
An example of protractor configuration
// An example configuration file.
exports.config = {
// Do not start a Selenium Standalone sever - only run this using chrome.
chromeOnly: true,
chromeDriver: './node_modules/protractor/selenium/chromedriver',
seleniumAddress: 'http://0.0.0.0:4444/wd/hub',
baseUrl: 'http://0.0.0.0:9000',
// Capabilities to be passed to the webdriver instance.
@willmendesneto
willmendesneto / gist:196f84c884cf501dfced
Created March 19, 2015 17:58
AngularJS: testing form validation
// In your controller

this.item = {
    userType: ''
};
<!-- In your html template -->