Skip to content

Instantly share code, notes, and snippets.

Avatar

Xi Lin xilin

View GitHub Profile
@xilin
xilin / repo-rinse.sh
Created Sep 21, 2020 — forked from nicktoumpelis/repo-rinse.sh
Cleans and resets a git repo and its submodules
View repo-rinse.sh
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive
@xilin
xilin / wwdc.sh
Created Nov 4, 2019 — forked from idiomatic/wwdc.sh
Fetch WWDC videos, slides, and sample code.
View wwdc.sh
#!/bin/bash
# usage: get [ RESOLUTION [ YEAR [ IDS... ] ] ]
resolution=${1:-SD}
year=${2:-2015}
shift
shift
ids=$*
RESOLUTION=$(echo $resolution | tr '[:lower:]' '[:upper:]')
@xilin
xilin / lc.js
Last active Dec 7, 2019
copy desc in leetcode for notion
View lc.js
var l = getEventListeners(document).copy[0];
document.removeEventListener('copy', l.listener, l.useCapture);
// change format so that codes inside `PRE` tag can show correctly in notion
for (let strong of [...document.getElementsByTagName('code')].filter(i => i.parentNode.tagName === 'PRE')) {
const textNode = document.createElement('span');
textNode.innerHTML = strong.innerHTML;
strong.parentNode.replaceChild(textNode, strong);
}
for (let strong of [...document.getElementsByTagName('strong')].filter(i => i.parentNode.tagName === 'PRE')) {
const textNode = document.createElement('span');
@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.
You can’t perform that action at this time.