Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Focusing

S. M. AMRAN smamran

:octocat:
Focusing
View GitHub Profile
@smamran
smamran / DefaultVsParameterised.java
Created Sep 20, 2015
Java Default Constructor vs Parameterised Constructor
View DefaultVsParameterised.java
class Main {
public static void main(String[] args) {
Person person = new Person(); // will get error as defautl empty constructor is not given
}
}
class Person {
String firstName;
@smamran
smamran / GitHubCommands.md
Created Sep 20, 2015
GitHub commands utility
View GitHubCommands.md

Setting New remote URL in Local Repository

  1. New URL
@smamran
smamran / ReferencePreservation.java
Created Sep 21, 2015
Java Object Reference Preservation
View ReferencePreservation.java
class ReferencePreservation {
public static void main(String[] args) {
B b = new B();
b.x = 10;
System.out.println("Before method call b.x " + b.x);
A a = new A();
a.method(b);
@smamran
smamran / getValuesFromObjectKeys.js
Created Sep 22, 2015 — forked from coreyc/getValuesFromObjectKeys.js
functional way to get values from object keys
View getValuesFromObjectKeys.js
var inputObject = { 0: 'a', 1: 'b', 2: 'c' };
var values = [];
Object.keys(inputObject).forEach(function(key) {
values.push(inputObject[key]);
return values;
});
console.log(values);
@smamran
smamran / Fxservidor.java
Created Sep 22, 2015
Java FX Hello World
View Fxservidor.java
// Always ensure Java Class Name is same as File Name in JavaFX. Otherwise give error in running
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
@smamran
smamran / ISOCppDraft-2015.md
Last active Sep 22, 2015
ISO cpp Draft september 9, 2015
View ISOCppDraft-2015.md
@smamran
smamran / ConnectivityCheck.java
Created Sep 22, 2015
Check Whether Mobile is Connected to Network
View ConnectivityCheck.java
ImageView iv;
iv = (ImageView) findViewById(R.id.icon);
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ConnectivityManager mConMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mNetworkInfo = mConMgr.getActiveNetworkInfo();
if (mNetworkInfo != null && mNetworkInfo.isConnected()) {
System.out.println("Yes Connected");
} else {
@smamran
smamran / AmbiguousOverloading.java
Last active Sep 22, 2015
Java Ambiguous Function Overloading
View AmbiguousOverloading.java
class Main {
static int max(int x, double y) {
return (x > y) ? x : (int) y;
}
static int max(double x, int y) {
return (x > y) ? (int) x : y;
}