This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script is used to resize the screenshot produced by fastlane screenshot | |
# to its appropriate size acceptable by App Store Connect | |
# DEFAULTS | |
IPHONE_11="1284x2778" | |
IPHONE_8_PLUS="1242x2208" | |
IPAD_PRO_3RD="2048x2732" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import {Keyboard} from 'react-native'; | |
import {render, act, cleanup} from '@testing-library/react-native'; // a better testing framework for event triggering | |
import {MyComponent} from 'mycomponent.js'; | |
describe('Test MyComponent', () => { | |
afterAll(cleanup); | |
test('Text shown by default', () => { | |
const {queryByText} = render(<MyComponent />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import {Keyboard} from 'react-native'; | |
import {mount} from 'enzyme'; | |
import {MyComponent} from 'mycomponent.js'; | |
describe('Test MyComponent', () => { | |
const mockSetShowText = jest.fn(); | |
const mockUseState = jest.spyOn(React, 'useState'); | |
const mockKeyboardListener = jest.spyOn(Keyboard, 'addListener'); | |
const keyboardCallbackMap = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import {View, Text, Keyboard} from 'react-native'; | |
const MyComponent = () => { | |
const [showText, setShowText] = React.useState(true); | |
// Use keyboard event (https://reactnative.dev/docs/keyboard) | |
React.useEffect(() => { | |
Keyboard.addListener('keyboardDidShow', _keyboardDidShow); | |
Keyboard.addListener('keyboardDidHide', _keyboardDidHide); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you come from bash you might have to change your $PATH. | |
export PATH=/usr/local/bin:/usr/local/sbin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH="/Users/fanchenbao/.oh-my-zsh" | |
# Set default editor | |
export EDITOR='nano' | |
# Set name of the theme to load --- if set to "random", it will |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
from collections import deque | |
# Definition for a binary tree node. | |
class TreeNode: | |
def __init__(self, val=0, left=None, right=None): | |
self.val = val | |
self.left = left | |
self.right = right |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def levenshtein(token1, token2): | |
mtx = [[0] * (len(token2) + 1) for _ in range(len(token1) + 1)] | |
# fill the first column and row | |
for j in range(len(token2) + 1): | |
mtx[0][j] = j | |
for i in range(len(token1) + 1): | |
mtx[i][0] = i | |
# DP | |
for i, t1 in enumerate(token1): | |
for j, t2 in enumerate(token2): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is heavily borrowed from AWSIoTPythonSDK's sample code here: | |
https://github.com/aws/aws-iot-device-sdk-python/blob/master/samples/basicShadow/basicShadowUpdater.py | |
""" | |
from time import sleep | |
from AWSIoTPythonSDK.MQTTLib import AWSIoTMQTTShadowClient | |
import json | |
import logging | |
logger = logging.getLogger("AWSIoTPythonSDK.core") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {PureComponent} from 'react'; | |
import { | |
View, | |
Text, | |
TouchableHighlight, | |
TouchableOpacity, | |
} from 'react-native'; | |
class Demo extends PureComponent { | |
constructor(props) { |