Skip to content

Instantly share code, notes, and snippets.

@haifengkao
haifengkao / UIViewAnimationOptionTransitionFlipFromLeftExample
Created November 10, 2013 17:59
To animate a view whose size is (40,60) from point (0,10) to point (300,300), while flipping its view on the y axis (horizontal flip of 180 degrees), and the size changing to (20,30). As requested by Anil.
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
{
"indent" : {
"value": " ",
"ArrayExpression": 1,
"AssignmentExpression": 1,
"BinaryExpression": 1,
"ConditionalExpression": 1,
"CallExpression": 1,
"CatchClause": 1,
"ConditionalExpression": 1,
@haifengkao
haifengkao / dropbox
Last active September 24, 2015 04:16 — forked from benhedrington/dropbox
Dropbox init.d
#!/bin/sh
#
# Copied from http://forums.dropbox.com/topic.php?id=38529#post-414344
# Modified by jay@gooby.org (@jaygooby on Twitter)
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
@haifengkao
haifengkao / gist:7fbff3a20a3ba9f7636008e61a16c0a3
Created November 13, 2016 09:57
ycm_extra_conf.py for objective-c setting of YouCompleteMe
import os
import ycm_core
flags = [
'-D__IPHONE_OS_VERSION_MIN_REQUIRED=70000',
'-resource-dir',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0',
'-mios-simulator-version-min=7.0',
'-arch i386',
'-fblocks',
@haifengkao
haifengkao / open_finder_tab.sh
Last active October 24, 2023 19:04
A shell script function to open a Finder tab from terminal
# open the current folder in Finder's tab
function oft() {
local folder_name=$1
if ! [[ -d $1 ]]; then
# it is a file, get the enclosing folder
folder_name="$(dirname "$1")"
fi
# if no arguments are given, we use the current folder
@haifengkao
haifengkao / validation.kt
Created September 6, 2019 07:43
kotlin applicative example
package com.yanbin.fpworkshop.part4
import arrow.core.Try
import arrow.core.Tuple2
import arrow.core.flatten
import java.time.LocalDate
interface Validation {
fun validateAccountNo(no: String): Try<String>
fun validateAccountName(name: String): Try<String>
@haifengkao
haifengkao / package.swift
Last active March 5, 2020 08:56
Cocoapods to swift package manager example
// swift-tools-version:5.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MyProject",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
@haifengkao
haifengkao / clientMain.js
Created March 9, 2020 09:02
Sourcekit-lsp iOS support
function sourcekitLspServerOptions() {
// Load the path to the language server from settings
const executableCommand = vscode_1.workspace.getConfiguration("sourcekit-lsp").get("serverPath") ||
vscode_1.workspace
.getConfiguration("swift")
.get("languageServerPath", "/usr/local/bin/sourcekit-lsp");
const toolchain = vscode_1.workspace
.getConfiguration("sourcekit-lsp")
.get("toolchainPath");
@haifengkao
haifengkao / tpuError.log
Created August 15, 2020 07:25
Tensorflow TPU Error
InvalidArgumentError: 9 root error(s) found.
(0) Invalid argument: {{function_node __inference_train_function_80125}} Compilation failure: Detected unsupported operations when trying to compile graph broadcast_weights_1_assert_broadcastable_is_valid_shape_has_valid_nonscalar_shape_true_79965_const_0[] on XLA_TPU_JIT: DenseToDenseSetOperation (No registered 'DenseToDenseSetOperation' OpKernel for XLA_TPU_JIT devices compatible with node {{node broadcast_weights_1/assert_broadcastable/is_valid_shape/has_valid_nonscalar_shape/has_invalid_dims/DenseToDenseSetOperation}}){{node broadcast_weights_1/assert_broadcastable/is_valid_shape/has_valid_nonscalar_shape/has_invalid_dims/DenseToDenseSetOperation}}
[[broadcast_weights_1/assert_broadcastable/is_valid_shape/has_valid_nonscalar_shape]]
[[broadcast_weights_1/assert_broadcastable/is_valid_shape]]
TPU compilation failed
[[tpu_compile_succeeded_assert/_16364550150888184836/_30]]
[[TPUReplicate/_compile/_2384856891229734177/_29/_1132]]
(1) Invalid argument
@haifengkao
haifengkao / combineTest.swift
Last active September 1, 2020 12:01
combineLatest test
import Cocoa
import Combine
var subscriptions = Set<AnyCancellable>()
func futureIncrement(
integer: Int,
afterDelay delay: TimeInterval) -> AnyPublisher<Int, Never> {
Deferred {