Skip to content

Instantly share code, notes, and snippets.

View JamieAP's full-sized avatar
🎯
Focusing

Jamie JamieAP

🎯
Focusing
View GitHub Profile
#! /usr/bin/env bash
###
# In order to free up some space by removing unused languages from Semaphore environment
# Add the line below to your setup command in Project Settings
#
# wget https://gist.githubusercontent.com/mimimalizam/e3fd7084f88384f4b2dfca035e3da2d4/raw/remove_unused_languages.sh && bash remove_unused_languages.sh
#
# These commands will:
1,5c1,4
< total 520
< drwxr-xr-x 67 jamie staff 2278 25 Apr 21:11 .
< drwxr-xr-x 18 jamie staff 612 25 Apr 14:32 ..
< -rw-r--r-- 1 jamie staff 85 3 Mar 13:19 00-namespace.yaml
< -rw-r--r-- 1 jamie staff 586 25 Apr 16:36 03-auth.yaml
---
> total 392
> drwxr-xr-x 52 jamie staff 1768 25 Apr 21:11 .
> drwxr-xr-x 14 jamie staff 476 24 Apr 09:05 ..
### Keybase proof
I hereby claim:
* I am jamieap on github.
* I am jamieap (https://keybase.io/jamieap) on keybase.
* I have a public key ASAW47piBSQQjH-O0cEm7b5_8VGAVaK_rxq5PbPGvIPhKwo
To claim this, I am signing this object:
import com.google.common.base.Throwables;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Main {
ServerBootstrap b = new ServerBootstrap();
b.group(acceptorGroup, handlerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new MySocketInitialiser())
.option(ChannelOption.SO_BACKLOG, 5)
.childOption(ChannelOption.SO_KEEPALIVE, true);
b.localAddress(port).bind().sync();
LOG.info("Started on port {}", port);
Your name is Jamie Perkins!
# jamie at eduD692.kent.ac.uk in ~ [12:08:52]
$ telnet localhost 9000
Trying ::1...
Connected to localhost.
Escape character is '^]'.
{"firstName":"Jamie", "lastName":"Perkins"}
INFO [2016-02-16 12:06:38,880] nettytest.SocketServer: Started on port 9000
public class JsonDecoder<T> extends MessageToMessageDecoder<String, T> {
private static final Gson GSON = new GsonBuilder().create();
private final Class<T> clazz;
public JsonDecoder(Class<T> clazz, Class<?>... acceptedMsgTypes) {
super(acceptedMsgTypes);
this.clazz = checkNotNull(clazz);
}
/**
* Performs the initial set up of sockets as they connect to Netty.
* Registers the pipeline of handlers that received messages are passed through
*/
public class MySocketInitialiser extends ChannelInitializer<SocketChannel> {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();