Skip to content

Instantly share code, notes, and snippets.

View creativedrewy's full-sized avatar

Andrew Watson creativedrewy

View GitHub Profile
fun <A> chain(vararg funcs: (A) -> Unit): (A) -> Unit {
return fun(a: A) {
funcs.forEach { it(a) }
}
}
fun logThenDoSomething() {
chain({ Log.v("TAG", "Log this first, yo!")}, ::functionInMyClass)
}
@creativedrewy
creativedrewy / CustomDatePicker.kt
Last active April 15, 2022 12:45 — forked from izmajlowiczl/CustomDatePicker.java
Date/Time Picker fix for ScrollView - Kotlin
package com.myproject.myapp.myviews
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.DatePicker
/**
* Extended DatePicker to allow for year-selection scrolling within a scrollview
*/
@creativedrewy
creativedrewy / 2016-10-27.md
Last active August 12, 2021 14:10
## Quick Hit: Getting valid thumbnails using Google Drive Library on Android

Update 10-28-2016: Update to the discussion of the request fields.

The Problem:

When using the Google Drive Java Client Library to list a user's photos and videos in your app, the thumbnailLink property is empty.

The Solution:

As far as I can tell, there is literally no good documentation on the solution for this. However, with the help of a co-worker and the REST API operations, I've gotten the solution.

@creativedrewy
creativedrewy / 2016-08-05.md
Last active September 12, 2016 18:00
## Quick Hit: Android menus inside library projects

Summary: Android has issues if you have identically named menu resources in a library and consuming app project.

I recently discovered something to look out for if you are attempting to work with Activity toolbar/actionbar menus inside of a library. In my case, here is what I was doing:

  • Working with an activity inside of a library project.
  • Attempting to inflate a menu resource in the library Activity that was contained inside of the library project.
  • Open the library activity (actually an extended version of the activity) from the consuming Android app.

When I ran my consuming app activity, I was not seeing changes reflected to the menu in my app. This was really, really confusing.

@creativedrewy
creativedrewy / 06-03-2016.md
Last active January 25, 2024 07:10
## Quick Hit: styling an Android checkbox w/ AppCompat compatibility

The Problem

It turns out trying to find information about how to style an Android checkbox is actually quite challenging. Searching reveals a smattering of blog posts and Statck Overflow articles that don't really solve the problem. Here's what I was trying to do:

  • Change the default unchecked "open box" color on a checkbox
  • Change the default checked box color on a checkbox
  • Use in an API leve 18 Android app

It turns out the solution is relatively simple.

@creativedrewy
creativedrewy / Language Logos
Last active August 29, 2015 14:10
Programming Language Logos
Programming Language/Frameworks URLs:
http://commons.wikimedia.org/wiki/File:Java_logo_and_wordmark.svg
http://commons.wikimedia.org/wiki/File:Ruby_on_Rails_logo.svg
http://commons.wikimedia.org/wiki/File:PHP-logo.svg
http://commons.wikimedia.org/wiki/File:HTML5_logo_and_wordmark.svg
http://commons.wikimedia.org/wiki/File:Python-logo-notext.svg
http://commons.wikimedia.org/wiki/File:Android_logo_2.svg
http://commons.wikimedia.org/wiki/File:Apple_iOS_new.svg
@creativedrewy
creativedrewy / immediate_call_inline_function.coffee
Created March 9, 2013 03:29
Using the "do" keyword in coffeescript
switch message
when "hi" then returnData = "bye"
when "goodbye" then do ->
part1 = "This is just "
part2 = "a sample of how to do this"
returnData = part1 + part2
@creativedrewy
creativedrewy / one_arg_cs_func_right_way.coffee
Created March 9, 2013 03:09
Using the "do" keyword in coffeescript
#The right way to call the no-argument function:
returnData = do processData
@creativedrewy
creativedrewy / one_arg_cs_func_wrong_way.coffee
Last active December 14, 2015 17:29
Using the "do" keyword in coffeescript
#Calling a function with arguments:
returnData = processData "First Argument", 3, "third"
#Pretend the same function had no arguments, call like this? No, wrong:
returnData = processData
@creativedrewy
creativedrewy / NFCDataHandling.as
Last active December 11, 2015 04:08
Sample Adobe AIR Android application class that handles incoming NFC intent data.
package
{
import flash.desktop.NativeApplication;
import flash.events.InvokeEvent;
public class NFCDataHandling extends Sprite
{
/**
* Constructor
*/