Skip to content

Instantly share code, notes, and snippets.

@hemantborole
hemantborole / S3Utils.scala
Created March 13, 2018 20:35
Encrypt and Decrypt S3 objects using Customer Encryption Key
/**
* decrypt s3 object using the secret key
* @param objectSummary s3 file summary reference to decrypt
* @param kmsCmkOld kms key obtained from objects userMetadata
* @return (String, String, Array[Byte]) tuple containing
* md5 hash of contents of the s3 object
* kmsKeyId kms key id for kms encryption on server side for the s3 object.
* data bytes in the decrypted s3 object
*/
def decryptS3Object( objectSummary : S3ObjectSummary,
@hemantborole
hemantborole / tab_mi.rb
Created January 1, 2011 16:45
Code for activerecord-sqlserver-adapter
class TabMI < ActiveRecord::Base
establish_connection MyDB
set_table_name 'tab'
set_primary_key 'tabid'
def taber(tabid)
tabinfo = TabMI.where(:tabid => tabid).first
puts "=============== Existing attr text #{tabinfo['ATTR_TEXT']}===============" ## Works perfect.
puts "=============== setting attr text to new attr==============="
tabinfo['ATTR_TEXT'] = "New Attr"
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1024
int main() {
int i =0;
char env[][MAX] = {"one", "two", "three" };
char **newenv = NULL;
PoolParty core loadtime: 0.146382
No autoscalers defined
Launching new nodes and then shutting down original nodes
Starting node: 0...
Waiting for node to launch............. OK
Terminating node: 0...
running on CloudProviders::Ec2
for cloud: monitor
minimum_instances: 1
##CURL Request Directly to WATSON
curl -i --header 'Transfer-Encoding: Chunked' "http://<WATSON_SERVER:PORT>/smm/watson?imei=hemant&grammar=business.search.lm&resultFormat=json&metrics=1&audioFormat=amr" --data-binary @<path_to_audio_amr_file>
##CURL Request to Minerva
curl -i --header 'Transfer-Encoding: Chunked' "http://<MINERVA_SERVER:PORT>/asr?imei=hemant&grammar=qme.lm&resultFormat=json&audioFormat=au" --data-binary @<path_to_audio_au_file>
## if you have a au audio file instead of the amr, change the audioFormat in the urls above. (applies to both minerva and watson)
## the grammar parameter is the one that points to a directory name under /mnt/grammars/lm, in case you want to change that to chacha
#!/bin/bash
BASE_DIR="/mnt/grammars"
curl="curl --retry 3 --silent --show-error --fail"
instance_data_url=http://169.254.169.254/latest/user-data
# Starting an instance
# ec2-run-instance --user-data-file "http://s3_url"
require 'java'
require '"#{File.dirname(__FILE__)}/<relative_path>/lib.jar"
include_class your.classname
#!/usr/bin/ruby
log = File.open('thread.log','w') ## logging to see threads flow.
TIMEOUT = 3
t1 = Time.now
## Start a timer thread
timer = Thread.start {
log.puts 'Started.. '