Skip to content

Instantly share code, notes, and snippets.

Avatar

Sourabh Soni sourabh86

View GitHub Profile
@sourabh86
sourabh86 / CloneObject.java
Created April 29, 2020 08:28
Java method to deep clone any object with Jackson ObjectMapper
View CloneObject.java
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
public static <T> T getClone(T objectToClone, Class<T> classType){
T clonedObject = null;
ObjectMapper objectMapper = new ObjectMapper();
try {
clonedObject = objectMapper
.readValue(objectMapper.writeValueAsString(objectToClone),classType);
} catch(IOException e) {
@sourabh86
sourabh86 / activity_main.xml
Last active August 29, 2015 14:16
Main activity layout for RemoteDroid example http://goo.gl/xRzfmE
View activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
@sourabh86
sourabh86 / MainActivity.java
Last active July 24, 2020 04:14
MainActivity for RemoteDroid Example http://goo.gl/xRzfmE
View MainActivity.java
package in.codesmith.remotedroid;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
@sourabh86
sourabh86 / RemoteDroidServer.java
Last active August 29, 2015 14:16
Server class which accepts commands from a remote android client over LAN. Used as demo code for http://goo.gl/xRzfmE
View RemoteDroidServer.java
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.MouseInfo;
import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@sourabh86
sourabh86 / ContactActivity.java
Last active November 21, 2021 06:35
Code to send data to Google Docs sheet from Android activity
View ContactActivity.java
package in.codesmith.contactusexample;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@sourabh86
sourabh86 / NewClass.js
Last active August 29, 2015 14:15
Class in ES6
View NewClass.js
class NewClass extends DummyClass {
constructor(variableA, variableB) {
super(variableA, variableB);
this.id = NewClass.defaulIdGenerator();
this.elements = [];
//...
}
update(test) {
//...
@sourabh86
sourabh86 / Default.js
Created January 28, 2015 18:32
Overriding Ext.layout.Default. This should be placed under /app/override/layout/
View Default.js
Ext.define('Ext.layout.override.Default', {
override: 'Ext.layout.Default',
removeInnerItem: function(item) {
// check for valid element
if (item.element !== null) {
item.element.detach();
}
}
View tambola.php
<?php
include_once('input.php');
//save each row in different variable
$top_row = array(5,21,31,60,81);
$mid_row = array(17,37,59,63,88);
$bottom_row = array(9,39,45,77,90);
if(count($input_array)<1){
//No numbers to check
echo "No Input Yet!!";
@sourabh86
sourabh86 / MainClass.java
Created October 4, 2013 14:43
Main class for hibernate 4 example
View MainClass.java
package com.cc.example.hibernate;
import java.util.Iterator;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
@sourabh86
sourabh86 / employee.hbm.xml
Created October 4, 2013 14:39
Employee hibernate mapping for hibernate 4 example
View employee.hbm.xml
<?xml version="1.0"?><!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.cc.example.hibernate">
<class name="com.cc.example.hibernate.Employee" table="EMPLOYEE">
<id name="id" type="long" column="ID" length="20">
<generator class="assigned"/>
</id>
<property name="firstName" column="FIRSTNAME" type="string" length="20">