Skip to content

Instantly share code, notes, and snippets.

Xi Lin xilin

Block or report user

Report or block xilin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@xilin
xilin / NSObject+Debounce.h
Created Mar 10, 2018 — forked from berzniz/NSObject+Debounce.h
Debounce method for Objective C
View NSObject+Debounce.h
@interface NSObject (Debounce)
- (void)debounce:(SEL)action delay:(NSTimeInterval)delay;
@end
@xilin
xilin / reload-table.m
Last active May 9, 2017
Reload table with a snapshot transition
View reload-table.m
// From https://github.com/facebookarchive/AsyncDisplayKit/issues/616#issuecomment-133422166
- (void)reloadData
{
UIView *snapshot = [_tableView snapshotViewAfterScreenUpdates:NO];
[self.view insertSubview:snapshot aboveSubview:_tableView];
[_tableView beginUpdates];
[_tableView reloadData];
[_tableView endUpdatesAnimated:NO completion:^(BOOL completed) {
@xilin
xilin / font-boosting.css
Created Apr 19, 2017 — forked from mojoaxel/font-boosting.css
Disable font boosting on mobile browsers
View font-boosting.css
/* disable font boosting on mobile browsers */
body * {
max-height: 1000000em; /* Chrome for Android */
-moz-text-size-adjust: none; /* Firefox Mobile */
-webkit-text-size-adjust: 100%; /* Safari */
}
View gist:2c2040cfc8f306850222b73eb8218b3c
// The trick is to link the DeviceSupport folder from the beta to the stable version.
// Updated on Jan 24th, 2017 for Xcode 8.3b1
ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/10.3\ \(14E5230d\)/ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
// Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
// sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
View gist:8d3aed526fdbe6c5ecd34462e25fb0aa
→ curl -iI -v -A " " "http://www.la-grange.net/"
* About to connect() to www.la-grange.net port 80 (#0)
* Trying 128.30.54.58... connected
* Connected to www.la-grange.net (128.30.54.58) port 80 (#0)
> HEAD / HTTP/1.1
> User-Agent:
> Host: www.la-grange.net
> Accept: */*
>
< HTTP/1.1 200 OK
@xilin
xilin / README.md
Created Aug 9, 2016 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
View README.md
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@xilin
xilin / PSPDFUIKitMainThreadGuard.m
Created Jan 7, 2016 — forked from steipete/PSPDFUIKitMainThreadGuard.m
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
View PSPDFUIKitMainThreadGuard.m
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@xilin
xilin / linkmap.js
Created Dec 7, 2015 — forked from bang590/linkmap.js
XCode Linkmap Parser
View linkmap.js
var readline = require('readline'),
fs = require('fs');
var LinkMap = function(filePath) {
this.files = []
this.filePath = filePath
}
LinkMap.prototype = {
start: function(cb) {
@xilin
xilin / UIScrollView_did_end.m
Created Sep 12, 2015
how to check when UIScrollView end scroll
View UIScrollView_did_end.m
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
//[super scrollViewWillBeginDragging:scrollView]; // pull to refresh
self.isScrolling = YES;
NSLog(@"+scrollViewWillBeginDragging");
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
View CollectionsPredicateFilterSample.java
import static java.lang.System.out;
import static java.util.Arrays.asList;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
public class ListTests {
public static void main( String[] args ) {
List<String> names = asList( "Ted", "Fred", "Jed", "Ned" );
You can’t perform that action at this time.