Skip to content

Instantly share code, notes, and snippets.

@gatesakagi
gatesakagi / willjspractice1.js
Last active June 21, 2017 17:20
保哥JS練習
/*
請完成以下 API 設計,讓你的程式可以執行以下程式碼,
並且得到預期的結果。串接 add 的次數沒有上限,最後一個 API 是 result() 才會回傳結果。
$(1).add(2).add(3).add(99).result() === 105
$(1).add(2).add(3).result() === 6
*/
var $ = function(num) {
return {
add: function(numadd) { return $(num+numadd); },
result: function() { return num; }
@gatesakagi
gatesakagi / gist:7b6125a69acd20b990a89dfe5e7506dc
Created April 21, 2017 06:05
RWD於電腦版及手機版的切換語法
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimun-scale=1.0">
<title>Document</title>
<style type="text/css">
div {
width: 300px;
height: 200px;
@gatesakagi
gatesakagi / drinkOrderAPI.gs
Last active November 14, 2022 17:30
Google App Script (讀取QueryString並寫入Sheet)
function doGet(e) {
//JSON.stringify(name)
if(typeof e !== 'undefined') {
var params = e.parameter;
var name = params.name;
var drinkIndex = params.drinkindex;
var drink = params.drink;
var drinkPrice = params.drinkprice;
var sugar = params.sugar;
var ice = params.ice;
@IBAction func switchAction(_ sender: UISwitch) {
print("switchGood\(switchGood.isOn), switchFast\(switchFast.isOn), switchCheap\(switchCheap.isOn)")
switch sender.tag {
case 0: //switchGood
setupSwitchsStatus(labelSource: labelGood, switchSource: switchGood, labelDesignated1: labelFast, switchDesignated1: switchFast, labelDesignated2: labelCheap, switchDesignated2: switchCheap)
case 1: //switchFast
setupSwitchsStatus(labelSource: labelFast, switchSource: switchFast, labelDesignated1: labelGood, switchDesignated1: switchGood, labelDesignated2: labelCheap, switchDesignated2: switchCheap)
switch sender.tag {
case 0: //switchGood
if (sender.isOn == true) {
labelGood.alpha = 1.0
if (switchFast.isOn == true) {
switchCheap.setOn(false, animated: true)
labelCheap.alpha = 0.5
} else if (switchCheap.isOn == true) {
switchFast.setOn(false, animated: true)
labelFast.alpha = 0.5