Skip to content

Instantly share code, notes, and snippets.

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.mortbay.log.Log;
@jack21
jack21 / Breadcrumb-Blog.html
Last active February 23, 2018 04:49
部落格麵包屑 Schema.org
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [{
"@type": "ListItem",
"position": 1,
"item": {
"@id": "FG部落格首頁網址",
"name": "部落格"
@jack21
jack21 / BlogPost.html
Last active February 23, 2018 04:12
部落格文章 Schema.org
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BlogPosting",
"headline": "部落格文章標題",
"image": "該文章主圖",
"editor": "部落客名稱",
"publisher": "部落格名稱",
"url": "文章網址",
"datePublished": "文章發布時間,格式如右: 2015-09-20",
@jack21
jack21 / Forum.html
Last active February 23, 2018 04:19
討論區文章 Schema.org
<script type="application/ld+json">
{
"@context":"http://schema.org",
"@type":"DiscussionForumPosting",
"@id":"討論區文章網址",
"headline":"討論區文章標題",
"author": {
"@type": "Person",
"name": "發文者名稱"
},
@jack21
jack21 / Product.html
Last active February 23, 2018 04:58
市調商品 Schema.org
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"name": "評鑑商品名稱",
"description": "",
"url": "評鑑商品網址",
"image": "評鑑商品圖片網址",
"offers": {
"@type": "Offer",
@jack21
jack21 / contracts...MappingDemo.sol
Created September 3, 2022 07:38
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract Test {
enum Period {
AM, PM
}
struct Student {
uint no;
@jack21
jack21 / contracts...MappingTypeDemo.sol
Created September 3, 2022 09:57
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract MappingTypeDemo {
enum Period {
AM, PM
}
struct Student {
uint no;
@jack21
jack21 / contracts...MappingRestrictDemo.sol
Created September 3, 2022 10:01
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract MappingTypeDemo {
mapping(bool => int) map;
// mapping 不能是 local variable
function mappingInLocalVariable() external view {
// mapping(bool => int) memory map; // 打開此行會報錯
@jack21
jack21 / contracts...MappingDemo.sol
Created September 3, 2022 10:09
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract MappingDemo {
mapping(string => uint8) scoreMap;
function setScore(string memory name, uint8 score) external {
scoreMap[name] = score;
}
@jack21
jack21 / contracts...ArrayTypeDemo.sol
Created September 3, 2022 12:01
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
contract ArrayTypeDemo {
// two way to declare fixed length array
uint[5] fixedLengthArray1;
uint[] fixedLengthArray2 = [1, 2, 3];
// declare dynamic length array