Skip to content

Instantly share code, notes, and snippets.

View dahernan's full-sized avatar

David Hernandez dahernan

View GitHub Profile
@dahernan
dahernan / gist:10652080
Created April 14, 2014 14:15
bash_prompt
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
# Screenshot: http://i.imgur.com/s0Blh.png
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi

##Recommendation Engine Services

####IREUS Recommendation Engine for stores as SaaS

http://www.ireus.net/

####Plista

@dahernan
dahernan / auth.go
Last active August 29, 2015 14:15
Basic auth login route
// example for Minimal Auth
// it does not compile is just as a guide for rolling your own
// some code for login by http post
func (a *AuthRoute) Login(w http.ResponseWriter, req *http.Request) {
var authForm map[string]string
err := RequestToJsonObject(req, &authForm)
if err != nil {
Render().JSON(w, http.StatusUnauthorized, nil)
@dahernan
dahernan / bio.md
Last active August 29, 2015 14:17
short bio

David Hernandez is an independent Software Engineer in London, he helps companies to improve their software. He worked different countries like Spain, UK and Australia, participating in projects like the BBC London Olympics 2012, helping to achieve Continuous Delivery at Atlassian, or delivering services to the citizens at the Government Digital Services.

You can find David speaking and collaborating at Go London User Group, because Go is his favourite language.

@dahernan on Twitter

@dahernan on Github

<html>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="https://github.com/joewalnes/smoothie/raw/master/smoothie.js"></script>
<script src="http://localhost:8080/socket.io/socket.io.js"></script>
<div>
<p>Node.js Rabbitmq Websockets Canvan Smoothie Groovy</p>
<canvas id="mycanvas" width="800" height="300">
@dahernan
dahernan / rabbitmqinject.groovy
Created March 9, 2011 14:59
rabbitmqinject.groovy
import com.rabbitmq.client.*
import java.util.Random
@Grab(group='com.rabbitmq', module='amqp-client', version='1.7.2')
params = new ConnectionParameters(
username: 'guest',
password: 'guest',
virtualHost: '/',
requestedHeartbeat: 0
)
@dahernan
dahernan / sshExec
Created March 28, 2011 16:02
Exec ssh command passing the password as a parameter
# set Variables
set password [lrange $argv 0 0]
set ipaddr [lrange $argv 1 1]
set scriptname [lrange $argv 2 2]
set arg1 [lrange $argv 3 c3]
set timeout -1
# now connect to remote UNIX box (ipaddr) with given script to execute
spawn ssh root@$ipaddr $scriptname $arg1
match_max 100000
expect -timeout 4 "yes/no" {send "yes\r"}
@dahernan
dahernan / CharMatcher.java
Created August 15, 2011 11:51
CharMatcher example
package testting.testinggggg;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
@dahernan
dahernan / gist:2820052
Created May 28, 2012 16:43
Local Cache
// Simple cache
private ConcurrentHashMap<String, String> cache;
String resource = cache.get(url.toString());
...
// Guava
@dahernan
dahernan / gist:2820065
Created May 28, 2012 16:51
Filter a list
// old filter
List<WhiteListKeyword> filtered = new ArrayList<WhiteListKeyword>();
for (WhiteListKeyword whiteListKeyword : whiteListKeywords) {
if(keyword.equals()){
filtered.add(whiteListKeyword.getKeyword());
}
}