Skip to content

Instantly share code, notes, and snippets.

View Keshava11's full-sized avatar
🎯
Focusing

Bruce Keshava11

🎯
Focusing
View GitHub Profile
@Keshava11
Keshava11 / custom_actionbar
Last active August 29, 2015 14:01
Access ActionBar Title TextView For All Android, Setting Marquee To It And Also Detecting If Marquee Is Activated And Hence Shrinking(Customizing) TextView
This is about how to access action bar title for all versions, detecting if marquee is activated for the actionbar title and if it is then customizing the font.
This mainly emphasizing on avoiding custom view as long as one can access actionbar title textview this way.
Since there is no direct way to customize the title TextView in android, a way is :
getResources().getIdentifier(String resId, String resType, String package);
So when it comes for actionbar in all versions of android we can access it as :
int titleId = 0;
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB)
@Keshava11
Keshava11 / .gitignore
Created November 1, 2014 08:10
Simple .gitignore file for an Android project.
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
# Built application files
*.apk
*.ap_
@Keshava11
Keshava11 / 51-android.rules
Created January 15, 2015 08:41
Sample 51-android.rules file
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="054c", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="0fce", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="17ef", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="8087", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
@Keshava11
Keshava11 / colors.xml
Last active October 16, 2021 22:51
Xml file containing hex codes for all colors form material-design pallete
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_50">#fde0dc</color>
<color name="red_100">#f9bdbb</color>
<color name="red_200">#f69988</color>
<color name="red_300">#f36c60</color>
<color name="red_400">#e84e40</color>
<color name="red_500">#e51c23</color>
@Keshava11
Keshava11 / .hgignore
Created September 25, 2015 06:14
Simple .hgignore file for Android projects based on Mercurial
.classpath
.project
syntax: glob
*.class
*.apk
*.dex
*.ap_
*.suo
.metadata\*
@Keshava11
Keshava11 / FireBasePushMessage.py
Created July 8, 2016 10:46
Python script (App Server) to post a downstream message to a particular device using FireBase Cloud Messaging.
import urllib2
import json
payload = {'data': {'name':'Robby', 'dept':'HRD'},'to':'<Token-Generated-In-Device>'}
url = 'https://fcm.googleapis.com/fcm/send'
headers = {'Content-Type': 'application/json', 'Authorization': 'key=<YourServerKey>'}
# When request body has to be plain text
# headers = {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'Authorization': 'key=<YourServerKey>'}
@Keshava11
Keshava11 / FireBaseDownStreamMessage.py
Created July 8, 2016 10:49
Another Python script (App Server) to post a downstream message to a particular device using FireBase Cloud Messaging.
import requests
import json
payload = {'data': {'name':'Robby', 'dept':'HRD'}, 'to':'<Token-Generated-In-Device>'}
url = 'https://fcm.googleapis.com/fcm/send'
myheaders = {'Content-Type': 'application/json', 'Authorization': 'key=<YourProjectServerKey>'}
data=json.dumps(payload)
@Keshava11
Keshava11 / TimeFormatter.java
Created August 8, 2016 09:15
Utility to format time in milliseconds as format hh:mm:ss .
package com.utils.formatter;
import java.util.IllegalFormatException;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.time.DurationFormatUtils;
public class TimeFormatter {
private static final String DURATION_FORMAT = "%02d:%02d:%02d";
@Keshava11
Keshava11 / eclipse.ini
Created December 26, 2016 20:33
Simple update to Eclipse based ScalaIDE config file.
-vm
C:\Program Files\Java\jdk1.8.0_25\bin\javaw.exe
-startup
plugins/org.eclipse.equinox.launcher_1.3.200.v20160318-1642.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.400.v20160518-1444
-vmargs
-Xmx2G
-Xms200m
-XX:MaxPermSize=512m
@Keshava11
Keshava11 / FileNameUtils.java
Created December 28, 2016 09:18
File name utility extracted from FileNameUtils class in Apache's IO library
/**
* Simplest utility to fetch the name of file from full path extracted from {@link FileNameUtils} given under below link
* References : https://android.googlesource.com/platform/packages/apps/UnifiedEmail/+/master/src/org/apache/commons/io/FilenameUtils.java
*/
public class FileNameUtils {
/**
* The Unix separator character.
*/