Skip to content

Instantly share code, notes, and snippets.

View sirvon's full-sized avatar

SirVon Thomas sirvon

  • XNA Inc.
  • California, USA
View GitHub Profile
@sirvon
sirvon / TwitterVideoApiClient.class
Created January 10, 2016 17:51
upload video to twitter via android client
public class TwitterVideoApiClient extends TwitterApiClient{
private static final String TWITTER_UPLOAD_URL = "https://upload.twitter.com";
private RestAdapter twitterVideoApiClientAdapter;
public TwitterVideoApiClient(TwitterSession session) {
@gbaman
gbaman / HowToOTG.md
Last active May 16, 2024 20:10
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

@sebastianbenz
sebastianbenz / gcm-high-prio.sh
Last active August 4, 2021 15:29
Send high priority GCM messages via curl (Android Doze mode & App Standby testing)
curl -X POST \
-H "Authorization: key= YOUR-API-KEY" \
-H "Content-Type: application/json" \
-d '{
"registration_ids": [
"YOUR-GCM-REGISTRATION-ID"
],
"data": {
"message": "Hello Message"
},
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.os.Build.VERSION;
public class AlarmManagerCompat {
private final AlarmManager mAlarmManager;
public AlarmManagerCompat(Context context) {
@christophermark
christophermark / Doze_Mode_Behavior.md
Last active August 20, 2021 21:37
Android Marshmallow Idle Mode Behavior

What is "idle mode"?

Idle mode is a state where the phone has no network connectivity and apps are temporarily suspended. Idle mode gets triggered by one of two ways: an asleep, still, unplugged phone (Doze mode), and when an app has not been opened in a significant amount of time (App Standby Mode). During idle mode via Doze, the phone will wake up periodically for a short amount of time, allowing apps to run and use network connectivity. Using several different methods outlined below, it is possible to wake apps up during idle mode outside of these maintenance windows.

Time to enter Doze mode

1 hour of being still after the screen turns off.

Time to enter App Standby mode

TBD

Idle maintenance windows

@ZacSweers
ZacSweers / RxJava.md
Last active September 3, 2018 18:52 — forked from cesarferreira/RxJava.md
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@igroomgrim
igroomgrim / LocationService.swift
Last active September 10, 2023 18:06
Simply Singleton CLLocationManager Class in Swift
//
// LocationService.swift
//
//
// Created by Anak Mirasing on 5/18/2558 BE.
//
//
import Foundation
import CoreLocation
@cesarferreira
cesarferreira / RxJava.md
Last active February 2, 2022 07:28
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@ToeJamson
ToeJamson / 1.java
Created August 5, 2015 15:51
Connected Car Tech Preview: Android Auto and PubNub
private Pubnub pubnub;
protected void initPubnub() {
Pubnub pubnub = new Pubnub("demo", "demo");
try {
// subscribe methods here
} catch (Exception e) {
Log.d(“PUBNUB”,e.toString());
}
}
@ftvs
ftvs / PhonecallReceiver.java
Last active October 11, 2023 10:05
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: Gabe Sechan http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {