public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {
private int mItemOffset;
public ItemOffsetDecoration(int itemOffset) {
mItemOffset = itemOffset;
}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Show the activity over the lockscreen and wake up the device. If you launched the app manually | |
* both of these conditions are already true. If you deployed from the IDE, however, this will | |
* save you from hundreds of power button presses and pattern swiping per day! | |
*/ | |
public static void riseAndShine(Activity activity) { | |
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED); | |
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE); | |
PowerManager.WakeLock lock = |
The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.
However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getForegroundPackage() { | |
ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); | |
RunningTaskInfo foregroundTaskInfo; | |
foregroundTaskInfo = am.getRunningTasks(1).get(0); | |
String foregroundTaskPackageName = foregroundTaskInfo.topActivity.getPackageName(); | |
return foregroundTaskPackageName; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2015 The TensorFlow Authors. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.................................................. ............................... .......,-~~'''''''~~--,,_ | |
.................................................. ..................................,-~''-,:::::::::::::::::::''-, | |
.................................................. .............................,~''::::::::',::::::: :::::::::::::|', | |
.................................................. .............................|::::::,-~'''___''''~~--~''':} | |
.................................................. .............................'|:::::|: : : : : : : : : : : : : : :| | |
.................................................. .............................|:::::|: : :-~~---: : : -----: | | |
.................................................. ............................(_''~-': : : :o: : :|: :o: : : :| | |
.................................................. .............................'''~-,|: : : : : : ~---': : : :,'--NEVA GAHN | |
.................................................. .................................|,: : : : : :-~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import requests | |
import sys | |
def GetMetrixNames(url): | |
response = requests.get('{0}/api/v1/label/__name__/values'.format(url)) | |
names = response.json()['data'] | |
#Return metrix names | |
return names |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a custom error class that holds both the error that occured, | |
// and a function to invoke if it retries. | |
data class MyCustomError( | |
val error: Throwable? = null, | |
val retry: (() -> Unit)? = null | |
) | |
// Create a state class that represents the current state of your screen. | |
// This is where you'd wanna put data you have to display, like a list of items | |
// or maybe an error, and a function to call if you want to retry something |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generate a `:something-intensifies:` Slack emoji, given a reasonable image | |
# input. I recommend grabbing an emoji from https://emojipedia.org/ | |
set -euo pipefail | |
# Number of frames of shaking | |
count=10 | |
# Max pixels to move while shaking |