Skip to content

Instantly share code, notes, and snippets.

View WeiChiaChang's full-sized avatar
🐻
How bear you

WesleyZen WeiChiaChang

🐻
How bear you
  • Planet Earth
  • Tainan, Taiwan
View GitHub Profile
let a = 1
let b = 1
let count = 0
while (a <= 20) {
while (b <= 20) {
if (((a * 2 + b) <= 20) && a * 2 > b && a !== b) {
console.log(`發現等邊三角形 | 三邊長分別為: ${a}、${a}、${b}`)
count++
}
function isInValidTriangle (a, b, c) {
const result = !((a+b)>c) || !((b+c)>a) || !((c+a)>b) ||
!((a-b)<c) || !((b-a)<c) || !((b-c)<a) || !((c-b)<a) ||!((c-a)<b) ||
!((a-c)<b) || !(a>0) || !(b>0) || !(c>0)
return result
}
if (isInValidTriangle(a, b, c)) {
console.log ('invalid')
} else if (a===b && b===c) {
if (isValidTriangle(a, b, c)) {
if (a === b && b === c) {
console.log("是等邊三角形!")
} else if (a === b || b === c || a === c) {
console.log("是等腰三角形!")
} else {
console.log("是不等邊三角形!")
}
} else {
console.log("Invalid! (無法組成有效三角形) ")
@WeiChiaChang
WeiChiaChang / flag.js
Created February 21, 2020 05:02
Flags Name After Google Translate
var flags = [
{
"code": "Afghanistan",
"name": "Afghanistan",
"img": "https://lipis.github.io/flag-icon-css/flags/4x3/af.svg"
},
{
"code": "Aland Islands",
"name": "Aland Islands",
"img": "https://lipis.github.io/flag-icon-css/flags/4x3/ax.svg"
@WeiChiaChang
WeiChiaChang / cors-anywhere.js
Created February 13, 2020 05:06
cors-anywhere
// Reference:
// https://github.com/Rob--W/cors-anywhere
// Listen on a specific host via the HOST environment variable
var host = process.env.HOST || '0.0.0.0';
// Listen on a specific port via the PORT environment variable
var port = process.env.PORT || 8081;
var cors_proxy = require('cors-anywhere');
cors_proxy.createServer({
@WeiChiaChang
WeiChiaChang / batch-img.js
Created February 11, 2020 08:49
Batch multiple images
let imageLinks = []
const async = require('async')
let fs = require('fs')
let request = require('request')
let path = require('path')
const downloadImage = (src, dest, callback) => {
request.head(src, (err, res, body) => {
if (err) { console.log(err); return }
<template>
<div class="zoomer" ref="zoomer" @mousemove="moveBG" @mouseout="mouseOut">
<div class="img normal v-fade"
v-show="!hoverNow"
:style="{
backgroundImage: `url(${imgNormal})`
}"
></div>
<div
v-show="hoverNow"
@WeiChiaChang
WeiChiaChang / gist:c2c7e39b20df1d16a45e8fd5b5abe9fd
Created September 18, 2019 04:46 — forked from ansonparker/gist:1228449
Lossless FLV to MP4 conversion
Open command prompt (Terminal) and run:
ffmpeg -i "filename.flv" -vcodec copy -acodec copy "filename.mp4"
This will copy video track and audio track from filename.flv to filename.mp4. The operation is lossless (there is no quality loss).
@WeiChiaChang
WeiChiaChang / easing.js
Created September 17, 2019 08:14 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@WeiChiaChang
WeiChiaChang / fullscreen.css
Created September 8, 2019 02:41 — forked from yang-wei/fullscreen.css
Full size background image using CSS cover in mobile devices
html {
background: url(image url) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 100%;
overflow: hidden;
}