Skip to content

Instantly share code, notes, and snippets.

View ivanmkc's full-sized avatar

Ivan Cheung ivanmkc

  • Google
  • New York
View GitHub Profile
@jrsonline
jrsonline / gist:dd9799929e1aceb5d99e83fc6ac2b43b
Last active December 19, 2019 09:19
Simple implementation of RxSwift's "toBlocking" for Apple's Combine, now using the DispatchQueue
extension Publisher {
func toBlockingResult(timeout: Int) -> Result<[Self.Output],BlockingError> {
var result : Result<[Self.Output],BlockingError>?
let semaphore = DispatchSemaphore(value: 0)
let sub = self
.collect()
.mapError { error in BlockingError.otherError(error) }
.timeout(
.seconds(timeout),
@delacrixmorgan
delacrixmorgan / FlakyCamera.md
Last active March 31, 2020 21:21
Camera2 Infinite Loop in `CONTROL_AF_STATE_PASSIVE_FOCUSED`

Camera2 Infinite Loop in CONTROL_AF_STATE_PASSIVE_FOCUSED

There's a few reasons.

a) While you are capturePicture(), the AutoFocus state is stucked at CONTROL_AF_STATE_PASSIVE_FOCUSED and there is no way to shake it off.

Thus, you'll need to manually restart the focus and get a lock on it again.

b) setRepeatingRequest() from captureSession is overwhelming it.

# -*- coding: utf-8 -*-
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@swyoon
swyoon / np_to_tfrecords.py
Last active November 29, 2022 06:39
From numpy ndarray to tfrecords
import numpy as np
import tensorflow as tf
__author__ = "Sangwoong Yoon"
def np_to_tfrecords(X, Y, file_path_prefix, verbose=True):
"""
Converts a Numpy array (or two Numpy arrays) into a tfrecord file.
For supervised learning, feed training inputs to X and training labels to Y.
For unsupervised learning, only feed training inputs to X, and feed None to Y.
@trey
trey / happy_git_on_osx.md
Last active February 18, 2024 10:46
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"