Skip to content

Instantly share code, notes, and snippets.

View kkc's full-sized avatar
🌴
On vacation

Kakashi Liu kkc

🌴
On vacation
View GitHub Profile
好的,我來將我剛剛設計的桌遊概念用中文詳細解釋一遍。這個遊戲的核心概念是結合了商業經營、策略規劃、風險管理,以及一些玩家互動的元素。
首先,我需要將遊戲的整體畫面呈現出來。想像一個熱鬧的火車站旁邊,有一條主要的街道,街道上有許多可以蓋建築的地點。玩家扮演不同的店家,可以購買這些地塊,然後蓋自己的商店。火車站是人潮的來源,特別是在天氣好的時候。地塊的位置很重要,越靠近車站的地塊越貴,但同時也更有優勢。遊戲中還有一些共享的資源,像是天氣效果,還有一些玩家會競爭的設施。
這個遊戲圍繞幾個核心的循環。玩家買地,蓋商店,吸引顧客。他們要管理金錢,升級建築,還可以陷害對手,同時應對多變的天氣。天氣系統增加了一些不確定性,也需要玩家投資在共同的基礎設施上。最靠近車站的地塊有優先選擇客人的權利,這增加了競爭的層面。
現在,我們來看看具體的遊戲機制。建築物要從一樓開始蓋,這增加了一種進展感。天氣系統會影響顧客的數量(晴天人多、雨天可能損壞、颱風停電),玩家可以選擇蓋避雷針來減少損失,但這樣就不能再往上蓋了。發電機和停車場則只能蓋在地下室,這讓玩家需要考慮是要優先衝高樓層還是蓋設施。
不同的商店和設施也增加了遊戲的深度。某些商店會有最適合的地點,像是便利商店適合在一樓,離車站近一點。停車場和發電機放在地下室是很合理的安排,而且它們看起來會是玩家需要的設施,玩家必須在這些基礎設施和純粹的盈利之間做選擇。
@kkc
kkc / get_or_create.py
Created September 8, 2020 07:40 — forked from jleclanche/get_or_create.py
SQLAlchemy get or create
def get_or_create(session, model, defaults=None, **kwargs):
"""
Get or create a model instance while preserving integrity.
"""
try:
return session.query(model).filter_by(**kwargs).one(), False
except NoResultFound:
if defaults is not None:
kwargs.update(defaults)
@kkc
kkc / slides I read
Last active July 2, 2020 08:25
Slides I read
[Linux Container Internals 2.0](https://docs.google.com/presentation/d/1S-JqLQ4jatHwEBRUQRiA5WOuCwpTUnxl2d1qRUoTz5g/edit#slide=id.g3e1a17e39e_2_41)
@kkc
kkc / AWS CLI VPC-Network
Created April 28, 2020 03:29
AWS CLI commands to build a sample VPC
aws> ec2 describe-vpcs
aws> ec2 create-vpc --cidr-block 10.0.0.0/16
aws> ec2 create-tags --resources vpc-f0bff594 --tags Key=Name,Value=sample-vpc
aws> ec2 describe-vpcs
aws> ec2 describe-internet-gateways
aws> ec2 create-internet-gateway
aws> ec2 create-tags --resources igw-6992410d --tags Key=Name,Value=sample-vpc-igw
aws> ec2 attach-internet-gateway --vpc-id vpc-f0bff594 --internet-gateway-id igw-6992410d
aws> ec2 describe-internet-gateways
aws> ec2 describe-subnets --query 'Subnets[?VpcId==`vpc-f0bff594`]'
ifconfig (or ip link, ip addr) - for obtaining information about network interfaces
ping
for validating, if target host is accessible from my machine.
ping is also could be used for basic DNS diagnostics - we could ping host by IP-address or by its hostname and then decide if DNS works at all. And then traceroute or tracepath or mtr to look what's going on on the way there.
dig
@kkc
kkc / gist:73daa92c15e0dfd9ec316298d5fc438f
Created March 13, 2020 13:25
Analyze pcap storing on S3
You can pull a capture from S3 into #Wireshark using the AWS CLI:
aws s3 cp s3://my-bucket/odd-http.pcap - | wireshark -k -i -
@kkc
kkc / gist:a82e4fdd5197ad9cf29f98bc649ccc94
Created October 15, 2018 12:48
Using environment variables in Kubernetes deployment spec
https://serverfault.com/questions/791715/using-environment-variables-in-kubernetes-deployment-spec
A much easier/cleaner solution: envsubst
In deploy.yml:
LoadbalancerIP: $LBIP
Then just create your env var and run kubectl like this:
export LBIP="1.2.3.4"
@kkc
kkc / S3-Static-Sites.md
Created July 25, 2018 07:48 — forked from bradwestfall/S3-Static-Sites.md
Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects. Also covers deployments.

S3 Static Sites

What this will cover

  • Host a static website at S3
  • Redirect www.website.com to website.com
  • Website can be an SPA (requiring all requests to return index.html)
  • Free AWS SSL certs
  • Deployment with CDN invalidation

Resources

@kkc
kkc / AMI_finder
Created December 28, 2017 08:50
Find the most recent Ubuntu AMI 16.04 using aws-cli (or any other AMI for that matter)
#!/bin/sh
# Use AWS CLI to get the most recent version of an AMI that
# matches certain criteria. Has obvious uses. Made possible via
# --query, --output text, and the fact that RFC3339 datetime
# fields are easily sortable.
export AWS_DEFAULT_REGION=us-east-1
aws ec2 describe-images \
@kkc
kkc / readContent.js
Created October 16, 2017 16:01
promise and singleton
var fs = require('fs');
function Reader() {
this.content = null;
}
Reader.prototype.getContent = function() {
if (this.content === null) {
return new Promise((resolve, reject) => {
console.log('new promise');