Skip to content

Instantly share code, notes, and snippets.

View nguyenhuy's full-sized avatar

Huy Nguyen nguyenhuy

View GitHub Profile
@Adlai-Holler
Adlai-Holler / CATransactionObserving.mm
Last active June 12, 2023 06:23
How to observe CoreAnimation transaction commits as activities. Covers run-loop commits and UIKit-direct-flush commits, but not CADisplayLink scroll view commits.
/**
* Don't use this in production!
*
* Screenshot of it working: https://user-images.githubusercontent.com/2466893/27601666-f65159f0-5b24-11e7-969d-fe86103c21de.png
*/
/**
* This is real, private CA API. Valid as of iOS 10.
*/
typedef enum {
@ragulka
ragulka / convert.php
Created September 5, 2016 07:44
Convert Dashlane Export CSV to a 1Password compatible CSV
<?php
// Place this file in th same directory with your Dashlane Export.csv
// and run using the following command in your Terminal:
//
// php convert.php
//
// This will create a file named fixed.csv, which should work for
// 1Password 6 import. In addition to moving fields into correct places,
// this will also try to remove hashed lines {...}, as well as lines where
@jdmaturen
jdmaturen / company-ownership.md
Last active July 29, 2023 22:39
Who pays when startup employees keep their equity?

Who pays when startup employees keep their equity?

JD Maturen, 2016/07/05, San Francisco, CA

As has been much discussed, stock options as used today are not a practical or reliable way of compensating employees of fast growing startups. With an often high strike price, a large tax burden on execution due to AMT, and a 90 day execution window after leaving the company many share options are left unexecuted.

There have been a variety of proposed modifications to how equity is distributed to address these issues for individual employees. However, there hasn't been much discussion of how these modifications will change overall ownership dynamics of startups. In this post we'll dive into the situation as it stands today where there is very near 100% equity loss when employees leave companies pre-exit and then we'll look at what would happen if there were instead a 0% loss rate.

What we'll see is that employees gain nearly 3-fold, while both founders and investors – particularly early investors – get dilute

@levi
levi / documentation.markdown
Last active November 29, 2019 16:06
AsyncDisplayKit Layout Transition API

AsyncDisplayKit Layout Transition API

Animating between layouts

The layout transition API makes it easy to animate between a node's generated layouts in response to some internal state change in a node.

Imagine you wanted to implement this sign up form and animate in the new field when tapping the next button:

Imgur

@clementgenzmer
clementgenzmer / FBAnimationPerformanceTracker.h
Last active September 18, 2023 23:02
FBAnimationPerformanceTracker
/*
* This is an example provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"More" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
// maybe show an action sheet with more options
[self.tableView setEditing:NO];
}];
moreAction.backgroundColor = [UIColor lightGrayColor];
UITableViewRowAction *blurAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Blur" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
}];
@ijoshsmith
ijoshsmith / arrayToDict.swift
Last active November 1, 2019 05:08
Create Swift Dictionary from Array
/**
Creates a dictionary with an optional
entry for every element in an array.
*/
func toDictionary<E, K, V>(
array: [E],
transformer: (element: E) -> (key: K, value: V)?)
-> Dictionary<K, V>
{
return array.reduce([:]) {
@cmelchior
cmelchior / AndroidManifest.xml
Last active December 25, 2015 13:59
Adding support for ".res-auto" in ContentProvider authorities in AndroidManifest.xml. This replaces ".res-auto" with the current package name, making it possible to install multiple build variants on the same devices without getting [INSTALL_FAILED_CONFLICTING_PROVIDER]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.trifork.example"
android:installLocation="auto"
android:versionName="@string/client_info" >
<!-- ... -->
<application
android:hardwareAccelerated="true"
@mediavrog
mediavrog / compile-volley
Created August 22, 2013 02:21
Compile Google Volley to JAR
$ git clone https://android.googlesource.com/platform/frameworks/volley
$ cd volley
$ android update project -p .
$ ant jar
// Then, copy bin/volley.jar into your libs/ folder and off you go!