Skip to content

Instantly share code, notes, and snippets.

View sankars's full-sized avatar

Sankar sankars

  • Dubai
View GitHub Profile
@sankars
sankars / hbase_phoenix.sql
Created August 21, 2013 14:57
Hbase Phoenix queries
CREATE TABLE "1004_ALERT_TYPE"
(
NAME varchar(100) primary key,
d.atd varchar(100),
d.atn varchar(10)
)
select * from "1004_ALERT_TYPE" limit 100
import java.util.Properties;
public class PrintSystemProperties{
public static void main(String[] args) {
Properties prop = System.getProperties();
for( String name : prop.stringPropertyNames())
{
System.out.println("foo" == "foo");
System.out.println(new String("bar") == new String("bar"));
System.out.println("bar" == new String("bar").intern());
String a = "12345";
String b = "12345";
System.out.println(a == b);
System.out.println(a.equals(b));
@sankars
sankars / Dev_ElasticSearch
Created December 23, 2013 08:07
Development Environment setup for Elastic Search using Maven
1) mvn archetype:create -DgroupId=com.jmi.elasticsearch -DartifactId=ESearchSamples
2) Open pom.xml and add
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>0.90.7</version>
</dependency>
@sankars
sankars / hbase_query_scan.rb
Created January 8, 2014 15:54
JRuby code to scan a hbase table
import org.apache.hadoop.hbase.client.Scan
import org.apache.hadoop.hbase.util.Bytes
import org.apache.hadoop.hbase.client.HTable
import org.apache.hadoop.hbase.HBaseConfiguration
config = HBaseConfiguration.create()
family = Bytes.toBytes("family-name")
qual = Bytes.toBytes("qualifier")
scan = Scan.new()
@sankars
sankars / rename_files_dir.sh
Last active August 29, 2015 13:55
Rename all files having its name or its contents matching the regex in a directory.
for i in *; do new_name=$(echo $i | sed -e 's/1012/1015/g'); sed -i 's/1012/1015/g' $i ; mv $i $new_name; done
@sankars
sankars / hbase_shell_scan_filter.rb
Last active August 29, 2015 13:56
scan query with filters
scan '1012_HIERARCHY_TYPE',{FILTER=>"SingleColumnValueFilter('D','HTN',=,'binary:Country') AND TimestampsFilter(1391167399643)"}
scan '1012_DEVICE_ENERGY', { FILTER =>"RowFilter(=,'substring:2/6')"}
scan '1012_DEVICE_ENERGY', { FILTER =>"RowFilter(=,'regexstring:6')"}
@sankars
sankars / alert_script.sh
Created February 15, 2014 14:49
Shell script to check data availability in HBase through its REST interface and notifies user if no data is found
#!/bin/sh
HBASE_REST_SERVER='http://hbase_rest_server:8080'
### Open customers file and read customer list
while read line
do
IFS=', ' read -a array <<< $line
while true; do
# Waste time
if [ $wasted_time -gt 100000 ]; then
exit 0
fi
done
## declare an array variable
declare -a arr=("element1" "element2" "element3")
## now loop through the above array
for i in "${arr[@]}"
do
echo "$i"
# or do whatever with individual element of the array
done