Skip to content

Instantly share code, notes, and snippets.

View YanceyOfficial's full-sized avatar
🎯
Focusing

Yancey Leo YanceyOfficial

🎯
Focusing
View GitHub Profile
@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@YanceyOfficial
YanceyOfficial / App.js
Last active January 28, 2019 09:31
[源码] 尝试创建一个React通用UI组件
import React, { Component } from 'react';
import Button from './components/Button/Button';
import { useState } from 'react';
import { library } from '@fortawesome/fontawesome-svg-core';
import {
faSpinner,
faTrashAlt,
faSave,
} from '@fortawesome/free-solid-svg-icons';
@YanceyOfficial
YanceyOfficial / robot.html
Created January 25, 2019 16:32
调戏图灵机器人
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Robot</title>
<style>
#feedback{
display: flex;
flex-direction: column;
@YanceyOfficial
YanceyOfficial / sass_memorandum.scss
Last active July 24, 2019 09:44
Sass Memorandum
@charset "UTF-8";
// 数组的两种定义 有逗号/无逗号
$font_family: 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, sans-serif;
$margin: 10px 5px 10px 5px;
body {
font-family: $font_family;
margin: $margin;
}
// 父组件
<template>
<div class="home">
<Child
staticTxt="向子组件传递静态文字"
:propValue="propValue"
@parentMethod2="parentMethod2"
:parentMethod3="parentMethod3"
/>
</div>
@leohxj
leohxj / .cz-config.js
Last active May 19, 2023 03:49
cz-customizable with emoji
'use strict';
module.exports = {
types: [
{
value: 'WIP',
name : '💪 WIP: Work in progress'
},
{
@spiralx
spiralx / promise.finally.polyfill.js
Created July 29, 2016 07:34
Polyfill to add a finally() method to the Promise object
Promise.prototype.finally = function (callback) {
return this.then(
value => this.constructor.resolve(callback()).then(() => value),
reason => this.constructor.resolve(callback()).then(() => { throw reason })
)
}
@lukas-h
lukas-h / license-badges.md
Last active July 27, 2024 13:38
Markdown License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

  • The badges do not fully replace the license informations for your projects, they are only emblems for the README, that the user can see the License at first glance.

Translations: (No guarantee that the translations are up-to-date)

@creamidea
creamidea / memorize.js
Last active July 14, 2022 15:26
函数式编程当中,缓存技巧叫做「记忆」(memorization),一阶乘函数。
function memorize(f) {
var cache = {};
// 这个函数是什么意思呢
// 就是使用闭包的特性,保留了cache的值
// 这值将间接使用上次调用时产生的值。下面例子中会详细讲解。
return function() {
console.log(cache); // 打印缓存值
// 这里的key就是一个签名档意思,也就是被缓存函数的参数
var key = Array.prototype.join.call(arguments, ',');
// console.log(key)