Skip to content

Instantly share code, notes, and snippets.

View harshvishu's full-sized avatar
🦀
Learning

हर्ष • Harsh • ハラシャ harshvishu

🦀
Learning
View GitHub Profile
@harshvishu
harshvishu / GetApplicationStatus.java
Last active August 29, 2015 14:27
The method 'isAppForeground()' of this class returns true if application is currently visible otherwise false
package com.package.application.*;//your own package
import android.app.ActivityManager;
import android.content.Context;
import java.util.List;
/**
* Created by harsh on 13/8/2015.
* <p/>
/**
* Created by harsh on 04-Jul-15.
* <p/>
* class optimizes the memory operation to create Typeface which is costly
* creates a static reference as this method may be use several times during the code execution
*/
public class Typefaces {
private static final Hashtable<String, Typeface> cache = new Hashtable<>();
public static Typeface get(Context c, String name) {
Language / Locale Supported since version
English, US (en_US) 1.1
German, Germany (de_DE) 1.1
Chinese, PRC (zh_CN) 1.5
Chinese, Taiwan (zh_TW) 1.5
Czech, Czech Republic (cs_CZ) 1.5
Dutch, Belgium (nl_BE) 1.5
Dutch, Netherlands (nl_NL) 1.5
English, Australia (en_AU) 1.5
@harshvishu
harshvishu / BinarySearchTree
Created August 29, 2016 10:44
Generic BinarySearchTree with map,filter,reduce
import Foundation
public class BinarySearchTree<T: Comparable>{
private (set) public var value: T
private (set) public var parent: BinarySearchTree?
private (set) public var left: BinarySearchTree?
private (set) public var right: BinarySearchTree?
public init(value: T){
self.value = value
@harshvishu
harshvishu / Scribblable
Created September 1, 2016 06:04
Scribblable modified class for drawing (Signature)
//
// Scribblable.swift
// Signature
//
// Created by harsh vishwakrama on 8/26/16.
//
import UIKit
// MARK: Scribblable protocol
# xcode-version-bump.sh
# @desc Auto-increment the version number (only) when a project is archived for export.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Check the checkbox "Run script only when installing"
# 6. Drag the "Run Script" below "Link Binaries With Libraries"
# 7. Insure your starting version number is in SemVer format (e.g. 1.0.0)
@harshvishu
harshvishu / Debounce Text Watcher
Created May 18, 2017 17:10
Custom TextWatcher with debounce operator (Notify text changes after delay)
package com.brotherpowers.your_package_name.Controller;
import android.os.Handler;
import android.os.Looper;
import android.text.Editable;
import android.text.TextWatcher;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
{"data":[{"name":"Sample Group","members":[{"amount":["27.98","13.19","56.73","49.35","51.27","79.65","39.58","90.32","95.1"],"name":"Carolina"},{"amount":["95.1","29.19","39.81","21.66","59.03","78.09","71.14","55.12","10.99","34.27"],"name":"Cruz"},{"amount":["58.14","23.86","58.3","84.15","26.22","80.48","63.76","49.95"],"name":"Madden"},{"amount":["24.05","68.99","23.95","21.82","45.62","38.25"],"name":"Shannon"},{"amount":["13.74","75.72","62.86","27.2","20.61","74.54","64.75"],"name":"Lambert"},{"amount":["64.35","66.16","93.57","37.39","95.65","91.07","45.77","78.32"],"name":"Byrd"},{"amount":["65.5","90.02","31.03","93.46","80.26","26.84","71.48","43.83"],"name":"Jimmie"},{"amount":["98.73","92.42","98.9","71.05","13.82","60.83","17.28","52.91","56.94"],"name":"Renee"}]}]}
{
"success": true,
"response": {
"id": "4",
"name": "Door",
"type": "building",
"bankLabel": "Location",
"elevatorLabel": "Sub-Location",
"user_id": "58",
"status": null,
typealias Codable = Decodable & Encodable