Skip to content

Instantly share code, notes, and snippets.

View Chromecast batch conversion script
#! /bin/bash
# Batch Convert Script by StevenTrux
# The Purpose of this Script is to batch convert any video file to mp4 or mkv format for chromecast compatibility
# this script only convert necessary tracks if the video is already
# in H.264 format it won't convert it saving your time!
# Put all video files need to be converted in a folder!
# the name of files must not have " " Space!
# Rename the File if contain space
View gist:9c99318faf116317d426
public Observable<Show> getShows() {
return authClient.getAuthString()
.flatMap(token -> contentApi.getShows(token, selectedMediaServer))
.flatMap(shows -> Observable.from(shows.getShows()))
.flatMap(this::getImdbId);
}
public Observable<Show> getImdbId(Show show) {
return omdbApi.searchByTitle(show.getTitle())
.flatMap(movie -> {
@rharter
rharter / View.java
Last active Dec 16, 2015
The issue here is that the View.setBackgroundDrawable method has been deprecated but the replacement method, View.setBackground, just delegates to the deprecated method. How can I handle this in a safe manner?
View View.java
/**
* Unless I'm mistaken, this should never happen. If you deprecate a method
* to replace it with another, shouldn't the actual functionality be moved
* to the new method and the deprecated method be made to delegate to the
* replacement method?
*/
public void setBackground(Drawable background) {
//noinspection deprecation
setBackgroundDrawable(background);
}
View gist:5407184
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
@rharter
rharter / colorcat.py
Created Jun 12, 2013
This is a simple modification fo Jeff Sharkey's colored logcat script that adds the ability to use standard logcat filtering. For instance, I use this script with `./colorcat.py -d Hashnote:* *:E`.
View colorcat.py
#!/usr/bin/python
'''
Copyright 2009, The Android Open Source Project
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
View images2android.sh
type mogrify >/dev/null 2>&1 || { echo >&2 "» This script requires mogrify. Please install ImageMagick first!"; exit 1; }
IOS_IMAGE_PATH="$1"
OUTPUT_PATH="$2"
mkdir -p $OUTPUT_PATH/res/drawable-hdpi $OUTPUT_PATH/res/drawable-mdpi $OUTPUT_PATH/res/drawable-xhdpi
echo " » Copy all resources to MDPI, this is"
echo " the same density as a non-retina iOS device"
find "${IOS_IMAGE_PATH}"/* -type f -exec cp {} ${OUTPUT_PATH}/res/drawable-mdpi/ \;
@rharter
rharter / AppRater.java
Created Sep 5, 2014
A simple utility class to manage rating (or really anything) call to action display.
View AppRater.java
package com.ryanharter.android.util;
import android.content.Context;
import android.content.SharedPreferences;
/**
* Keeps track of the number of app launches, and days since first launch, and
* provides an easy way to determine whether you should show a rating prompt
* or not.
*/
@rharter
rharter / AllStoriesFragment.java
Last active May 5, 2016
This contains many parts of the main fragment for an app I did that has an autoscrolling horizontal view pager on top of a list, very similar to Marvel. The reason I wanted to share this is because I think it is directly transferrable to solve some of the issues with the promo pager on the main screen. Notice the GestureDetector that is used. Th…
View AllStoriesFragment.java
private static GestureDetector GESTURE_DETECTOR;
private static final long HEADLINE_SCROLL_DELAY = 5000;
private Timer mAutoScroller;
private ViewPager mHeadlinePager;
private HeadlineAdapter mHeadlineAdapter;
View keybase.md

Keybase proof

I hereby claim:

  • I am rharter on github.
  • I am rharter (https://keybase.io/rharter) on keybase.
  • I have a public key ASC2PVpf79-TV0qyzGGs0SalYN6fNpE0cnhm0vTLNMsWFwo

To claim this, I am signing this object:

@rharter
rharter / copy_res.sh
Created Dec 6, 2016
Bash script to copy all versions of an Android resource from one project directory into another, preserving version qualifiers.
View copy_res.sh
#!/bin/bash
function usage {
name=$0
echo "Usage: $name"
echo ""
echo "Searches for and copies all versions of an Android resource"
echo "(currently only drawables) from one project directory into "
echo "another, preserving version qualifiers."
echo ""