Skip to content

Instantly share code, notes, and snippets.

View radzio's full-sized avatar
👨‍💻
Coding

Radek Piekarz radzio

👨‍💻
Coding
View GitHub Profile
@jsocol
jsocol / storage.js
Created March 18, 2011 14:05
Simple namespaced storage API for JS (largely stolen from Chris Van)
/**
* storage.js - Simple namespaced browser storage.
*
* Creates a window.Storage function that gives you an easy API to access localStorage,
* with fallback to cookie storage. Each Storage object is namespaced:
*
* var foo = Storage('foo'), bar = Storage('bar');
* foo.set('test', 'A'); bar.set('test', 'B');
* foo.get('test'); // 'A'
* bar.remove('test');
@mrsasha
mrsasha / methodcount.bat
Created September 14, 2014 16:08
.jar and .dex method count helpers for Windows. dx from build-tools in the Android SDK has to be in your PATH. Just call methodcount.bat "filename"
@ECHO OFF
IF "%1"=="" GOTO MissingFileNameError
IF EXIST "%1" (GOTO ContinueProcessing) ELSE (GOTO FileDoesntExist)
:ContinueProcessing
set FileNameToProcess=%1
set FileNameForDx=%~n1.dex
IF "%~x1"==".dex" GOTO ProcessWithPowerShell
REM preprocess Jar with dx
@smithaaron
smithaaron / ClickToSelectEditText.java
Last active January 2, 2019 18:37 — forked from rodrigohenriques/ClickToSelectEditText.java
Used to make your EditText a better option than Spinners
public class ClickToSelectEditText <T> extends AppCompatEditText {
CharSequence mHint;
OnItemSelectedListener<T> onItemSelectedListener;
ListAdapter mSpinnerAdapter;
public ClickToSelectEditText(Context context) {
super(context);
@a11n
a11n / DataBinding.java
Last active April 26, 2019 08:01
Android bidirectional data-binding
public class DataBinding {
@android.databinding.BindingAdapter("bind")
public static void addTextChangedListener(EditText view, final int variable) {
final ViewDataBinding binding = DataBindingUtil.findBinding(view);
view.addTextChangedListener(new TextWatcher() {
@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@bembu
bembu / wemos_mhz14.ino
Created March 11, 2016 15:33
Wemos D1 Mini + MH-Z14 + SoftwareSerial
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <ArduinoOTA.h>
#include <SoftwareSerial.h>
#include <Ticker.h>
const char* ssid = "Bembun";
const char* password = "ananasakaama";
@eyecatchup
eyecatchup / how-to-install.txt
Last active November 17, 2019 17:43
Instructions how to install (and run) "Leapcast" on Windows.
1. Download https://github.com/dz0ny/leapcast/archive/master.zip
2. Extract zip to C:\leapcast
3.1 Download Python 2.7:
x86: http://www.python.org/ftp/python/2.7.5/python-2.7.5.msi
x64: http://www.python.org/ftp/python/2.7.5/python-2.7.5.amd64.msi
3.2 Install Python to C:\Python27
NOTE: If you have a newer version, install 2.7.5 and edit the environment variable and change for example "C:\Python33" to "C:\Python27".
4.1 Download Setuptools here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#setuptools
@abeluck
abeluck / gist:6243306
Last active April 14, 2020 04:43
Local HTTP server to stream an InputStream to MediaPlayer on Android
/**
* This is simple HTTP local server for streaming InputStream to apps which are capable to read data from url.
* Random access input stream is optionally supported, depending if file can be opened in this mode.
*
* from: http://stackoverflow.com/a/9096241
*/
public class StreamOverHttp{
private static final boolean debug = false;
private final Browser.FileEntry file;
@hadilq
hadilq / LiveEvent.kt
Last active February 8, 2021 08:59
class LiveEvent<T> : MediatorLiveData<T>() {
private val observers = ConcurrentHashMap<LifecycleOwner, MutableSet<ObserverWrapper<T>>>()
@MainThread
override fun observe(owner: LifecycleOwner, observer: Observer<T>) {
val wrapper = ObserverWrapper(observer)
val set = observers[owner]
set?.apply {
add(wrapper)
@ianhanniballake
ianhanniballake / PlayerService.java
Created July 12, 2015 18:57
Minimal MediaSessionCompat needed to get RemoteControlClient to appear
package com.example.remotecontrolclient;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.media.AudioManager;
import android.os.IBinder;
import android.support.v4.media.MediaMetadataCompat;
@JakeWharton
JakeWharton / AutoGson.java
Last active November 28, 2021 12:32
A Gson TypeAdapterFactory which allows serialization of @autovalue types. Apache 2 licensed.
import com.google.auto.value.AutoValue;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization.
* <p>