Skip to content

Instantly share code, notes, and snippets.

View Mauker1's full-sized avatar
🎯
Focusing

Maurício C. P. Pessoa Mauker1

🎯
Focusing
View GitHub Profile
@alisdair
alisdair / intensify.sh
Created May 21, 2019 23:44
intensifies Slack emoji creator
#!/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
@AdamMc331
AdamMc331 / ErrorHandling.kt
Last active January 25, 2019 02:16
Shows a way to use function types to handle errors.
// 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
@aneeshkp
aneeshkp / prom_metrix_to_csv.py
Created June 13, 2018 14:03
Export data from Prometheus to csv file
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
.................................................. ............................... .......,-~~'''''''~~--,,_
.................................................. ..................................,-~''-,:::::::::::::::::::''-,
.................................................. .............................,~''::::::::',::::::: :::::::::::::|',
.................................................. .............................|::::::,-~'''___''''~~--~''':}
.................................................. .............................'|:::::|: : : : : : : : : : : : : : :|
.................................................. .............................|:::::|: : :-~~---: : : -----: |
.................................................. ............................(_''~-': : : :o: : :|: :o: : : :|
.................................................. .............................'''~-,|: : : : : : ~---': : : :,'--NEVA GAHN
.................................................. .................................|,: : : : : :-~
@mrry
mrry / tensorflow_self_check.py
Last active August 24, 2023 17:13
[DEPRECATED] TensorFlow on Windows self-check
# 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,
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;
}
@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active April 25, 2024 17:19
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

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

@yqritc
yqritc / gist:ccca77dc42f2364777e1
Last active March 29, 2024 10:25
Equal column spacing for Android RecyclerView GridLayoutManager by using custom ItemDecoration

ItemOffsetDecoration

public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

    private int mItemOffset;

    public ItemOffsetDecoration(int itemOffset) {
        mItemOffset = itemOffset;
    }
@JakeWharton
JakeWharton / gist:f50f3b4d87e57d8e96e9
Created February 7, 2015 01:59
Rise and Shine™, unlock and wake up your device automatically when you deploy from the IDE. Put this somewhere in your `src/debug/` code and run it when the application or main activity starts. Apache 2.
/**
* 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 =