Skip to content

Instantly share code, notes, and snippets.

View trustin's full-sized avatar
🌄
▂▃▅▇█▓▒░۩۞۩░▒▓█▇▅▃▂

Trustin Lee trustin

🌄
▂▃▅▇█▓▒░۩۞۩░▒▓█▇▅▃▂
View GitHub Profile
@trustin
trustin / gist:2404506
Last active October 3, 2015 05:58
Trustin's CrashPlan exclusion regular expressions for Windows (crashplan)
(?i)C:/Users/[^/]+/Music/iTunes/iTunes Media/Mobile Applications/.*
(?i)C:/Users/(Default|Public|All Users|Default User)/.*
(?i).*/(desktop\.ini|thumbs.db|ntuser\.ini)
(?i).*\.(bak|tmp|log[0-9]*|old)
(?i)C:/Users/[^/]+/(Application Data|NetHood|Contacts|Cookies|Dropbox|Links|Local Settings|My Documents|PrintHood|Recent|riotsGamesLogs|Saved Games|Searches|SendTo|시작 메뉴)/.*
(?i)D:/CrashPlan/.*
@trustin
trustin / hairtunes.patch
Created June 16, 2012 09:10
hairtunes.c patch that fixes stall hairtunes process
diff --git a/hairtunes.c b/hairtunes.c
index 6859cff..b5f3e7e 100644
--- a/hairtunes.c
+++ b/hairtunes.c
@@ -417,17 +417,25 @@ static void *rtp_thread_func(void *arg) {
int sock = rtp_sockets[0], csock = rtp_sockets[1];
int readsock;
char type;
+ struct timeval timeout;
@trustin
trustin / gist:2959515
Created June 20, 2012 11:51
XWiki InsertGistMacro example
function help() {
echo 'Want to embed this Gist?'
echo 'Use this: {{gist id="2959515"/}}'
}
$ help
Want to embed this Gist?
Use this: {{gist id="2959515"/}}
@trustin
trustin / pom.xml
Created June 21, 2012 12:27
Adding Netty to your POM's dependency set
<dependencies>
...
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<version>X.Y.Z.Q</version>
<scope>compile</scope>
</dependency>
...
</dependencies>
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.nio.ByteOrder;
ByteBuf buf = Unpooled.buffer(4);
buf.setInt(0, 1);
// Prints '00000001'
System.out.format("%08x%n", buf.getInt(0));
ByteBuf leBuf = buf.order(ByteOrder.LITTLE_ENDIAN);
// Before:
void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception;
void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception;
// After:
void channelRegistered(ChannelHandlerContext ctx) throws Exception;
void channelUnregistered(ChannelHandlerContext ctx) throws Exception;
void channelActive(ChannelHandlerContext ctx) throws Exception;
void channelInactive(ChannelHandlerContext ctx) throws Exception;
void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception;
// Before:
ctx.sendUpstream(evt);
// After:
ctx.fireInboundBufferUpdated();
public interface ChannelHandler {
void beforeAdd(ChannelHandlerContext ctx) throws Exception;
void afterAdd(ChannelHandlerContext ctx) throws Exception;
void beforeRemove(ChannelHandlerContext ctx) throws Exception;
void afterRemove(ChannelHandlerContext ctx) throws Exception;
void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception;
void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception;
...
public void inboundBufferUpdated(ChannelHandlerContext ctx) {
if (ctx.hasInboundByteBuffer()) {
ByteBuf buf = ctx.inboundByteBuffer();
...
} else {
Queue<MyMessage> buf = ctx.inboundMessageBuffer();
for (;;) {
MyMessage msg = buf.poll();
if (buf == null) {
break;
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent evt) {
Object msg = evt.getMessage();
if (msg instanceof ChannelBuffer) {
ChannelBuffer buf = (ChannelBuffer) msg;
...
} else {
MyMessage myMsg = (MyMessage) msg;
...
}