Skip to content

Instantly share code, notes, and snippets.

View matrush's full-sized avatar
:electron:
Building Threads

MatRush matrush

:electron:
Building Threads
View GitHub Profile
@siqin
siqin / gist:4201667
Created December 4, 2012 07:57
Remove Emoji in NSString
// XCode 4.2.1
@implementation NSString(EmojiExtension)
- (NSString*)removeEmoji {
__block NSMutableString* temp = [NSMutableString string];
[self enumerateSubstringsInRange: NSMakeRange(0, [self length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop){
@mckelvin
mckelvin / 1.sh
Last active December 18, 2015 13:48
#!/bin/sh
# 1.切换到工程目录
# 2.用gource-gravatar-getter将头像下载到.git/avatar,格式类似 .git/avatar/mckelvin.png
#
gource --seconds-per-day 0.6 \
--user-image-dir .git/avatar \
--multi-sampling -1360x760 \
--output-ppm-stream /tmp/vis_tmp.ppm \
--disable-progress \
--hide mouse \
@nbremer
nbremer / .block
Last active February 6, 2025 14:31
D3.js - Radar Chart or Spider Chart - Adjusted from radar-chart-d3
height: 650
license: mit
@rcabaco
rcabaco / gist:6765778
Created September 30, 2013 15:45
UITextView subclass to handle up/down cursor movement
// Code to handle up/down cursor motion in a UITextView.
//
// Based on code from OmniGroup's OUITextView
// https://github.com/omnigroup/OmniGroup/blob/master/Frameworks/OmniUI/iPad/OUITextView.m
//
#import "TextView.h"
@interface TextView ()
@matthiaswenz
matthiaswenz / gist:8088229
Last active January 1, 2016 03:49
UISearchBar customize Keyboard Return button type (iOS 7)
for (UIView *subview in searchBar.subviews) {
for (UIView *subSubview in subview.subviews) {
if ([subSubview conformsToProtocol:@protocol(UITextInputTraits)]) {
UIView<UITextInputTraits> *textInputField = (UIView<UITextInputTraits> *)subSubview;
textInputField.returnKeyType = UIReturnKeyDone;
break;
}
}
}
@namuol
namuol / INSTALL.md
Last active December 11, 2024 12:21
rage-quit support for bash

rage-quit support for bash

HOW TO INSTALL

Put flip somewhere in your $PATH and chmod a+x it.

Copy fuck into ~/.bashrc.

@syllog1sm
syllog1sm / gist:10343947
Last active September 19, 2024 23:54
A simple Python dependency parser
"""A simple implementation of a greedy transition-based parser. Released under BSD license."""
from os import path
import os
import sys
from collections import defaultdict
import random
import time
import pickle
SHIFT = 0; RIGHT = 1; LEFT = 2;
Simplify[RSolve[{a[n] == (B + 1) a[n - 1] - a[n - 2], a[0] == 0, a[1] == B}, a[n], n]]
Block[{B = 2}, Simplify[Table[a[n] /. First[%], {n, 10}]]]
@randomsequence
randomsequence / CIContext+IntermediateImage.m
Created May 12, 2014 12:20
CoreImage - Render a CIImage to an Intermediate CVPixelBuffer Backed Image
@implementation CIContext (IntermediateImage)
- (CIImage *)rsq_renderToIntermediateImage:(CIImage *)image {
CIImage *intermediateImage = nil;
CGSize size = image.extent.size;
CVPixelBufferRef pixelBuffer = NULL;
CVReturn status = CVPixelBufferCreate(kCFAllocatorDefault,
size.width,
size.height,
kCVPixelFormatType_32ARGB,
@nicklockwood
nicklockwood / Hacking UIView Animation Blocks.md
Last active August 24, 2024 17:08
This article was originally written for objc.io issue 12, but didn't make the cut. It was intended to be read in the context of the other articles, so if you aren't familiar with concepts such as CALayer property animations and the role of actionForKey:, read the articles in that issue first.

Hacking UIView animation blocks for fun and profit

In this article, I'm going to explore a way that we can create views that implement custom Core Animation property animations in a natural way.

As we know, layers in iOS come in two flavours: Backing layers and hosted layers. The only difference between them is that the view acts as the layer delegate for its backing layer, but not for any hosted sublayers.

In order to implement the UIView transactional animation blocks, UIView disables all animations by default and then re-enables them individually as required. It does this using the actionForLayer:forKey: method.

Somewhat strangely, UIView doesn't enable animations for every property that CALayer does by default. A notable example is the layer.contents property, which is animatable by default for a hosted layer, but cannot be animated using a UIView animation block.