Skip to content

Instantly share code, notes, and snippets.

View d3ep4k's full-sized avatar
🏠
Working from home

Deepak Mishra d3ep4k

🏠
Working from home
View GitHub Profile
@d3ep4k
d3ep4k / DBHelper.java
Created July 2, 2015 11:01
DB Helper to perform CRUD operations
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@d3ep4k
d3ep4k / ResultSetToXML.java
Created July 3, 2015 12:49
Result Set to XML Byte Stream
public static ByteArrayOutputStream ResultSetToXML(ResultSet rs)
throws ParserConfigurationException, SQLException,
XMLStreamException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLStreamWriter writer = XMLOutputFactory.newInstance()
.createXMLStreamWriter(baos);
writer.writeStartDocument();
writer.writeStartElement("Results");
@d3ep4k
d3ep4k / PassByValue.groovy
Created July 3, 2015 12:57
Java Pass by Value or Pass by Reference
class Dog{
String name
Dog(String name){
this.name = name;
}
String getName(){ return this.name;}
}
Dog aDog = new Dog("Max");
foo(aDog);
@d3ep4k
d3ep4k / JAXBTest.java
Created July 3, 2015 13:05
XML to Object JAXB
import java.util.List;
import javax.xml.bind.annotation.*;
import javax.xml.bind.*;
import java.io.*;
/**
* For mapping Detail XML to objects
*/
@XmlRootElement(name="Detail1")
class Detail{
@d3ep4k
d3ep4k / ShapedWindow.java
Last active August 29, 2015 14:26
Custom Shaped Window
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.geom.*;
public class ShapedWindow implements ActionListener{
ShapedPane pane = new ShapedPane();
final static int INTERVAL = 1000;
String[] tokens;
int counter = 0;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
console.log(xhr.responseText);
}
}
xhr.open('GET', 'http://www.html5rocks.com/en/tutorials/file/xhr2/', true);
xhr.send(null);
var mainApp = angular.module("mainApp", []);
//Tag name is mentioned at three places.
//1. Directive declaration
//2. Template
//3. Scope
//it does not take camel cased or works with special characters like - or _
var directive = function() {
var directive = {};
<!DOCTYPE html>
<!-- saved from url=(0051)https://mathiasbynens.github.io/jquery-placeholder/ -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
</head>
<body>
<input type="text" name="name" placeholder="Enter Name" autofocus="autofocus" />
<script src="./HTML5 placeholder jQuery Plugin_files/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
</head>
<body>
<input type="text" name="name" placeholder="Enter Name" autofocus="autofocus" />
<span></span>
<script src="./HTML5 placeholder jQuery Plugin_files/jquery.min.js">
</script>
<!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<style>
.holder{
color:grey;
margin-left: 2px;
margin-top:2px;
position:absolute;
}