Skip to content

Instantly share code, notes, and snippets.

View rock3r's full-sized avatar

Sebastiano Poggi rock3r

View GitHub Profile
@rock3r
rock3r / WidgetHelper.java
Last active August 29, 2015 13:57
How to update an homescreen widget (the right way)
package net.frakbot.gists.widgethelper;
/*
* Copyright 2014 Sebastiano Poggi
*
* 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
/**
* ArcUtils.java
* Copyright (c) 2014 BioWink GmbH. All rights reserved.
**/
/**
* Proper Java code style formatting
* Copyright (c) 2014 Sebastiano Poggi. Do whatever you want with this code.
*/
@rock3r
rock3r / grabdng.py
Created March 20, 2016 13:05
Grabs all DNG files from the connected Android device's camera roll
#!/usr/bin/python
import argparse, os, subprocess
# Grab the script directory to use as default
current_directory = os.path.dirname(os.path.abspath(__file__))
def parse_cli_arguments():
parser = argparse.ArgumentParser(description = 'Grabs all DNG files from the connected Android device\'s camera roll.')
@rock3r
rock3r / gfonts.py
Last active October 19, 2016 13:20
Rip fonts from Google Fonts for self-hosting, EZ
#!/usr/bin/python
#coding: utf-8
import argparse, os, tinycss, requests
def parse_cli_arguments():
parser = argparse.ArgumentParser(description='Downlads all available variants of a font from Google Fonts')
parser.add_argument('fontname', type=str, help='The name of the font. E.g., "Roboto", "Product Sans"')
return parser.parse_args()
@rock3r
rock3r / avd_flush_anim.xml
Last active January 20, 2017 13:20
Standardised Japanese Toilet 🚽 Big Flush 🌀 pictogram - as Animated Vector Drawable
<!-- All copyright to the original owners. The AVD version is free to use; please give attribution if you redistribute/modify -->
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="693dp"
android:height="693dp"
android:viewportWidth="693"
@rock3r
rock3r / prepareassets.sh
Last active April 28, 2017 23:43
Move/rename *-{m|h|xh|xxh|xxxh}dpi.png" assets into proper folder structure, ready for copypasta
#!/bin/bash
# License for any modification to the original (linked below):
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# Sebastiano Poggi wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.
# ----------------------------------------------------------------------------
prefix=${1-"drawable"}
buckets=( mdpi hdpi xhdpi xxhdpi xxxhdpi )
@rock3r
rock3r / AndroidOSVersionCheckerTest.kt
Created October 5, 2017 16:44
Testable Kotlin Android OS version checker, with tests
package me.seebrock3r.utils
import android.os.Build.VERSION_CODES.JELLY_BEAN_MR1
import android.os.Build.VERSION_CODES.JELLY_BEAN_MR2
import android.os.Build.VERSION_CODES.KITKAT
import android.os.Build.VERSION_CODES.LOLLIPOP
import android.os.Build.VERSION_CODES.LOLLIPOP_MR1
import android.os.Build.VERSION_CODES.M
import android.os.Build.VERSION_CODES.N
import org.assertj.core.api.Assertions.assertThat
@rock3r
rock3r / boot-into-cwm.sh
Created June 4, 2015 13:42
Root script for Asus Zenfone 2 for *NIX
#! /bin/bash
# How to use: save this in the folder where you extract the contents of this zip:
# http://click.xda-developers.com/api/click?format=go&jsonp=vglnk_14334252799608&key=f0a7f91912ae2b52e0700f73990eb321&libId=iai8ebh401000n4o000DAb9a6aa9o&loc=http%3A%2F%2Fforum.xda-developers.com%2Fzenfone2%2Fgeneral%2Fasus-zenfone-2-flashing-recovery-mode-t3096596&v=1&out=http%3A%2F%2Fwww.mediafire.com%2Fdownload%2Fv6m7n9j0gqins9b%2FCWM_Zenfone_2_Intel.zip&ref=http%3A%2F%2Fforum.xda-developers.com%2Fzenfone2%2Fgeneral&title=Asus%20Zenfone%202%20%7C%20Resources%20all%20in%20one%20thread%20%7C%20Asus%20ZenFone%202%20%7C%20XDA%20Forums&txt=%3Cb%3EDownload%20the%20Asus%20Zenfone%20temporary%20CWM%20package%3C%2Fb%3E
# Then chmod a+x it, and run it. Have your phone attached to the USB port with USB debugging enabled before starting.
# Setup
WORKINGDIR=$(pwd)
LAUNCHER="$WORKINGDIR/FB_RecoveryLauncher/recovery.launcher"
RECOVERY="$WORKINGDIR/FB_RecoveryLauncher/recovery.zip"
@rock3r
rock3r / RxFilterIsInstance.kt
Last active June 22, 2018 12:34
RxKotlin's ofType() name is not very easy to remember, given Kotlin has filterIsInstance() for the same. This helps alleviate the pain.
package me.seebrock3r.extensions.reactivex
import io.reactivex.Flowable
import io.reactivex.Observable
import io.reactivex.rxkotlin.ofType
@Deprecated(
message = "This is just a shorthand for RxKotlin's ofType()",
replaceWith = ReplaceWith("ofType<R>()", "io.reactivex.rxkotlin.ofType")
)
@rock3r
rock3r / CacheableProperty.kt
Created January 8, 2019 13:54
A cacheable property in Kotlin — basically, a variant of Lazy that can be invalidated and will be reloaded on the next access
package me.seebrock3r.util
import me.seebrock3r.util.CacheableProperty.CachedValue.*
import kotlin.properties.*
import kotlin.reflect.*
import kotlin.reflect.jvm.*
fun <T> cache(producer: () -> T): CacheableProperty<T> = CacheableProperty(producer)
class CacheableProperty<out T>(val producer: () -> T) : ReadOnlyProperty<Any, T> {