Skip to content

Instantly share code, notes, and snippets.

View 645. Set Mismatch.swift
/*
The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of one number and loss of another number.
Given an array nums representing the data status of this set after the error. Your task is to firstly find the number occurs twice and then find the number that is missing. Return them in the form of an array.
Example 1:
Input: nums = [1,2,2,4]
Output: [2,3]
Note:
View Gray box.html
<div style="display: block; padding: 9.5px; margin: 0 0 10px; font-size: 15px; line-height: 1.42857143; color: #333; word-break: break-all; word-wrap: break-word; background-color: #f5f5f5; border: 1px solid #ccc; border-radius: 4px;">
some text here
</div>
View gist:9a7316a73443f19fc9ef1b50ce237dfa
#pragma mark -- Animation
//动画停止执行的delegate
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
if ([[anim valueForKey:@"TransformScale"] isEqualToString:@"scaleAnimation"]) {
//清除上次的shapeLayer 防止内存泄露
for (CAShapeLayer *shapeLayer in shapeLayers) {
[shapeLayer removeAnimationForKey:kGroupAnimation];
[shapeLayer removeFromSuperlayer];
}
View format-all.sh
echo "\Clang-Format all files in current dir except ones in */libs/* folder and names containing *.framework.*"
find . -name "*.[hm]" ! -path "*/libs/*" ! -path "*.framework*" ! -path "*/ThirdParty/*" ! -path "*/Pods/*" -print0 | xargs -0 clang-format -i
echo "DONE"
@daoseng33
daoseng33 / .clang-format
Last active Aug 23, 2017
AlleyStore ObjC clang-format
View .clang-format
---
# BasedOnStyle: LLVM
AccessModifierOffset: -2
ConstructorInitializerIndentWidth: 4
AlignEscapedNewlinesLeft: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
View UIImage+GIF.h
//
// UIImage+GIF.h
// LBGIFImage
//
// Created by Laurin Brandner on 06.01.12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@daoseng33
daoseng33 / delete-feature-branches.sh
Created Dec 9, 2017 — forked from chrisjlee/delete-feature-branches.sh
Delete feature branch with prefix locally then remove all remote feature branches
View delete-feature-branches.sh
# Stole from:
# http://stackoverflow.com/questions/32122784/alias-script-to-delete-all-local-and-remote-git-branches-with-a-specific-prefix
git branch -D $(printf "%s\n" $(git branch) | grep 'feature/')
# Or this will work too to remove all remote branches:
# https://coderwall.com/p/eis0ba/remove-a-thousand-stale-remote-branches-on-git
git branch -r | awk -F/ '/\/feature/{print $2}' | xargs -I {} git push origin :{}
# Prune all origin branches
git remote prune origin
View type.swift
enum Type {
case regular
case system
case advertise
}
View enumWithImage.swift
enum Type {
case regular
case system
case advertise
var image: UIImage? {
switch self {
case .regular:
return UIImage(named: "regular")
case .system:
View enumTypeInt.swift
enum Type: Int {
case regular = 0
case system
case advertise
var image: UIImage? {
switch self {
case .regular:
return UIImage(named: "regular")
case .system: