Skip to content

Instantly share code, notes, and snippets.

@ahmedre
ahmedre / goodreads_to_book_track.py
Last active April 1, 2023 22:02
Goodreads export to Book Track friendly Importer
import csv
import requests
import sys
"""
This script converts a Goodreads export csv into a Book Track friendly csv.
It does this by querying Google Books' api for each book and adding its id,
along with removing some of the other unnecessary fields in the original
export.
@ahmedre
ahmedre / ContrivedTest.java
Last active January 27, 2017 09:34
Contrived RxJava2 Interrupted Thread Example
package com.quran.labs.androidquran.model.bookmark;
import org.junit.Test;
import io.reactivex.Single;
import io.reactivex.observers.TestObserver;
import io.reactivex.schedulers.Schedulers;
public class ContrivedTest {
@ahmedre
ahmedre / TintSeekbar.java
Created December 1, 2016 11:24
Tint a SeekBar
// backward-compatible means of tinting a progress bar
public void tintProgressDrawable(SeekBar seekBar, int tintColor) {
final Drawable progressDrawable = seekBar.getProgressDrawable();
if (progressDrawable != null) {
if (progressDrawable instanceof LayerDrawable) {
LayerDrawable ld = (LayerDrawable) progressDrawable;
int layers = ld.getNumberOfLayers();
for (int i = 0; i < layers; i++) {
ld.getDrawable(i).mutate().setColorFilter(tintColor, PorterDuff.Mode.SRC_ATOP);
}
@ahmedre
ahmedre / SimpleView.java
Created March 21, 2016 02:19
Fallback default values for View styles
public class SimpleView extends View {
final Paint paint = new Paint();
public SimpleView(Context context) {
this(context, null);
}
public SimpleView(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.SimpleViewStyle);
}
@ahmedre
ahmedre / material.sh
Created February 3, 2015 04:56
material design icon download helper
#! /bin/bash
# a shell script to make it easier to download images from google's
# material design icons project.
#
# usage:
# sh ~/material.sh -f ic_pause.png https://github.com/google/material-design-icons/blob/master/av/drawable-xxhdpi/ic_pause_white_24dp.png
# by default, it outputs to app/src/main/res/drawable-* in the current
# directory, but you can override with -o.
#
@ahmedre
ahmedre / RippleInterceptor.java
Created October 14, 2014 07:15
Ripples using Probe and MostafaGazar's Widgets
package com.cafesalam.experiments.app.ui;
import org.lucasr.probe.Interceptor;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import java.util.WeakHashMap;
@ahmedre
ahmedre / RevealInterceptor.java
Last active August 29, 2015 14:07
Ripples using Probe and RevealColorViews
package com.cafesalam.experiments.app.ui;
import org.lucasr.probe.Interceptor;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Point;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
@ahmedre
ahmedre / gist:235821
Created November 16, 2009 07:07
quran jetpack script
/* quran jetpack script
* --------------------
* a jetpack script which introduces a context menu that allows replacing
* instances of sura:ayah in textareas with the actual ayah text from the
* quran. tested under jetpack 0.6.2.
*
* http://whatstheplot.com/blog/2009/11/16/quran-jetpack-script/
*/
jetpack.future.import("menu");
@ahmedre
ahmedre / gist:165091
Created August 10, 2009 08:46
quran plugin for ubiquity 0.5+
CmdUtils.CreateCommand({
names: ["search quran", "search-quran"],
homepage: "http://whatstheplot.com",
icon: "http://alpha.quranicrealm.com/images/favicon.ico",
arguments: [ {role: 'object', nountype: noun_arb_text, label: 'query'} ],
preview: function( pblock, args ) {
if (args.object.text.length < 1){
pblock.innerHTML = "will search the quran for the specified text";
return;
@ahmedre
ahmedre / gist:113971
Created May 19, 2009 08:07
quran ubiquity plugin
CmdUtils.CreateCommand({
name: "search-quran",
homepage: "http://whatstheplot.com",
icon: "http://alpha.quranicrealm.com/images/favicon.ico",
takes: {"query": noun_arb_text},
preview: function( pblock, query ) {
if (query.text.length < 1){
pblock.innerHTML = "will search the quran for the specified text";
return;
}