Skip to content

Instantly share code, notes, and snippets.

View keidarcy's full-sized avatar
🧙‍♂️
making something

Xing Yahao keidarcy

🧙‍♂️
making something
View GitHub Profile
@keidarcy
keidarcy / slack_cotoha.js
Last active March 2, 2020 08:10
use cotohaapi to build a slackbot to analysis any sns message
const axios = require('axios').default;
const SlackBot = require('slackbots');
const URL = 'https://api.ce-cotoha.com/api/dev/nlp/v1/sentiment';
const COTOHA_TOKEN = process.env.COTOHA_TOKEN;
const SLACK_TOKEN = process.env.SLACK_TOKEN;
const USER_ID = process.env.USER_ID;
axios.defaults.headers.common['Authorization'] = `Bearer ${COTOHA_TOKEN}`;
@keidarcy
keidarcy / .editorconfig
Last active May 2, 2020 11:32
ESLint, Prettier, Airbnb Setup
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@keidarcy
keidarcy / tmux_cheat_sheet.md
Last active March 7, 2020 09:22
tmux cheat sheet
ctrl+b prefix
basic session
? Show shortcuts s show all sessions
: command mode d Detach from session
& Rename session
window pane
c create % splite left and right
@keidarcy
keidarcy / .eslintrc.json
Last active April 3, 2020 12:55
Mac Settings
{
"extends": [
"airbnb",
"plugin:prettier/recommended",
"prettier/react",
"plugin:node/recommended"
],
"env": {
"browser": true,
"commonjs": true,
@keidarcy
keidarcy / april.php
Last active June 16, 2020 07:43
My Japon dev memo
// 4月から計算一年内のもの
<!-- ・現在の日付が4月以降だったら
→4月から現在の日付カウントする
・現在の日付が3月以前だったら
→去年の4月から現在の日付までカウントする -->
private function isAnnual($date)
{
$orderTime = $date->format('Y-m-d');
@keidarcy
keidarcy / vue-proxy-reactivity.js
Last active April 20, 2020 09:21
implement js reactivity
let data = { price: 5, quantity: 2 };
let target = null;
let total = 0;
class Dep {
constructor() {
this.subscribers = [];
}
depend() {
if (target && !this.subscribers.includes(target)) {
@keidarcy
keidarcy / index.md
Last active April 27, 2020 01:26
es6 note

ES6 note

var, let, const

  • var → function scope
  • let, const → block scope
function say() {
    for (var i = 0; i < 5; i++ ) {
        console.log(i)
@keidarcy
keidarcy / getUniqueItem.js
Last active April 21, 2020 05:34
Some JavaScript memo
const obj = [
{ name: "Joe", age: 17 },
{ name: "Bob", age: 17 },
{ name: "Carl", age: 35 }
];
const objRes = [...new Map(obj.map((item) => [item.age, item])).values()];
const arrRes = [...new Set(obj.map((item) => item.age))]
console.log(objRes); //[{ name: "Bob", age: 17 },{ name: "Carl", age: 35 }]
console.log(arrRes);//[17, 35]
@keidarcy
keidarcy / app.js
Created May 1, 2020 11:31
single react todo
import React, { useState } from 'react'
const TodoItem = ({ index, name, complete, removeTodo, completeTodo }) => {
return (
<>
<li style={{ textDecoration: complete ? 'line-through' : '' }}>
{name}{' '}
<span>
{!complete && <button onClick={() => completeTodo(index)}>finish</button>}
</span>
@keidarcy
keidarcy / react-login.js
Last active May 16, 2020 04:14
login react vs vue
import React, { useState } from 'react'
const login = ({ username, password }) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (Object.is(username, 'bili') && Object.is(password, 'bili')) {
console.log(username, password)
resolve('success')
} else {
console.log(username, password)