Skip to content

Instantly share code, notes, and snippets.

View fmamud's full-sized avatar
💻

Felipe Mamud fmamud

💻
View GitHub Profile
@fmamud
fmamud / vamos.erl
Created October 27, 2015 18:49
Erlang vamos module
-module(vamos).
-author("fmamud").
-export([foreach/2, valid_time/1, show_me_your_name/2, can_i_drink/1, oh_god/1, odd_even/1, beach/1, show_macro/2]).
-define(TIMEOUT, 20).
-define(SOMA(X, Y), X + Y).
foreach(Fun, [H|T]) ->
Fun(H),
@fmamud
fmamud / records.erl
Last active October 27, 2015 18:55
Erlang Records Module
-module(records).
-compile(export_all).
-include("records.hrl").
-record(robot, {name,
type=industrial,
hobbies,
details=[]}).
-record(user, {id, name, group, age}).
@fmamud
fmamud / bora.erl
Created October 27, 2015 19:04
Erlang Bora module
-module(bora).
-export([echo/1,fibonacci/1,mysum/1, reverse/1]).
echo(Any) -> Any.
fibonacci(0) -> 1;
fibonacci(1) -> 1;
fibonacci(N) -> fibonacci(N-1) + fibonacci(N-2).
@fmamud
fmamud / FibInfiniteLoop.java
Last active November 9, 2015 17:36
Fibonacci with infinite loop
public class FibInfiniteLoop {
static void fib(long n) {
int a = 0, b = 1;
while (a < n) {
System.out.printf("%d %n", a);
a = b;
b = a + b;
}
}
@fmamud
fmamud / HttpFileGet.java
Last active November 9, 2015 17:41
Retrieve an image with a connection via proxy and uses the Java API NIO.2 to save the inputstream in a file on disk.
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Proxy.Type;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Paths;
public class HttpFileGet {
@fmamud
fmamud / historylangs.groovy
Last active November 12, 2015 02:01
History languages using Geb and Wikipedia
@Grapes([
@Grab("org.gebish:geb-core:0.12.2"),
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.45.0"),
@Grab("org.seleniumhq.selenium:selenium-support:2.45.0")
])
import geb.Browser
Browser.drive {
go "https://en.wikipedia.org/wiki/Groovy_(programming_language)"
@fmamud
fmamud / configProxy.txt
Created November 12, 2015 02:28
Configure JAVA_OPTS
# Windows
set JAVA_OPTS=-Dhttp.proxyHost=yourproxy -Dhttp.proxyPort=8080
# Unix
export JAVA_OPTS=-Dhttp.proxyHost=yourproxy -Dhttp.proxyPort=8080
@fmamud
fmamud / GetGrabConfig.ps1
Created November 12, 2015 02:32
Get file grapeConfig.xml
iwr -OutFile ~/.groovy/grapeConfig.xml https://gist.githubusercontent.com/lalyos/9366690/raw/grapeConfig.xml
@fmamud
fmamud / vararg_closure.groovy
Last active March 28, 2016 21:23 — forked from kdabir/vararg_closure.groovy
Closures as Varargs in groovy
def hello (...c) {
c.each {it.call()}
}
hello ({println 'hello'},{println 'namaste'}, {println 'hola'})
@fmamud
fmamud / github_pr_count.groovy
Last active July 1, 2016 18:10
Get all closed PR from private repository
@Grab('org.codehaus.gpars:gpars:1.2.1')
import static groovyx.gpars.GParsPool.*
import groovy.json.JsonSlurper
orgid = 0
orgname = 'X'
username = ''
token = 'X'