Skip to content

Instantly share code, notes, and snippets.

View lili668668's full-sized avatar

Tzu-Yin Hong lili668668

View GitHub Profile
mouse = "鼠"
cow = "牛"
tiger = "虎"
rabbit = "兔"
dragon = "龍"
snake = "蛇"
horse = "馬"
sheep = "羊"
monkey = "猴"
chicken = "雞"
@lili668668
lili668668 / stickyHeader2.vue
Created August 4, 2019 07:48
固定標題列
<template>
<div>
<table
:style="{ maxWidth: `${bodyWidthString}` }"
>
<thead ref="head">
<tr>
<th
v-for="(header,index) in headers"
:key="index"
@lili668668
lili668668 / stickyHeader.vue
Created August 4, 2019 06:55
虛擬表格的標題列
<template>
<div
ref="viewport"
:style="{ height: `${containerHeight}px` }"
@scroll.passive="onScroll"
>
<table
:class="$style.header"
>
<thead>
@lili668668
lili668668 / offset.js
Created August 1, 2019 16:13
計算表格位置的程式碼
offsetBody () {
const scrollTop = (this.$refs.viewport as Element).scrollTop
const remainTopNumber = Math.floor(this.remainLineNumber / 2)
const remainTopHeight = remainTopNumber * this.renderLineHeight
const remainBottomHeight = (this.remainLineNumber - remainTopNumber) * this.renderLineHeight
const thresholdHeight = this.thresholdNumber * this.renderLineHeight
const gap = scrollTop - this.bodyTranslateY
const overThreshold = gap < remainTopHeight - thresholdHeight || gap > remainTopHeight + thresholdHeight
const isReachBottom = this.totalHeight - (scrollTop + this.viewportHeight) < remainBottomHeight
const isReachTop = scrollTop < remainTopHeight
@lili668668
lili668668 / scroll.vue
Last active August 1, 2019 15:07
虛擬滾動表格的解說程式碼
<template>
<div
ref="viewport"
:style="{ height: `${viewportHeight}px` }"
@scroll.passive="onScroll"
>
<div
:style="{ height: `${totalHeight}px` }"
>
<section
@lili668668
lili668668 / simple.vue
Last active August 1, 2019 14:57
虛擬滾動表格解說的範例程式碼
<template>
<table>
<thead>
<tr v-for="(title, index) in titles">
<th key="index">{{ title }}</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in items">
<td key="index">{{ item }}</td>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Bridgewell</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<script>
@lili668668
lili668668 / proposal - 1.js
Last active January 8, 2019 06:58
Ads API 整合 GraphQL Schema Proposal
// refer to https://github.com/kdchang/reactjs101/blob/master/Appendix04/README.md
const facebookCampaignType = new graphql.GraphQLObjectType({
name: 'FacebookCampaign',
fields: {
id: { type: graphql.GraphQLString },
name: { type: graphql.GraphQLString },
status: { type: graphql.GraphQLString },
// other fields
}
@lili668668
lili668668 / add_score.js
Last active December 23, 2017 06:42
合併 學生名單 與 組別名單 與 用學號加分系統 與 zuvio 成績登計系統
const fs = require('fs')
const csv = require('fast-csv')
var addscore = fs.readFileSync("./addscore.csv").toString()
var students = fs.readFileSync("./student.csv").toString()
var arr = {}
var wa = []
csv
.fromString(students, {headers: true})
@lili668668
lili668668 / Test_Plot.py
Last active September 28, 2017 09:57
想給予一些比較,所以放上來
from bs4 import BeautifulSoup
import requests
import pandas as pd
import csv
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import time
import datetime