Skip to content

Instantly share code, notes, and snippets.

@phatmann
phatmann / build.gradle
Created Dec 20, 2019
Using an environment variable instead of a flavor in Android build script to work around App Center limitation
View build.gradle
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 Dec 12, 2016 — forked from znseaman/1001albums.md
Pitchfork's 1001 Albums You Must Hear Before You Die
View 1001albums.md
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 Apr 15, 2015
Encapsulate iOS background tasks in a Swift class
View BackgroundTask.swift
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 Mar 22, 2015
NSTextAttachment that scales and aligns image
View ImageAttachment
// 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
View LiveTweet-timeLinks-option.diff
View dm-rejects-blank-string-for-integer-fields.rb
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
View dm-query-build-err.rb
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
View merb-helpers_patch.rb
######## 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
View dm-associations-will-not-save.rb
#!/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:')
View select_country.rb
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",
You can’t perform that action at this time.