Skip to content

Instantly share code, notes, and snippets.

View cwy007's full-sized avatar
🤔
practicing rails & vue & react & react native

willian.chan cwy007

🤔
practicing rails & vue & react & react native
View GitHub Profile
@cwy007
cwy007 / asyncForEach.js
Last active July 31, 2024 03:02
异步forEach #javascript
// 1.forEach
// javascript异步forEach循环
// https://cloud.tencent.com/developer/information/javascript%E5%BC%82%E6%AD%A5forEach%E5%BE%AA%E7%8E%AF
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
@cwy007
cwy007 / nerd_fonts.md
Created September 1, 2023 03:28 — forked from davidteren/nerd_fonts.md
Install Nerd Fonts via Homebrew [updated & fixed]
{
"sync.gist": "4c4ee9d2586e1c9e225d17e3e110e2fb",
"sync.autoDownload": true,
"sync.autoUpload": true,
"sync.forceDownload": true,
"sync.forceUpload": true,
"sync.quietSync": true,
"workbench.colorTheme": "Default Dark+"
}
#!/usr/bin/env bash
shopt -s extglob
set -o errtrace
set -o errexit
set -o pipefail
rvm_install_initialize()
{
DEFAULT_SOURCES=(github.com/rvm/rvm bitbucket.org/mpapis/rvm)
@cwy007
cwy007 / faker.rb
Created August 6, 2019 02:54 — forked from tlikai/faker.rb
Ruby Faker::PhoneNumber 生成国内手机号
module Faker
class PhoneNumber < Base
class << self
def cell_phone
operators = [
134, 135, 136, 137, 138, 139, 147, 150, 151, 152, 157, 158, 159, 182, 187, 188, # china mobile
130, 131, 132, 145, 155, 156, 185, 186, 145, # china unicom
133, 153, 180, 181, 189 # china telecom
]
suffix = Random.rand(10000000...99999999)
@cwy007
cwy007 / javascript 语法.md
Created November 16, 2018 23:55
Array(amount).fill(object)

源代码

this.addProduct = function(amount, product) {
  products.push(...Array(amount).fill(product));
};

解释

Array(amount).fill(object)
@cwy007
cwy007 / js snippet.md
Created November 16, 2018 00:35
animalMethods 如何理解
const animalMethods = {
  eat(amount) {
    console.log(`${this.name} is eating.`)
    this.energy += amount
  },
  sleep(length) {
    console.log(`${this.name} is sleeping.`)
    this.energy += length
 },
http://chanweiyan.logdown.com/posts/7808902-linux-operations-file-transfer-compression
private
  def post_params
    params.permit(:name, :desc)
  end

# 这里做了白名单限制,只有在调用 post_params 方法时,才会生效,
# 在 action 中可以通过 params 获取到所有传进来的参数