Skip to content

Instantly share code, notes, and snippets.

@yssharma
yssharma / AESTest.java
Last active April 28, 2022 03:26
Basic java code to Encrypt/Decrypt Files present on the HDFS. The code does not use Map-Reduce jobs for the process. The code is cross-platform compatible C# modules. The C# code would need little tweaking for cross-platform compatibility: aes.Padding = PaddingMode.PKCS7; aes.Mode = CipherMode.CBC; aes.KeySize = 128; aes.BlockSize = 128;
package com.test.aes;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import java.security.spec.AlgorithmParameterSpec;
@yssharma
yssharma / ScriptMain.cs
Created December 30, 2013 06:28
C# encryption/ decryption code for Rijndael implementation. Cross platform compatible with the java code provided here: https://gist.github.com/yashs360/8178448
using System;
using System.Data;
using System.Security;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Text;
using System.IO;
namespace Rijndael.csproj
@yssharma
yssharma / AES.java
Last active January 1, 2016 17:39
Java Encryption/ Decryption with AES Cipher. Compatible with cross platform C# Rijndael Cipher.
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.security.Key;
@yssharma
yssharma / Connected.java
Last active December 27, 2015 14:19
Connected
package puzzles;
import java.util.Scanner;
/*
*
* 4
4
0 0 1 0
1 0 1 0
@yssharma
yssharma / MeetingSchedules.java
Last active December 27, 2015 11:09
Playing around with scheduling problems
package puzzles;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
/*
*
@yssharma
yssharma / OperatorFunctionResolver.java
Last active December 26, 2015 10:59
Sample Operator Function Resolver
package org.apache.drill.exec.resolver;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.drill.common.expression.FunctionCall;
import org.apache.drill.common.expression.LogicalExpression;
import org.apache.drill.common.types.TypeProtos.MajorType;
import org.apache.drill.exec.expr.fn.DrillFuncHolder;
@yssharma
yssharma / somefile.xml
Created October 17, 2013 07:10
xml test
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Hello World"
description="Matches and echoes 'Hello World' string in emails">
<!-- Declare feature dependencies. -->
<!-- This one is not specific to Gmail contextual gadgets. -->
<Require feature="dynamic-height"/>
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<label t="translate(0,346)">
@yssharma
yssharma / temp.java
Last active December 10, 2015 12:28
class Node { int data; Node next; public Node(int data) { this.data = data; } } public class LinkedList { private Node root; public void addAtEnd(int data) { if (root == null) { root = new Node(data); return; } Node tmp = root; while (tmp.next != null) { tmp = tmp.next; } tmp.next = new Node(data); } public void addAtFront(int data) { Node newRoot = new Node(data); newRoot.next = root; root = newRoot; } public void addAtIndex(int data, int index) { if (root == null) return;return data; } public void printList() { if (root == null) { System.out.println("List is Empty !!"); return; } Node tmp = root; System.out.println(); while (tmp != null) { System.out.print(">" + tmp.data); tmp = tmp.next; } } public staticvoid main(String[] args) { LinkedList list = new LinkedList(); list.printList(); list.addAtEnd(1); list.printList(); list.addAtFront(2); list.printList(); list.addAtEnd(3); list.printList(); list.addAtIndex(4, 2); list.printList(); list.addAtIndex(5, 4); list.printList(); list.addAtEnd(6); list.printList()
@yssharma
yssharma / Maximum.java
Created January 2, 2013 10:28
Code snippet from Hadoop Guide
import org.apache.hadoop.hive.ql.exec.UDAF;
import org.apache.hadoop.hive.ql.exec.UDAFEvaluator;
import org.apache.hadoop.io.IntWritable;
public class Maximum extends UDAF {
public static class MaximumIntUDAFEvaluator implements UDAFEvaluator {
private IntWritable result;