This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"github.com/bmizerany/pat" | |
"log" | |
"net/http" | |
) | |
type httpHandlerFunc func(w http.ResponseWriter, req *http.Request) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/bmizerany/assert" | |
"net/http" | |
"net/http/httptest" | |
"testing" | |
) | |
func TestJsonServerReturnsJsonDocumentWithRightHeaders(t *testing.T) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// old filter | |
List<WhiteListKeyword> filtered = new ArrayList<WhiteListKeyword>(); | |
for (WhiteListKeyword whiteListKeyword : whiteListKeywords) { | |
if(keyword.equals()){ | |
filtered.add(whiteListKeyword.getKeyword()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple cache | |
private ConcurrentHashMap<String, String> cache; | |
String resource = cache.get(url.toString()); | |
... | |
// Guava |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Script to increase the version number of the project and remove snapshots | |
Using Gmaven: http://docs.codehaus.org/display/GMAVEN/Executing+Groovy+Code | |
Execute standalone | |
$ mvn groovy:execute | |
<plugin> | |
<groupId>org.codehaus.gmaven</groupId> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To generate a self-signed SSL certificate using the keytool command on Windows, Mac, or Linux: | |
1 Open a command prompt or terminal. | |
2 Run this command: | |
keytool -genkey -keyalg RSA -alias tomcat -keystore selfsigned.jks -validity <days> -keysize 2048 | |
Where <days> indicate the number of days for which the certificate will be valid. | |
3 Enter a password for the keystore. Note this password as you require this for configuring the server. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bash funtions | |
function psgrep() { ps aux | grep -v grep | grep "$@" -i --color=auto; } | |
function fname() { find . -iname "*$@*"; } | |
Who is using the port 25 | |
$ lsof -i :25 | |
Ports that process is using | |
$ lsof -p 52808|grep TCP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) |