Skip to content

Instantly share code, notes, and snippets.

View letswritetw's full-sized avatar
🎯
Focusing

Let's Write - August letswritetw

🎯
Focusing
View GitHub Profile
const downloadCSV = data => {
let csvContent = '';
Array.prototype.forEach.call(data, d => {
let dataString = d.join(',') + '\n';
csvContent += dataString;
})
// 下載的檔案名稱
let fileName = '下載資料_' + (new Date()).getTime() + '.csv';
const buildData = data => {
return new Promise((resolve, reject) => {
// 最後所有的資料會存在這
let arrayData = [];
// 取 data 的第一個 Object 的 key 當表頭
let arrayTitle = Object.keys(data[0]);
arrayData.push(arrayTitle);
const apiUri = "https://api.github.com/repos/letswritetw/letswrite-github-issue-create/issues/1/comments";
const headers = new Headers();
headers.append("Accept", "application/vnd.github.v3+json");
headers.append("Authorization", "Bearer 取得的Token");
headers.append("Content-Type", "application/json");
let data = JSON.stringify({
"body": "這邊填寫 Comment 的內文"
});
const apiUri = "https://api.github.com/repos/letswritetw/letswrite-github-issue-create/issues";
const headers = new Headers();
headers.append("Accept", "application/vnd.github.v3+json");
headers.append("Authorization", "Bearer 取得的Token");
headers.append("Content-Type", "application/json");
let data = JSON.stringify({
"title": "這邊填寫 Issue 的標題",
"body": "這邊填寫 Issue 的內文"
@letswritetw
letswritetw / github-api-issues-get-markdown.html
Last active April 30, 2021 02:31
github-api-issues-get
<!-- html -->
<div id="app">
<div v-html="markdownToHtml(issue.body)"></div>
</div>
<!-- JS -->
<script>
import marked from 'marked'
new Vue({
@letswritetw
letswritetw / github-api-issues-get-issue.js
Last active April 30, 2021 01:42
github-api-issues-get
const uri = 'https://api.github.com/repos/letswritetw/letswrite-github-api-issues-get/issues/1';
const headers = new Headers();
headers.append('Accept', 'application/vnd.github.v3+json');
const config = {
method: 'GET',
headers: headers,
redirect: 'follow'
}
@letswritetw
letswritetw / dayjs-last-week-month2.js
Created April 28, 2021 14:30
dayjs-last-week-month
// 上個月第一天
const first = dayjs().subtract(1, 'month').startOf('month').format('YYYY-MM-DD');
console.log(first); // 2021-03-01
// 上個月最後一天
const end = dayjs().subtract(1, 'month').endOf('month').format('YYYY-MM-DD');
console.log(end) // 2021-03-31
firebase.auth()
.getRedirectResult()
.then((result) => {
if (result.credential) {
var credential = result.credential;
var token = credential.accessToken;
}
var user = result.user;
}).catch((error) => {
var errorCode = error.code;
const providerGithub = new firebase.auth.GithubAuthProvider();
firebase.auth()
.signInWithPopup(providerGithub)
.then((result) => {
let credential = result.credential;
let token = credential.accessToken;
let user = result.user;
}).catch((error) => {
let errorCode = error.code;
let errorMessage = error.message;
@letswritetw
letswritetw / vuepress-document-style-component.vue
Last active April 8, 2021 13:52
vuepress-document-style-component
<template lang="pug">
a.btn.btn-main(:href="uri" target="_blank") {{ title }}
</template>
<script>
export default {
data: () => {
return {}
},
props: ['title', 'uri']