Skip to content

Instantly share code, notes, and snippets.

public class Shape {
private int length;
private int width;
private Shape(int length, int width) {
// this constructs rectangle
this.length = length;
this.width = width;
}
private Shape(int length) {
// Constructs the square
public class SuperClass {
int i = 1;
}
public class SuperClass {
public void display() {
System.out.println("Super");
}
}
public class SuperClass {
public SuperClass() {
System.out.println("SuperClass Constr with no params");
}
public SuperClass(int a, int b) {
System.out.println("SuperClass Constr with two params");
}
}
@ajduke
ajduke / git-cleanup.sh
Created December 4, 2012 06:32 — forked from nvie/git-cleanup.sh
Very rough script that cleans up all old branches that are loosely hanging around after a while. Also updates the origin remote.
#!/bin/sh
fix_branch_output () {
# Strips first columns from the output, to remove whitespace and "current
# branch" marker from git-branch's output
cut -c 3-
}
local_branches () {
git branch | fix_branch_output
@ajduke
ajduke / gist:4571560
Last active December 11, 2015 08:09
mongod.conf
This is file taken from following repo to find it easily:
https://github.com/mongodb/mongo/blob/master/debian/mongodb.conf
More details on each properties find here:
http://www.mongodb.org/display/DOCS/File+Based+Configuration?pageVersion=13
# mongodb.conf
# Where to store the data.
package test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class HarshadNumber {
public static void main(String[] args) {
for (int i = 0; i < 250; i++) {
@ajduke
ajduke / .mongorc.js
Last active December 19, 2015 04:39 — forked from sawanoboly/.mongorc.js
including the which is current database
prompt = function() {
// set version
version = db.version();
dbName = db.getName()
// case mongos
if (rs.status().info == 'mongos') {
return rs.status().info + ':[' + version + '] > ';
}
// config or replica
@ajduke
ajduke / Example1-Output
Last active August 14, 2018 17:12
Getting started with GSON
toJson ---
Original Java object : ModelObject [name=myname, val=12, status=true, f=2.3]
Converted JSON string is : {"name":"myname","val":12,"status":true,"f":2.3}
fromJson----
Original JSON string is : {"name":"myname","val":12,"status":true,"f":2.3}
Converted Java object : ModelObject [name=myname, val=12, status=true, f=2.3]
@ajduke
ajduke / Example1.java
Last active December 20, 2015 08:09
Example 1 - GSON Example
final Gson gson = new Gson();
// original object instantiation
ModelObject modelObject = new ModelObject("myname", 12, true, 2.3);
System.out.println("toJson ---");
System.out.println("Original Java object : " + modelObject);
// converting an object to json object
String json = gson.toJson(modelObject);
System.out.println("Converted JSON string is : " + json);
System.out.println("fromJson----");