This file contains hidden or 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
class DivSize extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
width: 0 | |
} | |
this.resizeHandler = this.resizeHandler.bind(this); | |
} |
This file contains hidden or 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
// https://www.typescriptlang.org/docs/handbook/generics.html | |
function getProperty<T, K extends keyof T>(obj: T, key: K) { | |
return obj[key]; | |
} | |
let x = { a: 1, b: 2, c: 3, d: 4 }; | |
getProperty(x, "a"); // okay | |
getProperty(x, "m"); // error: Argument of type 'm' isn't assignable to 'a' | 'b' | 'c' | 'd'. |
This file contains hidden or 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
Promise.resolve("original") | |
.then( | |
resolved => { | |
console.log(`Upper Promise resolved, message is "${resolved}"`); | |
throw "stage1 throw error"; // -> This thrown error will trigger the following then()'s rejected function, but not in this then()'s rejection. | |
return "stage1 succeed"; | |
}, | |
rejected => { | |
console.log(`Upper Promise rejected, message is "${rejected}"`); | |
// throw "stage1 failed" // -> will let the following then() receive a rejected Promise with this string |
This file contains hidden or 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
'use strict'; | |
const main = () => { | |
const par1 = [3, 'smart']; | |
const par2 = [5, 'clip']; | |
const parser = (index, arr) => index % arr[0] === 0 ? arr[1] : ''; | |
for (let i = 1; i <= 100; i++) { | |
const st = parser(i, par1); | |
const cp = parser(i, par2); | |
console.log(`${i} -> ${st}${cp}`); |
This file contains hidden or 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
alias w='cd ~/workspace;ll' | |
alias gs='git status' | |
alias gd='git diff' | |
alias ga='git add' | |
alias gc='git commit' | |
alias gp='git push' | |
alias gl='git log' | |
alias gr='git reset' |
This file contains hidden or 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 | |
# Script: my-pi-temp.sh | |
# Purpose: Display the ARM CPU and GPU temperature of Raspberry Pi 2/3 | |
cpu=$(</sys/class/thermal/thermal_zone0/temp) | |
echo "$(date) @ $(hostname)" | |
echo "------------------------------" | |
echo "GPU => $(vcgencmd measure_temp)" | |
echo "CPU => $((cpu/1000))°C" |
This file contains hidden or 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
/* Demo program. | |
* https://esp32.com/viewtopic.php?f=2&t=3389 | |
* esp-idf git commit: 7e8c2a9c00a6fb05cd5da306b62c4474a999b1a2 | |
*/ | |
#include <stdio.h> | |
#include "freertos/FreeRTOS.h" | |
#include "freertos/task.h" | |
#include "esp_system.h" | |
#include "esp_spi_flash.h" |
This file contains hidden or 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
# | |
# Automatically generated file; DO NOT EDIT. | |
# Espressif IoT Development Framework Configuration | |
# | |
# | |
# SDK tool configuration | |
# | |
CONFIG_TOOLPREFIX="xtensa-esp32-elf-" | |
CONFIG_PYTHON="python" |
This file contains hidden or 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
#Where the cmake project lives under this subdirectory | |
CODESUBDIR := $(COMPONENT_PATH)/open62541 | |
#Path and name of the generated library | |
# LIBRARY := libopen62541.a | |
# C compiler flags | |
# original one: -std=gnu99 -Og -ggdb -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-old-style-declaration -DWITH_POSIX -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H -g -pipe -Wextra -Wformat -Wno-unused-parameter -Wno-unused-function -Wno-unused-label -Wpointer-arith -Wreturn-type -Wsign-compare -Wmultichar -Wstrict-overflow -Wcast-qual -Wmissing-prototypes -Winit-self -Wuninitialized -Wformat-security -Wformat-nonliteral -Wshadow -Wconversion -fvisibility=hidden -fPIC | |
CFLAGS := -Og -ggdb -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wal |
This file contains hidden or 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
#Where the cmake project lives under this subdirectory | |
CODESUBDIR := $(COMPONENT_PATH)/open62541 | |
#Path and name of the generated library | |
LIBRARY := libopen62541.a | |
#Some projects need include files that are not available in esp-idf. You can specify a directory to 'fake' | |
#these entries here. Note: this will not work if the project includes these in public header files. | |
INCLUDE_FIXUP_DIR := $(IDF_PATH)/components/lwip/include/lwip/posix |
NewerOlder