Skip to content

Instantly share code, notes, and snippets.

@lexrus
lexrus / ForkWeeklyReport.sh
Last active November 28, 2023 09:58
Fork custom command which export weekly report of current git user.
cd $path
DATE=`date -v-6d +"%Y-%m-%d"`
AUTHOR=`git config user.name`
LOG=`git log --branches --pretty=format:"\n%ad: %s" --date=short --after=$DATE --author="$AUTHOR"`
CHANGES=`git log --branches --date=short --after=$DATE --author="$AUTHOR" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "本周贡献代码: +%s行, -%s行, 总行数: %s\n", add, subs, loc }' -`
WEEKSTART=`date -v"monday" +"%-m月%d"`
TODAY=`date +"%-m月%d"`
REPORT="【周报】$WEEKSTART ~ $TODAY \n\n$CHANGES\n$LOG\n"
import SwiftUI
import PlaygroundSupport
struct ClickWheel: View {
var body: some View {
ZStack {
Circle()
.fill(LinearGradient(
gradient: Gradient(stops: [
.init(color: Color(#colorLiteral(red: 0.21568627655506134, green: 0.21568627655506134, blue: 0.21568627655506134, alpha: 1)), location: 0),
@ethanhuang13
ethanhuang13 / VirtualKeyboard.swift
Last active February 7, 2024 05:58
MacBook Air M1 Zhuyin Keyboard written with SwiftUI ~=300 LOC, < 4hrs
//
// VirtualKeyboard.swift
// MacBook Air M1 Zhuyin Keyboard
// Written with SwiftUI ~=300 LOC, < 4hrs
// Created by Ethan Huang on 2021/1/13.
// Twitter: @ethanhuang13
import SwiftUI
struct VirtualKeyboard: View {
@wogong
wogong / flomo.sh
Created December 13, 2020 17:07
flomo shell function
#!/bin/sh
fl () {
API="https://flomoapp.com/iwh/xxxxxxx/" # substitute with your flomo API
curl -s -H "Accept: application/json" -H "Content-type: application/json" -s -X POST $API -d '{"content":"'"$*"'"}'
}

WebAssembly 导学

提起 WebAssembly/Wasm 可能会想起它是一种可以在浏览器里运行 C/C++/Rust 的技术,实际上它是一个虚拟机标准,它的实现可以在 MCU(单片机)、移动设备、桌面电脑到服务器里面跑,可以嵌入到浏览器、嵌入到应用程序或者独立运行,没有具体的边界。

特点:

  1. 编译一次到处可运行(有点类似JVM虚拟机),源语言可以是 C/C++,Rust,Go,Swift ,TypeScript,C#,Kotlin 等等。
  2. 具体的功能依赖于导入的接口(Import API),否则只是一个单纯的运算器(栈式虚拟机)。目前接口主要有 Web JS 和 WASI 两种,前者用在浏览器里,后者可以作为独立应用程序(比如调用文件系统、socket 等)。
  3. 在 WASM 虚拟机里,只能调用宿主导入的方法和共享的内存,无法直接调用宿主的资源(比如 Web DOM 对象、文件系统等),所以天然具有沙盘安全特性。
  4. 性能很好,提供了接近本地程序的性能,同一段简单的 C 计算程序,以 WASM 方式运行大概慢 1 倍左右,相对一般动态语言慢几倍到上百倍来说,性能已非常突出。
@shaps80
shaps80 / SwiftUI-TextView.md
Last active May 6, 2023 22:17
A SwiftUI view that wraps a UITextView but provides almost all functionality though modifiers and attempts to closely match the Text/TextField components.
@waylybaye
waylybaye / index.js
Last active March 10, 2022 11:09
Send Notification using Telegram when new IAP is purchased
const functions = require('firebase-functions');
const TelegramBot = require('node-telegram-bot-api');
const token = "***"
const chatID = 1024 // your telegram id, you must first send a message to your bot
exports.notifyIAP = functions.analytics.event('in_app_purchase').onLog((event) => {
const purchaseValue = event.valueInUSD;
if (purchaseValue > 0) {
const bot = new TelegramBot(token, {polling: false});
@mayneyao
mayneyao / notion2blog.js
Last active February 29, 2024 18:01
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@Semo
Semo / Howto_Zsh5-6-2_Centos7.md
Last active April 14, 2024 06:20
How to install Zsh version 5.6.2 into CentOS 7

How to install Zsh version 5.6.2 into CentOS 7

Given that you have a clean installation of CentOS 7 which was already updated, by you, then you still have some dependencies to install make and install the external Zsh from the source. You must be root to get the stuff done.

Install GCC Development Tools

yum groupinstall "Development tools"

Check if it's working

@momo0v0
momo0v0 / _m.weibo.cn.md
Last active March 22, 2023 17:51
m.weibo.cn API