Skip to content

Instantly share code, notes, and snippets.

@phatmann
phatmann / build.gradle
Created December 20, 2019 13:00
Using an environment variable instead of a flavor in Android build script to work around App Center limitation
apply plugin: "com.android.application"
apply plugin: 'io.fabric'
import com.android.build.OutputFile
def enableProguardInReleaseBuilds = true
def endpoint = System.env.NEXT_ANDROID_APP_ENDPOINT
android {
@phatmann
phatmann / 1001albums.md
Last active December 12, 2016 15:31 — forked from znseaman/1001albums.md
Pitchfork's 1001 Albums You Must Hear Before You Die
50s
  • Sinatra, Frank – In the Wee Small Hours
  • Presley, Elvis – Elvis Presley (1956)
  • Louvin Brothers – Tragic Songs of Life
  • Prima, Louis – Wildest
  • Domino, Fats – This is Fats
  • Ellington, Duke – At Newport (1956)
  • Sinatra, Frank – Songs for Swingin’ Lovers!
  • Crickets – Chirping…
@phatmann
phatmann / BackgroundTask.swift
Created April 15, 2015 03:14
Encapsulate iOS background tasks in a Swift class
class BackgroundTask {
private let application: UIApplication
private var identifier = UIBackgroundTaskInvalid
init(application: UIApplication) {
self.application = application
}
class func run(application: UIApplication, handler: (BackgroundTask) -> ()) {
// NOTE: The handler must call end() when it is done
@phatmann
phatmann / ImageAttachment
Created March 22, 2015 22:23
NSTextAttachment that scales and aligns image
// Created by Tony Mann on 3/22/15.
// Copyright (c) 2015 7Actions. All rights reserved.
//
// Adapted from http://ossh.com.au/design-and-technology/software-development/implementing-rich-text-with-images-on-os-x-and-ios/
import UIKit
class ImageAttachment: NSTextAttachment {
var verticalOffset: CGFloat = 0.0
require 'rubygems'
gem 'dm-core', '0.10.1'
require 'dm-core'
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, "mysql://localhost/ts_test")
class Sample
include DataMapper::Resource
property :id, Serial
require 'rubygems'
gem 'dm-core'
require 'dm-core'
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, "mysql://localhost/YOUR_TEST_DB")
class CrawledPage
include DataMapper::Resource
property :id, Serial
######## broken version #########
# update_unbound_check_box handles :checked properly, but radio does not get the same treatment
def update_unbound_controls(attrs, type)
case type
when "checkbox"
update_unbound_check_box(attrs)
when "file"
@multipart = true
end
#!/usr/bin/env ruby
require 'rubygems'
gem 'dm-core', '~>0.9.9'
require 'dm-core'
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, 'sqlite3::memory:')
def select_country(opts = {})
opts[:collection] = countries.sort {|a,b| a[1] <=> b[1]}
opts[:selected] ||= 'US'
select opts
end
def countries
{
"AF" => "Afghanistan",
"AL" => "Albania",