Skip to content

Instantly share code, notes, and snippets.

@ssinganamalla
ssinganamalla / LoadProperties.java
Created January 12, 2016 23:15
Load config properties file located in resources directory
public static ApplicationProperties loadProperties() {
Properties prop = new Properties();
InputStream input = null;
try {
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
input = classloader.getResourceAsStream("config.properties");
// load a properties file
prop.load(input);
@ssinganamalla
ssinganamalla / JpaUserRepositoryImpl.java
Created August 16, 2013 00:19
find the single record.
public User findByEmail(String email) {
Query query = this.em.createQuery("SELECT user FROM User u where u.email= :theemail");
query.setParameter("theemail", email);
return (User) query.getSingleResult();
}
@*Empty div otherwise the deployment is not successful. keep the hack, till u figure out*@
<div></div>
@{
ViewBag.Title = "AFE Administration";
}
@ssinganamalla
ssinganamalla / HomeController
Created May 15, 2013 18:38
Preparing .NET MVC for Extjs using Controller
public class HomeController : Controller
{
public ActionResult Default()
{
return this.Redirect("/Home/main");
}
public ActionResult Index()
{
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("../../Scripts/resources/AfeAdmin-all.css")" rel="stylesheet" type="text/css" />
<!-- TO GO IN DEV MODE: comment the line -->
<!-- <script src="@Url.Content("../../Scripts/all-classes.js")" type="text/javascript"></script>-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>AfeAdmin</title>
<!-- <x-compile> -->
<!-- <x-bootstrap> -->
<link rel="stylesheet" href="bootstrap.css">
<script src="ext/ext-dev.js"></script>
<script src="bootstrap.js"></script>
@ssinganamalla
ssinganamalla / senchaappplugincopyallclasses.xml
Last active December 17, 2015 09:19
.sencha/app/plugin file to copy the all-classes.js to main
<!--
<target name="-after-generate-model">
... use ${args.path}, ${args.name} and ${args.fields} as needed ...
</target>
Other targets are similar. There are properties prefixed with "args." and the name of
the command line option that hold the parameters for the command.
-->
<!-- copy this in the .sencha/app/.plugin xml file below -->
<target name="-after-app-build">
@ssinganamalla
ssinganamalla / MaxNumber.java
Last active October 10, 2015 23:41
LargestNumber
/*
Given a list of non negative integers, arrange them such that they form the largest number.
For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.
Note: The result may be very large, so you need to return a string instead of an integer.
*/
public class MaxNumber {
String getLargestNumber(List<Integer> numbers) {
@ssinganamalla
ssinganamalla / LinkedListIntersection.java
Last active October 9, 2015 12:39
Intersection of two linkedlists
/*Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked lists:
A: a1 → a2
c1 → c2 → c3
B: b1 → b2 → b3
@ssinganamalla
ssinganamalla / ProgramSingle.java
Last active August 29, 2015 14:20
Single Dispatch
public class Program
{
/**
yes thats me
yes thats me
you will have to use Double Dispatch in order for u to print 2 statements
**/
public static void main(String[] args)