Skip to content

Instantly share code, notes, and snippets.

View srikanthps's full-sized avatar

Srikanth Shreenivas srikanthps

  • Dell EMC
  • Bangalore, INDIA
View GitHub Profile
# For stackoverflow issue http://stackoverflow.com/questions/34544049/process-a-file-using-hash
hash_array = []
# Parse the lines and store it in hash array
File.open("b.txt", "r") do |f|
f.each_line do |line|
# Splits are done around , and = preceded or followed
# by any number of white spaces
splits = line.chomp.split(/\s*,\s*/).map{|p| p.split(/\s*=\s*/)}
@srikanthps
srikanthps / RabbitMQMessagePublisherTest.java
Created September 27, 2012 10:48
Try this program - Not able to make this one work
package org.trpr.platform.integration.messaging.test;
import java.util.List;
import org.trpr.platform.integration.impl.messaging.RabbitMQConfiguration;
import org.trpr.platform.integration.impl.messaging.RabbitMQMessageConsumerImpl;
import org.trpr.platform.integration.impl.messaging.RabbitMQMessagePublisherImpl;
import org.trpr.platform.integration.spi.messaging.MessagingException;
/**
# In your local clone of your forked repository, you can add the original GitHub repository as a "remote".
# ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.)
# Then you can fetch all the branches from that upstream repository, and rebase your work to continue
# working on the upstream version. In terms of commands that might look like:
# Add the remote, call it "upstream":
git remote add upstream git://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
@srikanthps
srikanthps / Program.cs
Created August 27, 2012 13:01
C# Code to Digitally Sign Using a .P12 file (its really a hack, for reference purposes only!!!)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Xml;
using System.Xml;
@srikanthps
srikanthps / Sample Output - JRuby 1.6.7
Created April 7, 2012 07:51
Code to check whether a String contains balanced braces or not
{} is ** _Balanced_ ** (Time taken: 0.032)
{}{ is ~~ Unbalanced ~~ (Time taken: 0.0)
{{}} is ** _Balanced_ ** (Time taken: 0.0)
}{}{ is ~~ Unbalanced ~~ (Time taken: 0.0)
{{{{{ - balanced - }}}}} is ** _Balanced_ ** (Time taken: 0.015)
{{{}{{{}}}{}}} is ** _Balanced_ ** (Time taken: 0.0)
@srikanthps
srikanthps / Application Log
Created August 20, 2011 12:47
HBase Issue - Logs for HBase user mailing list
2011-08-20 17:20:08,088 [gridgain-#6%authGrid%] DEBUG [impl.steps.DataReader] - Looking up 928082348209 in database
2011-08-20 17:20:09,092 [gridgain-#6%authGrid%] DEBUG [hbase.client.HConnectionManager$HConnectionImplementation] - Lookedup root region location, connection=org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@2cc25ae3; hsa=DC1AuthDFSC1D3.cidr.gov.in:6020
2011-08-20 17:20:09,092 [gridgain-#6%authGrid%] DEBUG [hbase.client.HConnectionManager$HConnectionImplementation] - locateRegionInMeta parentTable=-ROOT-, metaLocation=address: DC1AuthDFSC1D3.cidr.gov.in:6020, regioninfo: -ROOT-,,0.70236052, attempt=0 of 10 failed; retrying after sleep of 1000 because: null
2011-08-20 17:20:09,093 [gridgain-#6%authGrid%] DEBUG [hbase.client.HConnectionManager$HConnectionImplementation] - Lookedup root region location, connection=org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@2cc25ae3; hsa=DC1AuthDFSC1D3.cidr.gov.in:6020
2011-08-20 17:20:10,095 [gridgain-
@srikanthps
srikanthps / README
Created August 2, 2011 15:39
How to configure GridGain Logging using log4j.properties
Sample grid-config.xml shows how to configure GridGain Logging
using log4j.properties. This is needed when you are integrating GridGain
in an legacy app that use log4j.propreties for log4j configuration,
whereas GridGain uses log4j.xml.
In the above example, we are setting gridLogger property by using an
instance of GridLogger which is constructed using a regular log4j Logger object.
Then we have log4jInitialization bean that initialzes log4j using
log4j.properties with the help of org.springframework.util.Log4jConfigurer.
@srikanthps
srikanthps / README
Created July 17, 2011 17:47
HBase Shell - Method to check whether a row exists in a table
To use this program, do the following:
1. Download the "row_existence.rb" to the server where you have HBase installed.
2. Fire up the HBase shell
> $HBASE_HOME/bin/hbase shell
3. Load the "row_existence.rb" into the shell
hbase(main):001:0> "directory_where_you_downloaded_the_file/row_existence.rb"
@srikanthps
srikanthps / README.txt
Created June 18, 2011 17:13
Ruby Application to create twitter tweets - "Tweeter"
Tweeter Application:
This application can be used to create tweet programmatically.
Pre-requisites:
==============
1. In order to use it, you need to have "twitter_oauth" gem installed.
gem install twitter_auth
2. Register an application on http://dev.twitter.com/. Select the "Application Type" as "client", as this program does is not a web-based application and hence, cannot have call back URL as needed for browser apps.
@srikanthps
srikanthps / MailerApp.java
Created July 17, 2010 16:38
Java app to send emails using "Gmail"
import java.security.Security;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;