Skip to content

Instantly share code, notes, and snippets.

@kazu69
kazu69 / ViewController.swift
Created July 6, 2014 10:24
swift UIActionSheet sample
//
// ViewController.swift
//
import UIKit
class ViewController: UIViewController, UIActionSheetDelegate {
@IBAction func tapButton(sender : AnyObject) {
var sheet: UIActionSheet = UIActionSheet();
let title: String = "Please choose a course";
@correia
correia / swift-kvo-example.swift
Last active April 16, 2023 02:38
A quick example for how to use Foundation style KVO from Swift. (Official documentation from Apple is forthcoming.)
//
// Swift-KVO
//
// Created by Jim Correia on 6/5/14.
// Copyright (c) 2014-2015 Jim Correia. All rights reserved.
//
// Update: 6/17/2014
//
// KVOContext has gone away; use the same idiom you'd use from Objective-C for the context
//
@cocoajin
cocoajin / ios_app_upload_needs_image.txt
Last active December 1, 2017 02:10
iOS 上传所需基本图片尺寸
/*
iOS上传所需基本图片
icon
● Icon.png – 57×57 iPhone应用图标
● Icon@2x.png – 114×114 iPhone Retina显示屏应用图标
● Icon-72.png – 72×72 iPad应用图标
@amster
amster / YourViewController.m
Last active October 24, 2022 20:44
Load a UIWebView in iOS that can also load local resources like images, CSS, and JavaScript
// An example viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
[self loadWebView];
}
// The example loader
//
// Assumes you have an IBOutlet for the UIWebView defined: @property (strong, nonatomic) UIWebView *wv;
@horte
horte / ContentPatternConverter.java
Created May 13, 2012 11:22
Partial Update in Spring 3.1 Controller using @RequestBody with Validation
public class ContentPatternConverter implements Converter<String, ContentPattern> {
private PatternService patternService;
@Autowired
public ContentPatternConverter(PatternService patternService) {
this.patternService = patternService;
}
@Override
@thurloat
thurloat / example.java
Created April 27, 2012 17:08
Jackson JSON ignore on deserialize only
package com.thurloat.foo;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/**
* In order to write a composite data property (stats) out to JSON without reading
* it back in, you need to explicitly ignore the property, as well as the setter and
* then apply the @JsonProperty annotation to the getter.
**/
@ideiudicibus
ideiudicibus / Beanutils.java
Created May 10, 2011 14:17
Merge two java beans useful when discovering differences
class Beanutils{
//merge two bean by discovering differences
private <M> void merge(M target, M destination) throws Exception {
BeanInfo beanInfo = Introspector.getBeanInfo(target.getClass());
// Iterate over all the attributes
for (PropertyDescriptor descriptor : beanInfo.getPropertyDescriptors()) {
// Only copy writable attributes
if (descriptor.getWriteMethod() != null) {
@searls
searls / Email.java
Created March 10, 2011 15:34
An example of stub, verify, and captor with Mockito (on TestNG)
package com.pillartechnology.mail;
import java.util.Date;
public class Email {
private String domain;
private String user;
private String body;
private Date timestamp;