Skip to content

Instantly share code, notes, and snippets.

View msomu's full-sized avatar

Somasundaram M msomu

View GitHub Profile
for file in *.png.webp; do mv "$file" "${file%.png.webp}.webp"; done
@msomu
msomu / StringReverseExample.java
Created February 4, 2015 14:59
Reverse string in java
/**
*
* Java program to reverse String in Java. There are multiple ways to reverse
* String in Java, you can either take help of standard Java API StringBuffer
* to reverse String in Java. StringBuffer has a reverse() method which return StringBuffer
* with reversed contents. On the other hand you can also reverse it by applying your
* own logic, if asked to reverse String without using StringBuffer in Java. By the way
* you can also use StringBuilder to reverse String in Java. StringBuilder is non thread-safe
* version of StringBuffer and provides similar API. You can use StringBuilder's reverse()
* method to reverse content and then convert it back to String
@msomu
msomu / MyActivity.java
Last active August 29, 2015 14:13
save data and process querry
package com.soms.mytestingapplications;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.EditText;
public class MyActivity extends ActionBarActivity {
@msomu
msomu / MyActivity.java
Last active August 29, 2015 14:13
Database save user and retrive
public class MyActivity extends ActionBarActivity {
SomsDatabaseAdapter somsDatabaseAdapter;
EditText userName,passWord;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
userName = (EditText) findViewById(R.id.edittext_username);
@msomu
msomu / MyActivity.java
Last active August 29, 2015 14:13
Insert into Database
public class MyActivity extends ActionBarActivity {
SomsDatabaseAdapter somsDatabaseAdapter;
EditText userName,passWord;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
userName = (EditText) findViewById(R.id.edittext_username);
@msomu
msomu / MyActivity.java
Last active August 29, 2015 14:13
SQLHelper class running example
public class MyActivity extends ActionBarActivity {
SomsHelper somsHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
somsHelper = new SomsHelper(this);
@msomu
msomu / MyActivity.java
Created January 14, 2015 08:37
To get the call logs of the Android Phone
private void getCallDetails() {
StringBuffer sb = new StringBuffer();
Cursor managedCursor = managedQuery(CallLog.Calls.CONTENT_URI, null, null, null, null);
int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER);
int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE);
int date = managedCursor.getColumnIndex(CallLog.Calls.DATE);
int duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION);
sb.append("Call Log :");
while (managedCursor.moveToNext()) {
String phNumber = managedCursor.getString(number);
@msomu
msomu / designer.html
Created January 8, 2015 08:30
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
@msomu
msomu / ListView.java
Created January 2, 2015 04:32
How to create a list view
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
//Once the root view for the fragment has been created
//the ListView with some dummy data
//Create some dummy data for the list view
String [] forecastArray = {
"Today - Sunny - 88/63",
"Tomorrow -Foggy - 70/40",
@msomu
msomu / CheckInternet.java
Created December 4, 2014 11:31
To check the internet connections on the android
/*
* @return boolean return true if the application can access the internet
*/
private boolean haveInternet(){
NetworkInfo info = ((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();
if (info==null || !info.isConnected()) {
return false;
}
if (info.isRoaming()) {
// here is the roaming option you can change it if you want to disable internet while roaming, just return false