Skip to content

Instantly share code, notes, and snippets.

View digerata's full-sized avatar

Mike Wille digerata

View GitHub Profile

Rounded rectangle with gradient background on the iPhone, NSTokenFieldCell style.

Screenshot

Unlike my previous implementation, this one is drawn inside a single view using Core Graphics. It can thus be used for optimized, fast-scrolling cells per Apple's TableViewSuite sample.

The gradient shades are changed from that implementation, too, and the border itself is gradiented (by drawing a smaller rectangle inside a larger one that becomes the border).

You need to include the uicolor-utilities category by Ars Technica.

Rounded rectangle with gradient background on the iPhone, NSTokenFieldCell style.

Screenshot

Unlike my previous implementation, this one is drawn inside a single view using Core Graphics. It can thus be used for optimized, fast-scrolling cells per Apple's TableViewSuite sample.

The gradient shades are changed from that implementation, too, and the border itself is gradiented (by drawing a smaller rectangle inside a larger one that becomes the border).

You need to include the uicolor-utilities category by Ars Technica.

@digerata
digerata / RoundedRectLabel.h
Created July 30, 2010 16:12
Create a UILabel with a rounded rect background like in the iPhone Mail app. (Much faster than using UILabel.layer.cornerRadius)
//
// RoundedRectLabel.h
//
#import <UIKit/UIKit.h>
@interface CountLabel : UILabel {
NSInteger cornerRadius;
UIColor *rectColor;
}
//Initialization - replace these values with your own account information
[[PATransactionHandler dataHolder] setDelegate:self];
[[PATransactionHandler dataHolder] setMerchantId:@"<mid>"];
[[PATransactionHandler dataHolder] setLoginId: @"<login id>"];
[[PATransactionHandler dataHolder] setUserName: @"<username>"];
[[PATransactionHandler dataHolder] setPassWord: @"<password>"];
[[PATransactionHandler dataHolder] setAppName: @"iPad Test"];
//Customization
[[PATransactionHandler dataHolder] setBackgroundImage:[UIImage imageNamed:@"background.png"]];
//Receiving the transaction response
-(void)transactionResults:(id)response
{
if ([[response objectForKey:@"Transaction status"] isEqualToString:@"Approved"])
{
NSLog(@"Transaction Approved");
NSLog(@"PNR ref: %@", [response objectForKey:@"PNFRef"]);
NSLog(@"Invoice: %@", [response objectForKey:@"Invoice"]);
NSLog(@"Card Type:%@", [response objectForKey:@"CardType"]);
}
@digerata
digerata / _compass-retina-sprites.scss
Created October 8, 2012 17:34 — forked from estahn/_compass-retina-sprites.scss
Using Compass to generate normal and retina sprite maps at once
@mixin all-retina-sprites($map, $map2x) {
@media (min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),
(min-device-pixel-ratio: 1.5),
(min-resolution: 1.5dppx) {
$base-class: sprite-map-name($map);
.#{$base-class}-all-retina-sprites {
$("input[data-role='tagsinput']").each(function() {
var placeholder = $(this).data('placeholder');
var saved = $(this).data('saved');
var autocomplete = jQuery(this).data('autocomplete');
jQuery(this).select2({
tags: true,
placeholder: placeholder,
minimumInputLength: 1,
ajax: {
Calling abort on jQuery (1.11.1) will result in an exception:
SyntaxError: JSON Parse error: Unexpected identifier "undefined"
Test case:
$.get('http://jsonip.com').abort();
@digerata
digerata / stripe.rb
Created March 29, 2016 23:39
Stripe initializer that makes it easy to work with development and production keys.
# override in production...
if ENV['STRIPE_KEY']
Rails.logger.warn "Using production environment keys for Stripe."
STRIPE_KEY = ENV['STRIPE_KEY']
STRIPE_PUBLISH = ENV['STRIPE_PUBLISH']
else
Rails.logger.warn "Using test keys for Stripe."
# dev values...
@digerata
digerata / sample.html
Created October 18, 2017 19:00
Example of what is output for the template
<!DOCTYPE html>
<html lang='en'>
<head>
<!-- ... -->
</head>
<body>
<!-- ... -->
<!DOCTYPE html>