Skip to content

Instantly share code, notes, and snippets.

View orhanobut's full-sized avatar

Orhan Obut orhanobut

View GitHub Profile
@orhanobut
orhanobut / gist:9362716
Created March 5, 2014 07:28
find the node in k distance in a given tree list, solution 2 : reverse back complexity = o (n)
public class HelloWorld {
public static void main(String[] args) {
Node r = new Node(0);
r.left = new Node(1);
r.right = new Node(2);
r.left.left = new Node(3);
r.left.right = new Node(4);
@orhanobut
orhanobut / gist:9362671
Last active August 29, 2015 13:57
find the node in k distance in a given tree list, solution 1 : shifting -> complexity = o (n)
public class HelloWorld {
public static void main(String[] args) {
Node r = new Node(0);
r.left = new Node(1);
r.right = new Node(2);
r.left.left = new Node(3);
r.left.right = new Node(4);
@orhanobut
orhanobut / gist:f1f0d9e59cb57c95b916
Created October 19, 2014 20:15
Create strike effect on text
textview.setText("my text");
textview.setPaintFlags(textview.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
netsh wlan set hostednetwork mode=allow ssid=name_of_network key=password
netsh wlan start hostednetwork
@orhanobut
orhanobut / MoveView.java
Created December 3, 2014 11:34
Move a view with fingers
//set imageview listener
imageView.setOnTouchListener(onButtonTouchListener);
//control the movement
private final View.OnTouchListener onButtonTouchListener = new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()){
case MotionEvent.ACTION_DOWN:
return true;
@orhanobut
orhanobut / stringmatchnumeric.java
Created December 16, 2014 16:20
To check whether string is positive numeric
string.matches("\\d+")

#to get started with dev -create a fork of the Signal-iOS repo https://github.com/WhisperSystems/Signal-iOS (click fork)

-clone that repo into a nice local directory

-add the original repository as a remote git remote add upstream https://github.com/WhisperSystems/Signal-iOS.git

@orhanobut
orhanobut / ReverseSinglyList.java
Created April 22, 2015 20:05
Reverse singly list in place
public static Node reverse(Node root){
if (root == null) return null;
Node p = null;
Node n = root;
while (n != null){
Node t = n.next;
n.next = p;
p = n;
n = t;
}
public class User {
private String name;
private Account account;
public String getName(){
return name;
}
public Account getAccount(){
return account;