Skip to content

Instantly share code, notes, and snippets.

View Gfast2's full-sized avatar
🚩

Su Gfast2

🚩
View GitHub Profile
@Gfast2
Gfast2 / framework-sizes.md
Created January 31, 2017 10:59 — forked from Restuta/framework-sizes.md
Sizes of JS frameworks, just minified + minified and gzipped, (React, Angular 2, Vue, Ember)

Below is the list of modern JS frameworks and almost frameworks – Angular, Ember and React.

All files were downloaded from https://cdnjs.com and named accordingly. Output from ls command is stripped out (irrelevant stuff)

As-is (minified)

$ ls -lhS
566K Jan 4 22:03 angular2.min.js
@Gfast2
Gfast2 / main.c
Created August 10, 2017 17:56
porting bmp280 driver for Beaglebone Black
/* This work is licensed under a Creative Commons CCZero 1.0 Universal License.
* See http://creativecommons.org/publicdomain/zero/1.0/ for more information. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
@Gfast2
Gfast2 / component.mk
Created October 10, 2017 07:52
The component.mk file for open62541 library
#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
@Gfast2
Gfast2 / component.mk
Last active October 13, 2017 12:29
component compiling description for porting open62541 to esp-idf.
#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
@Gfast2
Gfast2 / sdkconfig
Created October 15, 2017 18:17
addressing issue with unmathing baud rate between serial monitor and ESP32
#
# Automatically generated file; DO NOT EDIT.
# Espressif IoT Development Framework Configuration
#
#
# SDK tool configuration
#
CONFIG_TOOLPREFIX="xtensa-esp32-elf-"
CONFIG_PYTHON="python"
@Gfast2
Gfast2 / main.c
Created November 18, 2017 18:46
A "binky" Example on ESP32 using ESP-IDF FreeRTOS, which address potential bug when man use while(1) in main_app() with vTaskDelayUntil to deal with delay job.
/* 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"
@Gfast2
Gfast2 / getTemperature.sh
Created November 15, 2018 15:23
Read Raspberry Pi's GPU & CPU's temprature.
#!/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"
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'
@Gfast2
Gfast2 / smartclip.js
Created December 5, 2019 16:37
A small quick answer I found in the most elegant way to solve the problem.
'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}`);
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