Skip to content

Instantly share code, notes, and snippets.

Print array 4 elements each time
[*(1..16)].each { |v| v%4==0? p(v) : print("#{v},")}
@sriki77
sriki77 / Ruby_Day_1.rb
Created November 2, 2011 12:36
Ruby Day 1
#1. Print Hello World
puts "Hello World."
#2. Index of "Ruby"
puts "Hello Ruby".index("Ruby")
#3. Name 10 times
puts "Srikanth#{$/}" * 10
DateFormat indiaDtFmt = new SimpleDateFormat("dd/MM/yyyy HH'h'mm");
DateFormat gmtDtFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
indiaDtFmt.setTimeZone(TimeZone.getTimeZone("Asia/Calcutta"));
gmtDtFmt.setTimeZone(TimeZone.getTimeZone("GMT"));
Date worldWarIIDate = indiaDtFmt.parse("02/02/1944 06h30");
Date nonWorldWarIIDate = indiaDtFmt.parse("02/02/2006 06h30");
System.err.println(gmtDtFmt.format(worldWarIIDate) +" GMT");
@sriki77
sriki77 / SSLUnificationHandler.java
Created August 9, 2015 15:21
SSL Unification + Netty + Proxy
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 August 29, 2015 14:24
Serverside Code Gen By Swagger
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;