Skip to content

Instantly share code, notes, and snippets.

@sriki77
sriki77 / SSLUnificationHandler.java
Created Aug 9, 2015
SSL Unification + Netty + Proxy
View SSLUnificationHandler.java
public class SSLUnificationHandler extends ChannelInboundByteHandlerAdapter {
static final String NAME = "HttpSsLUnificationHandler";
protected void addSSLHandler(ChannelPipeline pipeline) throws Exception {
//SSL Engine init....
pipeline.addAfter(NAME, "sslHandler", new SslHandler(sslEngine));
}
@Override
@sriki77
sriki77 / JAXRSSessionsApi.java
Last active Aug 29, 2015
Serverside Code Gen By Swagger
View JAXRSSessionsApi.java
package io.swagger.api;
import io.swagger.annotations.ApiParam;
import io.swagger.api.factories.SessionsApiServiceFactory;
import io.swagger.model.Session;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@sriki77
sriki77 / Jdk1.6.0_18.java
Created May 20, 2012
Jdk 6 load class differences
View Jdk1.6.0_18.java
protected synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException
{
// First, check if the class has already been loaded
Class c = findLoadedClass(name);
if (c == null) {
try {
if (parent != null) {
c = parent.loadClass(name, false);
} else {
@sriki77
sriki77 / 5villas.prolog
Created Feb 6, 2012
5 villas Reasoning
View 5villas.prolog
#!/opt/local/bin/gprolog --consult-file
segment([H1,H2],[H1,H2]):-!.
segment([H1,H2],[H1,H2|_]):-!.
segment([H1,H2],[_,H4|T2]) :- segment([H1,H2],[H4|T2]).
adjacent([H1,H2],L1,L2) :- segment([H1,H2],L1),!;segment([H2,H1],L2),!.
valid_set([],_,_).
valid_set([H|T],Y,AL):- member(H,Y), \+(member(H,AL)), valid_set(T,Y,[H|AL]).
View 8queens.prolog
#!/opt/local/bin/gprolog --consult-file
valid_queen(Col) :-
member(Col,[1,2,3,4,5,6,7,8]).
valid_board([]).
valid_board([H|T]):- valid_queen(H),valid_board(T).
diags1(_,[],[]).
diags1(Row,[Col|QT],[D|DT]) :-
@sriki77
sriki77 / CompleteProgTrial.cs
Created Dec 26, 2011
Timer & Deferred Eval & GC
View CompleteProgTrial.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace TimerDeferredEval
{
class JobScheduler : IDisposable
{
private static readonly TimeSpan DueTime = new TimeSpan(0, 0, 0, 5);
View reverse.prolog
#!/opt/local/bin/gprolog --consult-file
rev([X],[X]).
rev([H|T],RL) :- rev(T,RT), append(RT,[H],RL).
View books.prolog
#!/opt/local/bin/gprolog --consult-file
book('Seven langauges in seven days','Bruce tate').
book('Beyond Java','Bruce tate').
book('Bitter Java','Bruce tate').
book('Spring Developer Note Book','Bruce tate').
book('C programming language','Ritchie','Kernighan').
book('Practice Of Programming','Kernighan','Pike').
book('Unix Programming Environment','Pike','Kernighan').
View attrxml.io
#!/usr/bin/env io
OperatorTable addAssignOperator(":", "genAttribute")
Builder := Object clone
Builder genAttribute := method(k,v,
k = k asMutable removePrefix("\"") removeSuffix("\"")
write(" "..(k)..("=\"")..(v).."\"") )
Builder curlyBrackets := method(
View 2d.io
list( list(2,3) list(3,4,5) list(6)) flatten sum