Skip to content

Instantly share code, notes, and snippets.

@gSrikar
gSrikar / All Permissions - Honor 9 Lite (8.0)
Last active June 22, 2023 07:40
Get List of all the permissions on a device using adb command. `adb shell pm list permissions`
android.permission.REAL_GET_TASKS
android.permission.ACCESS_CACHE_FILESYSTEM
android.permission.REMOTE_AUDIO_PLAYBACK
com.amazon.mp3.permission.UA_DATA
com.huawei.alarm.provider.writePermission
com.google.android.apps.photos.permission.C2D_MESSAGE
android.permission.REGISTER_WINDOW_MANAGER_LISTENERS
android.permission.INTENT_FILTER_VERIFICATION_AGENT
android.permission.BIND_INCALL_SERVICE
android.permission.PROVIDE_RESOLVER_RANKER_SERVICE
@gSrikar
gSrikar / Fetch Stock Prices and Save to Local Folder
Last active March 3, 2021 07:08
Fetch the stock prices from yahoo and save the data frame to the local machine. For more detailed explanation, check out my blog post https://www.gsrikar.com/2020/02/how-to-fetch-and-save-stock-price.html
1. Fetch the stock prices using pandas_datareader libray.
2. Use pandas to save the data frame to csv file or xlsx file.
3. Fetch and save for the desired ticker symbol between any date range.
@gSrikar
gSrikar / Tensor Rank and Tensor Shape - Tensorflow
Last active March 3, 2021 07:07
Tensors with different ranks shapes are created and printed out to the output. Tensor Ranks and Tensor Shapes are explained in detail at http://gsrikar.blogspot.com/2017/06/what-is-tensor-rank-and-tensor-shape.html
'''
Class creates tensors of different ranks and shapes
'''
import tensorflow as tf
def main():
'''
Main method
@gSrikar
gSrikar / Solution to TypeError or ValueError caused by Tensor dtype
Last active April 11, 2018 04:39
Example that resolves the TypeError: Input 'y' of 'Mul' Op has type float32 that does not match type int32 of argument 'x' or ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float64 in Tensorflow.
import tensorflow as tf
node1 = tf.constant(5) # dtype is int32
node2 = tf.constant(6.0) # dtype is float32
print('Node 1: ', node1) # Node 1: Tensor("Const:0", shape=(), dtype=int32)
print('Node 2: ', node2) # Node 2: Tensor("Const_1:0", shape=(), dtype=float32)
# Multiplication
# Convert the node1 type to float32 before multiplying
@gSrikar
gSrikar / Placeholders in TensorFlow
Last active July 24, 2017 00:30
Placeholders allow us to feed data to the model during the session. To get more detailed information about it, take a look at my blog post at http://gsrikar.blogspot.com/2017/06/tensorflow-how-to-use-placeholders.html
'''
Class uses placeholders instead of constants.
'''
import tensorflow as tf
def main():
'''
Main Method
@gSrikar
gSrikar / Arithmetic Operations in TensorFlow
Last active July 24, 2017 00:28
Gist explains how to perform Arithmetic operations in Tensorflow and show it in a computational graph. For more detailed explanation, check out the my blog post https://gsrikar.blogspot.com/2017/07/arithmetic-operations-tensorflow.html
'''
Class performs arithmetic operations on multiple tensors and
shows the Computational graph with the help of Tensorboard.
Uses constants for arithmetic operations
'''
import tensorflow as tf
@gSrikar
gSrikar / Update Progress Bar Color Continously
Last active June 23, 2017 19:19
The gist updates the color of the progress bar every few seconds like Inbox by Gmail app. The detailed explanation can be found in my blog post http://gsrikar.blogspot.com/2017/01/how-to-update-circular-progressbar.html
/**
* The amount of time that has to pass to update the progress bar color
*/
private static final long UPDATE_TIME_IN_MILLIS = 2000;
/**
* List of all the desired colors of the progress bar
*/
private ColorStateList[] colorsList;
@gSrikar
gSrikar / Solves Resources Not Found Exception
Last active January 16, 2017 13:28
This gist shows how to solve Resources Not Found Exception especially when implementing CountDownTimer. I've explained about the exception in detail in my blog post http://gsrikar.blogspot.com/2017/01/resources-not-found-exception-in-android.html
new CountDownTimer(10000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
Log.i(TAG, "Time in Milli until finished: " + millisUntilFinished);
int remainingTimeInSec = (int) (millisUntilFinished / 1000);
countDownTimeTextView.setText(String.valueOf(remainingTimeInSec));
}
@Override
public void onFinish() {
@gSrikar
gSrikar / Resources Not Found Exception Example
Last active January 16, 2017 13:28
This gist shows when a Resources Not Found Exception is thrown especially when implementing CountDownTimer. I've explained about the exception in detail in my blog post http://gsrikar.blogspot.com/2017/01/resources-not-found-exception-in-android.html
new CountDownTimer(10000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
Log.i(TAG, "Time in Milli until finished: " + millisUntilFinished);
int remainingTimeInSec = (int) (millisUntilFinished / 1000);
countDownTimeTextView.setText(remainingTimeInSec);
}
@Override
public void onFinish() {