Skip to content

Instantly share code, notes, and snippets.

@glacjay
glacjay / tun-ping-linux.go
Created September 18, 2010 12:26
Reading/Writing Linux's TUN/TAP device in Go.
package main
import (
"exec"
"log"
"os"
"syscall"
"unsafe"
)
@virasak
virasak / AuthenService.java
Created September 28, 2012 06:09
Simple Guice & JUnit4 Integration: Use the unit test itself as a module to provide member injection. Use @provides methods to build a module from unit test object.
import com.google.inject.Inject;
public class AuthenService {
private final UserDAO userDAO;
@Inject
public AuthenService(UserDAO userDAO) {
this.userDAO = userDAO;
@UnquietCode
UnquietCode / MockSQS.java
Last active October 1, 2022 04:00
Mock AWS SQS implementation which operatesin-memory rather than hitting the real SQS.
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.ResponseMetadata;
import com.amazonaws.regions.Region;
import com.amazonaws.services.sqs.AmazonSQS;
import com.amazonaws.services.sqs.model.*;
import com.google.common.hash.Hashing;
import java.util.*;
@paulmach
paulmach / serve.go
Last active March 28, 2024 15:31
Simple Static File Server in Go
/*
Serve is a very simple static file server in go
Usage:
-p="8100": port to serve on
-d=".": the directory of static files to host
Navigating to http://localhost:8100 will display the index.html or directory
listing file.
*/
package main
@neolitec
neolitec / BasicAuthenticationFilter.java
Created February 12, 2014 11:09
HTTP Basic authentication Java filter
package com.neolitec.examples;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@soarez
soarez / ca.md
Last active May 3, 2024 00:04
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@jniltinho
jniltinho / myip.go
Created March 26, 2014 16:55
Get My IP Golang
package main
/*
URL: https://github.com/mccoyst/myip/blob/master/myip.go
URL: http://changsijay.com/2013/07/28/golang-get-ip-address/
*/
import (
"net"
"os"
@magnetikonline
magnetikonline / README.md
Last active February 14, 2024 08:21
Nginx embedded variables.
@weapp
weapp / nginx.conf
Created August 4, 2014 17:21
Return common errors as json in Nginx
error_page 500 /500.html;
location /500.html{
return 500 '{"error": {"status_code": 500,"status": "Internal Server Error"}}';
}
error_page 502 /502.html;
location /502.html{
return 502 '{"error": {"status_code": 502,"status": "Bad Gateway"}}';
}
@zeroows
zeroows / CORSFilter.java
Last active October 4, 2022 11:44
To enable CORS support in Spring MVC 4 - Access-Control-Allow-Origin
package com.alkhodiry.mb.rest.filters;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;