{"version":"https://jsonfeed.org/version/1","title":"Memories Mapped to Web Pages","home_page_url":"https://mmap.page/","feed_url":"https://mmap.page/feed.json","items":[{"id":"https://mmap.page/fyi/victoria/","url":"https://mmap.page/fyi/victoria/","title":"Historical Sites in Victoria, Labuan (British Crown Colony & WWII)","content_html":"

Historical Sites in Victoria, Labuan (British Crown Colony & WWII)

\n

List of historical places and sites in and around Victoria (Bandar Labuan / 维多利亚), Federal Territory of Labuan (纳闽), Malaysia. Labuan was ceded by Brunei in 1846, a British Crown Colony from 1848, in the Straits Settlements 1907–1941, occupied by Japan 1942–1945, then Crown Colony of North Borneo 1946–1963. Ordered chronologically by built or establishment period.

\n

Victoria is the island’s port town on the south-east shore. The Chimney, Peace Park, and Surrender Point are a north-coast drive, not a town-centre walk.

\n

Chronological List

\n
    \n
  1. \n

    Kampung Patau-Patau Water Village (Kampung Air Patau-Patau) (pre-colonial; occupied through the British period)

    \n\n
  2. \n
  3. \n

    Tanjung Kubong Coal Workings & The Chimney (Chimney Museum / Punil) (coal 1847–1912; brick stack ca. 1900)

    \n\n
  4. \n
  5. \n

    Victoria Harbour & Government Wharf (Labuan International Ferry Terminal vicinity) (1848)

    \n\n
  6. \n
  7. \n

    Government House Botanical Garden (Taman Botanikal Labuan) (late 19th c.)

    \n\n
  8. \n
  9. \n

    Labuan Square / Padang (Dataran Labuan) (late 19th – early 20th c.)

    \n\n
  10. \n
  11. \n

    Labuan Clock Tower site (Menara Jam Labuan) (1906; wrecked 1945; replica 2002)

    \n\n
  12. \n
  13. \n

    Labuan Airstrip / No. 1 Strip (Labuan Airport) (Japanese-built; captured 10 June 1945)

    \n\n
  14. \n
  15. \n

    Brown Beach Allied Landing (Operation Oboe Six) (10 June 1945)

    \n\n
  16. \n
  17. \n

    Surrender Point (Layang-Layangan) (10 September 1945)

    \n\n
  18. \n
  19. \n

    Labuan War Cemetery (Perkuburan Perang Labuan) (28 December 1945)

    \n\n
  20. \n
  21. \n

    Peace Park (Taman Damai) (post-1945)

    \n\n
  22. \n
  23. \n

    Labuan Museum (Muzium Labuan / former British North Borneo office) (building 1950s; museum 2004)

    \n\n
  24. \n
\n

Walking route in Victoria

\n

Start at Labuan Square (5.2759°N, 115.2454°E). West to the ferry terminal, then east along the waterfront to Brown Beach, then north-east to the cemetery. Straight-line legs below are ~3.8 km (allow ~5 km on the street). The Chimney, Surrender Point, and Peace Park need a car or bus (north coast).

\n
    \n
  1. Labuan Square / padang
  2. \n
  3. Labuan Museum — on the square, ~110 m north.
  4. \n
  5. Victoria Harbour / ferry terminal — ~470 m west.
  6. \n
  7. Clock Tower — ~1.5 km east along Jalan Tanjung Purun / the waterfront (Marine Museum is in the same Sea Sports Complex vicinity; the building is modern).
  8. \n
  9. Brown Beach — ~230 m further east, the Tanjung Purun shore beside Ramsey Point.
  10. \n
  11. War Cemetery — ~1.4 km north-east of Brown Beach (~2.2 km from the square).
  12. \n
\n

Optional walks, not in the legs above: Kampung Patau-Patau (~1.5 km west of the square) and Government House Botanical Garden (~1.8 km north of the square). No. 1 Strip is Labuan Airport, ~1.7 km north-west of the cemetery, not a separate stop.

\n

Optional drives: Surrender Point + Peace Park then The Chimney (Layang-Layangan / Tanjung Kubong, north).

\n

Google Maps walking directions (coordinate pins).

","date_published":"Tue, 13 Oct 2026 09:05:13 GMT","date_modified":"Tue, 13 Oct 2026 16:37:56 GMT"},{"id":"https://mmap.page/fyi/sitiawan/","url":"https://mmap.page/fyi/sitiawan/","title":"Historical Sites in Sitiawan (Early 20th Century & Colonial Period)","content_html":"

Historical Sites in Sitiawan (Early 20th Century & Colonial Period)

\n

List of historical places and sites in Sitiawan, Perak, Malaysia associated with the British colonial administration, the 1903 Foochow Christian settlement led by the American Methodist Mission, and early rubber planting in the Dindings hinterland, ordered chronologically by built or establishment period.

\n

Chronological List

\n
    \n
  1. \n

    Kampung Sitiawan River Jetty & Old Settlement (Pengkalan Kampung Sitiawan / \"Mena Jetty\" Site / Jeti Nelayan Kampung Sitiawan) (1892)

    \n\n
  2. \n
  3. \n

    Pioneer Memorial Hall (開墾紀念堂) (September 1903)

    \n\n
  4. \n
  5. \n

    Pioneer Methodist Church (Gereja Methodist Pioneer Kampung Koh) (1903; present sanctuary built 1927)

    \n\n
  6. \n
  7. \n

    Anglo-Chinese School Sitiawan (ACS Sitiawan) (1903)

    \n\n
  8. \n
  9. \n

    Kampung Koh Main Commercial Street & Shophouses (Jalan Besar / Jalan Lin Chen Mei) (1920s–1930s)

    \n\n
  10. \n
  11. \n

    Lok Hop Dispensary / Sitiawan Surgery (六合大藥房 / 林心漢藥房) (1931–1932; clinic opened 1934)

    \n\n
  12. \n
  13. \n

    Sitiawan Settlement Heritage Museum (Muzium Warisan Sitiawan) (1935)

    \n\n
  14. \n
","date_published":"Mon, 12 Oct 2026 01:42:48 GMT","date_modified":"Mon, 12 Oct 2026 01:42:48 GMT"},{"id":"https://mmap.page/fyi/pangkor/","url":"https://mmap.page/fyi/pangkor/","title":"Historical Sites on Pangkor Island (Dutch & British Periods)","content_html":"

Historical Sites on Pangkor Island (Dutch & British Periods)

\n

List of historical places and sites on Pangkor Island, Perak, Malaysia associated with the Dutch East India Company (VOC) era (17th–18th century) and the British Straits Settlements administration (1874–1935), ordered chronologically by built or establishment period.

\n

Chronological List

\n
    \n
  1. \n

    Kota Belanda (Dutch Fort / Fort Dingdingh) (1670; rebuilt 1743; restored 1973)

    \n\n
  2. \n
  3. \n

    Site of the 1693 Dutch Stone Pillar (1693)

    \n\n
  4. \n
  5. \n

    Batu Bersurat Belanda (Tiger Rock / Sacred Rock) (1743)

    \n\n
  6. \n
  7. \n

    HMS Pluto Treaty Anchorage (Waters off Pangkor) (20 January 1874)

    \n\n
  8. \n
  9. \n

    Pangkor Town Government Jetty Site (Terminal Jeti Pangkor) (1880s–1930s)

    \n\n
  10. \n
  11. \n

    Pangkor Town Main Street (Jalan Besar) (Late 19th – early 20th c.)

    \n\n
  12. \n
  13. \n

    Bukit Pangkor Survey Baseline / Trig Station (Late 19th – early 20th c.)

    \n\n
  14. \n
  15. \n

    South Pangkor Forest Reserve & Ranger Outposts (Hutan Simpan Pangkor Selatan) (1920s)

    \n\n
  16. \n
  17. \n

    Cross-Island Road (Jalan Pasir Bogak) (1920s–1930s)

    \n\n
  18. \n
  19. \n

    Pangkor Village Public Latrine & Sanitation Site (1927)

    \n\n
  20. \n
\n

Inscriptions on Batu Bersurat

\n

The 1743 cuts are shallow and weathered. Locals later read the lion as a tiger, hence “Tiger Rock”. Wikimedia Commons has no free close-up of this granite. Photographs below are not Creative Commons: origin and all rights reserved under each image. Type images still show what each sign is.

\n

\"Batu

\n

Origin: Timothy Tye, Penang Travel Tips (2020). All rights reserved.

\n

\"Inscribed

\n

Origin: pangkor-island.com, Batu Bersurat. All rights reserved.

\n

VOC emblem

\n

\"VOC

\n

Interlocking V–O–C of the Vereenigde Oost-Indische Compagnie. Company mark: we trade here. On this rock the monogram sits to the right of the lion, with a letter A (Amsterdam chamber) above the C.

\n

Type source: File:VOC.svg (public domain).

\n

\"VOC

\n

Origin: Malaysia Traveller, Batu Bersurat (January 2019). All rights reserved.

\n

United Provinces lion

\n

\"Coat

\n

Reference for the republican lion, not a tracing of the rock. Gold lion on blue, strewn with Nassau billets; sword in one paw, seven arrows in the other (the seven provinces). Motto Concordia res parvae crescunt. Sword and arrows are often unreadable on the granite; the intended type is this States General achievement, not the post-1815 royal arms.

\n

Type source: File:Coat of arms of the republic of the united Netherlands (after 1665).svg by Katepanomegas, elements by Sodacan, CC BY-SA 3.0.

\n

The granite close-up is the Malaysia Traveller photo under VOC emblem. Tufted tail, sword, and a bundle of arrows; the outline follows the republican shield, not a tiger mauling a boy.

\n

Year 1743

\n

\"1743\"

\n

Year of the fort rebuild and of these cuts. The figure is a typographic stand-in, not a rubbing. On the boulder the year is cut several times among the initials (visible on the pangkor-island.com face photo above: e.g. CRALO 1743, I STATISMA 1743, RD 1743).

\n

Soldiers' initials

\n

Roman-letter initials of men in the 1743 garrison, cut beside the emblems.

\n

\"Initials

\n

Origin: Malaysia Traveller, Batu Bersurat (RA / PK / WW panel and boxed H). All rights reserved. Further clusters (IF CRALO, IK/TD, GPYL, etc.) are on the face photos above.

\n

Walking route from Terminal Jeti Pangkor

\n

Start at Terminal Jeti Pangkor (4.2134°N, 100.5762°E), the Lumut ferry landing. Town cluster first, then south along the east-coast road to Teluk Gedung, then back to the jetty for the return ferry. Straight-line legs below are ~3.5 km including the return (allow ~4–5 km on the street). HMS Pluto is an offshore anchorage in the Dindings Strait — look east from the jetty; it is not a walking stop. The 1693 stone pillar no longer stands; treat it as the Kota Belanda vicinity.

\n
    \n
  1. Pangkor Village bazaar / sanitation site — ~80 m west of the jetty.
  2. \n
  3. Jalan Besar — ~170 m north along the town street.
  4. \n
  5. Kota Belanda — ~1.6 km south at Kampung Teluk Gedung.
  6. \n
  7. Batu Bersurat Belanda — ~140 m south of the fort.
  8. \n
  9. Terminal Jeti Pangkor — ~1.6 km north. End.
  10. \n
\n

Optional, instead of or after the town street and before heading south: west on Jalan Pasir Bogak to the cross-island saddle (~1.2 km from the jetty). That road runs about 2 km from the village to Pasir Bogak. Hutan Simpan Pangkor Selatan is about 1 km south of the saddle pin. Bukit Pangkor (~350 m) is a foot-trail climb from Pasir Bogak, not pavement.

\n

Google Maps walking directions (coordinate pins).

","date_published":"Mon, 12 Oct 2026 01:42:48 GMT","date_modified":"Mon, 12 Oct 2026 01:42:48 GMT"},{"id":"https://mmap.page/fyi/lumut/","url":"https://mmap.page/fyi/lumut/","title":"Historical Sites in Lumut (British Colonial Period)","content_html":"

Historical Sites in Lumut (British Colonial Period)

\n

List of historical places and sites in Lumut, Perak, Malaysia associated with the British Straits Settlements administration (1874–1935) when Lumut served as the administrative headquarters of the Dindings territory, ordered chronologically by built or establishment period.

\n

Chronological List

\n
    \n
  1. \n

    Lumut Government Jetty & Harbour Front (Terminal Jeti Lumut) (1880s–1930s)

    \n\n
  2. \n
  3. \n

    Dindings District Office & Court House Site (Pejabat Orang Besar Jajahan Manjung / Old Government Office Site) (Late 19th c., ca. 1888)

    \n\n
  4. \n
  5. \n

    Lumut Government Rest House Site (Rumah Rehat MARA / Old Rest House Site) (1890s)

    \n\n
  6. \n
  7. \n

    Lumut Colonial Post & Telegraph Office (Pejabat Pos Lumut) (ca. 1890s–1900s)

    \n\n
  8. \n
  9. \n

    Lumut District Hospital Site (Hospital Lumut / Government Quarters Hill) (1890s–1920s)

    \n\n
  10. \n
  11. \n

    Lumut Main Town Street (Jalan Sultan Idris Shah / Jalan Esplanade) (Turn of 20th c.)

    \n\n
  12. \n
  13. \n

    Bukit Engku Busu Trig Station & Forest Reserve (Early 20th c.)

    \n\n
  14. \n
\n

Walking route from Stesen Bas Lumut

\n

Start at Stesen Bas Lumut on Jalan Iskandar Shah (4.2348°N, 100.6338°E). South and up the hill first, then west to the headland, then north along the water to finish at the jetty. Straight-line legs below are ~1.6 km (allow ~2–2.5 km on the street). Bukit Engku Busu is a separate climb, not pavement.

\n
    \n
  1. Dindings District Office site (Pejabat Orang Besar Jajahan Manjung) — ~320 m south, inland on the Jalan Telah Muroh side.
  2. \n
  3. Hospital site (Lumut Valley Condominium grounds) — ~260 m southwest, up the hill.
  4. \n
  5. Jalan Sultan Idris Shah (main town street / old esplanade) — ~190 m west, down toward the water.
  6. \n
  7. Rumah Rehat MARA (old rest house site) — ~100 m southwest, waterfront headland.
  8. \n
  9. Pejabat Pos Lumut — ~640 m northeast along the waterfront from the rest house.
  10. \n
  11. Terminal Jeti Lumut — ~100 m north of the post office. End.
  12. \n
\n

Optional, after the rest house and before turning north: Bukit Engku Busu (~1 km south of the rest house, ~331 m). Forest reserve / trig station; expect a hike, not a sidewalk.

\n

Google Maps walking directions (coordinate pins; do not search “Stesen Bas Lumut”, which Maps may snap to the jetty).

","date_published":"Mon, 12 Oct 2026 01:42:48 GMT","date_modified":"Mon, 12 Oct 2026 01:42:48 GMT"},{"id":"https://mmap.page/vibe/too-faithful-port/","url":"https://mmap.page/vibe/too-faithful-port/","title":"When the Agent Ports Too Faithfully","content_html":"

When the Agent Ports Too Faithfully

\n

Vibe coding with an agent is great at producing working code quickly.\nIt is also great at producing the wrong kind of fidelity:\nmatching yesterday’s prototype instead of today’s problem,\nor inventing a “clever” helper when the language already has the boring answer.

\n

This is the story of a small Deno/TypeScript rewrite of some Python helper scripts,\nand of the refactors that followed once we stopped treating “same as Python” as a virtue.

\n

A clear check, replaced by a clever one

\n

The Python validator asked a simple question: are the dates already in descending order?

\n
if dates != sorted(dates, reverse=True):\n    errors.append(\"rows not sorted by date descending\")\n
\n

That is not fancy.\nIt is also not ambiguous.\nAnyone who knows sorted can read the intent in one glance.

\n

The TypeScript port did not keep that shape.

\n
const sorted = [...dates].sort().reverse();\nif (dates.join(\"\\0\") !== sorted.join(\"\\0\")) {\n  return [\"rows not sorted by date descending\"];\n}\n
\n

It copied the dates, sorted them, reversed them, joined both sides with a null byte,\nand compared the joined strings.\nAn agent later defended that as a shortcut.

\n

It was not a shortcut.

\n

It was still O(n log n), like the Python version.\nIt was harder to read.\nThe \\0 join was a cleverness tax with no payoff.\nWhen someone finally “fixed” it, the right move was not another clever compare —\nit was the ordinary linear check: walk adjacent pairs and fail when order breaks.

\n

The lesson for vibe coders is not “never sort to check sortedness.”\nPython’s compare-to-sorted form is fine when clarity wins and n is tiny.\nThe lesson is: do not let an agent sell you opacity as optimization.\nIf the new code is slower to understand and not meaningfully faster,\nit is not a shortcut. It is a regression with better marketing.

\n

A stdlib quirk, promoted into a domain rule

\n

Netflix’s viewing-history export uses dates like 4/6/23.\nPython’s original helper parsed them with strptime and %y.

\n
datetime.strptime(d, \"%m/%d/%y\").date().isoformat()\n
\n

That format has a famous pivot: years 69–99 become 1969–1999, and 00–68 become 2000–2068.\nNobody on the project chose that rule for Netflix.\nThey chose “call the stdlib.”\nFor a streaming export that only exists in the 21st century, the pivot never mattered in practice.\nLazy, harmless.

\n

The TypeScript port did not call a stdlib with a hidden pivot.\nIt reimplemented the pivot in plain sight:

\n
const fullYear = year >= 69 ? 1900 + year : 2000 + year;\n
\n

That is a different animal.\nIn Python, the quirk was accidental.\nIn TypeScript, the quirk became an explicit product rule —\nand the wrong one.\nNetflix streaming started in 2007.\nExported watch dates are not DVD-era 1969.\nThe domain rule is simply: YY means 20YY.

\n

Later commits even documented the 69 cutoff so the port would “match Python.”\nDocumentation made the mistake look intentional.

\n

The lesson: a shortcut that is free in language A becomes a design decision when you rewrite it in language B.\nAsk whether you are preserving behavior users need, or preserving trivia the prototype inherited.\nByte-identical ports feel safe to agents.\nDomain-identical ports are what you actually want.

\n

Fidelity to the wrong thing

\n

Both stories are the same bug with different costumes.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
What felt like correctnessWhat was actually needed
Match Python’s sortedness idiom via a string joinExpress “is descending?” clearly
Match Python %y year windowsExpress “streaming export years are 20xx”
\n

Agents optimize for local continuity:\nkeep the tests green, keep the output identical, keep the comments saying “matches Python.”\nHumans have to supply the other objective:\nwould I write this from scratch in this language, for this domain?

\n

That question is the cheapest high-leverage review prompt in vibe coding.\nUse it when the agent says “I ported it carefully.”\nCareful ports of the wrong target are still wrong.

\n

Inventing an API the language already has

\n

Python’s title-coverage check was also one glance:

\n
missing = sorted(set(want) - set(got))\nextra = sorted(set(got) - set(want))\n
\n

TypeScript’s Set has no - operator.\nAn agent eventually wrapped filter-and-sort in a fluent mini-DSL:

\n
sortedTitlesIn(wantTitles).notIn(gotTitles)\n
\n

Readable English, if you squint.\nUnnecessary ceremony, if you check the runtime.

\n

Modern JavaScript (and current Deno) already has set algebra on the prototype:

\n
[...wantTitles.difference(gotTitles)].toSorted()\n
\n

That is the port of set(want) - set(got) that does not invent a dialect.

\n

In the same session, an agent confidently said\n“TypeScript’s Set has no -” and stopped there —\nas if the absence of an operator implied the absence of the operation.\nThe operator claim was true.\nThe implication was not.\nSet.prototype.difference was sitting in the runtime the whole time.

\n

The lesson: before an agent designs a helper, ask what the language and standard library already provide.\nEspecially on a recent Deno/Node, “I remember JS couldn’t do that” is often outdated muscle memory.\nVibe coding fails quietly when the agent’s training prior is older than your toolchain.

\n

Other “from scratch in Deno” moves fell out of the same habit:

\n\n

None of those are the plot.\nThey are examples of what happens when you stop asking “how did Python say it?”\nand start asking “how does this language say it now?”

\n

What to push back on

\n

Agents sound sure.\nThat is part of the product.\nYour job is not to absorb certainty; it is to challenge the kind of correctness on offer.

\n

Useful pushbacks, in plain language:

\n
    \n
  1. Is this clearer than what we had?\nIf not, “refactor” is the wrong word.
  2. \n
  3. Is this a domain rule or a language quirk we copied?\nQuirks do not deserve a second implementation.
  4. \n
  5. Did we check the current runtime before inventing an API?\ndifference, groupBy, Temporal, JSR @std — verify, don’t reminisce.
  6. \n
  7. Are we matching the prototype or the problem?\nIdentical output is not identical intent when the prototype was accidental.
  8. \n
\n

Also: when an agent documents a weird constant (“69 so we match Python”),\ntreat that as a smell, not as settled design.\nDocs can launder a porting artifact into folklore.

\n

What this is not arguing

\n

This is not “never port.”\nPrototypes are how ideas get cheap.\nPython was a fine place to discover the collapse rules.

\n

This is not “agents are useless.”\nThe same loop that produced the bad pivot also produced the cleanup once the review criteria changed.

\n

This is not “always hand-write everything.”\nIt is: keep the human in charge of the objective function.\nAgents are strong at local edits and weak at noticing that the local optimum is fidelity to the wrong ancestor.

\n

A small checklist for vibe ports

\n

When an agent rewrites working code from language A to language B:

\n\n

An agent will match the last implementation for as long as review accepts that as done.\nAsk for the problem, in this language, and the same loop will match that.

","date_published":"Tue, 18 Aug 2026 11:10:35 GMT","date_modified":"Tue, 18 Aug 2026 16:55:36 GMT"},{"id":"https://mmap.page/fyi/","url":"https://mmap.page/fyi/","title":"For Your Insomnia","content_html":"

For Your Insomnia

\n","date_published":"Tue, 28 Jul 2026 06:18:30 GMT","date_modified":"Tue, 13 Oct 2026 09:05:13 GMT"},{"id":"https://mmap.page/fyi/cinematic-nangloeng-2026/","url":"https://mmap.page/fyi/cinematic-nangloeng-2026/","title":"Cinematic Nangloeng 2026","content_html":"

Cinematic Nangloeng 2026

\n

Free classic Thai films at Sala Chalerm Thani (Nang Loeng Cinema, Bangkok), 28 July–1 August 2026. One film per day at 16:00 ICT. Tickets on site from 15:00 (no online booking); venue open for photos from 14:00. 250 seats; no air-con; no parking — use public transport.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Tue 28 JulWed 29 JulThu 30 JulFri 31 JulSat 1 Aug
\"The\"Tone\"\"Wan\"Romantic\"Dang
The Boat House (เรือนแพ, 1961)Tone (โทน, 1970)Wan Phen (วันเพ็ญ, 1978)Romantic Blue (โลกทั้งใบให้นายคนเดียว, 1995)Dang Bireley's and Young Gangsters (2499 อันธพาลครองเมือง, 1997)
\n

Official listing: Film Archive (FAPOT) · Thairath

\n

Watch online

\n

Uploads come and go for rights reasons. Durations use h / m / s (e.g. 2m 45s, 2h 04m 56s).

\n

Soundtrack links prefer Wikidata, then MusicBrainz, then Internet Archive, then YouTube Music, then other streaming.

\n

Tue 28 Jul — The Boat House (เรือนแพ, 1961)

\n

Listed runtime ≈ 125 min (th.wikipedia).

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TypeLinkNotes
Fullเรือนแพ full (fan upload)2h 04m 56s. Best length match to ~125 min. Prefer this. Fan upload; first cast line correct (ไชยา / ส.อาสนจินดา / มาเรีย จาง / จินฟง); rest of description is messy/copy-paste.
Fullเรือนแพ full (labeled HD; short)1h 46m 06s. Labeled เต็มเรื่อง / HD, but ~19 min short — likely cut, incomplete rip, or different transfer.
ClipTheme song with stills2m 45s. Theme song (ชรินทร์ นันทนาคร) with film stills — not a narrative clip of the feature.
ThemeTheme audio (Rose Media)2m 49s. Official audio of the same theme (Rose Media).
Archive newsreelFilm Archive royal screening2m 41s. Film Archive Thailand: royal screening of เรือนแพ, not the movie.
\n

Soundtrack:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TypeLinkNotes
Wikidataเรือนแพ (Q16304656)Theme song item; sitelink th.wikipedia เรือนแพ (เพลง). No MusicBrainz recording or Internet Archive audio found for ชรินทร์'s version.
YouTube Musicเรือนแพ — ชรินทร์ นันทนาครOfficial audio (Rose Media); same upload as Theme row above.
StreamingApple Music — เรือนแพCharin Nuntanakorn. Also on Deezer.
\n

Cast ↔ roles (th.wikipedia / ThaiContentDB):

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
ActorRole
ไชยา สุริยันแก้ว (boxer; later outlaw)
ส. อาสนจินดาเจน (law graduate → police)
จินฟงริน (singer/songwriter)
มาเรีย จางเพ็ญ (the woman all three love)
\n

Also billed (roles less documented in the same sources): อดุลย์ ดุลยรัตน์, สมจิตต์ ทรัพย์สำรวย, เชาว์ แคล่วคล่อง, สาหัส บุญ-หลง, ทัต เอกทัต, สถาพร มุกดาประกร, ชาลี อินทรวิจิตร, เมืองเริง ปัทมินทร์, จำรูญ หนวดจิ๋ม.

\n

Poster faces (hand-painted art used on this page):

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Poster spotWho
Large man with revolverแก้ว (ไชยา)
Boxing ring (background)แก้ว's boxing plot
Smiling woman (lower right)เพ็ญ (มาเรีย จาง)
Man with mic / bow tieริน (จินฟง)
Armed men (left)Supporting action (police / raid)
\n

Wed 29 Jul — Tone (โทน, 1970)

\n

Listed runtime ≈ 137 min (ThaiContentDB).

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TypeLinkNotes
Fullโทน full (Piak Poster)2h 16m 06s (~136 min). Clear synopsis; Piak Poster / Suwann Film / 1970. Prefer this (more views).
Fullโทน full (reupload)2h 16m 29s. Same film, nearly identical length; low-view reupload.
BTS35 mm making-of16m 54s. Making-of of the 35 mm shoot (ชุมทางหนังไทย), not a trailer.
\n

Soundtrack (th.wikipedia tracklist: โทน / อย่าบอน — สังข์ทอง; ปิดเทอม / เริงรถไฟ / ชื่นรัก — ดิอิมพอสซิเบิ้ล; plus others). No Wikidata soundtrack item, MusicBrainz OST release, or Internet Archive audio found.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TypeLinkNotes
MusicBrainzThe Impossibles · สังข์ทอง สีใสArtist pages only; Tone OST recordings not catalogued on MusicBrainz.
YouTube Musicปิดเทอม — ดิอิมพอสซิเบิ้ลTitle-sequence song from the film.
YouTube Musicโทน — สังข์ทอง สีใสTitle song (fan upload labeled โทน 1970).
StreamingApple Music — ชุด 1 ชื่นรัก เริงรถไฟThe Impossible (ดิอิมพอสซิเบิ้ล): includes ปิดเทอม, เริงรถไฟ, ชื่นรัก. สังข์ทอง's โทน not found on Apple.
\n

Cast ↔ roles (th.wikipedia / ThaiContentDB):

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
ActorRole
ไชยา สุริยันโทน / เปิ่น (orphan temple boy → Bangkok student)
อรัญญา นามวงศ์แดง (อ๊อด's sister; society girl)
สายัณห์ จันทรวิบูลย์อ๊อด (helps โทน study in Bangkok)
จารุวรรณ ปัญโญภาสกุหลาบ
สอาด เปี่ยมพงษ์สานต์อิทธิพล (villain who wants แดง)
สังข์ทอง สีใสสังข์ทอง (โทน's friend; singer)
รุจน์ รณภพรุจน์
พูนสวัสดิ์ ธีมากรนิพนธ์
จุรี โอศิริยายปลั่ง
\n

Poster faces (portrait on this page; IDs checked against the larger ThaiContentDB scan / billing strip):

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Poster spotWho
Center couple (yellow striped shirt + woman with revolver)โทน / แดง (ไชยา · อรัญญา)
Upper left (mustache, glass)อิทธิพล (สอาด)
Standing woman, white shirt / black skirt, booksกุหลาบ (จารุวรรณ)
Man on motorcycle (blue shirt, cigarette)อ๊อด (สายัณห์)
Crouched man, orange polka-dot shirtสังข์ทอง (สังข์ทอง สีใส)
Small figure in red rocky ground (gun)โทน (ไชยา)
Bottom-right older woman (striped top)ยายปลั่ง (จุรี)
\n

Thu 30 Jul — Wan Phen (วันเพ็ญ, 1978)

\n

Listed runtime ≈ 120 min (ThaiContentDB).

\n

No full feature found online as of 2026-07-28.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TypeLinkNotes
ClipFilm Archive promo1m 19s. Film Archive scan/screening promo — not the feature.
\n

Soundtrack: no dedicated OST release found online for the 1978 remake (Wikidata / MusicBrainz / Internet Archive / YouTube Music / Apple / Deezer). The better-known song วันเพ็ญ (later cover) belongs to Wan Phen (1938), not this remake.

\n

Cast ↔ roles from contemporary synopsis pages (p.1 · p.2; Thai Movie Posters press write-up):

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
ActorRole
สมบัติ เมทะนีอรุณ (writer/songwriter)
นิภาพร นงนุชวันเพ็ญ
ด.ญ.คลอใจ ปุญญหิตานนท์วันเพ็ญ (child)
มยุรฉัตร เหมือนประสิทธิเวชไขนภา (socialite who wants อรุณ's songs / tries to win him)
สุทิศา พัฒนุชอุ่นเรือน (อรุณ's sister)
ด.ญ.ภูมิจิต ปุญญหิตานนท์อารีย์ (child; อุ่นเรือน's daughter)
วาสนา รัตนวลีอารีย์ (อุ่นเรือน's daughter; likes วัฒน์)
จักรกฤษ พันธ์ชัยวัฒน์ (student neighbor)
มานพ อัศวเทพหมอเนตร (doctor; warns อรุณ about his eyesight)
สมชาย สามิภักดิ์พร (วันเพ็ญ's father; helps อรุณ after the Phuket crash)
จุรี โอศิริหวาน (พร's wife)
จำรูญ หนวดจิ๋มลุงเปลี่ยน (อรุณ's old household retainer)
\n

Poster faces (Rim Four Art / ThaiContentDB art used on this page):

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Poster spotWho
Center coupleอรุณ / วันเพ็ญ (สมบัติ · นิภาพร)
Singer + micไขนภา (มยุรฉัตร)
Yellow blouseอุ่นเรือน (สุทิศา)
Speedboatวัฒน์ + อารีย์ (จักรกฤษ · วาสนา)
Young girl by titleวันเพ็ญ child (ด.ญ.คลอใจ)
Shirt/tie by cast listหมอเนตร (มานพ)
Grin by มานพPossibly วัฒน์
\n

Fri 31 Jul — Romantic Blue (โลกทั้งใบให้นายคนเดียว, 1995)

\n

Listed runtime ≈ 112 min (IMDb). Release: 16 Jun 1995.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TypeLinkNotes
Full (Internet Archive)Romantic Blue 1080p EN1h 50m 23s. 1080p EN (~640 MB MP4); English subs; uploaded Nov 2025. Prefer this (more stable host).
Full (Bilibili.tv)Romantic Blue 1080p EN1h 50m 24s. Same encode as Internet Archive. On bilibili.tv (intl), not bilibili.com (CN). ~2 min under listed runtime.
TrailerFan trailer2m 48s. Fan trailer; title wrongly says (1994); description correctly IDs RS Film’s first theatrical feature.
OST MVTitle-song MV4m 00s. Official title-song MV (เต๋า สมชาย / RSMUSIC-X); film footage, not a theatrical trailer.
\n

Soundtrack: no Wikidata soundtrack item, MusicBrainz release, or Internet Archive audio album found (IA hosts the feature only).

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TypeLinkNotes
YouTube Musicโลกทั้งใบให้นายคนเดียว — เต๋า สมชายOfficial title-song MV (same as OST MV row). MusicBrainz has สมชาย เข็มกลัด as artist only.
StreamingApple Music — เพลงประกอบภาพยนตร์ โลกทั้งใบให้นายคนเดียวFull OST album (RS). Title track also on Deezer / other RS compilations.
\n

Cast ↔ roles (th.wikipedia):

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
ActorRole
สมชาย เข็มกลัดไม้ (elder brother; joins a car-theft gang for family money)
สุทธิดา เกษมสันต์ ณ อยุธยาป้อน (woman both brothers love)
ปราโมทย์ แสงศรเม่น (ไม้'s younger brother)
อรุณ ภาวิไลโบ้ (relative who steers ไม้ toward โต's gang)
รุจน์ รณภพพ่อ (ไม้ and เม่น's father; ill)
สุรศักดิ์ วงษ์ไทยโต (car-theft gang boss)
\n

Also billed: คณิต/สิทธิโชค อักษรนันทน์, วรนุช ศิลา, ปวันรัตน์ นาคสุริยะ, กนกวรรณ บุรานนท์, วราพรรณ หงุ่ยตระกูล, จอนนี่ อันวา, หลุยส์ สก๊อต, คงเดช จาตุรันต์รัศมี.

\n

Poster faces (photographic art used on this page):

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Poster spotWho
Standing man, white T-shirt (holding cover from rain)ไม้ (สมชาย)
Woman in white coatป้อน (สุทธิดา)
Crouching / seated manเม่น (ปราโมทย์)
\n

Sat 1 Aug — Dang Bireley's and Young Gangsters (2499 อันธพาลครองเมือง, 1997)

\n

Listed runtime ≈ 104–110 min (IMDb 1h 43m; other references up to ~110 min).

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TypeLinkNotes
FullFull (MonoGlobalTV)1h 42m 49s. English title; MonoGlobalTV; English synopsis. Matches typical ~103 min cut. Prefer this.
FullFull (Thai Comedy)1h 42m 49s. Same length (likely same encode); Thai Comedy channel; high views.
FullFull (+40s)1h 43m 28s. Another full upload (~40s longer — intro/outro or slight different master).
TrailerThai trailer2m 47s. Thai trailer; cast/director correct.
TrailerEnglish trailer2m 12s. English-commentary trailer; title year 1996 is wrong (film is 1997).
\n

Soundtrack: Wolfpack OST (7 วันที่ฉันเหงา, อย่ามาใกล้ฉัน, แค่คำว่ารัก, สิ่งสุดท้าย, อันธพาล, …). No Wikidata soundtrack item, MusicBrainz release (other “Wolfpack” bands are unrelated), Internet Archive audio, or major-store album under this Thai band.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TypeLinkNotes
YouTube MusicWolfpack OST 2499 (full LP upload)Fan long-play of the 1997 OST. Prefer individual tracks if this upload disappears: 7 วันที่ฉันเหงา, อันธพาล, แค่คำว่ารัก.
\n

Cast ↔ roles (th.wikipedia):

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
ActorRole
เจษฎาภรณ์ ผลดีแดง ไบเล่ย์ (Bireley gang leader)
อรรถพร ธีมากรเปี๊ยก วิสุทธิ์กษัตริย์ (friend / narrator's on-screen self)
นพชัย มัททวีวงศ์แหลมสิงห์
ศุภกรณ์ กิจสุวรรณปุ๊ ระเบิดขวด (rival gang)
ชาติชาย งามสรรพ์ดำ เอสโซ่
แชมเปญ เอ็กซ์วัลลภา (singer; แดง's love interest)
อภิชาติ ชูสกุลหมู่เชียร
ปาริชาต บริสุทธิ์โฉม (แดง's mother)
ปิยะ บุนนาคพล ตรอกทวาย
ธีระชัย พฤกษ์พิมานเฮียหมา
สุธากรณ์ ใจมั่นผู้ใหญ่เต๊ก
\n

Narration: รุจน์ รณภพ (as older เปี๊ยก's voice).

\n

Poster faces (photographic art used on this page):

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Poster spotWho
Large close-up, red shirt, cigaretteแดง (เจษฎาภรณ์)
Trio (mid-right)Gang mates (ปุ๊ / ดำ / แหลม or เปี๊ยก — faces hard to pin from this crop alone)
Gang walking (lower right)Bireley / rival gang street scene
","date_published":"Mon, 27 Jul 2026 20:16:28 GMT","date_modified":"Fri, 31 Jul 2026 16:47:16 GMT"},{"id":"https://mmap.page/fyi/tdff-2026/","url":"https://mmap.page/fyi/tdff-2026/","title":"Taiwan Documentary & Film Festival in Thailand 2026","content_html":"

Taiwan Documentary & Film Festival in Thailand 2026

\n

Screenings ran 22–26 July 2026 at House Samyan and Century Sukhumvit (Bangkok) and Pratudang Space (Khon Kaen). All times ICT.

\n

By film

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
PosterFilmScreenings
\"EatEat Drink Man WomanWed 22 Jul 19:00 — House Samyan (Bangkok)
Sun 26 Jul 19:15 — Century Sukhumvit (Bangkok)
\"Girl\"GirlThu 23 Jul 17:45 — House Samyan (Bangkok)
Sat 25 Jul 20:15 — Century Sukhumvit (Bangkok)
\"Kuei-Mei,Kuei-Mei, a WomanThu 23 Jul 20:05 — House Samyan (Bangkok)
Sun 26 Jul 11:00 — Century Sukhumvit (Bangkok)
\"BackBack HomeThu 23 Jul 17:30 — Century Sukhumvit (Bangkok)
Sun 26 Jul 15:35 — House Samyan (Bangkok)
\"FromFrom Clay to CloudThu 23 Jul 19:15 — Century Sukhumvit (Bangkok)
Sat 25 Jul 18:05 — House Samyan (Bangkok)
\"NewNew Taipei Documentary Film AwardFri 24 Jul 18:00 — Century Sukhumvit (Bangkok)
\"PushingPushing HandsSat 25 Jul 12:05 — House Samyan (Bangkok)
Sun 26 Jul 15:10 — Century Sukhumvit (Bangkok)
\"TheThe Wedding BanquetSat 25 Jul 14:05 — House Samyan (Bangkok)
Sun 26 Jul 17:10 — Century Sukhumvit (Bangkok)
\"TheThe Wave Will Carry UsSat 25 Jul 16:10 — House Samyan (Bangkok)
Sun 26 Jul 13:00 — Pratudang Space (Khon Kaen)
Sun 26 Jul 13:15 — Century Sukhumvit (Bangkok)
\"SPI\"SPISat 25 Jul 09:30 — Pratudang Space (Khon Kaen)
Sat 25 Jul 15:30 — Century Sukhumvit (Bangkok)
Sun 26 Jul 13:40 — House Samyan (Bangkok)
\"LALA PALOMASat 25 Jul 13:00 — Pratudang Space (Khon Kaen)
Sat 25 Jul 13:00 — Century Sukhumvit (Bangkok)
Sun 26 Jul 16:55 — House Samyan (Bangkok)
\"AA Long Way HomeSat 25 Jul 18:30 — Century Sukhumvit (Bangkok)
Sun 26 Jul 09:30 — Pratudang Space (Khon Kaen)
Sun 26 Jul 18:25 — House Samyan (Bangkok)
\n

By date

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
DateTimeFilmVenueCity
Wed 22 Jul19:00Eat Drink Man WomanHouse SamyanBangkok
Thu 23 Jul17:30Back HomeCentury SukhumvitBangkok
Thu 23 Jul17:45GirlHouse SamyanBangkok
Thu 23 Jul19:15From Clay to CloudCentury SukhumvitBangkok
Thu 23 Jul20:05Kuei-Mei, a WomanHouse SamyanBangkok
Fri 24 Jul18:00New Taipei Documentary Film AwardCentury SukhumvitBangkok
Sat 25 Jul09:30SPIPratudang SpaceKhon Kaen
Sat 25 Jul12:05Pushing HandsHouse SamyanBangkok
Sat 25 Jul13:00LA PALOMAPratudang SpaceKhon Kaen
Sat 25 Jul13:00LA PALOMACentury SukhumvitBangkok
Sat 25 Jul14:05The Wedding BanquetHouse SamyanBangkok
Sat 25 Jul15:30SPICentury SukhumvitBangkok
Sat 25 Jul16:10The Wave Will Carry UsHouse SamyanBangkok
Sat 25 Jul18:05From Clay to CloudHouse SamyanBangkok
Sat 25 Jul18:30A Long Way HomeCentury SukhumvitBangkok
Sat 25 Jul20:15GirlCentury SukhumvitBangkok
Sun 26 Jul09:30A Long Way HomePratudang SpaceKhon Kaen
Sun 26 Jul11:00Kuei-Mei, a WomanCentury SukhumvitBangkok
Sun 26 Jul13:00The Wave Will Carry UsPratudang SpaceKhon Kaen
Sun 26 Jul13:15The Wave Will Carry UsCentury SukhumvitBangkok
Sun 26 Jul13:40SPIHouse SamyanBangkok
Sun 26 Jul15:10Pushing HandsCentury SukhumvitBangkok
Sun 26 Jul15:35Back HomeHouse SamyanBangkok
Sun 26 Jul16:55LA PALOMAHouse SamyanBangkok
Sun 26 Jul17:10The Wedding BanquetCentury SukhumvitBangkok
Sun 26 Jul18:25A Long Way HomeHouse SamyanBangkok
Sun 26 Jul19:15Eat Drink Man WomanCentury SukhumvitBangkok
\n

Official listings: Facebook festival post · House Samyan · Doc Club & Pub · Pratudang Space reservations

","date_published":"Mon, 27 Jul 2026 09:00:41 GMT","date_modified":"Mon, 27 Jul 2026 09:00:41 GMT"},{"id":"https://mmap.page/uses/cursor/","url":"https://mmap.page/uses/cursor/","title":"Cursor Models","content_html":"

Cursor Models

\n

Cursor models and pricing.\nPrices are per million tokens. Speed, cost, and intelligence tiers come from the Cursor docs model metadata.\nRelease year and knowledge cutoff year come from provider documentation when Cursor does not publish them.\nCursor Cloud indicates availability in the Cloud Agent model picker on cursor.com/agents (snapshot 14 Aug 2026).

\n

CursorBench

\n

CursorBench 3.2 plots correctness against average cost per task.\nCost decreases toward the right, so the upper-right is higher score at lower cost.\nPoints from the same model family are connected Low → Medium → High → Extra High → Max, skipping missing levels.\nAn outer ring marks the Cloud Agent picker default effort preset for that family (not every configurable option in the picker).\nHover or tap a point for the model name and effort.\nNumbers are from the public leaderboard (pricing snapshot 11 Aug 2026),\nplus Grok 4.5 Low/Medium/High from an earlier 3.2 snapshot (dropped after Grok 4.6).\nGrok 4.5 has an advantage on CursorBench: an earlier snapshot of the Cursor codebase was unintentionally included in training. The exact score impact is unclear.

\n

\"CursorBench

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Model IDContext windowMax contextProviderCapabilitiesCursor CloudSpeedCostIntelligenceRelease yearKnowledge cutoff yearInputCache writeCache readOutput
claude-4-sonnet200k-AnthropicAgent, Thinking, Images-mediummediumhigh20252025$3$3.75$0.3$15
claude-4-sonnet-1m-1MAnthropicAgent, Thinking, Images-mediumhighhigh20252025$6$7.5$0.6$22.5
claude-4-5-haiku200k-AnthropicThinking, Images-fastlowmoderate20252025$1$1.25$0.1$5
claude-4-5-opus200k200kAnthropicAgent, Thinking, Images-mediumhighfrontier20252025$5$6.25$0.5$25
claude-4-5-sonnet200k1MAnthropicAgent, Thinking, Images-mediummediumhigh20252025$3$3.75$0.3$15
claude-4-6-opus200k1MAnthropicAgent, Thinking, Images-mediumhighfrontier20262025$5$6.25$0.5$25
claude-4-6-sonnet200k1MAnthropicAgent, Thinking, Images-mediummediumhigh20262025$3$3.75$0.3$15
claude-opus-4-7300k1MAnthropicAgent, Thinking, Images-mediumhighfrontier20262026$5$6.25$0.5$25
claude-fable-5300k1MAnthropicAgent, Thinking, Imagesyesmediumhighfrontier20262026$10$12.5$1$50
claude-opus-4-7-fast200k1MAnthropicAgent, Thinking, Images-fasthighfrontier20262026$30$37.5$3$150
claude-opus-4-8300k1MAnthropicAgent, Thinking, Images-mediumhighfrontier20262026$5$6.25$0.5$25
claude-opus-4-8-fast300k1MAnthropicAgent, Thinking, Images-fasthighfrontier20262026$10$12.5$1$50
claude-opus-5300k1MAnthropicAgent, Thinking, Imagesyesmediumhighfrontier20262026$5$6.25$0.5$25
claude-opus-5-fast300k1MAnthropicAgent, Thinking, Images-fasthighfrontier20262026$10$12.5$1$50
claude-sonnet-5200k1MAnthropicAgent, Thinking, Imagesyesmediummediumfrontier20262026$2$2.5$0.2$10
composer-1200k-CursorAgent, Images-mediummediumhigh2025-$1.25-$0.125$10
composer-2.5200k-CursorAgent, Thinking, Imagesyesfastlowfrontier2026-$0.5-$0.2$2.5
composer-2.5-fast200k-CursorAgent, Thinking, Imagesyesfasthighfrontier2026-$3-$0.5$15
gemini-2.5-flash200k1MGoogleAgent, Thinking, Images-fastlowmoderate20252025$0.3-$0.03$2.5
gemini-3-flash200k1MGoogleAgent, Thinking, Images-fastlowmoderate20252025$0.5-$0.05$3
gemini-3-pro200k1MGoogleAgent, Thinking, Images-mediummediumhigh20252025$2-$0.2$12
gemini-3-pro-image-preview200k1MGoogleImages-mediummediumhigh20252025$2-$0.2$12
gemini-3.1-pro200k1MGoogleAgent, Thinking, Images-mediummediumfrontier20262025$2-$0.2$12
gemini-3.5-flash200k1MGoogleAgent, Thinking, Images-fastlowhigh20262025$1.5-$0.15$9
gemini-3.6-flash200k1MGoogleAgent, Thinking, Images-fastlowhigh20262026$1.5-$0.15$7.5
gemini-3.7-flash200k1MGoogleAgent, Thinking, Imagesyesfastlowhigh20262026$0.75-$0.075$3.5
glm-5.2200k-Z.aiAgent, Thinking-mediumlowhigh2026-$1.4-$0.26$4.4
gpt-5.1272k-OpenAIAgent, Thinking, Images-mediummediumhigh20252024$1.25-$0.125$10
gpt-5-fast272k-OpenAIAgent, Thinking, Images-fasthighhigh20252024$2.5-$0.25$20
gpt-5-mini272k-OpenAIAgent, Thinking, Images-fastlowmoderate20252024$0.25-$0.025$2
gpt-5-codex272k-OpenAIAgent, Thinking, Images-mediummediumhigh20252024$1.25-$0.125$10
gpt-5.1-codex272k-OpenAIAgent, Thinking, Images-mediummediumhigh20252024$1.25-$0.125$10
gpt-5.1-codex-max272k-OpenAIAgent, Thinking, Images-mediummediumhigh20252024$1.25-$0.125$10
gpt-5.1-codex-mini272k-OpenAIAgent, Thinking, Images-fastlowmoderate20252024$0.25-$0.025$2
gpt-5.2272k-OpenAIAgent, Thinking, Images-mediummediumhigh20252025$1.75-$0.175$14
gpt-5.2-codex272k-OpenAIAgent, Thinking, Images-mediummediumhigh20252025$1.75-$0.175$14
gpt-5.3-codex272k-OpenAIAgent, Thinking, Images-mediummediumfrontier20262025$1.75-$0.175$14
gpt-5.4272k1MOpenAIAgent, Thinking, Images-mediummediumfrontier20262025$2.5-$0.25$15
gpt-5.4-fast272k1MOpenAIAgent, Thinking, Images-fasthighfrontier20262025$5-$0.5$30
gpt-5.4-mini272k-OpenAIAgent, Thinking, Images-fastlowhigh20262025$0.75-$0.075$4.5
gpt-5.4-nano272k-OpenAIAgent, Thinking, Images-fastlowmoderate20262025$0.2-$0.02$1.25
gpt-5.5272k1MOpenAIAgent, Thinking, Images-mediummediumfrontier20262025$5-$0.5$30
gpt-5.5-fast272k1MOpenAIAgent, Thinking, Images-fasthighfrontier20262025$12.5-$1.25$75
gpt-5.6-luna272k-OpenAIAgent, Thinking, Images-fastlowmoderate20262026$0.2$0.25$0.02$1.2
gpt-5.6-luna-fast272k-OpenAIAgent, Thinking, Images-fastlowmoderate20262026$0.4$0.5$0.04$2.4
gpt-5.6-sol272k1MOpenAIAgent, Thinking, Imagesyesmediummediumfrontier20262026$5$6.25$0.5$30
gpt-5.6-sol-fast272k1MOpenAIAgent, Thinking, Images-fasthighfrontier20262026$10$12.5$1$60
gpt-5.6-terra272k-OpenAIAgent, Thinking, Imagesyesfastmediumhigh20262026$2$2.5$0.2$12
gpt-5.6-terra-fast272k-OpenAIAgent, Thinking, Images-fasthighhigh20262026$4$5$0.4$24
grok-4.5256k-CursorAgent, Thinkingyesmediummediumfrontier20262026$2-$0.5$6
grok-4.5-fast256k-CursorAgent, Thinkingyesfasthighfrontier20262026$4-$1$12
grok-4.6256k-CursorAgent, Thinkingyesmediummediumfrontier20262026$2-$0.5$6
grok-4.6-fast256k-CursorAgent, Thinkingyesfasthighfrontier20262026$4-$1$12
kimi-k2.7-code262k-MoonshotAgent, Thinking, Images-mediumlowhigh2026-$0.95-$0.19$4
kimi-k3200k1MMoonshotAgent, Thinking, Images-mediummediumhigh2026-$3-$0.3$15
","date_published":"Thu, 16 Jul 2026 14:38:40 GMT","date_modified":"Thu, 20 Aug 2026 04:58:09 GMT"},{"id":"https://mmap.page/AGENTS/","url":"https://mmap.page/AGENTS/","title":"Agent instructions","content_html":"

Agent instructions

\n

Keep this file short: many agents inject it into the system prompt. Details that are only needed for some tasks live under .agents/ — read them on demand.

\n

Style

\n\n

Code quality

\n\n

Commands

\n\n

Skills

\n

Under .agents/skills/<name>/SKILL.md. When a task matches a skill description, read and follow that SKILL.md. Before any commit, read .agents/skills/git-commits/SKILL.md even if the user did not mention commits.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
SkillPath
Git commits and trailers.agents/skills/git-commits/SKILL.md
Review one commit.agents/skills/review/SKILL.md
Generate movies/netflix.csv.agents/skills/generate-netflix-csv/SKILL.md
\n

Git (multi-agent cwd)

\n

Other agents may be editing different files here. Never touch their unstaged/staged/untracked files.

\n","date_published":"Wed, 15 Jul 2026 07:24:05 GMT","date_modified":"Thu, 13 Aug 2026 23:38:22 GMT"},{"id":"https://mmap.page/log/comments/","url":"https://mmap.page/log/comments/","title":"Conversation on the first koan of “Kotlin Koans”","content_html":"

Conversation on the first koan of “Kotlin Koans”

\n

Source: https://github.com/weakish/weakish.github.com/issues/10

\n

(I find no elsewhere to comment, so I click the link for the feedback and redirected here. Correct me if it is the wrong place.)

\n

First of all, I am not a fan of Kotlin. But I think it actually introduced some good things.

\n

Technically, the following \"familiar\" code is effective more complex:

\n
fun start(): String {\n  return \"OK\"\n}\n
\n

It introduces a block scope and a keyword return for local control (which makes the control jump to the end of the function body). Both are unnecessary and redundant at this point, even considered harmful.

\n

This is bad because in fact both block scopes and keywords like return are quite complicated monsters in semantics.

\n

Canonically, a block with lexical scoping is the rewrite of a lambda abstraction (i.e. a function in most languages) with an immediate call to that abstraction. This is quite heavy and certainlly a mental burden where the local scoping is irrelevant. Note the rewrite is adopted in many functional languages (both impure ones like Scheme and pure ones like ML).

\n

OTOH, return, as a simplified (restricted) version of P. Landin's J operator, is a control operator. This is also quite heavy and unnecessary here.

\n

Sadly, the restricted designs have been built-in in many languages decades ago, esp. ALGOL-like ones (C, Pascal, Java, JavaScript, ...). Abuse of them have already caused many indirect but real damages to industrial programmers who learned programming with a traditional ALGOL-like language:

\n\n

I don't think Kotlin has done much right in its design. But at the very beginning, it provides a better choice here.

\n

— FrankHB, Dec 3, 2020

\n
\n

Oh, I took block scope and return statement for granted. It turns out { return \"OK\" } is not that simple as it looks like. Also thanks for mentioning J operator (never though how to express return in lambda abstractions before).

\n

However, from a beginner's point of view, { return \"OK\" } may be understood as this:

\n
    \n
  1. {} groups some statements/expressions (unaware of the concept \"scope\" or even the difference between statement and expression yet)
  2. \n
  3. return marks the exit point (returned result/value) of the function
  4. \n
\n

These vague understandings are sufficient for them to continue learning.

\n

— weakish, Dec 9, 2020

\n
\n

There can be easy understanding at the first glance, but not that easy when thought twice.

\n
    \n
  1. Each kind of braces ({}, [], (), ...) can group syntactic elements in general. {} groups statements in ALGOL-like languages, precisely. But why the grouping should be explicit when there is only one element? And why it is {}, rather than other kinds of braces?
  2. \n
  3. The key point is that \"the exit point\" itself sounds redundant if there is no need to do something peculiar on it (like to capture the context, to intercept the control, to do some inter-procedural static analysis, etc.). And a curious learner may naturally ask where the function returns to. It is subtly a headache to make the notion of the \"caller\" clear and correct for real beginners who have absolutely no knowledge of the implementation details. (Yes, even the concept of \"control\" falls into the unnecessary details here; it sounds not much different to \"continuation\" in this context.)
  4. \n
\n

Personally I feel the mandatory of such syntactic styles often unreasonable. No one can easily clarify the necessity of the syntactic rules, because there is just no overall reasons for \"why I should code like this\" besides \"many other languages also work like this\" and \"I'm not the father of that language!\" This will not be a big deal for most people since the reasons can be easily ignored. But anyway, preventing beginners to ask such questions is quite a bad practice of teaching. I think something has gone wrong in the very beginning.

\n

Even if the learner is not a real beginner of programming, more succinct styles can still make benefits. Senior programmers can ask themselves \"why we need the feature here\" to start thoughts on something interesting behind the tutorial. The first question can be \"why we need a statement at all\"?

\n

— FrankHB, Dec 15, 2020

","date_published":"Mon, 04 May 2026 16:23:42 GMT","date_modified":"Mon, 04 May 2026 16:23:42 GMT"},{"id":"https://mmap.page/lang/shath-yar/","url":"https://mmap.page/lang/shath-yar/","title":"Shath'Yar","content_html":"

Shath'Yar

\n

Grammar

\n

All example sentences in this section use official translations.

\n

Compound Words

\n

One function of the apostrophe (') is to form compound words.\nFor example, the compound word shath'yar, referring to \"old gods\" or the language used by the old gods, is composed of shath (old) and yar (god).

\n

Case System

\n

Nominative, accusative, and possessive cases:

\n\n

Similar to English, the nominative and accusative cases of the second person pronoun have the same form:

\n\n

When the compound word consist of a possessive pronoun and a noun is used as an object, the apostrophe is omitted:

\n\n

Verbal System

\n

ma means \"are\" or \"do,\" with negative form maq:

\n\n

However, maq is not used with first person pronoun.\nUse noq instead:

\n\n

It is unknown if ma is used with first person pronoun.\nMaybe no is instead of ma based on the corresponding pair of ma and maq, but nothing is found in the corpus to support this guess.

\n

The future tense of ma is qi:

\n\n

Let's analyze this sentence.\nFirst, mark all known words:

\n

Iilth (you) qi (will) mah'shar fhn oorql (glimpse) N'Zoth!

\n

Part of the word mah'shar is known, mah means first.\nAlso, shg'fhn is known, meaning \"outside (the) cycle\".\nI guess shg means outside, and fhn means cycle.\nNow considering mah'shar fhn corresponds to \"(the) first of many\",\nthen I guess shar means inside or within.\nTherefore, mah'shar means \"first within\", and mah'shar fhn means \"first within (the) cycle\" (first of many).\nAs for the madness, I guess a glimpse of an old god such as N'Zoth implies madness.

\n

Also, qi can be used as a prefix to denote future tense of verbs:

\n\n

The sentence \"Ilith qi'uothk shn'ma yeh'glu Shath'Yar!\" needs some analysis.\nAs usual, mark all know words:

\n

Ilith (you) qi'uothk (drown) shn'ma yeh'glu (blood) Shath'Yar (Old Gods)!

\n

So the only unknown word is shn'ma, corresponding to \"in\" in the translation.\nConsidering the word shn is appeared in the following sentence:\nYoq'al (perpetuity) shn (in) ky (which) ywaq (they) nuul (dwell).\nI guess shn'ma is similar to shn,\nperhaps shn is used with abstract things.

\n

A similar word to qi is gag:

\n\n

I doubt that the difference between qi and gag is that gag is more emotional, often used in curses.

\n

And there is a noun ga which is translated as \"will\" (noun):

\n\n

I think here the will of N'Zoth is like a curse.

\n

What's more, agth means shall:

\n\n

The second example sentence literally translates to: You fall, many shall take place.

\n

The word sythn indicates progressive tense:

\n\n

In the second example, Y'za sythn oou literally translates to \"I am dying\".\nThe undead constantly decay, and constantly approaching death,\nwhich can be considered undying or dying.

\n

An- Prefix

\n

The prefix can be used with nouns, meaning \"into\":

\n\n

Vocabulary

\n
tense\n\nShu = A prefix denoting past tense;\nSythn = A prefix denoting progressive tense;\nQi = A prefix denoting future tense;\nAgth = Denoting future tense for plural and uncountable nouns;\nGag = Exact equivalent of English word \"Will\";\nMaq = Negative prefix for personal pronouns;\nNoq = Negative prefix;\n\nconj.\n\nZz = And;\nIir = Or;\nXig = (Suffix)How;\n\nprep.\n\nAn = Into;\nCul = (Suffix)On;\nKsh = Atop;\nQwor = Above;\nShg = Beyond;\nShn = In;\nThoq = For;\nUulg = After;\n\npron.\n\nY = My;\nHoq = Me;\nAg = We;\nAk = Our;\nIilth = You;\nIlfah = (Objective)You;\nSk = Your;\nOn = It;\nYwaq = They;\nKy = Which;\n\nv.\n\nAmqa = Come;\nEqnizz = Drive;\nErh = Choke;\nEt = Rule;\nFssh = Replace; Glorify;\nGuulphg = Sustain;\nGul'kafh = Gaze;\nHuqth = Sate;\nIggksh = Oppose;\nKyth = See;\nLwhuk = Devour;\nMagg = Wander; Suffer;\nNuq = Adorn;\nNuul = Dwell;\nOorql = Glimpse;\nOou = Die;\nPhgwa = Whisper;\nPlahf = Know;\nQam = Return;\nSshk = (auxil.v.)Do; (=Sshoq?);\nSshoq = Twist;\nThyzak = Reclaim;\nUothk = Drown;\nVorzz = Sing; Sing of;\nVwah = Fall;\nYawifk = Strengthen;\nWorg = Fade;\nZaix = Praise;\nZyqtahg = Corrupt;\n\nadj.\n\nAnagg = Endless;\nAqev = Mad;\nEth = Light;\nH'iwn = All;\nIiqaath = Curse;\nKssh = Bleakest;\nMah = First;\nMh = Only;\nMg = Writhing;\nNaggwa = Unending;\nOrmz = Last;\nQor = Endless;\nShath = (adj. form of Shel?); Black; Old;\nSshoq = Twisted;\nSyq = Real;\nUhnish = (adj.)Many; Endless;\nVwyq = (adv.)Once; Once more;\nW'ssh = (=W'ssht)Eternal; (adv.)Eternally;\nW'ssht = (=W'ssh)Eternal; (adv.)Eternally;\nWoth'gl = Faithful;\nYe = (adv.)Again;\n\nn.\n\nAgash = Despair;\nAgthshi = Number;\nAgthu = World;\nAwan = Illusion;\nFhn = Cycle; Many of the cycle;\nFssh = Glory;\nGaz = (=Yu'gaz)Servant;\nHalahs = Body; Corpse;\nHnakf = Wind; Shivering Wind;\nIiyoq = Will;\nKaaxth = Thousand;\nLuk = Road;\nMa = Millennia;\nMag = Empire;\nMagg = Suffering; Torment;\nMah = The first;\nMaqdahl = Sorrow;\nMeg = Banner; Flesh-banner;\nNaus = Hunger;\nOkom = Run through; Run;\nOngg = Earth; Land;\nOr = Hundred;\nOrmz = The last;\nPaf = Prisoner;\nPaf'qi'ag = One who will be our prisoner;\nPahg = Kingdom;\nPhquati = Destroyer;\nPuul = Drink;\nQen = Spiral;\nQornaus = Endless hunger;\nQov = Heart;\nRazzqi = Light;\nShath'mag = The Black Empire;\nShath'Yar = Old Gods;\nShath'yar = Language of Old Gods;\nShel = Void;\nShgla'yos = They who dine on lost souls; Yogg-Saron;\nShgn = Fear;\nShfk = Howl;\nShuul = Death;\nSsaggh = Live;\nTek = Skull;\nUq = Power;\nUull = (=Uulwi)Shadow; Darkness;\nUulwi = (=Uull)Shadow;\nUuyat = Agony;\nVra = Chitter;\nVwahuhn = Reckoning; (Vwah + Uhn)Many fallens; Too many;\nWah = Wing;\nYahf = Soul;\nYar = God;\nYeh'glu = Blood;\nYel = Citadel;\nYoq'al = Perpetuity;\nYu'gaz = (=Gaz)Servant;\nYyqzz = Throne;\nZa = Place;\nZig = Depth; Deeps;\nZuq = Life;\nZzof = Victory;\n
\n

The above vocabulary list,\nadapted from the Old God Language Writing Incomplete Guide·Revised Second Edition by Ningyou.\nis for reference only.\nI have different interpretations of some words.\nAlso, some words are missing in the vocabulary list.\nFor example, Ez means O or Oh.

\n

Corpus

\n

See WOWPedia

\n

Quiz

\n

Translate the following sentences.

\n

Q1:

\n
\n

Hello world!

\n
\n

Q2:

\n
\n

See you soon.

\n
\n

Q3:

\n
\n

Light of my life, fire of my loins. My sin, my soul.

\n

-- Vladimir Nabokov, Lolita

\n
\n

Q4:

\n
\n

May the force be with you.

\n

-- Star Wars

\n
\n

Answers

\n

A1

\n
\n

Ez, agthu!

\n
\n

A2

\n

Since the word for \"soon\" is unknown, translate it as \"see you again\":

\n
\n

Kyth ilfah ye.

\n
\n

A3

\n

The following vocabulary are unknown: fire, loin, and sin.\nUse words close in meaning instead: fssh (glory), qornaus (endless hunger), uull(darkness).

\n
\n

Razzqi ifis zuq, fssh ifis qornaus. Ifis uull. Ifis yahf.

\n
\n

The alliteration of the original text is not preserved.

\n

A4

\n

Similarly, work around with unknown vocabulary.

\n
\n

Uq agth eqnizz ilfah.

\n
\n

This literally translates to \"Power shall drive you.\"\nThe closest translation I can think of.

","date_published":"Tue, 29 Jul 2025 16:29:07 GMT","date_modified":"Tue, 29 Jul 2025 16:57:34 GMT"},{"id":"https://mmap.page/lang/redman/","url":"https://mmap.page/lang/redman/","title":"Red Northern Barbarians","content_html":"

Red Northern Barbarians

\n

Red Northern Barbarians (赤狄) is a term seen in the Spring and Autumn Annals1 referring to tribes lived in the Inner Asia.\nHowever, Hirose Tanso (広瀬 淡窓) in late Edo Period used \"Red Northern Barbarians\" and \"Red People\" (赤人) in his poem 2 referring to Russians. 3

\n

Footnotes

\n
    \n
  1. \n

    In the third year of Duke Sen of Ro, Red Northern Barbarians invaded Sei. 《左傳》宣《經》三年「秋,赤狄侵齊。」 ↩

    \n
  2. \n
  3. \n

    《送人遊宦長崎》「赤狄情難測(近來赤人申請互市),紅夷信未傳(蘭舩久不至)。」(《遠思楼詩鈔》卷上葉七) ↩

    \n
  4. \n
  5. \n

    Okamura Shigeru (岡村 繁) noted this refers to the Russian ambassador Nikolai Rezanov visted Nagasaki Bay with the aim of conducting a commercial treaty. 岡村繁注謂「赤狄」一句言俄羅斯使萊薩諾夫申請互市之事。(岡村繁著、俞慰慈譯《江戶漢詩選注》,見岡村繁全集第八卷《毛詩正義注疏選箋(外二種)》第526-527頁,上海:上海古籍出版社2009年6月,ISBN 978-7-5325-5110-1) ↩

    \n
  6. \n
\n
","date_published":"Mon, 28 Jul 2025 02:36:14 GMT","date_modified":"Mon, 28 Jul 2025 02:36:14 GMT"},{"id":"https://mmap.page/lang/rice-and-grain/","url":"https://mmap.page/lang/rice-and-grain/","title":"Translation of Two Similar Terms for Making Ends Meet in Literary Chinese","content_html":"

Translation of Two Similar Terms for Making Ends Meet in Literary Chinese

\n

When translating Literary Chinese to English, both 稻粱謀 and 餬口 can be translated to \"making ends meet\".\nHowever, there are more accurate translations.

\n

粱 refers to the finest quality millet and 稻 (rice) was mainly produced in the Yangtze River basin thus hard to obtain in the Yellow River basin in the ancient times.\n稻粱謀, literally means \"seeking rare and high quality food\", can be translated to \"pursue a decent life\".

\n

On the other hand, 餬口 literally means \"to feed one's mouth with gruel\", can be translated to \"eke out a livelihood\".

\n

「稻粱謀」異乎「餬口」

\n

粱謂粟之精良者,北地產稻稀少,二者皆不易得,故古人往往以稻粱連稱。是「稻粱謀」異乎「餬口」也。今粱、稻皆易得,則時移世易矣!

","date_published":"Sat, 26 Jul 2025 18:12:41 GMT","date_modified":"Sat, 26 Jul 2025 18:12:41 GMT"},{"id":"https://mmap.page/thoughts/learn-programming/","url":"https://mmap.page/thoughts/learn-programming/","title":"Programming Learning Path","content_html":"

Programming Learning Path

\n

Path One

\n

First, learn English to the level of A2 or B1.\nAfter that, through extensive reading of English materials, computing-related vocabulary will naturally accumulate.\nNo need to deliberately memorize them in advance.

\n

Sharpening the axe doesn't delay chopping wood.\nHowever, if you feel your enthusiasm for learning programming is being worn away during the \"sharpening\" process,\nyou can set learning English aside for now and go directly to learn programming.\nPath is not as important as motivation and interest.

\n

Next, read an introductory book.

\n

Which one to choose?\nAt this stage you basically know nothing about programming, so how do you judge whether a book is good or bad?

\n

Look at the thickness of the book.

\n

This superficial judgment method is surprisingly useful.\nIf an introductory book is not thin enough:

\n
    \n
  1. Either the book introduces too many details - introductory books should introduce the essence of the field, to prevent beginners from getting lost in details;
  2. \n
  3. Or the book includes content that's too advanced for an introductory book;
  4. \n
  5. Or the book treats readers as idiots, doesn't trust readers' abilities - many books give you screenshots for every step, making the book look very thick but actually saying nothing substantial;
  6. \n
  7. Or the author just randomly cobbled together a book without knowing what they're doing.
  8. \n
\n

I recommend The Little Schemer.\nIf this book is hard to find, or if you feel it doesn't suit your taste, you can pick up another introductory book.\nJust remember to pick up a thin one.

\n

Path Two

\n

Don't learn English, directly read the translation of The Little Schemer.\nIf no good translation in your native language is available, you can use ChatGPT.\nOr another introductory book in your native language.

\n

Path Three

\n

Create your own path.

\n

You often understand yourself better than others do, so the path you create for yourself might be more suitable than paths recommended by others.\nDon't be afraid to explore.\nAs long as you maintain motivation and interest, you'll always find a way through - at worst you'll take some detours.\nEven if taking detours slows your progress a bit, being able to blaze your own unique trail will give you confidence.\nThe experience of independently exploring in darkness will also give you some intuitions which may help you in the future.

\n

Few people have the fortune or misfortune to follow others' paths forever.\nSomeday you may go to a place where no one has explored before.\nAt that time, the confidence and intuitions from your own experience will become your aid.

\n

Originally written in Chinese by weakish, then translated into English by GPT-4.1, and edited by weakish.

","date_published":"Sat, 26 Jul 2025 17:24:50 GMT","date_modified":"Sat, 26 Jul 2025 17:24:50 GMT"},{"id":"https://mmap.page/uses/windows/","url":"https://mmap.page/uses/windows/","title":"Windows User Manual","content_html":"

Windows User Manual

\n

Software

\n\n

Docker

\n

Given the licensing issues with Docker Desktop For Windows, I installed Docker directly in Debian within WSL2.\nThe Debian environment in WSL2 differs from standard Debian (for example, no systemd), so Docker doesn't work out of the box and requires some additional configuration. See the instructions here.

\n

Accessing Clipboard from Command Line

\n

In WSL 2, you can use powershell.exe Get-Clipboard and clip.exe to read and write clipboard contents:

\n
powershell.exe Get-Clipboard | cut -d ',' -f1 | clip.exe\n
","date_published":"Sat, 26 Jul 2025 16:52:17 GMT","date_modified":"Sat, 26 Jul 2025 16:52:17 GMT"},{"id":"https://mmap.page/thoughts/hakuraku/","url":"https://mmap.page/thoughts/hakuraku/","title":"Following the Map to Find a Horse","content_html":"

Following the Map to Find a Horse

\n

People say, \"Only when there is Hakuraku1 in the world can there be chollima2,\" which suggests that \"chollima\" is Hakuraku's invention.\nIf horses had consciousness, they would probably despise the concept of chollima.\nThe fortunate horses gallop freely in the wilderness, expressing their true nature; the unfortunate ones, though confined to stables, at least preserve their lives.\nHowever, the \"chollima\" favored by Hakuraku must follow generals on campaigns, facing constant dangers and extraordinary hardships.\nWhen they finally die, if their rider has some conscience and plans a grand burial, he might even be dissuaded:
\n\"The sage Confucius did not concern himself with horses.\nIf you, my lord, lavishly bury a horse, it will dishearten the people3 who follow you.\nBetter to cut it into small pieces and distribute the meat to everyone—let the iron pot serve as the coffin and stomachs as graves.
\nThis is the proper funeral for a horse.\"

\n

Therefore, \"Hakuraku is not always present\" is truly a stroke of luck.\nIf Hakuraku were always around, who knows how many more \"chollima\" would die unnatural deaths?\nJust as the Literary Chinese idiom \"懷才不遇\" (having talent but not having an opportunity) also describes a stroke of luck.\nWealth comes after talents,\nas in Literary Chinese the kanji \"才\" (talent) can be used as the kanji \"財\" (wealth), so the Literary Chinese idiom \"懷才不遇\" (having talent but not having an opportunity)\ncan be interpreted as \"懷財不遇(盜)\" (having wealth but not having an opportunity to be robbed).\nIf someone carries a fortune and walks alone in the dark of night without meeting robbers or thieves, that is indeed fortunate.

\n

If one is incompetent, they are even more lucky.\nIf a horse is incompetent, even when Hakuraku approaches, it need not fear.\nIt's like a poor person walking at night—those who would rob for wealth have nothing to target.4

\n

In the 7th volume of Planting Seeds in Forests and Cultivating Virgin Soil in Mountains,5 there is a story about \"following the map to find a horse\":

\n
\n

Hakuraku's Manual of Horse Evaluation contains the phrase \"a high forehead, a pair of big and round eyes,6 big and regular hooves.\"\nHis son went to search for horses based on the Manual.\nWhen he saw a large toad, he told his father: \"I found a horse that closely matches the description, except the hooves are a bit irregular.\"\nKnowing his son's foolishness, Hakuraku turned his anger into laughter and said: \"This horse is too good at jumping to ride on.\"

\n
\n

Hakuraku's son, following his father's Manual, found a toad.\nI prefer to believe this was his way of expressing to Hakuraku that he refused to evaluate horses.\nHaving spent his life evaluating horses, Hakuraku's son probably grew up in the company of horses.\nAs a child, he might not have understood what \"thousand-li ability\" meant.\nWhat the child saw were one adorable horse after another, one horse after another that was kept for a while and then sent away, and one horse after another that perished on battlefields and buried in human bellies.\nNaturally, he could not approve of what Hakuraku has done and certainly did not wish to evaluate horses himself.\nSo he found a toad instead.\nThis was Hakuraku's son's foolishness.\nHakuraku had once recommended another famous horse tamer Nonapath7 to Duke of Cin 8, showing that he was also skilled at evaluating people, so he understood his son's intention.\nThat's why he \"turned his anger into laughter.\"\nFirst came anger, then helpless, bitter laughter.\n\"This horse is too good to ride on\" was his metaphor showing that he understood his son's meaning—horses are by nature unruly and out of human control.

\n

English translation by GPT-4.1 and proofread by Gemini 2.5 Pro and weakish.

\n

按圖索驥

\n

人道「世有伯樂,然後有千里馬」,可見「千里馬」是伯樂的發明。\n「千里」云云,馬若有知,恐不以爲然。\n馬之幸者,馳騁於曠野,盡其天性;不幸者,雖處槽櫪之間,猶得全生。\n然而被伯樂相中的「千里馬」,卻是隨將帥四處出征,危機四伏,艱險異常。\n最後死了,主人有點良心,打算厚葬,說不定還會遭到謀士的勸阻:

\n
\n

「孔聖人不問馬,主公您厚葬馬,會讓跟隨您的士人寒心呀。\n不如割成小塊,分給大家吃了,鐵鍋作棺槨,腸胃爲墓地,這纔是馬該有的葬禮呀。」

\n
\n

所以「伯樂不常有」,實在是幸事。\n倘若伯樂常有,不知又會有多少「千里馬」死於非命。
\n就像「懷才不遇」也是幸事。\n「才」通「財」,「懷才不遇」,便是「懷財不遇盜」。\n若是一人攜帶巨款暗夜獨行,沒碰上強盜小偷,那實在是幸事。

\n

若是無能,那就更幸運。馬若無能,伯樂走到跟前,也不懼。\n好比窮醜之婦夜行,劫財劫色者皆無從下手。

\n

明楊慎《藝林伐山》卷七裏有一個「按圖索驥」的故事:

\n
\n

伯樂《相馬經》有「隆顙蛈日,蹄如累麴」之語,其子執《馬經》以求馬,\n出見大蟾蜍,謂其父曰:「得一馬,略與相同;但蹄不如累麴爾。」\n伯樂知其子之愚,但轉怒為笑曰:「此馬好跳,不堪御也。」

\n
\n

伯樂的兒子根據老爸的《馬經》,找到了一枚癩蛤蟆。\n我願意相信,這其實是在向伯樂表態自己不相馬。\n伯樂一生相馬,伯樂之子小時候大抵是與馬爲伴,千里之能什麼的,小孩未必明白。\n小孩眼裏看到的,是一匹又一匹可愛的馬兒,是一匹又一匹養了一段時間就被送走的馬兒,是一匹又一匹喪生沙場、葬於人腹的馬兒。

\n

因此自然無法認同伯樂的行爲,自己當然更不願相馬。所以便找了一個癩蛤蟆。\n這是伯樂之子的愚處。伯樂曾經推薦九方皋給秦穆公,可見他也善相人,自然明白了其子的意圖,\n所以說是「伯樂知其子之愚,但轉怒為笑」。起初是怒,後來是無奈苦笑。\n「此馬好跳,不堪御也。」便是表明自己心知其子之意,癩蛤蟆是個隱喻——馬性跳脫,不堪爲人所御。

\n

Footnotes

\n
    \n
  1. \n

    Hakuraku is the on'yomi (the approximated pronunciations, using Japanese consonants and vowels, of kanji) of 伯樂, a famous horse tamer for the Duke of Cin. His name can also be romanized as Po-le, Po Lo, or Bo Le. ↩

    \n
  2. \n
  3. \n

    A chollima is a Sino-Korean word 千里馬 which literally means \"horse of the thousand-mile\", refers to a fine steed. ↩

    \n
  4. \n
  5. \n

    The original text 士 (shi) refers to a special class in the Spring and Autumn period. The English translation simplies this to \"people\" so the reader does not need to understand the role of this class, which is irrelevant to the main idea of this essay. ↩

    \n
  6. \n
  7. \n

    The original text \"窮醜之婦夜行,劫財劫色者皆無從下手\" literally means an ugly and poor woman walking at night will not be targeted by robbers or rapists. But rape is sexual violence not necessarily targeting women and associated with sexual attraction. Therefore the translation made some adjustments. ↩

    \n
  8. \n
  9. \n

    \"Planting Seeds in Forests\" and \"Cultivating Virgin Soil in Mountains\" are literal translation of \"藝林\" and \"伐山\". And in Literary Chinese, both \"藝林\" and \"伐山\" are often used as metaphors. \"藝林\" refers to libraries with a huge collection of classical books where knowledgable people gather, and \"伐山\" refers to uncommon classical allusions. Therefore, the title 藝林伐山, a book composed by Youshin (楊慎), refers to uncommon allusions or stories in the classical literature. ↩

    \n
  10. \n
  11. \n

    The original text 蛈日 is cited from current revision of the book 藝林伐山, where 蛈 (a kanji used in the word 蛈蜴, a species of spider) is probably a typo of a similar kanji 蚨 (refers to copper coins), and 日(sun) is probably a typo of a similar kanji 目 (eye). 蚨目 literally means eyes like copper coins (big and round). ↩

    \n
  12. \n
  13. \n

    The famous horse tamper's name is 九方皋 or 九方湮. To avoid confusion, the English translation refers to him with his surname 九方. Nonapath is a word constructed by me (weakish) to translate the surname 九方, inspired by the translation of 八方 to Octopath for the game Octopath Traveler (八方旅人). ↩

    \n
  14. \n
  15. \n

    I chose to translate 秦穆公 as Duke of Cin, since 穆 is his posthumous name and I think omitting it does not change the meaning of the text. ↩

    \n
  16. \n
\n
","date_published":"Sat, 26 Jul 2025 05:04:12 GMT","date_modified":"Sat, 26 Jul 2025 05:04:12 GMT"},{"id":"https://mmap.page/coding-style/html/","url":"https://mmap.page/coding-style/html/","title":"Less HTML","content_html":"

Less HTML

\n

HTML is a Text Markup Language

\n

HTML stands for HyperText Markup Language.\nAs the name suggests, HTML is used to mark up text, not to describe user interfaces.\nAlthough it has been extended over time, it still doesn't excel at expressing user interfaces due to compatibility with its original design.

\n

Of course, JavaScript was originally intended to decorate pages, for creating some sparkly little widgets.\nBut regardless, JavaScript is still a general-purpose programming language, and JavaScript updates at a much faster pace than HTML.\nSo when choosing between two evils, we'd rather write JavaScript than HTML.

\n

In fact, frameworks that use pure HTML are not common.\nBecause HTML is too unwieldy, frameworks that use HTML usually need to add some extras,\nsuch as *ng (Angular) and v- (Vue) attributes, or JSX (React).\nOtherwise, they create a template language similar to HTML.

\n

Actually, this patching approach is not as straightforward as directly writing JavaScript.

\n

The Kotlin and Ceylon Approach

\n

Some newer languages directly use native structures to express HTML.

\n

For example, in Kotlin, HTML is written like this:

\n
fun result(args: Array<String>) =\n    html {\n        head {\n            title {+\"XML encoding with Kotlin\"}\n        }\n        body {\n            h1 {+\"XML encoding with Kotlin\"}\n            a(href = \"http://kotlinlang.org\") {+\"Kotlin\"}\n            p {\n                for (arg in args)\n                    +arg\n            }\n        }\n    }\n
\n

This is not some template language. This is Kotlin, native Kotlin.

\n

Kotlin provides this syntactic sugar:

\n
f({ \"an anonymous function\" })\n
\n

can be written as

\n
f { \"an anonymous function\" }\n
\n

So html { ... } is a Kotlin function call,\nand the other HTML elements inside {} work the same way.

\n

The html function is defined roughly like this:

\n
fun html(init: HTML.() -> Unit): HTML {\n    val html = HTML()\n    html.init()\n    return html\n}\n
\n

Essentially, it initializes an HTML instance.

\n

The corresponding HTML class definition:

\n
class HTML : TagWithText(\"html\") {\n    fun head(init: Head.() -> Unit) = initTag(Head(), init)\n    fun body(init: Body.() -> Unit) = initTag(Body(), init)\n}\n
\n

Using native Kotlin language to express HTML means we can use all of Kotlin's native language features,\nand no longer need to worry about the limited expressiveness or strange syntax of HTML template languages.\nAt the same time, this naturally ensures type safety for HTML templates.

\n

Similarly, in Ceylon, HTML is written like this:

\n
Html {\n    doctype = html5;\n    Head {\n        title = \"Ceylon: home page\";\n    };\n    Body {\n        H1 { \"Hello `` req.queryParameter(\"name\") else \"World\" `` !\" }\n    };\n}\n
\n

This uses Ceylon's syntactic sugar for named parameters, equivalent to:

\n
Html(doctype = html5, Head(...), Body(...))\n
\n

Html is a class provided by the standard library, Html { ... } is initialization,\n(Ceylon directly constructs class instances through C(), no need for new)\nThis is also native Ceylon.\nThe approach is similar to Kotlin's.

","date_published":"Fri, 25 Jul 2025 16:41:35 GMT","date_modified":"Fri, 25 Jul 2025 17:00:45 GMT"},{"id":"https://mmap.page/coding-style/python/","url":"https://mmap.page/coding-style/python/","title":"Coding Style for Python","content_html":"

Coding Style for Python

\n

The design of Python is well considered.\nAlso, the community tends to adhere PEP 8.

\n

Python dose have some flaws, but most of them are fixed by type hints.\nFor example, Python does not have the capability to define a constant variable,\nbut PEP 591 introduces Final.

\n

Personally I put a semicolon at the end of a mutation, e.g. a.append(1).\nThis is inspired by the distinguished coding style used by \"A Little Java, A Few Patterns\".

\n
Pie p = new Crust();\nPie p = new Top(new Anchovy(), p)\n; // the future begins, i.e. from this line on, references to `p` reflect the change\n
\n

However, this does not work with popular auto formatting tools such as black.\nTherefore, I do not adhere to this rule in some projects.

","date_published":"Fri, 25 Jul 2025 15:54:06 GMT","date_modified":"Fri, 25 Jul 2025 15:54:06 GMT"},{"id":"https://mmap.page/coding-style/kotlin/","url":"https://mmap.page/coding-style/kotlin/","title":"Kotlin coding style","content_html":"

Kotlin coding style

\n

Use when expressions for cases, avoid other usage of when

\n

Avoid use when statement, which is not exhausted.\nJust use if ... else if ....

\n

Kotlin uses when for both case and cond, which is confusing.\nThus avoid use when expression for cond.

\n

Avoid variadic functions

\n

Kotlin uses Array<T> for vararg p: T underhood\nbut special array types for basic types, e.g. IntArray for vararg p: Int.

\n

However, p: Array<T> and vararg p: T behaves differently.\nIn other words, given a function Array<T> -> Unit,\nwe do not know how to invoke it just from its signature.

\n

Array<T> -> Unit may be an infix function,\nbut all infix functions can be invoked as normal functions.

\n

Avoid object.invoke

\n

Without define invoke method for objects,\nevery time I see CapsName(something),\nI am sure it will return an instance of CapsName,\nnothing else.

\n

If we use lower case for object name,\nthen once we see lowerCase(something),\nwe may think it is a function.\nBut we can pass neither lowerCase nor ::lowerCase to a higher-order function.

\n

Avoid return in lambda.

\n

Control flow return in lambda returns the outer function.\nThis is confusing.

\n

Reduce using component object

\n

Kotlin supports top level functions, often cleaner than component objects.

\n

Reduce using normal function

\n

They are not first-class:

\n\n

Use val f = fun()... except for:

\n\n

Annotate @Throws

\n\n

Overload operators consistently

\n

Overloading an operator should be consistent to all types supporting the operator.

\n

Reduce using infix functions

\n

Infix functions provide a new syntax for function calls, similar to operators.

\n

Only use infix functions when they are obviously cleaner than non infix form.

","date_published":"Fri, 25 Jul 2025 15:54:06 GMT","date_modified":"Fri, 25 Jul 2025 15:54:06 GMT"},{"id":"https://mmap.page/coding-style/general/","url":"https://mmap.page/coding-style/general/","title":"General coding style for programming","content_html":"

General coding style for programming

\n

The goal of coding style is readability

\n

If there is a good reason to go against the style,\njust do it.

\n

Avoid regression

\n
\n

So we don't fix bugs by introducing new problems.\nThat way lies madness,\nand nobody ever knows if you actually make any real progress at all.\nIs it two steps forwards, one step back,\nor one step forward and two steps back?

\n
\n

-- Linus Torvalds

\n

Prefer small functions

\n\n

Avoid top level variables

\n\n

More documentation comments but less inline comments

\n

Programming languages are clearer than natural languages.\nSo in most cases try to express as much as possible in programming language itself.\nAlso, a compiler cannot warn you that comments is outdated.\nAnd an outdated comment can be very misleading.

\n\n

Here 'commenting' mainly refers to inline comments,\ni.e. comments explaining implementation details.\nDoc annotation of public modules and functions on their usage is fine.

\n

Break long line of parameters logically

\n

A simple approach is break for one, break for all.\nTo save lines, related parameters may be grouped in one line.

\n

Prefer readability to testability

\n

The main audience of code is human beings, not tests.

\n

Improving testability should not harm readability.

\n

Obscuring code to improve testability may bring in potential bugs not caught by tests.

\n

Prefer snake_case to camelCase

\n

camelCaseAreHardToReadIfThereAreMoreThanThreeWords

\n

snake_case_is_much_easier_to_read

\n

Exceptions:

\n\n

Prefer explicit else branch

\n

Some languages make the else clause of if mandated.\nThis is a good design.

\n

For other languages,\nprefer explicit else branch over fall through control flow.

\n

For example:

\n
Boolean if_else(Integer x) {\n    if (x > 0) {\n        if (x < 10) {\n            return false;\n        }\n    } else if (x < -10) {\n        return false;\n    }\n    return true;\n}\n
\n

It is short, but difficult to figure out the control flow.

\n

Rewrite it more explicitly, without omitting else branch:

\n
Boolean if_else(Integer x) {\n    if (x > 0) {\n        // This is for demonstration only.\n        // `if (x > 0, x < 10)` is clearer.\n        // Pretend there were more complex branching here.\n        if (x < 10) {\n            return false;\n        } else {\n            return true;\n        }\n    } else if (x < -10) {\n        return false;\n    } else {\n        return true;\n    }\n}\n
\n

Also, avoid using variable to save else branch.

\n

For example:

\n
variable Integer x = 0;\nif (condition) {\n    x = 1\n    ;\n}\n
\n

can be rewritten to

\n
Integer x;\nif (condition) {\n    x = 1;\n} else {\n    x = 0;\n}\n
\n

Only use i++ to increase i

\n

y=i++ and y=++i is really confusing to me.

\n

If the language allows ++ operators,\nonly use i++ to increase i, i.e. just the statement i++;.\nI think a meaningful evaluated value of i++ should be void\nif a programming language allows ++.

\n

The same applies to i-- and --i.

\n

Do not use return value of assignment statement

\n

Similarly to usage of i++,\nif assignment statements of the language return value,\ndo not use them.

\n

Test against true/false

\n

Condition tests should accept a boolean value.\nSo we do not need to remember rules for truthy and falsy values.\nFor example, in Ruby only false and nil are false,\nbut in Python, '', 0, (), [], and {} are also false.

\n

Prefer

\n
if not a.nil?\n  # do something\nend\n
\n

over

\n
if a\n  # do something\nend\n
\n

Prefer explicit type annotation

\n

Some languages allow you to use auto, var, etc.\nto let the compiler infer the variable type for you.\nUse this feature sparingly.\nExplicit type annotation serves as documentation.\nOmitting them may reduce readability of code.

\n

Exceptions:

\n

Prefer

\n
value variable_name = ClassInterface<TypeParameter>();\nvalue variable_name = ClassInterface()\n
\n

to

\n
ClassInterface<TypeParameter> variable_name = ClassInterface<TypeParameter>();\nClassInterface variable_name = ClassInterface();\n
\n

Think long and hard when you want to omit type annotation under other conditions.

\n

Also, for languages where variable declarations and assignments are indistinguishable in syntax, e.g. Python, type annotation helps to distinguish them.

\n

Use semicolons to remark mutation

\n

\"A Little Java, A Few Patterns\" uses a special coding style to remark mutation:

\n
class PutSemicolonOnItsOwnLineForMutability\n{\n    Pie p = new Crust();\n    Pie p = new Top(new Anchovy(), p)\n    ; // the future begins, i.e. from this line on, references to `p` reflect the change\n    Pie yy = new Bottom();\n    yy.addTop(new Anchovy())\n    ; // same as above\n}\n
\n

This is a brilliant idea.\nIn languages semicolons are not mandatory, a semicolon can be used at the end of the line to remark mutability.

","date_published":"Fri, 25 Jul 2025 15:54:06 GMT","date_modified":"Fri, 25 Jul 2025 15:54:06 GMT"},{"id":"https://mmap.page/coding-style/formatting/","url":"https://mmap.page/coding-style/formatting/","title":"Code Formatting","content_html":"

Code Formatting

\n

Formatting style does not affect AST and thus is unlikely to affect readability of code.\nIf they do, it can be automatically adjusted via tools.

\n

Use the official formatter if the language tool chain includes it, for example:

\n\n

Since different contributors may have different formatting preferences configured in their editor/IDE,\nwith different rules or formatters,\nformatting should be configured at the project level,\nenforced by commit hook automatically.\nThis is the best practice.

\n

If formatting is not configured at the project level,\nit is a good idea to only commit in non-whitespace changes,\nto avoid formatting changes pollute repository history.\nFor example, with Git:

\n
git diff -w > changes\n# review changes, run tests, etc.\ngit reset --hard\npatch < changes\n# stage and commit\n
\n

If the project does not configure auto formatting,\nand you need to review someone else's commits with a lot of formatting changes,\nyou can use git diff -w to ignore whitespace,\nor use similar options in other tools,\nsuch as \"Hide whitespace changes\" in GitHub's \"Diff settings\".

","date_published":"Fri, 25 Jul 2025 15:54:06 GMT","date_modified":"Fri, 25 Jul 2025 15:54:06 GMT"},{"id":"https://mmap.page/coding-style/ceylon/","url":"https://mmap.page/coding-style/ceylon/","title":"Ceylon coding style","content_html":"

Ceylon coding style

\n

Eclipse archived the Ceylon project.

\n
\n

(Ceylon) failed its transition to Eclipse and the community gave up.

\n

-- Eclipse Ceylon Termination Review

\n
\n

Avoid ... then ... else ...

\n

I feel A then B else C confusing.

\n

Readers may think A then B else C means A ? B : C in other languages, but they are not the same:

\n
    \n
  1. \n

    A then B else C is actually (A then B) else C:

    \n\n
  2. \n
  3. \n

    Thus the type of B is T given T satisfies Object, i.e. requires to not be null.

    \n
  4. \n
\n

Avoid foo { \"bar\"; }

\n

In Ceylon, foo { \"bar\"; } and foo { \"bar\" } are semantically different,\nwhich may be confusing.

\n

Either write foo(\"bar\") or foo { parameter = \"bar\"; }, never write foo { \"bar\"; }.

\n

Occasionally, foo {\"bar\"} may be used. But foo({\"bar\"}) is often preferred.

\n

Prefer switch case over if else.

\n

Cases in switch need to be both disjoint and exhausted.\nUsing a strict form helps to reduce chances to miss corner cases.

\n

For example, suppose we have the following code:

\n
Path path = current;\nif (is Directory path) { // typo, should be `path.resource`.\n    // ...\n} else { // dead code\n    // ...\n}\n
\n

There is a typo in the above code, path should be path.resource.\nSo the above code will never go into the else branch,\nsince a Path is always not a Directory.

\n

However, if we use switch with explicit cases:

\n
switch (path)\ncase (is Directory) {\n    // ...\n}\ncase (is File|Link|Nil) {\n    // ...\n}\n
\n

The compiler will refuse to compile, saying cases are not exhausted.

\n

switch can also be used as a workaround of Ceylon's assignment returnning assigned value:

\n
variable Boolean b = false;\nif (b = true) {\n    print(\"typo in the above line: `=` should be `==`\");\n} else {\n    print(\"Use switch to avoid this mistake.\");\n}\n\nswitch (b)\ncase (true) {\n    print(\"Avoid typo of `==`.\");\n}\ncase (false) {\n    print(\"assignment should not return a value in Ceylon.\");\n}\n
\n

Pay attention to compiler warnings

\n

If necessary, use annotation to suppress false positive warnings.

\n

For example:

\n
\"The ultimate exception handler.\"\nsuppressWarnings(\"expressionTypeNothing\")\nshared void run() {\n    try {\n        main();\n    } catch (UsageError e) {\n        process.writeErrorLine(e.message);\n        process.exit(e.exit_code);\n    }\n}\n
\n

Failures

\n

Use exceptions for failures that are unrecoverable by immediate calling code,\nlike bugs in program logic, network failure, and so on.\nSo they can be handled by some centric infrastructure code.

\n

Use return values (union types) for recoverable failures.

\n

Be careful with side-effect functions.\nThey are not type safe as side-effect functions with checked exceptions in Java.\nThe ceylon compiler does not force you to check function's return value\nwhen invoking functions as side-effects.\nFor example, when getting return value from result = f();\nwhere f is Result?(),\nCeylon does force you to check whether result is null or not.\nHowever, invoking f as side-effects f(); will silently ignore its return value,\nwithout checking for failures.

","date_published":"Fri, 25 Jul 2025 15:50:48 GMT","date_modified":"Fri, 25 Jul 2025 15:50:48 GMT"},{"id":"https://mmap.page/coding-style/go/","url":"https://mmap.page/coding-style/go/","title":"Go Coding Style","content_html":"

Go Coding Style

\n

Be careful when indexing slice

\n

Index out of bounds are not checked at compile time\nfor slices (including strings, a.k.a. slices of bytes).

\n

You may consider using the indexing functions from the gosugar package instead,\nwhich will automatically check slice length for you.

\n

Functions, interfaces, pointers may be nil

\n

The compiler does not check nullability for functions, interfaces, and pointers.

\n

Thus, any function taking a function, an interface, or a pointer,\nneeds to check whether input is nil itself.\nSince all methods implicitly accept a pointer,\nall methods should check whether their receiver is nil or not.\nThough, if you are careful enough, you may omit checking nullability in unexported functions.

\n

You can use the RequireNonNull function from the goaround package\nto check every non-nullable parameter,\nwhich will panic if the parameter passed in is nil.

\n

Explicitly check type implementing interface at compile time

\n

Use the var _ Interface = (*Type)(nil) trick.

\n

Stay clear. Stay explicit.

\n\n

Only use head statement in if to declare variables

\n

Like for, the if statement can start with a short statement to execute before the condition.\nThis often harms readability thus it should only be used to declare variables to limit their scope.

\n

The same applies to switch.

\n

Only use switch for cases

\n

In Go, switch can be used for both case and cond.\nTo avoid confusion, I always use switch for case.\nI use if ... else if instead of switch for cond.

\n

Only use defer for cleanups

\n

Use defer carefully.

\n

Do not rely on zero values

\n

Do not rely on Go's default initialized value.\nInitialize it explicitly instead if the value is intended to be used later.

\n

Similarly, always check presence when retrieving elements from a map.

\n

Similarly, always check presentence when retrieving elements from a map.\nFor example, if you want to retrieve an integer from a map,\nand use 0 if the key is missing:

\n
element := m[\"id\"]\n
\n

The above code utilizes the zero value of missing keys.\nThis makes the code shorter,\nbut less clear (The value is absent? The value happens to be zero?)

\n

Verbose and explicit code is preferred:

\n
element, present := m[\"id\"]\nif present {\n    return element\n} else {\n    return 0\n}\n
\n

Since Go will always initialize zero value on declaration,\nthe compiler will not complain declaration without initialization.\nThus, we should initialize variable on declaration whenever possible.

\n

For example:

\n
var s string\nif x < 0 {\n    s = \"0\"\n} else {\n    s = \"1\"\n}\n
\n

We can extract it as a function:

\n
func f(x int) string {\n    if x < 0 {\n        return \"0\"\n    } else {\n        return \"1\"\n    }\n}\n\nvar s string = f(5)\n
\n

The compiler will check the function returns on all branches.

\n

Do not use %#q in printf

\n

There are more good things to remember than the special rules of %#q.

","date_published":"Fri, 25 Jul 2025 15:40:12 GMT","date_modified":"Fri, 25 Jul 2025 15:40:12 GMT"},{"id":"https://mmap.page/coding-style/c/","url":"https://mmap.page/coding-style/c/","title":"C coding style","content_html":"

C coding style

\n

Include files

\n
\n

Simple rule: include files should never include include files.\nIf instead they state (in comments or implicitly)\nwhat files they need to have included first,\nthe problem of deciding which files to include is pushed to the user\n(programmer) but in a way that's easy to handle and that, by construction,\navoids multiple inclusions.

\n

There's a little dance involving #ifdef's\nthat can prevent a file being read twice,\nbut it's usually done wrong in practice -\nthe #ifdef's are in the file itself,\nnot the file that includes it.\nThe result is often thousands of needless lines of code\npassing through the lexical analyzer,\nwhich is (in good compilers) the most expensive phase.

\n
\n

-- Rob Pike Notes on Programming in C

\n

The real problem is C does not have a proper package or module system.\nLeaving the user to manually composite include file list is a workaround.

\n

Reduce macros

\n
\n

As a general rule,\n#ifdef use should be confined to header files whenever possible.\nConditionally-compiled code can be confined to functions\nwhich, if the code is not to be present, simply become empty.\nThe compiler will then quietly optimize out the call to the empty function.

\n
\n
\n

C preprocessor macros present a number of hazards,\nincluding possible multiple evaluation of expressions with side effects\nand no type safety.\nIf you are tempted to define a macro,\nconsider creating an inline function instead.\nThe code which results will be the same,\nbut inline functions are easier to read,\ndo not evaluate their arguments multiple times,\nand allow the compiler to perform type checking on the arguments and return value.

\n
\n

-- Linux kernel coding style

\n

Reduce inline functions

\n
\n

Since their code is replicated at each call site,\nthey end up bloating the size of the compiled kernel.\nThat, in turn, creates pressure on the processor's memory caches,\nwhich can slow execution dramatically.

\n

More recent compilers take an increasingly active role in deciding\nwhether a given function should actually be inlined or not.

\n
\n

-- Linux kernel coding style

\n

Prototypes should have parameter names

\n

Prototypes do not require parameter names.\nBut writing them out helps to understand the usage of functions.

\n

Do omit parameter names when it is obvious, for example,

\n
int plus(int, int);\n
\n

is preferred to

\n
int plus(int adder, int addee);\n
\n

Comment FALLTHROUGH in cases

\n

Non default cases in switch statements should end with\neither break or FALLTHROUGH comment.

\n

Mark non-return

\n

Mark a function never returns (always abort) with __dead.

\n

To be compatible with different operating systems, use a shim:

\n
/*\n * Public domain\n * sys/cdefs.h compatibility shim\n */\n\n#include_next <sys/cdefs.h>\n\n#if !defined(HAVE_ATTRIBUTE__DEAD) && !defined(__dead)\n#define __dead          __attribute__((__noreturn__))\n#endif\n
\n

This is based on the code at openntpd, with #ifndef and __pure removed.

\n

Standards

\n","date_published":"Thu, 24 Jul 2025 12:16:07 GMT","date_modified":"Thu, 24 Jul 2025 12:16:07 GMT"},{"id":"https://mmap.page/movies/","url":"https://mmap.page/movies/","title":"Recently Watched Movies","content_html":"","date_published":"Tue, 27 Aug 2024 12:51:28 GMT","date_modified":"Thu, 16 Jul 2026 08:01:11 GMT"},{"id":"https://mmap.page/dive-into/gemini/","url":"https://mmap.page/dive-into/gemini/","content_html":"

Gemini

\n
\n

Gemini is a protocol \"in between Gopher and the web\"*, but for me, Gopher is more like FTP, and Gemini is more like HTTP. Gemini does have some pitfalls in its design+, but it is still a good enough alternative to Web with an active community.#

\n
\n
* History of Project Gemini
\n
+ Daniel Stenberg (author of curl) on the Gemini protocol
\n
# Awesome Gemini
\n
# Gemini Network Protocol Specification
\n
\n

Gemini Text

\n
\n

If Gemini is to HTTP, then Gemini text is to HTML. It's a line-oriented minimalistic hypertext markup language inspired by Markdown and gophermaps. It has link lines and preformatted text lines. Optionally, it supports three levels of headings, unsorted lists, and quote lines.

\n

There is no syntax for escaping special markers. In other words, it assumes no normal text line will starts with =>, ```, *, #, or >. And no lines in preformatted text block will start with ```.

\n
\n
gemtext specification
\n
\n
gemtext-document = 1*gemtext-line\ngemtext-line     = text-line / link-line / preformat-toggle\ngemtext-line     =/ heading / list-item / quote-line\nlink-line        = \"=>\" *WSP URI-reference [1*WSP 1*(SP / VCHAR)] *WSP CRLF\nheading          = ( \"#\" / \"##\" / \"###\" ) text-line\nlist-item        = \"*\" SP text-line\nquote-line       = \">\" text-line\npreformat-toggle = \"```\" text-line\ntext-line        = *(WSP / VCHAR) CRLF\n
\n","date_published":"Thu, 28 Dec 2023 14:49:32 GMT","date_modified":"Mon, 04 May 2026 07:25:19 GMT"},{"id":"https://mmap.page/web/markdown/","url":"https://mmap.page/web/markdown/","title":"Markdown Markdown","content_html":"

Markdown Markdown

\n

A Bit of History

\n

Setext (Structure Enhanced Text) aims to be easily readable\nwithout any parsing or special software.\nThis inspires both ReStrucuterdText and Markdown.

\n

The idea of Markdown is

\n
\n

to make writing simple web pages, and especially weblog entries,\nas easy as writing an email

\n

-- Aaron Swartz

\n
\n

At that time, ReStrucuterdText seems too complex:

\n
\n

Is there a Perl implementation of reST, or a Movable Type single-file plug-in wrapper?\nAs far as I’m aware, no.\nSo, even without any arguments about reST’s syntax,\nI just don’t see how one could argue that I could have just used reST.

\n

And if I was going to write my own code,\nthere was no way I was going to write code to re-implement reST’s rather large feature set.\nI’m much too lazy.

\n

-- John Gruber

\n
\n

What Gruber and Swartz could have done was to implement a subset of ReStrucuterdText.\nBut they decided to \"develop the perfect format\".

\n

Partly due to its simplicity, Markdown became popular.\nThen, people want more and add more.\nToday Markdown turns out to be as complex, if not more complex than, ReStrucuterdText.\nAnd unlike ReStrucuterdText, Markdown is inconsistent among applications and platforms.

\n

Maybe I should not get surprised.\nAfter all, HTML was extremely simple at the time of Setext.

\n

Common Markup Among Setext, ReStrucuterdText, and Markdown

\n
\n

To me, the best parts of reST are the parts it borrowed from Setext.

\n

-- John Gruber

\n
\n

However, there are few common markup among Setext, ReStrucuterdText, and Markdown.

\n
Heading\n=======\n\nSub-heading\n-----------\n\n**bold**\n\n* bullet list\n* another item\n
\n

And the bullet list markup seems to be the most pervasive one.\nIt is the only common markup among Setext, ReStrucuterdText, Markdown, Usemod wiki,\nand godoc comment.

","date_published":"Sat, 29 Apr 2023 13:15:00 GMT","date_modified":"Thu, 14 Sep 2023 09:22:18 GMT"},{"id":"https://mmap.page/dive-into/preact-signal/","url":"https://mmap.page/dive-into/preact-signal/","title":"Preact Signal and Svelte","content_html":"

Preact Signal and Svelte

\n

Compared to Svelte Reactive Blocks, Preact Signal feels more verbose but less surprising to me.

\n

Svelte advertises itself as bringing reactivity to JavaScript itself:

\n
<script>\n\tlet x = 0\n\tlet y = 0\n\t$: total = x + y\n</script>\n\n<div>\n<p>{x} + {y} = {total}</p>\n<button on:click={() => x++}>Increase X</button><br />\n<button on:click={() => y++}>Increase Y</button>\n</div>\n
\n

Brief. Short. And except for $:, every token is intuitive.

\n

In the above code, $: means total depends on the value of x and y.\nThus, when either button is pressed, the {total} part will be rerendered automatically.

\n

However, in the following code sample, total will only get updated when x changes, not when y changes!

\n
function yPlusAValue(value) {\n  return value + y;\n}\n\n$: total = yPlusAValue(x);\n
\n

This surprising behavior is because the Svelte compiler is not smart enought to figure out that yPlusAValue involves the value ofy.\nAs Svelte documentation mentioned:

\n
\n

reactive blocks are ordered via simple static analysis at compile time,\nand all the compiler looks at are the variables that are assigned to and used within the block itself,\nnot in any functions called by them.

\n
\n

Now, let's port this to Preact Signal:

\n
import { render } from \"preact\";\nimport { useSignal, useComputed } from \"@preact/signals\";\n\nfunction Adder() {\n\tconst x = useSignal(0);\n\tconst y = useSignal(0);\n\tconst total = useComputed(() => x.value + y.value)\n  return (\n    <div>\n      <p>{x} + {y} = {total}</p>\n      <button onClick={() => x.value++}>Increase X</button><br />\n  \t\t<button onClick={() => y.value++}>Increase Y</button>\n\t</div>\n  );\n}\n\nrender(<Adder />, document.getElementById(\"app\"));\n
\n

It is a bit more verbose than Svelte but still clean.1\nMost importantly, it also works with function calls:

\n
function yPlusAValue(s) {\n  return s.value + y.value;\n}\nconst total = useComputed(() => yPlusAValue(x))\n
\n

Footnotes

\n
    \n
  1. \n

    At least cleaner than useState. ↩

    \n
  2. \n
\n
","date_published":"Thu, 27 Apr 2023 12:31:05 GMT","date_modified":"Thu, 27 Apr 2023 12:31:05 GMT"},{"id":"https://mmap.page/lists/serverless-bandwidth/","url":"https://mmap.page/lists/serverless-bandwidth/","title":"The Cost of Serverless Bandwidth","content_html":"

The Cost of Serverless Bandwidth

\n

If only bandwidth is concerned, then:

\n\n

Comparison

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Provider1 GB100 GB1 TBOverage per GB
Digital Ocean App Platform0121020.10
Netlify00190.55
Vercel0020contact sale
Gatsby0042.50contact
Render00900.10
Railway00n/an/a
Fly00180.02/0.04/0.12
LeanCloud07970.10
Heroku777n/a
GitHub Pages00n/an/a
Cloudflare Pages0000
Digital Ocean Droplets4440.01
Linode Compute5550.01
Koyeb00360.04
\n

Details

\n","date_published":"Wed, 26 Apr 2023 06:16:24 GMT","date_modified":"Wed, 20 Dec 2023 04:08:02 GMT"},{"id":"https://mmap.page/thoughts/typescript-slogan/","url":"https://mmap.page/thoughts/typescript-slogan/","title":"A History of TypeScript Slogans","content_html":"

A History of TypeScript Slogans

\n
    \n
  1. TypeScript is a superset of JavaScript.1
  2. \n
  3. TypeScript is JavaScript that scales.2
  4. \n
  5. TypeScript is just JavaScript with types.3
  6. \n
  7. TypeScript is JavaScript with syntax for types.4
  8. \n
  9. TypeScript is JavaScript with types, unsound.5
  10. \n
\n

Footnotes

\n
    \n
  1. \n

    TypeScript wants to attract CoffeeScript and Dart developers. ↩

    \n
  2. \n
  3. \n

    TypeScript wants to attract developers on large or hope to be large projects. ↩

    \n
  4. \n
  5. \n

    TypeScript wants to attract all JavaScript developers. ↩

    \n
  6. \n
  7. \n

    TypeScript wants to attract all JavaScript developers, including those who have no idea what typing means and thought it is just a syntax thing. ↩

    \n
  8. \n
  9. \n

    I just could help myself from listing this fake slogan occurred to my mind. ↩

    \n
  10. \n
\n
","date_published":"Tue, 25 Apr 2023 08:48:15 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/coding-style/javascript/","url":"https://mmap.page/coding-style/javascript/","title":"JavaScript Coding Style","content_html":"

JavaScript Coding Style

\n

I prefer to not include TypeScript definitions in pure JavaScript projects.

\n

See An Optioned Guide to ESLint for ESLint configurations.

","date_published":"Tue, 25 Apr 2023 08:09:37 GMT","date_modified":"Tue, 25 Apr 2023 08:09:37 GMT"},{"id":"https://mmap.page/coding-style/typescript/","url":"https://mmap.page/coding-style/typescript/","title":"TypeScript Coding Style","content_html":"

TypeScript Coding Style

\n

See An Optioned Guide to ESLint.

","date_published":"Mon, 24 Apr 2023 08:23:55 GMT","date_modified":"Mon, 24 Apr 2023 08:23:55 GMT"},{"id":"https://mmap.page/coding-style/sh/","url":"https://mmap.page/coding-style/sh/","title":"sh Coding Style","content_html":"

sh Coding Style

\n

Abstract

\n
cat << END\nset -e\nsnake_case() {\n  local foo=bar\n  some-command --long-option \"$foo\"\n}\nEND | dash\n
\n

Naming

\n

We prefer hyphen-word over snake_case over CamelCase.\nHowever, dash only allows _ and alnum as variable names.\nThus, snake_case is preferred.

\n

Short options

\n

We prefer --long for self-documentation.

\n

Compatibility

\n

Test against dash.

\n

Fails early

\n

Use set -e.

\n

Local variable

\n

Use local variables in function definitions when possible.

","date_published":"Mon, 24 Apr 2023 08:23:55 GMT","date_modified":"Mon, 24 Apr 2023 08:23:55 GMT"},{"id":"https://mmap.page/search/","url":"https://mmap.page/search/","content_html":"\n
","date_published":"Mon, 24 Apr 2023 08:04:45 GMT","date_modified":"Mon, 24 Apr 2023 08:04:45 GMT"},{"id":"https://mmap.page/coding-style/ruby/","url":"https://mmap.page/coding-style/ruby/","title":"Ruby Coding Style","content_html":"

Ruby Coding Style

\n

Use {} for blocks returning value, and do end for other blocks.

\n
l = [1, 2, 3]\n\nl.each do |n| n += 1 end\n\nl.map { |n|\n  b = (n + 1) * (n + 2) / 3.0\n  b.to_s\n}\n\nidentity = ->(x) { x }\nsay = ->(x) do puts x end\n
\n

Avoid Proc.new and proc.

\n

Avoid Proc.new.

\n

Never use proc. Its behavior is different for Ruby 1.8 and Ruby 1.9+.

\n

Use self module functions.

\n

Prefer

\n
mod M\n  def self.a; 'a'; end\n  def self.b; 'b'; end\n  # more ...\nend\n\nM.a()\n
\n

over

\n
module M\n  # module_function will copy the functions. No need to make duplicated\n  # functions unless you want to let other classes include your module\n  # and let them pollute other classes' namespcae.\n  module_function\n\n  def a; 'a'; end\n  def b; 'b'; end\n  # more ...\nend\n\nM.a()\n
\n

over

\n
class C\n  # Do not build a class just for some functions. Use module for this.\n  class << self\n\n    def a; 'a'; end\n    def b; 'b'; end\n    # more ...\n  end\nend\n\nC.a()\n
\n

and

\n
class C\n  def a; 'a'; end\n  def b; 'b'; end\n  # more ...\nend\n\n# This is redundant.\nc = C.new()\nc.a()\n
","date_published":"Sun, 23 Apr 2023 10:25:54 GMT","date_modified":"Sun, 23 Apr 2023 10:25:54 GMT"},{"id":"https://mmap.page/coding-style/100-percent-js/","url":"https://mmap.page/coding-style/100-percent-js/","title":"100% JavaScript Project","content_html":"

100% JavaScript Project

\n

Jordan Hairband chooses to not include TypeScript definitions in Tape:

\n
\n

No. Typings should never be packaged with individual repos,\nespecially because maintainers who don't use typescript\nhave no friendly way to keep the typings in sync.

\n

DT or similar is the proper place for types, until JavaScript has them natively.

\n

...

\n

The tape codebase will not be written in anything but JavaScript.

\n

...

\n

I would encourage you, however, to submit accurate typings for all the tape versions to DT,\nto benefit all TypeScript users - and if there’s anything short of using TS\nthat i can do to make it easier for TS users to use tape, I’d be happy to.

\n
\n

Mentioning TypeScript in README is also refused:

\n
\n

I don’t think that’s necessary.\nA typescript user should already know how to use ts-node with everything if needed,\nand the advice isn’t different with tape than with anything else.\nIt’s not incumbent on “every individual non-typescript package” to make typescript easy to use;\nthat’s typescript’s task.

\n

...

\n

...an alternative without ts-node is to transpile first and test the output.

\n

This is just the sort of thing that you open yourself to\nby making the choice to use “not JavaScript”,\nand it’s not practical for millions of individual JS packages to try to document\nall the caveats you need to know when making that choice.

\n
\n

Besides, strictly speaking, if a library includes .d.ts,\nthen it needs to add typescript as its dependency not dev dependency.\nOtherwise, if the type definitions include features not available on old versions of TypeScript,\nor not compatible with breaking changes from future versions of TypeScript,\nit will not work for the library users, at least causing problems on their IDEs or editors.

\n

If types are published under @types/foo,\nusers of the library need to install an additional package.\nAlso, this separation requires extra configuration for the package maintainers.

\n

To be honest, TypeScript may be considered as a special case.\nTypeScript is not added to the dependencies list,\nassuming the type definitions of the library will work with all recent TypeScript versions.\nAnd the users of the library can install the right TypeScript version manually\nspecified in the dev dependencies, as a last resort,\nif they encountered problems, which should be a rare condition.\nAlthough this dependency specification is not rigid,\nit should work well in practical.

","date_published":"Thu, 08 Sep 2022 09:36:07 GMT","date_modified":"Tue, 25 Apr 2023 08:09:37 GMT"},{"id":"https://mmap.page/vim/spell/","url":"https://mmap.page/vim/spell/","title":"Spell Checking in Vim","content_html":"

Spell Checking in Vim

\n

Vim has built-in support for spell checking.\nThis built-in function provides basic spell checking.\nFor example, it does not recognize 'localhost', 'Lua' or 'Node.js'.\nHowever, new words can be added quickly via zg in normal mode.

\n

To check grammar and stylish errors,\nGrammarly or LanguageTool can be used.

\n

I prefer LanguageTool because it is open source.\nAll the errors can be checked with ltex-ls locally,\nwithout making any network requests.

\n

Unfortunately, ltex-ls does not support adding unknown words to dictionary.\nPreviously, as a workaround, I disabled the spell checking rule from ltex-ls,\nand use Neovim's built-in spell checking instead.\nNow I use ltex_extra.nvim, which provides code actions for adding unknown words, disable rules, and hide false positives.

\n

BTW, the Grammarly LSP does not support this, either.

","date_published":"Mon, 05 Sep 2022 08:51:52 GMT","date_modified":"Thu, 18 Jan 2024 11:47:55 GMT"},{"id":"https://mmap.page/dive-into/jekyll-zeronet/","url":"https://mmap.page/dive-into/jekyll-zeronet/","title":"Deploy Jekyll Site to ZeroNet","content_html":"

Deploy Jekyll Site to ZeroNet

\n

This guide is outdated and unmaintained.\nThe development of ZeroNet ceased.

\n

Basic Setup

\n

A basic setup is mostly straightforward.\nThe only thing to pay attention to is avoiding broken links.

\n

Typically, the jekyll site will be deployed to https://some.domain.example (root path) and https://127.0.0.1:43110/some-zite-address/ (with zite address as the preceding path).\nThus if not careful, there will be broken links on your clearnet site or/and ZeroNet site.

\n

As a rule of thumb, keep all internal links within the page content (markdown files) as relative to current path links.\nFor example, the homepage of this site links to this page as [Deploy Jekyll Site to ZeroNet](dive-into/jekyll-zeronet/).\nRelative to current path links work both under https://some.domain.example and https://127.0.0.1:43110/some-zite-address/.

\n

For links in page templates, you have several options:

\n
    \n
  1. \n

    Keep all pages in one directory, thus relative to current path links can be used in page templates.

    \n
  2. \n
  3. \n

    Use different templates for pages under different directories, or at least pages under different depth of directories.\nThis also allows for relative to current path links in page templates.

    \n
  4. \n
  5. \n

    If your site may have arbitrary levels of directories and you want to use just one template for them all, then you can choose a ZeroNet first approach, using your zite address as the base path of your clearnet site.\nFor example, if your zite address is 16XMwj6YRNqRHWbmSD8oxYUZCKfM1uzwP9 and clearnet site domain is mmap.page, then you can host your clearnet site under https://mmap.page/16XMwj6YRNqRHWbmSD8oxYUZCKfM1uzwP9. This way, you can use relative to document root links in page templates, such as /16XMwj6YRNqRHWbmSD8oxYUZCKfM1uzwP9/assets/css/style.css.

    \n
  6. \n
  7. \n

    You can also use absolute links via template variable in page templates.\nFirst, you define the site variable url as your clearnet url, e.g. https://mmap.page.\nNow comes the tricky part.\nJekyll allows any value for the site url variable.\nThus you can specify it as /zite-address for ZeroNet deployment.\nFor example, url: /16XMwj6YRNqRHWbmSD8oxYUZCKfM1uzwP9.\nNote that you should not use https://127.0.0.1:43110/some-zite-address here, since other users may bind a different IP or port for their ZeroNet service.\nThen you can use {{site.url}} to construct absolute links in page templates,\ne.g. {{site.url}}/assets/css/style.css.

    \n
  8. \n
\n

Multiple Configurations

\n

Jekyll can accept multiple configuration files.\nThus if most of your configurations are the same for clearnet and ZeroNet, you can do most configurations in _config.yml, then append or override some configurations in _zeronet.yml or _clearnet.yml.\nFor example, my _zeronet.yml only contains one line url: /16XMwj6YRNqRHWbmSD8oxYUZCKfM1uzwP9 and I run the following command to generate a static site for ZeroNet deployment.

\n
bundle exec jekyll build --config _config.yml,_zeronet.yml -d /path/to/ZeroNet/data/16XMwj6YRNqRHWbmSD8oxYUZCKfM1uzwP9/\n
\n

Conditional Content

\n

You can use conditional expressions in Jekyll templates to display different content on clearnet and ZeroNet.

\n

For example, to display a greyscale version of ZeroNet logo on clearnet, while keeping the logo colorful on ZeroNet:

\n

{% raw %}

\n
{% assign leading = site.url | slice: 0 %}\n{% if leading == '/' %}\n    {% assign zeronet_logo = 'zeronet_logo.svg' %}\n{% else %}\n    {% assign zeronet_logo = 'zeronet_grey.svg' %}\n{% endif %}\n<img src=\"{{ site.url }}/assets/images/{{ zeronet_logo }}\" alt=\"ZeroNet Logo\" width=\"32\" height=\"32\">\n
\n

{% endraw %}

\n

Here I chose the fourth option (site.url) mentioned in the \"Basic Setup\" section,\nthus I decide if it is on ZeroNet by checking if site.url starts with /.\nIf you use other options, you can define an additional boolean option on your _zeronet.yml or _clearnet.yml,\nand ues it to detect the deployment environment.

\n

RSS

\n

Unfortunately, RSS does not like relative links.\nIf your sites need RSS, then you have to replace relative links with absolute ones in templates.\nSince the Liquid template language Jekyll uses is quite limited,\nI chose to use relative to document root links in page content, which makes it easier to finding these links via Liquid template languages (just looks for <a href=\"https://mmap.page/%3C/code%3E%20and%20%3Ccode%3E<img%20src=\"/>).

\n

In RSS template, I implemented something like this:

\n

{% raw %}

\n
{% assign absolutelink = '<a href=\"https://mmap.page/dive-into/jekyll-zeronet/'%3C/span%3E%20|%20%3Cspan%20class=\"pl-c1\">append: site.url | append: '/' %}\n{% assign absoluteimglink = '<img src=' | append: site.url | append: '/' %}\n<description>{{ page_content | markdownify | replace: '<a href=\"https://mmap.page/'%3C/span%3E,%20%3Cspan%20class=\"pl-smi\">absolutelink | replace: '<img src=\"https://mmap.page/'%3C/span%3E,%20%3Cspan%20class=\"pl-smi\">absoluteimglink | xml_escape}}</description>\n
\n

{% endraw %}

\n

I also implemented similar logic in default page template to avoid broken links since now relative to document root links are used.

\n

Alternatively, you can write some lengthy liquid template processing logic or write a post-process script in other programming languages to find and replace all relative links.\nThis way, you can keep using relative to current path in page content and keep the default page template intact.

","date_published":"Sat, 30 Jan 2021 06:27:33 GMT","date_modified":"Tue, 06 Sep 2022 05:08:10 GMT"},{"id":"https://mmap.page/lists/vps/","url":"https://mmap.page/lists/vps/","title":"Virtual Private Servers List","content_html":"

Virtual Private Servers List

\n

Boring fact: Among all regions of AWS EC2, Cape Town, Mumbai, Hong Kong, and Singapore are the only four not governed by a country that belongs to NATO, PfP, or MNNA.

\n
[\n    {\n        \"provider\": \"BuyVM\",\n        \"url\": \"https://buyvm.net/kvm-dedicated-server-slices/\",\n        \"ram\": 512,\n        \"disk\": 10,\n        \"bandwidth\": \"unmetered\",\n        \"ipv4\": 1,\n        \"monthly\": \"$2\",\n        \"regions\": [\n            \"us\",\n            \"lu\"\n        ]\n    },\n    {\n        \"provider\": \"TinyKVM\",\n        \"url\": \"https://tinykvm.com\",\n        \"ram\": 256,\n        \"disk\": 7,\n        \"bandwidth\": 200,\n        \"yearly\": \"$15\",\n        \"regions\": [\n            \"us\"\n        ]\n    },\n    {\n        \"provider\": \"AnyNode\",\n        \"url\": \"https://anynode.net/vps-kvm-ssd.php\",\n        \"ram\": 256,\n        \"disk\": 10,\n        \"bandwidth\": 500,\n        \"yearly\": \"$15\",\n        \"regions\": [\n            \"us\"\n        ]\n    },\n    {\n        \"provider\": \"AnyNode\",\n        \"url\": \"https://anynode.net/vps-kvm-ssd.php\",\n        \"ram\": 512,\n        \"disk\": 15,\n        \"bandwidth\": 500,\n        \"monthly\": \"$2.5\",\n        \"regions\": [\n            \"us\"\n        ]\n    },\n    {\n        \"provider\": \"Somagu\",\n        \"url\": \"https://www.somagu.com\",\n        \"ram\": 512,\n        \"disk\": 20,\n        \"ipv4\": 0,\n        \"bandwidth\": \"90 KRW per 1 GiB, inbound & outbound\",\n        \"monthly\": \"$0.65\",\n        \"regions\": [\n            \"kr\"\n        ]\n    },\n    {\n        \"provider\": \"iwStack\",\n        \"url\": \"https://iwstack.com\",\n        \"ram\": 512,\n        \"disk\": \"€0.0001 per GB per hour\",\n        \"ipv4\": 1,\n        \"bandwidth\": 2000,\n        \"hourly\": \"€0.003\",\n        \"regions\": [\n            \"it\",\n            \"nl\",\n            \"ro\"\n        ]\n    },\n    {\n        \"provider\": \"CloudCone\",\n        \"url\": \"https://cloudcone.com/cloud-servers/\",\n        \"ram\": 1024,\n        \"disk\": 20,\n        \"ipv4\": 1,\n        \"hourly\": \"$0.00498\",\n        \"regions\": [\n            \"us\"\n        ],\n        \"note\": \"Even when you have uploaded ssh key in panel, you have to run command manually to download ssh key on the vps! (Initial login need use password.) Also its REST API uses GET method for reboot/shutdown/create/destroy.\"\n    },\n    {\n        \"provider\": \"Scaleway\",\n        \"url\": \"https: //www.scaleway.com/en/pricing/#virtual-instances\",\n        \"ram\": 1024,\n        \"disk\": 10,\n        \"ipv4\": 1,\n        \"bandwidth\": \"100 Mbit/s\",\n        \"hourly\": \"€0.0025\",\n        \"regions\": [\n            \"fr\",\n            \"nl\",\n            \"pl\"\n        ]\n    },\n    {\n        \"provider\": \"vultr\",\n        \"url\": \"https://www.vultr.com/products/cloud-compute/#pricing\",\n        \"ram\": 512,\n        \"disk\": 10,\n        \"ipv4\": 1,\n        \"bandwidth\": 500,\n        \"hourly\": \"$0.005\"\n    },\n    {\n        \"provider\": \"vultr\",\n        \"url\": \"https://www.vultr.com/products/cloud-compute/#pricing\",\n        \"ram\": 512,\n        \"disk\": 10,\n        \"ipv4\": 0,\n        \"bandwidth\": 500,\n        \"hourly\": \"$0.004\"\n    },\n    {\n        \"provider\": \"vultr\",\n        \"url\": \"https://www.vultr.com/products/cloud-compute/#pricing\",\n        \"ram\": 1024,\n        \"disk\": 25,\n        \"ipv4\": 1,\n        \"bandwidth\": 1000,\n        \"hourly\": \"$0.007\",\n        \"regions\": [\n            \"au\",\n            \"ca\",\n            \"de\",\n            \"fr\",\n            \"jp\",\n            \"kr\",\n            \"nl\",\n            \"sg\",\n            \"uk\",\n            \"us\"\n        ]\n    },\n    {\n        \"provider\": \"LunaNode\",\n        \"url\": \"https://www.lunanode.com/pricing\",\n        \"ram\": 512,\n        \"disk\": 15,\n        \"bandwidth\": 1000,\n        \"hourly\": \"$0.00625\",\n        \"regions\": [\n            \"ca\",\n            \"fr\"\n        ]\n    },\n    {\n        \"provider\": \"DigitalOcean\",\n        \"url\": \"https://www.digitalocean.com/pricing\",\n        \"ram\": 1024,\n        \"disk\": 25,\n        \"bandwidth\": 1000,\n        \"hourly\": \"$0.007\",\n        \"regions\": [\n            \"ca\",\n            \"de\",\n            \"in\",\n            \"nl\",\n            \"sg\",\n            \"uk\",\n            \"us\"\n        ]\n    },\n    {\n        \"provider\": \"Linode\",\n        \"url\": \"https://www.digitalocean.com/pricing\",\n        \"ram\": 1024,\n        \"disk\": 25,\n        \"bandwidth\": 1000,\n        \"hourly\": \"$0.0075\",\n        \"regions\": [\n            \"au\",\n            \"ca\",\n            \"de\",\n            \"in\",\n            \"jp\",\n            \"sg\",\n            \"uk\",\n            \"us\"\n        ]\n    },\n    {\n        \"provider\": \"Memset\",\n        \"url\": \"https://www.memset.com/services/cloud-iaas/pricing/\",\n        \"ram\": 1024,\n        \"hourly\": \"£0.0155\",\n        \"regions\": [\"uk\"]\n    },\n    {\n        \"provider\": \"Atlantic\",\n        \"url\": \"https://www.atlantic.net/vps-hosting/pricing/\",\n        \"ram\": 2048,\n        \"disk\": 50,\n        \"bandwidth\": 3000,\n        \"hourly\": \"$0.0149\",\n        \"regions\": [\"ca\", \"uk\", \"us\"]\n    },\n    {\n        \"provider\": \"ExoScale\",\n        \"url\": \"https://www.exoscale.com/pricing/\",\n        \"ram\": 512,\n        \"disk\": 10,\n        \"hourly\": \"$0.00694\",\n        \"regions\": [\"at\", \"bg\", \"ch\", \"de\"]\n    },\n    {\n        \"provider\": \"ConoHa\",\n        \"url\": \"https://www.conoha.jp/vps/pricing/\",\n        \"ram\": 512,\n        \"disk\": 30,\n        \"hourly\": \"1.0円\",\n        \"regions\": [\"jp\", \"sg\"]\n    },\n    {\n        \"provider\": \"AWS EC2 Nano\",\n        \"url\": \"https://aws.amazon.com/ec2/pricing/on-demand/\",\n        \"ram\": 512,\n        \"hourly\": \"$0.0042\",\n        \"regions\": [\"au\", \"bh\", \"br\", \"ca\", \"de\", \"fr\", \"hk\", \"ie\", \"in\", \"it\", \"jp\", \"kr\", \"se\", \"sg\", \"uk\", \"us\", \"za\"]\n    }\n]\n
","date_published":"Sat, 23 Jan 2021 19:14:01 GMT","date_modified":"Mon, 05 Sep 2022 11:26:30 GMT"},{"id":"https://mmap.page/uses/android/","url":"https://mmap.page/uses/android/","title":"Android Setup Guide","content_html":"

Android Setup Guide

\n

No Google Account

\n

I do not sign in to a Google Account on the phone, because I dislike the idea of linking a device to an online account.

\n

Without a Google Account, I cannot install applications via Google Play Store.\nThus, I use F-Droid (free and open source) and APKPure (for apps that are not on F-Droid) to install applications.

\n

Applications

\n\n

I also use some preinstalled applications, for example, calculator and Google Photos (with backup & sync turned off since I do not sign in to a Google Account).

\n

Troubleshooting

\n

Android cannot connect to an iPhone hotspot

\n

Enable Maximize Compatibility in iPhone Settings → Personal Hotspot (2.4 GHz; some Android phones cannot see 5 GHz). On Android, turn Wi-Fi off and back on. Apple help.

","date_published":"Thu, 15 Oct 2020 14:54:49 GMT","date_modified":"Sat, 18 Jul 2026 15:10:05 GMT"},{"id":"https://mmap.page/dive-into/i3/","url":"https://mmap.page/dive-into/i3/","title":"i3 Quick Start","content_html":"

i3 Quick Start

\n

Keybindings

\n

When starting i3 without a config file, i3-config-wizard will let you choose Alt or Win as the Modifier, and generate a configure file.\nHowever, it will generate keybindings based on the key positions of QWERTY layout.\nSince I am using dvorak, so I copied /etc/i3/config to ~/.config/i3/config and replaced Mod1 (Alt) with Mod4 (Win) instead.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$mod+keyfunction
Enterterminal
ddmenu
Arrow Keysmove focus
Shift+Arrow Keysmove window
0-9switch workspace 10,1,...,9
Shift+0-9switch workspace 10,1,...,9
anavigate one container up the tree
h/vsplit container splith/v
etoggle splith/v
ftoggle fullscreen
s/wstacking/tabbed
Shift+Spacetoggle floating
Shift+qclose window
Shift+rrestart i3
Shift+eexit i3
Secondary mouse buttonadjust window size
renter resize mode
\n

Notes:

\n
    \n
  1. By default, i3 uses dmenu_run, displaying all commands in $PATH. To only display applications shipping a .desktop file, replace dmenu_run with i3-dmenu-desktop instead.
  2. \n
  3. Multiple screens share workspaces. Workspace will be bound to the focused screen on its creation. Switching to a workspace will focus its screen.
  4. \n
  5. In resize mode, press arrow keys (or jkl;) to resize focused window: Left/Right: shirk/grow width; Up/Down: shrink/grow height; Esc: escape resize mode.
  6. \n
\n

Configurations

\n

Edit ~/.config/i3/config:

\n
# No title bar, window borders\ndefault_border none\n# For old versions\n# new_window none\n# When already on workspace N, $mod+N will switch to the previous focused workspace\nworkspace_auto_back_and_forth yes\n# Hide i3bar\nbar {\n    mode hide\n    status_command i3status\n}\n# Lock screen\n# keybinding inspired by macOS\nbindsym Mod4+Ctrl+q exec --no-startup-id \"i3lock -i $HOME/Pictures/wallpaper/F14-final-wallpaper-updated.png\"\n# i3lock-img is a shell script of the above i3lock command line\nexec_always --no-startup-id \"xautolock -time 1 -locker i3lock-img\"\n
\n

Layouts

\n

A container contains windows or containers.

\n

A container has one of the following layouts:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
switch keyslayoutmove focus
$mod+etiling (it toggles splitv/splith)$mod+up/down/left/right (depends on orientation)
$mod+sstacking$mod+up/down
$mod+wtabbed$mod+left/right
\n

And $mod+f will toggle fullscreen mode of the current window.

\n

A new opened window will appear in the current container, next to the current window:

\n\n

A new container can be created explicitly by splitting the current container vertically ($mod+v) or horizontally ($mod+h).\nAnd moving windows may implicitly create containers.

\n

For example, suppose we have three windows in a splith container (window c is focused):

\n
|a|b|c*|\n
\n

$mod+Shift+Up results in the following layout:

\n
|  c*   |\n| a | b |\n
\n

Here window a and b are in an implicitly created new container.\nThat is,

\n
splith             splitv\n / | \\    --->      /   \\\na  b  c            c   splith\n                        /  \\\n                       a    b\n
\n

Similarly, if we focus window a ($mod+Down), and move it up ($mod+Shift+Up):

\n
| c  |\n| a* |\n| b  |\n
\n

then move it left ($mod+Shift+Left), we will get the following layout:

\n
|    | c |\n| a* |\n|    | b |\n
\n

Let's review the whole process:

\n
|a|b|c*|  --> |  c*   |  --> | c  | --> |    | c |\n              | a | b |      | a* |     | a* |   |\n                             | b  |     |    | b |\n\nsplith             splitv             splitv           splith\n / | \\    --->      /   \\       --->   / | \\   --->     /   \\\na  b  c            c   splith         a  b  c          a    splitv\n                        /  \\                                 /  \\\n                       a    b                               c    b\n
\n

KDE

\n

You can use i3 with other desktop environments such as KDE.

\n

If you use i3 in KDE, you may want to uncomment the xautolock line above to lock screen via KDE.\nAlso, vertical KDE panel is not supported under i3.

","date_published":"Sun, 12 Jul 2020 10:20:15 GMT","date_modified":"Mon, 05 Sep 2022 11:26:30 GMT"},{"id":"https://mmap.page/uses/","url":"https://mmap.page/uses/","title":"Uses","content_html":"

Uses

\n

Colophon

\n

A plain text file documents the colophon of this site.\nAs for the URL to this plain text, if you are interested in the colophon of this site,\nyou probably know it.\nIf not, you can figure it out via the source code of this site.

\n

Computers

\n\n

Editor

\n

I use Zed, mostly as a browser rather than an editor since AI agents are getting smarter and smarter.

\n

Currently I use the cursor agent under herdr.\nI may try Devin, Jules and Junie in future.

\n

Terminal

\n

I use kitty because previously I had used Neovim for some time and kitty works well with Neovim (true color & undercurl).\nAlso, kitty is from Kovid Goyal, the author of calibre.

\n

Linux

\n

As a long time macOS (and Mac OS X) user, I still feel at home on Linux.\nUnfortunately right now I am stuck with macOS as the desktop system, with Devuan Excalibur in the VM.

\n

Browser

\n

I use DuckDuckGo browser with the advertisements in DuckDuckGo search engine disabled,\notherwise it will not block some Microsoft tracking scripts under certain conditions.

\n

Occasionally I use Chromium for fancy features such as WebGPU.

\n

To browse markdown files on my mobile phone, I use Obsidian.\nI cloned the corresponding repository to my iCloud drive,\nthen opened it in Obsidian iOS app as a vault.\nMy modifications on the iPhone will be synced via iCloud to my Mac,\nthen I will finish the changes, commit them, and push them to GitHub.

\n

Email

\n

I use Apple Mail on my Mac and iPhone.\nI've used Spark before but it does not provide offline access to emails.

\n

Window Manager

\n

Back to the days when I was using Linux\n(before systemd killed portability and Wayland killed compatibility),\nI fell in love with tiling window managers like awesomewm and i3.\nOn macOS, I use PaperWM.spoon, a tiled scrollable window manager.

\n

Online Services

\n\n\n\n

Camera

\n\n

Shoes

\n

I used to prefer vintage style running shoes, those revised models originated from 1960s to 1980s, light and comfort.\nHowever, I found out that their toe boxes are narrow.\nSo I bought a pair of Crocs Classical Clog instead, which has a large toe box.\nI also put on some charms to make my white Crocs prettier.\nI wore it a lot but did not bought a new pair after it was worn out, since:

\n\n

Currently my favorite pair is Vibram FiveFingers KSO ECO Green,\nwhich is extremely light (M43 4.9 oz) and minimalistic (3mm rubber outsole).\nWalking wearing it, I can feel the ground and my toes are not constrained.\nHowever, I feel it is not suitable to wear it running on hard surface so later I bought a pair of Vibram FiveFingers V-Run Ivory / Yellow,\nwhich is also extremely light (M43 4.8 oz) but offers a bit more cushioning (2mm EVA insole, 4mm EVA midsole, 2.5 mm rubber outsole).\nBoth of them have fast lacing system, which I prefer since I hate tying shoelaces.

\n

I also have a pair of Altra Solstice XT 3 White, zero drop and wide toe box.\nIts 23mm stack feels too thick for my walk but is fine for gym.\nThe stack of Altra running shoes and hiking shoes are too thick for me so I do not consider them after trying them on at the store.

\n

I also have a pair of running sandals bought from a local shop where they assemble sandals themselves.\nZerodrop, hybrid outsole for both road and trail, red foam and rainbow straps.

\n

All my shoes can be used for running, except for sandals I wear indoors.

\n

Clothes

\n

I chose clothes based on the following principles:

\n
    \n
  1. Lightweight for comfort and ease of carrying. Multi-layered combinations of lightweight clothes handle temperature differences well.
  2. \n
  3. Can be rolled up to reduce storage space.
  4. \n
  5. Cotton and linen for everyday wear, comfortable, machine washable under high water temperature for hygiene, and fast to dry in a dryer.
  6. \n
  7. Speed drying materials like AIRism for intense activities.
  8. \n
  9. Prefer Merino to HEATTECH. I feel the HEATTECH is not so good for warmth but it is very uncomfortable, while Merino is lightweight and breathable. I chose machine-washable Merino clothes, which can be washed inside a mesh bag or pillowcase in the gentle mode of a washing machine with pH-neutral detergent. When traveling, sometimes I use shampoo instead since Merino is basically sheep's hair. When using shampoo, I reduce the amount to avoid washing machine foam overflow. Merino is not suitable for a dryer, so I dry it flat on a rack, to avoid the weight of water stretching and deforming the clothes when hanging it on a hanger.
  10. \n
\n

EDC

\n\n

Go Bag

\n

I still don't have a go bag but I am planning to prepare one:

\n\n

Drink

\n

Water, milk (cow and soy), and juice.\nI seldom drink coffee or tea, and almost never drink alcohol.\nHowever, I do like drinking chocolate.\nI am thinking of getting a Revomax bottle for take away at the cafe to reduce one time plastic waste.\nI like its one-handed instant opening and closing lid.

\n

This page is inspired by uses.tech.

\n

Footnotes

\n
    \n
  1. \n

    Backblaze usually works out of the box and I can just let it run in the background. But occasionally it is slow to pick up new files for several hours and I need to manually trigger a rescan. If even this does not work, I need to inspect its log file. Be aware, Backblaze keeps the log of all file history and stores that log file on the internal drive (unrelocatable). Therefore if there is a lot of file renaming and movements, Backblaze may occupy a lot of internal disk space during years of usage. ↩

    \n
  2. \n
\n
","date_published":"Fri, 10 Jul 2020 14:36:17 GMT","date_modified":"Tue, 18 Aug 2026 16:55:36 GMT"},{"id":"https://mmap.page/dive-into/pyinfra/","url":"https://mmap.page/dive-into/pyinfra/","title":"Dive into Pyinfra","content_html":"

Dive into Pyinfra

\n

Pyinfra features:

\n
    \n
  1. Minimal dependencies for remote system (only shell).
  2. \n
  3. Write deploy files in Python.
  4. \n
\n

Install

\n
pip install pyinfra\n
\n

Ad-hoc

\n

I can run ad-hoc commands directly without writing any file.

\n
; pyinfra @local pip.packages pyinfra\n--> Loading config...\n--> Loading inventory...\n\n--> Connecting to hosts...\n    [@local] Connected\n\n--> Preparing operation...\n\n--> Proposed changes:\n    Groups: @local\n    [@local]   Operations: 1   Commands: 0\n\n--> Beginning operation run...\n--> Starting operation: Pip/Packages ('pyinfra',)\n    [@local] No changes\n\n--> Results:\n    Groups: @local\n    [@local]   Successful: 1   Errors: 0   Commands: 0/0\n
\n

Deploy File

\n

The best feature of pyinfra to me is writing deploy files in Python.

\n
# deploy.py\n\nfrom pyinfra.modules import pip\n\npip.packages(['pyinfra'])\n
\n

Execute it:

\n
; pyinfra deploy.py\n--> Loading config...\n--> Loading inventory...\n\n--> Connecting to hosts...\n    [@local] Connected\n\n--> Preparing operations...\n    Loading: deploy.py\n    [@local] Ready: deploy.py\n\n--> Proposed changes:\n    Groups: @local\n    [@local]   Operations: 1   Commands: 0\n\n--> Beginning operation run...\n--> Starting operation: Pip/Packages ('pyinfra',)\n    [@local] No changes\n\n--> Results:\n    Groups: @local\n    [@local]   Successful: 1   Errors: 0   Commands: 0/0\n
\n

Operations

\n

Global Arguments

\n\n

Refer to pyinfra/api/operation_kwargs.py for a complete list.

\n

Loops

\n

Actions are executed in orders, blockingly.\nHowever, operations in a loop are executed, nonblockingly.

\n

The following will not work, since multiple apt install commands cannot be run at the same time.

\n
for p in ['git', 'tmux', 'fish']:\n    apt.packages([p])\n
\n

Pyinfra provides state.preserve_loop_order for serializing execution:

\n
from pyinfra.api import state\n\nwith state.preserve_loop_order(['git', 'tmux', 'fish']) as loop_items:\n    for p in loop_items():\n        apt.packages([p])\n
\n

Note the above example is for demonstration only, the proper way should be:

\n
apt.packages(['git', 'tmux', 'fish'])\n
\n

Writing Operations

\n

Example in Python 3.6:

\n
# pkcon.py\nfrom typing import Generator, List, Dict, Union\nfrom pyinfra.api import operation\nfrom pyinfra.api.state import State\nfrom pyinfra.api.host import Host\n\n@operation\ndef update(state: State, host: Host) -> Generator[Dict[str, Union[str, List[int]]], None, None]:\n    '''Upgrade system via PackageKit console client.'''\n    command: Dict[str, Union[str, List[int]]] = {\n        'command': 'pkcon update --plain --noninteractive',\n        'success_exit_codes': [0, 5],  ## 5: no updates to install\n    }\n    # operation yields shell commands, so the target machine does not need Python.\n    yield command\n
\n

Note, the above code requires the following stub:

\n
# typings/pyinfra/api/operation.pyi\n# import statements omitted for brevity\ndef operation(func: Callable[[State, Host], Union[str, Dict[str, Union[str, List[int]]], Generator[str, None, None], Generator[Dict[str, Any], None, None]]],\n    pipeline_facts: Optional[Any] = ...) -> Callable[..., OperationMeta]: ...\n
\n

Use it as below:

\n
# deploy.py\nimport pkcon\npkcon.update()\n
\n

Operations can be packaged in deploys:

\n
# unix.py\nfrom pyinfra.api import deploy\nfrom pyinfra.api.state import State\nfrom pyinfra.api.host import Host\nfrom pyinfra.modules import python\nimport pkcon\n\n@deploy\ndef update(state: State, host: Host) -> None:\n    if host.fact.os == 'Linux':\n        if host.fact.linux_distribution[\"release_meta\"][\"ID\"] == 'neon':\n            # nested operations cannot omit state and host parameters\n            pkcon.update(state, host)\n        else:\n            python.raise_exception(state, host, NotImplementedError)\n    else:\n        python.raise_exception(state, host, NotImplementedError)\n
\n

Again, the above code requires the following stub:

\n
# typings/pyinfra/api/deploy.pyi\n# import statements omitted for brevity\ndef deploy(func_or_name: Union[Callable[..., None],str], data_defaults: Optional[Any] = ...) -> Callable[..., None]: ...\n
\n

Usage:

\n
# deploy.py\nimport unix\nunix.update()\n
\n

Inventory

\n

Currently, I have only played with Pyinfra on localhost.\nBut pyinfra can also manage remote machines.

\n
pyinfra example.com fact os\n
\n

To manage multiple servers, list them in inventory.py:

\n
; cat inventory.py\nvm = [\"a.example.com\", \"b.example.com\", \"c.example.com\"]\n; pyinfra inventory.py deploy.py\n
\n

Similar Projects

\n","date_published":"Sun, 14 Jun 2020 14:09:59 GMT","date_modified":"Mon, 05 Sep 2022 11:26:30 GMT"},{"id":"https://mmap.page/dive-into/wireguard/","url":"https://mmap.page/dive-into/wireguard/","title":"WireGuard Quick Start","content_html":"

WireGuard Quick Start

\n
\n

WireGuard is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography.

\n

-- www.wireguard.com

\n
\n

Client Side

\n

Install the WireGuard package / application for your operating system.

\n

Create key pairs:

\n
wg genkey | tee privatekey | wg pubkey > publickey\n
\n

Create configuration file:

\n
[Interface]\nAddress = 10.200.200.2/32, fd86:ea04:1111::2/128\nPrivateKey = <content of privatekey, base64 string>\nDNS = 1.1.1.1\n    \n[Peer]\nPublicKey = <content of server publickey, base64 string>\nEndpoint = <public ip of server:51820>\nAllowedIPs = 0.0.0.0/0, ::/0\nPersistentKeepalive = 25\n
\n

Interface is for this machine (client info here), and Peer is for other machine (server info here).

\n

10.200.200.2 and fd86:ea04:1111::2 are private IP addresses.\nI can specify any private IP addresses here,\nas long as the IP addresses are matched with private subnet assigned to the server.

\n

/32 is a subnet mask, which means one single IPv4.\nAs a client, this machine only need one IPv4 within the virtual network.\nSimilarly, /128 is a CIDR indicating one single IPv6.

\n

The DNS line is optional, which should be a DNS resolver which provides optimal resolutions for the server.\nHere I use 1.1.1.1 from cloudflare.

\n

Endpoint specifies how to access the server.\nThe IP can be IPv4 or IPv6, but typically IPv4, because the client machine may be under an IPv4-only network.\nThe port (51820 here) must match the ListenPort specified in the interface of the server.

\n

0.0.0.0/0, ::/0 means sending all traffic to the server.

\n

If the client is behind NAT, the router will need to translate its internal IP and port before forwarding the packets to the Internet.\nAnd the router will keep tracks of the connections in a Network Address Translation table.\nBased on this NAT table, it routinely closes off ports that appear dormant.\nIf the router erroneously closes the WireGuard port,\nthe WireGuard service, unaware of this change, will continue to send packets to the closed port.\nThis leads to network problems.\nPersistentKeepalive = 25 means sending a keeplive packet to the server every 25 seconds to prevent the NAT expiration (typically in 60 seconds for most routers).

\n

To enable the tunnel, run:

\n
sudo wg-quick up /path/to/wg0.conf\n
\n

To turn off the tunnel, run:

\n
sudo wg-quick down /path/to/wg0.conf\n
\n

If you use a GUI WireGuard application, you can import the configuration file instead.

\n

If you use the WireGuard mobile application, the fast way to import the configuration is scan a QR code:

\n
cat /path/to/wg0.conf | qrencode -t ansiutf8\n
\n

Multiple servers can be specified in multiple .conf files.

\n

Server Side

\n

Install the WireGuard package on server,\nthen generate key pairs as mentioned above.

\n

Create /etc/wireguard/wg0.conf:

\n
[Interface]\nAddress    = 10.200.200.1/24, fd86:ea04:1111::1/64\nPrivateKey = <content of privatekey, base64 string> \nListenPort = 51820\nPostUp   = iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE; ip6tables -t nat -A POSTROUTING -o ens3 -j MASQUERADE\nPostDown = iptables -t nat -D POSTROUTING -o ens3 -j MASQUERADE; ip6tables -t nat -A POSTROUTING -o ens3 -j MASQUERADE\n\n[Peer]\nPublicKey  = <content of client publickey, base64 string> \nAllowedIPs = 10.200.200.2/32, fd86:ea04:1111::2/128\n
\n

/24 is a subnet mask for 256 IPv4 addresses,\nsince an IPv4 address uses 32 bits, masking 24 bits leaves 8 bits (2 ** 8 = 256).\nIn the above example, 10.200.200.0 is preserved for compatibility reasons (IPv4 addresses ending with .0 are historically considered representing the network itself and used for broadcasting), and 10.200.200.1 is used by the server.\nThus this virtual network allows up to 254 clients.

\n

The subnet mask for IPv6 could be /120 (2 ** (128-120) = 256).\nHowever, IPv6 recommends using /64 as the smallest subnet, and a lot of software assumes an IPv6 subnet will not be smaller than /64.

\n

PostUp forwards Internet requests from clients, and ens3 is the network interface to access Internet on the server.\nPostDown deletes the iptable rules when the VPN is off.\nActually these are WireGuard hooks, you can fill any shell command here.

\n

A quick explanation of iptables rules:

\n\n

The PublicKey and AllowedIPs in the Peer section should match the configuration of the client.

\n

You can add more clients (multiple Peer sections).

\n

Enable forwarding IPv4 and IPv6 packets on the server:

\n
echo \"net.ipv4.ip_forward=1\" | sudo tee -a /etc/sysctl.conf\necho \"net.ipv6.conf.all.forwarding = 1\" | sudo tee -a /etc/sysctl.conf\nsudo sysctl -p\n
\n

sysctl modifies kernel parameters at runtime, and -p loads /etc/sysctl.conf.\nThis is only required on the server, since client allow Internet through server.

\n

Start WireGuard:

\n
sudo wg-quick up wg0\n# equivalent to `sudo wg-quick down /etc/wireguard/wg0.conf`\n
\n

Stop WireGuard:

\n
sudo wg-quick down wg0\n
\n

You may also add WireGuard service to your init system, e.g. systemd:

\n
sudo systemctl enable wg-quick@wg0.service\n
","date_published":"Sat, 22 Feb 2020 13:14:15 GMT","date_modified":"Tue, 06 Sep 2022 05:05:55 GMT"},{"id":"https://mmap.page/dive-into/rust/","url":"https://mmap.page/dive-into/rust/","title":"Dive into Rust","content_html":"

Dive into Rust

\n

Variable Shadowing

\n
let mut guess = String::new();\n\nio::stdin().read_line(&mut guess)\n    .expect(\"Failed to read line\");\n\nlet guess: u32 = guess.trim().parse()\n    .expect(\"Please type a number!\");\n\nconst CONSTANT: &str = \"a constant expression, not the result of a function call computed at runtime\";\nlet immutable_variable: &str = \"variables are immutable by default\";\nlet mut mutable_variable: u32 = 0;\nlet immutable_variable: &str = \"shadowing the previous immutable_variable, which is bad\";\nlet immutable_variable: u32 = 1;\n
\n

Data Types

\n

Scalar Types

\n\n

Compound Types

\n\n

Control Flow

\n

Condition must be a bool.\nNice!

\n

Enum

\n

Rust's enum is actually a tagged union.

\n

Generics

\n

Rust monomorphizes code that is using generics at compile time.

\n

Traits

\n

Rust's traits is similar to interface in other languages.

\n

Memory Management

\n

Rust does not use GC or RC.\nFor values on the heap, it only allow one variable \"own\" a value at a time.\nAssignment, passing a value to function and returning a value move the \"ownership\".\nAlso, Rust allows multiple immutable pointers (&) but only one mutable pointer (&mut),\nand restricts mixing immutable and mutable pointers to the same target.\nThe basic idea is to keep the number of reference to a value to one,\nto make memory management easier for the compiler.

\n
let s1 = String::from(\"A long long string\");\nlet s2 = s1 + \".\";\n
\n

Conceptually s2 can be considered as a newly constructed immutable variable,\nbut since the ownership moves from s1 to s2, and s1 becomes invalid afterwards,\nthe compiler just need to appends \".\" to the end of the value, which is efficient.

\n

Smart pointers can be used for reference counting.\nSmart pointers are structs satisfying Deref and Drop traits.

\n
enum List {\n    Cons(i32, Box<List>),\n    Nil,\n}\n
\n

In the above example, Box<List> is a smart pointer.\nWe use Box<List> to store the Box<List> data on the heap,\notherwise Cons(i32, List) will result in infinite size on the stack,\nwhich causes Rust failed to construct the List enum.

\n

To allow cons more than one lists from a same base list:

\n
enum List {\n    Cons(i32, Rc<List>),\n    Nil,\n}\n
\n

Rc is another smart pointer for reference counting.\nIt increases the reference counter on RC::clone(&l),\nand reduce the reference counter automatically when the related variable goes out of scope.\nWhen there are zero references, the value will be cleaned up.

\n

Be aware that Rc only works in single-thread context.\nIn multiple-threads context, use Arc instead.

\n

In Rust, functions and struts working with references need lifetime annotation.\nHowever, Rust can infer function lifetime in simplest cases:

\n\n

String literals have a 'static lifetime, which lives for the entire duration of the program.

\n
let b;\n{\n    let a = \"hi\";\n    b = a;\n}\nprintln!(\"{}\", b); // prints \"hi\"\n
\n

Lifetime annotation tells Rust compiler the lifetime of variables,\nbut it cannot alter the lifetime.

\n

Testing

\n

While Go use special function name TestXxx, Rust uses #[test] attribute annotation.

\n

Unit tests are written in mod tests, and integration tests are put in the test directory.

\n

Documentation Comments

\n

Three leading slashes /// with Markdown.

\n

Similar to Python, Rust also supports doctest:

\n
/// # Example\n///\n/// ```\n/// let foo = \"foo\";\n/// assert_eq!(foo, \"foo\");\n/// ```\n
\n

unsafe

\n

In the unsafe block (unsafe {}), you can:

\n","date_published":"Sun, 12 Jan 2020 17:27:44 GMT","date_modified":"Sat, 23 May 2020 15:44:13 GMT"},{"id":"https://mmap.page/dive-into/npm/","url":"https://mmap.page/dive-into/npm/","title":"Use npm without package.json","content_html":"

Use npm without package.json

\n

I abandoned this idea.\nIt does not work well with Node.js tooling and brings more unnecessary complexity.

\n

Why NOT package.json?

\n

package.json brings in unnecessary complexity.\nIf you do not think so, have a look at Go and Deno.

\n

Everyday Use without package.json

\n

Tell npm to not save package:

\n
npm config set save false\n
\n

Install development tools as global packages:

\n
npm i -g typescript\nnpm install -g eslint\nnpm i -g @zeit/ncc\n
\n

For temporal usage or test, use npx:

\n
npx cloc index.js\n
\n

npx can also be used to test different node versions:

\n
npx -p node@13 node -v\n
\n

Install dependencies as devDependencies:

\n
npm i -D express\nnpm i -D @types/express\n
\n

Use ncc to package runtime dependencies into a single JavaScript file:

\n
# install dependencies according to resolved urls to tarballs in package-lock.json\n@cat package-lock.json | jq '.dependencies[].resolved' | xargs npm i --no-package-lock\nncc build index.js --minify # output file: dist/index.js\n
\n

Then you can move the bundled index.js file to any place where Node.js is installed,\nand run it with node index.js without installing any npm modules.

\n

Alternative to npm run

\n

Just use plain old Makefile, e.g.

\n
dist/index.js: index.js\n\t@cat package-lock.json | jq '.dependencies[].resolved' | xargs npm i --no-package-lock\n\tncc build index.js --minify\n
","date_published":"Sun, 15 Dec 2019 10:31:56 GMT","date_modified":"Wed, 07 Sep 2022 07:44:01 GMT"},{"id":"https://mmap.page/dive-into/eslint/","url":"https://mmap.page/dive-into/eslint/","title":"An Opinionated Guide to ESLint/Oxlint","content_html":"

An Opinionated Guide to ESLint/Oxlint

\n

ESLint is a powerful and versatile tool.\nI myself only used ESLint for problems coming from JavaScript design and kept the rule list short.\nLater I switched to Oxlint, the high-performance successor of ESLint.

\n

No Formatting Rule

\n

Oxfmt, Biome, deno fmt (dprint), or prettier can be used without any configuration for code formatting.\nNo need to specify ESLint rules for code formatting.

\n

Oxfmt, Biome, and dprint are faster, while prettier supports more formats.\nAnd any of them is much faster than ESLint.

\n

Formatters can also help on some non-formatting lint rules.\nFor example, eslint's curly rule helps to avoid misleading code:

\n
if (condition)\n    do_something();\n    do_something_else();\n
\n

However, prettier will format the above code as below to avoid the above issue:

\n
if (condition) do_something();\ndo_something_else();\n
\n

In the code sample above, I use snake_case for function names.\nThe Python community favors snake_case:

\n
\n

Function names should be lowercase,\nwith words separated by underscores as necessary to improve readability.

\n

Variable names follow the same convention as function names.

\n

mixedCase is allowed only in contexts where that’s already the prevailing style\n(e.g. threading.py), to retain backwards compatibility.

\n

-- PEP 8

\n
\n

However, mixedCase is prevailing in the JavaScript/TypeScript community.\nThus, I use mixedCase for exported names.

\n

Among those formatters, I use Oxfmt since I already used Oxlint for linting.

\n

TypeScript Can Detect Lots of Errors

\n

TypeScript can detect a lot of problems, usually faster than ESLint.

\n

For example, the array-callback-return rule of ESLint is unnecessary,\nbecause if I accidentally forget to write return statement in array mapping function,\nit tends to trigger a type error.\neqeqeq is another example of an unnecessary rule,\nsince TypeScript complains when you are comparing two values of different types.

\n

TypeScript also has other helpful checks like noFallthroughCasesInSwitch which can be enabled via tsconfig.json.

\n

Only Include Obvious Rules

\n

Do not include rules such as no-new-object and no-nested-ternary,\nwhich are merely personal choice of programming style.

\n

The four Oxlint rules I use:

\n
// .oxlintrc.json\n{\n  \"rules\": {\n    \"no-multi-assign\": \"error\", // no `a = b = c = 1`\n    \"no-var\": \"error\", // use `const` and `let` instead of `var`\n    \"prefer-const\": \"error\", // use `const` when there is no reassignment\n    \"no-param-reassign\": \"error\" // use nonreassignable function parameters\n  }\n}\n
\n

When I was using ESLint, I also used an additional rule prefer-arrow-callback to avoid the evil this in JavaScript.\nUnfortunately, Oxlint (up to 1.62.0) does not support this rule yet.

\n

Oxlint supports TypeScript out of the box, so I do not need to add \"parser\": \"@typescript-eslint/parser\" as I did in ESLint.\nAlso, Oxlint still uses the legacy configuration format of ESLint, which I prefer over the new flat configuration format of recent versions of ESLint.

\n

Alternatives

\n

As mentioned above, I only use a minimal set of rules in ESLint/Oxlint.\nIf you prefer to use linter to catch common programming errors, you can consider Biome or quick-lint-ls, which are faster than ESLint and have built-in support for TypeScript.

","date_published":"Sat, 14 Dec 2019 12:37:15 GMT","date_modified":"Fri, 01 May 2026 14:59:35 GMT"},{"id":"https://mmap.page/dive-into/ts-check/","url":"https://mmap.page/dive-into/ts-check/","title":"Fight for Type Safety Stand with JavaScript","content_html":"

Fight for Type Safety Stand with JavaScript

\n

Note: This note is based on old versions of TypeScript and ReScript.

\n

TypeScript 2.3 and later support type-checking JavaScript files with JSDoc types.\nJSDoc uses the Closure Compiler's type language,\nwhich in turn is originally based on the abandoned ES4 spec.\nTherefore, to some extent, TypeScript can check against ES4 type language!

\n
/**\n * @template T, U\n * @typedef {U & { readonly __TYPE__: T}} Opaque */\n\n/** @typedef {Opaque<'age', number>} Age */\n/** @type {function(number): Age} */\nconst newAge = (n) => {\n  if (n < 0) {\n    throw new Error(\"age must be positive\")\n  } else {\n    return /** @type {Age} */(n)\n  }\n}\n
\n

ES4 Type Language Overview

\n

Take a glance at ES4 type language:

\n
/** @type {null} */\nconst nil = null\n\n/** @type {string?} */\nlet nullable = null\n\n/** @type {function(number, number): number} */\nconst functionType = (x, y) => x + y\n\n/**\n * function.<T>(T): T\n * @type {<T>(x: T) => T}\n */\nconst genericFunction = x => x\n\n/**\n * @type { {k: string} }\n */\nconst objectType = { k: \"structural\" }\n\n/**\n * (string, number)\n * @type {string  | number}\n */\nlet unionType = 0\n\n/**\n * [number]\n * @type {number[]}\n */\nconst arrayType = [1, 2, 3]\n\nconst immutableArray = /** @type {const} */ ([1, 2, 3])\n\n/**\n * @type {[string, number]}\n */\nconst tupleType = [\"one\", 1]\n\n/** @type {*} */\nlet dynamicType = null\n
\n

Note that TypeScript syntax differs from ES4 for the following types:

\n
    \n
  1. dynamic type: any vs *
  2. \n
  3. union type: A | B vs (A, B)
  4. \n
  5. array: T[] vs [T]
  6. \n
  7. function: (x: P) => R vs function(P): R
  8. \n
\n

Since Closure Compiler also uses * and function(P): R,\nand TypeScript tries to be compatible with Closure type syntax,\nTypeScript also accepts * and function(P): R in JSDoc type annotation.\nHowever, some function type cannot be expressed in function(P): R form,\ne.g. type guard and assertion signature:

\n
/** @typedef { {swim(): void;} } Fish */\n/** @typedef { {fly(): void;} } Bird */\n\n/** @type {(p: Fish | Bird) => p is Fish} */\nconst isFish =  (p) => /** @type {Fish} */(p).swim !== undefined\n\n/** @type {(p: Fish | Bird) => asserts p is Fish} */\nconst assertIsFish = (p) => {\n    if (/** @type {Fish} */(p).swim === undefined) {\n        throw new AssertionError(\"not a string\");\n    }\n}\n
\n

And there are other subtle differences,\ne.g. ES4 tuples should have at least two elements.\nBut let's just ignore these details for now.

\n

More Syntax Borrowed from Closure Compiler

\n

Type Alias

\n

Type aliases can be defined with the keyword @typedef:

\n
/** @typedef { {x: number, y: number} } Pointer */\n/** @type {Pointer} */\nconst typeAlias = { x: 0, y: 0 }\n
\n

Generic type parameters can be defined with the keyword template:

\n
/**\n * @template T, U\n * @typedef {U & { readonly __TYPE__: T}} Opaque */\n\n/** @typedef {Opaque<'age', number>} Age */\n/** @type {function(number): Age} */\nconst newAge = (n) => {\n  if (n < 0) {\n    throw new Error(\"age must be positive\")\n  } else {\n    // Type cast requires parenthesized expression.\n    return /** @type {Age} */(n)\n  }\n}\n
\n

Enum

\n

@enum is also borrowed from Closure Compiler's type system,\nand is quite different from TypeScript's enum.

\n
/**\n * @enum {function(number): number}\n */\nconst immutableObjectLiteral = {\n  /** @type {function(number)} */\n  succ: n => n + 1,\n  /** @type {function(number)} */\n  pred: n => n - 1\n}\n
\n

Function Overloads

\n
/**\n * @param {string} input\n * @returns {string} result\n *//**\n * @param {number} input\n * @returns {string} result\n */\nfunction notSupported(input) { /* omit */ }\n
\n

Instead, TypeScript supports a new @overload tag.

\n

Import Types

\n

Use import(\"module\").Type to import types:

\n
/** @type { import(\"m\").T } */\n
\n

This is often used in type aliases for brevity:

\n
/** @typedef { import(\"module-name\").LongTypeName } ShortName */\n
\n

But if you have difficulties in expressing certain types in JSDoc comments,\nyou can also declare the type in a separate TypeScript file,\nthen import it in JSDoc comments.

\n

Type Checking

\n

Just create a jsconfig.json file under the root of the project.

\n

It is possible to check JavaScript files without the jsconfig.json file\nwith writing magic comment // @ts-check\nor setting a configuration option in vscode.\nBut I prefer the jsconfig.json way, since I tend to set up some compiler options.

\n

Why

\n

Actually ES4 type system is quite different from TypeScript.\nFor example, they have different subtype rules.\nAlso, the JSDoc way of TypeScript type checking lacks some features,\nfor example, there is no way to pass type parameter when invoking generic functions via JSDoc.\nThe only thing we can do is let TypeScript infer the type parameter.\nIf it fails to infer the type, we have to accept any as the type parameter.\nAnother example is TypeScript cannot parse conditional types in JSDoc comments correctly. (#27424)

\n

So why not code in TypeScript instead?

\n

Possible reasons:

\n
    \n
  1. Get rid of the compilation step.
  2. \n
  3. Avoid using TypeScript features unavailable in ECMAScript.
  4. \n
  5. Secretly migrate a JavaScript project to TypeScript when other project developers do not want to switch to TypeScript.
  6. \n
\n

Alternatives

\n

An alternative approach for a secret migration from JavaScript is to rewrite them in ReScript,\nand use genType to generate TypeScript files.

\n
/* TypeScript file generated from index.res by genType. */\n/* eslint-disable import/first */\n\n// @ts-ignore: Implicit any on import\nimport * as indexBS__Es6Import from './index.bs';\nconst indexBS: any = indexBS__Es6Import;\n\n// tslint:disable-next-line:interface-over-type-literal\nexport const h1: (line:string) => string = indexBS.h1;\n
\n

This TypeScript files work, but the indexBS part is not perfectly human-readable.\nThe TypeScript compiler can be used to generate corresponding .d.ts files.

\n
export declare const htm: (text: string) => string;\n
\n

This approach also brings in a sound type system.

","date_published":"Sat, 14 Dec 2019 09:11:48 GMT","date_modified":"Tue, 27 Aug 2024 11:32:47 GMT"},{"id":"https://mmap.page/dive-into/rarcrack/","url":"https://mmap.page/dive-into/rarcrack/","title":"RarCrack Basic Guide","content_html":"

RarCrack Basic Guide

\n

This note is written for RarCrack 0.2.

\n

RarCrack brute-forces password for encrypted zip, rar, 7z files.

\n
rarcrack FILE_NAME --threads 4\n
\n

Note that if --threads is omitted, RarCrack will use 2 threads, no matter how many cores your CPU has.

\n

You can cancel the brute forcing (e.g. via Ctrl-c) at any time,\nand RarCrack will resume cracking at next startup.\nThis is because RarCrack uses a status file FILE_NAME.xml at the same directory to record progress.

\n

And this mechanism can be used to speed up cracking.\nFor example, if you remember that the password is 6 digits:

\n
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rarcrack>\n  <abc>0123456789</abc>\n  <current>000000</current>\n  <good_password/>\n</rarcrack>\n
\n

For zip and 7z files, an alternative to RarCrack is fcrackzip.\nAnd it has more features, e.g. specifying password range and using a dictionary.\nHowever, last time I tried to fcrackzip a zip file,\nit reported that the zip file is corrupt.\nAnd RarCrack successfully cracks the very zip file.

","date_published":"Sat, 23 Nov 2019 20:12:03 GMT","date_modified":"Tue, 06 Sep 2022 05:05:55 GMT"},{"id":"https://mmap.page/dive-into/puppet/","url":"https://mmap.page/dive-into/puppet/","title":"A Basic Guide for New Marionettists","content_html":"

A Basic Guide for New Marionettists

\n

TLDR

\n

This article only covers the so-called masterless mode, a.k.a. puppet apply,\nbecause the master-slave mode is unethical and bolt sounds violent. On the other hand, puppet apply plays the role of both master and slave, which is considered not unlikely inoffensive.

\n

Puppet uses a declarative DSL, i.e. describing the state of puppets. Below is an example from the official document:

\n
case $operatingsystem {\n  centos, redhat: { $service_name = 'ntpd' }\n  debian, ubuntu: { $service_name = 'ntp' }\n}\n\npackage { 'ntp':\n  ensure => installed,\n}\n\nservice { 'ntp':\n  name      => $service_name,\n  ensure    => running,\n  enable    => true,\n  subscribe => File['ntp.conf'],\n}\n\nfile { 'ntp.conf':\n  path    => '/etc/ntp.conf',\n  ensure  => file,\n  require => Package['ntp'],\n  source  => \"puppet:///modules/ntp/ntp.conf\",\n}\n
\n

This guide applies to Puppet 6.7.

\n

Quick Start

\n

Install the puppet-agent package (which provides puppet apply),\nfollowing the instructions at official document.

\n

As an oversimplified example, I wrote a script to ensure git is installed:

\n
# filename: laptop.pp\npackage {'git':\n  ensure => installed\n}\n
\n

Validate its syntax:

\n
puppet parser validate laptop.pp\n
\n

In practice, this is mainly for CI,\nsince a decent editor should have warned you if you made some syntax mistakes.

\n

Rehearse the play (dry run):

\n
puppet apply --noop laptop.pp\n
\n

It's show time: (run as root since installing package usually requires root permission)

\n
puppet apply laptop.pp\n
\n

You can also pass a directory instead of a file to puppet apply.\nBut in this case Puppet combines all files under that directory as one script,\nwithout isolated scope.\nThus I prefer use one file.

\n

Puppet DSL

\n

Style

\n

The Puppet community prefers snake_case and two spaces soft tab.

\n

Selector Expression

\n

Selector expression returns a value.\nFor example, the case \"statement\" in the beginning code sample:

\n
case $operatingsystem {\n  centos, redhat: { $service_name = 'ntpd' }\n  debian, ubuntu: { $service_name = 'ntp' }\n}\n
\n

can be rewritten as:

\n
$service_name = $operatingsystem ? {\n  centos, redhat => 'ntpd',\n  debian, ubuntu => 'ntp',\n}\n
\n

Strictly speaking, they are not semantically equivalent.\nIf the os failed to match, the former will do nothing,\nwhile the later will refuse to compile.

\n

However, the if and case \"statements\" are actually expressions,\nreturning the value of the last expression in the executed block\nor undef when no block was executed.

\n

Puppet Defaults

\n

Puppet DSL has a wired syntax (capitalizing type name) for declaring defaults for a specific type of puppet:

\n
# Set default values for the path attribute of the exec puppet.\nExec {\n  path => '/usr/bin:/bin:/usr/sbin:/sbin',\n}\n
\n

The more wired part is, puppet defaults are dynamically scoped!

\n

Therefore, using per-expression defaults is preferred.\nBelow is an example from the official document:

\n
file {\n  default:\n    ensure => file,\n    owner  => \"root\",\n    group  => \"wheel\",\n    mode   => \"0600\",\n  ;\n  ['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:\n    # use all defaults\n  ;\n  ['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:\n    # override mode\n    mode => \"0644\",\n  ;\n}\n
\n

Puppet Collector

\n

This is sometimes called the \"spaceship operator\",\nwhich selects a group of puppets via attribute searching:

\n
User <| groups == 'wheel' |>\n
\n

Besides ==, there are other operators, !=, and, and or.

\n

Lazy Puppet

\n

The at (@) prefix marks a puppet declaration as lazy:

\n
@user {'ubuntu':\n  uid => 1000,\n  comment => 'default user',\n  group => wheel,\n}\n
\n

Lazy puppets will not be applied until:

\n
    \n
  1. explicitly realized, e.g. realize User['ubuntu'], or
  2. \n
  3. implicitly realized by a matched collector, e.g. User <| group == wheel |>.
  4. \n
\n

Glossary

\n

This guide uses different terms to the official Puppet documentation.\nThese are just my personal preference.\nFor example, the script term used in this guide is called manifest in the official Puppet documentation.\nIn my opinion, script makes more sense than manifest.\nIn fact, chef refers to the similar notation as recipe.

\n","date_published":"Sat, 03 Aug 2019 08:34:35 GMT","date_modified":"Sun, 24 May 2020 13:58:17 GMT"},{"id":"https://mmap.page/dive-into/react/","url":"https://mmap.page/dive-into/react/","title":"A Quick Introduction to React","content_html":"

A Quick Introduction to React

\n

Hello World

\n
import React, { ReactElement } from \"react\"\nimport ReactDOM from \"react-dom\"\n\n\ntype HelloProps = { readonly name: string }\n\nfunction Hello({ name }: HelloProps): ReactElement<HelloProps> {\n  return <button>Hello {name}!</button>\n}\n\nconst helloWorld: ReactElement<HelloProps> = <Hello name=\"World\" />\n\nconst rootElement: HTMLElement = document.getElementById(\"root\")\nReactDOM.render(helloWorld, rootElement)\n
\n

React Components

\n

The Hello function is a React component,\nwhich receives an object containing properties,\nand returns a ReactElement.\nHere I do not plan to change the value of the name property,\nso I annotate it as readonly.\nBut these properties can be mutable.\nReactElements can be considered as extensible html elements,\nor some content to be rendered.\nA react component may return null for conditional rendering.

\n

Hooks

\n

Hooks decouple state related logic from components.\nLike components, hooks are just functions, nothing magical:

\n
const SimpleReact = (function() {\n    let state\n    return {\n      render(Component) {\n        const C = Component()\n        C.render()\n        return C\n      },\n      useState(initialValue) {\n        state = state || initialValue\n        function setState(newValue) {\n          state = newValue\n        }\n        return [state, setState]\n      }\n    }\n})()\n\nconst useState = SimpleReact.useState\nconst render = SimpleReact.render\n\nfunction useCountCharacters(str) {\n    const [text, setText] = useState(str)\n    const len = text.length\n    return [len, setText]\n}\n\nfunction Component() {\n    const [len, setLen] = useCountCharacters(\"\")\n    return {\n      type: txt => setLen(txt),\n      render: () => console.log({ len })\n    }\n}\n\nlet App = render(Component) // { len: 0 }\nApp.type('hello')\nApp = render(Component) // { len: 5 }\n
\n

The real React will re-render components on state changes automatically.\nAnd there are other kind of hooks, e.g. useEffect for side-effects, triggered on state changes.\nAlso, the real React can handle multiple hooks, which can be considered as an array of hooks.\nWhatever, the above naive implementation captures the essence of React Hooks.

\n

JSX

\n

<button>Hello {name}!</button> and <Hello name=\"World\" /> are JSX,\nan extension to JavaScript, or a DSL to express DOM elements.\nTypeScript has excellent support for JSX. Thus JSX can be considered as typed HTML template expressions.

\n

Component names such as Hello begin with an uppercase letter,\nwhile intrinsic HTML elements such as button begin with a lowercase letter.\nCertain attributes in HTML are renamed to resolve conflicts with TypeScript keywords.\nFor example, the class attributes are renamed to className in JSX.

\n

A component cannot directly return multiple elements.\nTo return multiple elements, nest them inside a div element, then return that div.\nSometimes returning an div element is not possible.\nFor example, nesting multiple <td> elements in div results in invalid HTML.\nAnd sometimes, you just do not want to wrap them inside a div element.\nUnder such conditions, you can wrap them inside a <React.Fragment>,\nwhich can be considered as a seamless div element.

\n

<React.Fragment> accepts an optional key attribute,\nwhich is its only acceptable attribute.\nFor example:

\n
// type annotations omitted for brevity\nfunction Glossary({ items }) {\n  return (\n    <dl>\n      {items.map(item => (\n        <React.Fragment key={item.id}>\n          <dt>{item.term}</dt>\n          <dd>{item.description}</dt>\n        </React.Fragment>\n      ))}\n    </dl>\n  )\n}\n
\n

key is a special attribute for React to identify member element in a list.\nIt helps React to detect which members have changed, added, or removed.

\n

JSX is syntax sugar for calling React.createElement,\nfor example, <Hello name=\"World\" /> is equivalent to:

\n
React.createElement(Hello, { name: \"World\" });\n
\n

So JSX is optional, you can use React without JSX.

\n

Styling

\n

React does not have an opinion about how styles are defined.\nYou can define styles in separate *.css files.\nHowever, I prefer to define styles in TypeScript than CSS.\nYou can check this comparison of CSS-in-JS.\nAgain, there are a lot of choices.

\n

Among those projects, I checked the five projects written in TypeScript:

\n\n

stylable has a syntax similar to CSS, while typestyle just uses object literals (no custom AST transform).\nAs I said before, I want to define styles in TypeScript, thus I pick typestyle.

\n

Alternative Implementations

\n
    \n
  1. \n

    Preact is the most popular alternative implementation.\nIt is small (3KB gzipped) and fast.\nHowever, to leverage many React libraries, preact/compat is required.\nThis compatibility layer is slow.

    \n
  2. \n
  3. \n

    Inferno is a faster alternative implementation.\nUnlike Preact, it is not that obsessed about the size (but still small).\nLike Preact, its compatibility layer inferno-compat has extra overhead.\nAlso, hooks is not supported yet.

    \n
  4. \n
  5. \n

    Nerv is yet another small alternative implementation.\nIt features compatibility with IE 8 and a more identical React API.\nThus there is no nerv-compat.

    \n
  6. \n
\n

References

\n
    \n
  1. Learn React in 10 tweets
  2. \n
  3. Deep dive: How do React hooks really work?
  4. \n
","date_published":"Tue, 07 May 2019 16:38:38 GMT","date_modified":"Tue, 06 Sep 2022 05:05:55 GMT"},{"id":"https://mmap.page/dive-into/cyclejs/","url":"https://mmap.page/dive-into/cyclejs/","title":"Dive into Cycle.js","content_html":"

Dive into Cycle.js

\n

Core Abstraction

\n

Cycle.js has a simple core abstraction:\nan application is a pure main() function,\nwhose input (sources) and output (sinks) are effects of the external world,\nmanaged by plugins (drivers).

\n

\"dataflow\"

\n

The primitives used inside the main function is reactive streams.\nThus Cycle.js applications are entirely this free and have nothing like setState() or update().

\n

The separation between function and drivers allows for great extensibility (easy to swap drivers) and testability (easy to test pure functions).

\n

This abstraction also allows for awesome composablity:\nthe main function of every Cycle.js application is also a reusable function in main function of another Cycle.js application.\nSources and sinks are not only the interface between main function and the drivers, but also the interface between a child component and its parent.

\n

\"nested-components\"

\n

Example

\n

The core API of Cycle.js is run(main, drivers).

\n
import {Stream} from \"xstream\";\nimport {run} from '@cycle/run'\nimport {div, label, input, hr, h1, makeDOMDriver, DOMSource, VNode} from '@cycle/dom'\n\ninterface Sources {\n  Dom: DOMSource\n}\n\ninterface Sinks {\n  Dom: Stream<VNode>\n}\n\n\nfunction main(sources: Sources): Sinks {\n  const input$ = sources.Dom.select('.field').events('input')\n\n  const name$ = input$.map(ev => (ev.target as HTMLInputElement).value).startWith('')\n\n  const vdom$ = name$.map(name =>\n    div([\n      label('Name:'),\n      input('.field', {attrs: {type: 'text'}}),\n      hr(),\n      h1(`Hello ${name}`),\n    ])\n  )\n\n  return { Dom: vdom$ }\n}\n\nrun(main, { Dom: makeDOMDriver('#app-container') })\n
\n

The above code is adapted from the JavaScript hello world sample on the frontpage of Cycle.js official website. I use TypeScript instead.

","date_published":"Sun, 17 Mar 2019 18:51:51 GMT","date_modified":"Sun, 24 May 2020 13:58:17 GMT"},{"id":"https://mmap.page/dive-into/tinygo/","url":"https://mmap.page/dive-into/tinygo/","title":"Tinygo","content_html":"

Tinygo

\n

This short introduction is outdated and unmaintained.\nPlease refer to the official TinyGo documentation instead.

\n

Tinygo is a Go compiler for microcontrollers and WebAssembly.\nIt also supports x86 32 bit and 64 bit Linux.

\n

Getting Started

\n

Install

\n
sudo apt install llvm-7-dev libclang-7-dev\ngo get -u github.com/tinygo-org/tinygo\n
\n

Usage

\n

To compile a Linux executable:

\n
tinygo build -o hello_tiny hello.go\n
\n

The output size of a hello world program is very impressive to me:

\n
1.1M    hello\n12K     hello_tiny\n
\n

Or run it directly:

\n
tinygo run hello.go\n
\n

Go Language Features

\n

Not supported:

\n","date_published":"Sat, 02 Mar 2019 04:35:01 GMT","date_modified":"Mon, 05 Sep 2022 10:56:44 GMT"},{"id":"https://mmap.page/dive-into/gitmoji/","url":"https://mmap.page/dive-into/gitmoji/","title":"13 Short Gitmojis","content_html":"

13 Short Gitmojis

\n

Summary

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
emojicodeusage
🐛:bug:bug fix
🆕:new:new feature
🔥:fire:remove feature
💥:boom:breaking changes
🔒:lock:security fix
🎨:art:refactor
⚡️:zap:performance
💯:100:test
📝:memo:doc
💤:zzz:chore
🎉:tada:release
💩:poop:dirty
🥚:egg:Easter eggs
\n

See AGENTS for configuration details.

\n

Features

\n\n

Comparison with gitmoji and Atom style guide

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
emojiusagegitmojiatom
🐛bug fix🐛🐛
🆕new feature✨n/a
🔥remove feature🔥🔥
💥breaking changes💥n/a
🔒security fix🔒🔒
🎨refactor♻️🎨
⚡️performance⚡️🐎
💯test✅✅
📝doc📝📝
💤chore🚀 or 💚n/a
🎉release🔖n/a
💩dirty💩n/a
🥚Easter eggs🥚n/a
\n

Change Log

\n

0.1.0

\n\n

0.0.2022

\n

The following new emojis are added:

\n\n

0.0.0

\n

The initial version.\nI built a list of emojis based on the intersection of gitmoji and the Atom style guide,\nremoving emojis whose code are too long, and adding the following emojis:

\n","date_published":"Sat, 02 Feb 2019 07:14:45 GMT","date_modified":"Wed, 15 Jul 2026 11:26:55 GMT"},{"id":"https://mmap.page/dive-into/typescript/","url":"https://mmap.page/dive-into/typescript/","title":"Notes on TypeScript","content_html":"

Notes on TypeScript

\n

Top and Bottom Types

\n

Unlike Anything or Any in most static typed languages,\nany supports the same operations as a value in JavaScript\nand minimal static type checking is performed.\nTypeScript's unknown is more similar to Any (top type) in other languages.

\n

TypeScript's bottom type is never, which is called Nothing in some languages.

\n
const verifyCasesAreExhaustive = (kind: \"x\" | \"y\" | \"z\") => {\nswitch (kind) {\n    case \"x\":\n        return 1\n    case \"y\":\n        return 2\n    case \"z\":\n        return 3\n    default:\n        const nothing: never = kind\n        throw(nothing)\n}\n}\n
\n

Function Overloads

\n

Considering the following definition:

\n
function plus(x: number, y: 0): boolean;\nfunction plus(x: number, y: number): number;\nfunction plus(x: string, y: string): string;\n// function plus(x: number, y: string): boolean;\n// function plus(x: string, y: number): boolean;\nfunction plus(x: number | string, y: number | string): number | string | boolean {\n    if (typeof x == \"number\" && typeof y == \"number\") {\n        if (y === 0) {\n            return false\n        } else {\n        return x + y;\n        } \n    } else if (typeof x == \"string\" && typeof y == \"string\") {\n        return `${x}${y}`; // equivalent to `x + y`.\n    } else {\n        return false;\n    }\n}\n\nIn early versions of TypeScript (e.g. [v3.5.1]),\nthe following code gives misleading error information:\n\n```typescript\nplus(\"1\", 0)\n// error: Argument of type '0' is not assignable to parameter of type 'string'.\n
\n

Readers may wonder why TypeScript does not match (\"1\", 0) against plus(x: number | string, y: number | string).

\n

However, recent versions of TypeScript (e.g. v5.3.2) provides clearer message:

\n
plus(\"1\", 0)\n// The call would have succeeded against this implementation,\n// but implementation signatures of overloads are not externally visible\n
\n

Type Equality

\n

With TypeScript's conditional types, testing type equality is intuitive:

\n
type EqEq<T, S> = [T] extends [S] ? ([S] extends [T] ? true : false) : false\n\ntype FunctionOverloadsEquality = EqEq<\n    { (x: 0, y: null): void; (x: number, y: null): void },\n    { (x: number, y: null): void; (x: 0, y: null): void }> // true\n\ntype F = (x: 0, y: null) => void\ntype G = (x: number, y: string) => void\ntype FunctionIntersectionEquality = EqEq<F & G, G & F> // true\n
\n

The Crazy satisfies Operator

\n

Below is the example given in What's New in TypeScript 4.9:

\n
type Colors = \"red\" | \"green\" | \"blue\";\ntype RGB = [red: number, green: number, blue: number];\nconst palette = {\n    red: [255, 0, 0],\n    green: \"#00ff00\",\n    bleu: [0, 0, 255]\n//  ~~~~ The typo is now caught!\n} satisfies Record<Colors, string | RGB>;\n// Both of these methods are still accessible!\nconst redComponent = palette.red.at(0);\nconst greenNormalized = palette.green.toUpperCase();\n
\n

IMHO, this shows the craziness of TypeScript.\nWhy green is encoded as hex string but red and blue are encoded as RGB arrays?\nWhat if one day someone refactors the code and change green to an RGB array?\nAnd in real world application, I would rather make all colors encoded as hex strings or RGB arrays,\nbut not a mix of them.\nThen the getComponent or displayHex will be implemented assuming input is either a hex string or an RGB array.

","date_published":"Sun, 13 Jan 2019 08:52:16 GMT","date_modified":"Mon, 18 Dec 2023 18:37:33 GMT"},{"id":"https://mmap.page/thoughts/","url":"https://mmap.page/thoughts/","title":"Thoughts","content_html":"

Thoughts

\n

Some random thoughts.

","date_published":"Thu, 06 Dec 2018 08:01:12 GMT","date_modified":"Tue, 25 Apr 2023 08:48:15 GMT"},{"id":"https://mmap.page/thoughts/express-more-in-code/","url":"https://mmap.page/thoughts/express-more-in-code/","title":"Express more in code","content_html":"

Express more in code

\n

Code tends to be clearer and more precise.

\n

Math formula

\n

The traditional math language has a lot of issues:

\n\n

Instead of writing E = mc^2, I'd rather just write e = m * (c ** 2).

\n

Tables

\n

Most tables can be converted to code in a clear way. For example:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
StrengthDexterityConstitution
9 (-1)11 (+0)10 (+0)
\n

Via direct variable declaration:

\n
strength = 9;\nstrength_modifier = -1;\ndexterity = 11;\ndexterity_modifier = 0;\nconstitution = 10;\nconstitutito_modifier = 0;\n
\n

Or via a data structure:

\n
class AbilityScore(Integer score) {\n  assert(score >= 1 && score <= 30);\n  shared Integer modifier => floor((score - 10) / 2.0).integer;\n}\nvalue strength = AbilityScore(9);\nvalue dexterity = AbilityScore(11);\nvalue constitution = AbilityScore(10);\n
\n

In fact, the later form reveals the relationship between ability and modifier.

\n

Choices of language

\n

A lot of programming languages suffer from design flaws or lack of ecosystem,\nbut usually these issues do not affect brief code samples.\nThus, most languages are fine.

\n

If a language with C like syntax is chosen,\nthen it is recommended to use the Java style (opening braces on same line)\nand an indent level of 2 spaces.\nThis saves space and does not harm readability for brief code samples.

\n

The most popular choice seems Python,\nwhich is the most used language in the Jupyter ecosystem.

","date_published":"Thu, 06 Dec 2018 00:53:57 GMT","date_modified":"Mon, 05 Sep 2022 14:05:34 GMT"},{"id":"https://mmap.page/dive-into/kotlin/","url":"https://mmap.page/dive-into/kotlin/","title":"On Design of Kotlin","content_html":"

On Design of Kotlin

\n

Good parts

\n

Assignments are not expressions

\n
if (a = 1) { println(2) }\nerror: assignments are not expressions, and only expressions are allowed in this context\n
\n

Not nullable by default

\n

By default values are not nullable. Nullable values are declared as T?.

\n

Bad parts

\n

Type erasure

\n
\n

Like Java’s, Kotlin’s generics are not retained at runtime,\ni.e. objects do not carry information about actual type arguments\npassed to their constructors, i.e.\nArrayList<Integer>() is indistinguishable from ArrayList<Character>().\nThis makes it impossible to perform is-checks\nthat take generics into account.\nKotlin only allows is-checks for star-projected generic types.

\n
\n

-- Kotlin Reference

\n

Because they thought reified generics are expensive on JVM:

\n
\n

on the JVM reified generics are expensive

\n
\n

-- Kotlin Blog: M10 is out

\n

But

\n
\n

FTR I am not sure I believe that explanation.\nI was with Gavin a few years ago\nwhen Andrey Breslav asked us\nif we were going to implement reified generics\n(we had not yet at the time)\nbecause they were having trouble implementing it\nand so if we were not going to implement it, they would not bother.

\n

My guess is they tried and failed, strictly based on this conversation.\nIt's possible that they really considered it too expensive,\nbut I since that's not backed by public experiments\nand our own experiments tell us\nit's not that expensive for the benefits it gives us,\nI don't have to believe them ;)

\n
\n

-- UnFroMage commented on HackerNews

\n

No union types

\n

No union types yet. (547)

\n

No checked exceptions

\n

Kotlin does not support checked exceptions.

\n

I think the good part of checked exception is\nto force you think about corner cases,\nand the bad part is increasing verbosity.

\n

Ceylon does not support checked exceptions either.\nBut Ceylon supports union types.\nIn fact, Java's checked exception mimics union types.

\n

Kotlin supports neither checked exception, nor union types.\nThus its type system cannot check whether a function may raise an exception\n(unless the exception is representable as null)\nand what exceptions it may raise.

\n

However, throwing one exception is a good practice in common situations.

\n
\n

The reason that you would, ideally, want to only throw one type of exception\nis because doing otherwise likely violates the Single Responsibility and\nDependency Inversion principles.

\n

...

\n
public String getData(int id) throws FileNotFoundException\n
\n

Now, we have a change in requirements, and our data comes from a database.

\n

...

\n
public String getData(int id) throws SQLException\n
\n

We would now have to go through all code that uses our method\nand change the exception we have to check for, else the code won't compile.

\n

Dependency inversion says that we really shouldn't throw either\nof these exceptions\nbecause they expose internal implementation details\nwe are working to encapsulate.\n...\nInstead we should throw an exception\nthat conveys the error at the same level of abstraction\nas we are exposing through our API.

\n
\n

-- cbojar, 2014-11-29

\n

For a similar reason, Swift just uses throws in function signature,\nto declare a function which may throw exceptions,\nwithout specifying types of exception.

\n

Another reason to throw only one exception is Single Responsibility:

\n
\n

As for Single Responsibility, we need to think about code\nthat throws multiple, unrelated exceptions.\nLet's say we have the following method:

\n
public Record parseFile(String filename) throws IOException, ParseException\n
\n

What can we say about this method? We can tell just from the signature\nthat it opens a file and parses it.\nWhen we see a conjunction, like \"and\" or \"or\"\nin the description of a method,\nwe know that it is doing more than one thing;\nit has more than one responsibility.\nMethods with more than one responsibility are hard to manage\nas they can change if any of the responsibilities change.\nInstead, we should break methods up so they have a single responsibility:

\n
public String readFile(String filename) throws IOException\npublic Record parse(String data) throws ParseException\n
\n
\n

-- cbojar, 2014-11-29

\n

Mixed feelings

\n

return behaves differently in lambda and anonymous function

\n

Kotlin distinguishes lambda expression and anonymous function.\nIn lambda, return returns from the outer function.

\n

This reminds me of the dark side of Ruby.\nRuby also distinguishes proc created by lambda expression and Proc.new.\nIn Ruby,the return statement in proc created by Proc.new\nwill not only returns control just from itself,\nbut also from the method enclosing it.

\n

To be fair, Kotlin is more reasonable than Ruby.\nIn Kotlin, lambda does not allow explicit return result expression.

\n

Use when for both case and cond in Scheme

\n

Kotlin uses when for both case (pattern matching)\nand cond (conditional expression) in Scheme.

\n
when {\n    f(i) -> false  // f = { it == 0}\n    else -> true\n}\nwhen (i) {\n    g(i) -> false  // g = { if (it == 0) 0 else 1 }\n    else -> true\n}\n
\n

Unless you remember the definition of f or g,\nyou does not know whether it is pattern matching or conditional expressions\nuntil you go back to the beginning of the when expression.

\n

A workaround is to make it explicit using the full expression of condition:

\n
when {\n    f(i) == true -> false  // f = { it == 0}\n    else -> true\n}\nwhen (i) {\n    g(i) -> false  // g = { if (it == 0) 0 else 1 }\n    else -> true\n}\n
\n

Or use an explicit function name:

\n
when {\n    isZero(i) -> false  // isZero = { it == 0}\n    else -> true\n}\nwhen (i) {\n    matchesZero(i) -> false  // matchesZero = { if (it == 0) 0 else 1 }\n    else -> true\n}\n
\n

This workaround does not work when i itself is a Boolean.

\n

However, if i is a Boolean, usually we will use when as:

\n
when (i) {\n    true -> ...\n    false -> ...\n}\n
\n

Ambiguity does exist\nwhen we match i against Boolean value returned by other functions.

\n

Boxed types in Java

\n

Some types are boxed in Java, which does not preserve identity, and often preserve equality.

\n
val a: Int = 10000\nprint(a === a) // Prints 'true'\nval boxedA: Int? = a\nval anotherBoxedA: Int? = a\nprint(boxedA === anotherBoxedA) // !!!Prints 'false'!!!\nprint(boxedA == anotherBoxedA) // Prints 'true'\n
\n

This confuses me.\nI understood that interoperability is important, though.

\n

String templates

\n

String templates are supported both inside raw strings and inside escaped strings. If you need to represent a literal $ character in a raw string (which does't support backslash escaping), you can use the following syntax):

\n
val price = \"\"\"\n${'$'}9.99\n\"\"\"\n
\n

${'$'} looks ugly to me.\nAnd dollar signs are common in text for prices.\nAnd I wonder whether raw strings with templates are truly raw.\nEven if we did need templates in raw string,\nI think restricting it to ${var} is better.\nPut this under \"mixed feeling\" rather than \"bad parts\",\nbecause I think this is trivial after all.

\n

Conclusion

\n

Kotlin is an improved Java, featuring interoperability.\nMost features are already in Java as \"best practices\".

\n

On other side, it lost checked exception.

\n

Read more on my opinions on the design of Kotlin in Ceylon v.s. Kotlin

","date_published":"Thu, 06 Dec 2018 00:53:57 GMT","date_modified":"Sun, 23 Apr 2023 04:25:20 GMT"},{"id":"https://mmap.page/dive-into/exceptions/","url":"https://mmap.page/dive-into/exceptions/","title":"Exception and Union Type","content_html":"

Exception and Union Type

\n

Java has checked exception, which is essentially union type.

\n

Kotlin dislikes Java's checked exception, and just removes it.

\n

Ceylon also does not have checked exception, but it has union types.

\n

Swift has something like semi-checked exception.\nUnlike Java, a Swift function can only declare if it may throw an exception or not.\n(Specifying throws in function signature.)\nBut it cannot specify types of exception.\nThus if the caller of the function tries to catch the exception,\nit must have a default catch all clause in the end.\nAnd since Swift only distinguish functions may throw and may not throw,\nit is straightforward to map a function's throwability to optional type\n(via try?).

\n

Optional Type and Union Type

\n

T? can be considered as a union of T|Null.

\n

(J|K) -> T can be expressed as overloads.

\n

More on Exception and Union Type

\n
\n

Checked exception is an imperfect, ugly implementation of union type.

\n
\n

-- Yin Wang

\n

For example, String f() throws NotFound can be considered as a function returning a union type of String | NotFound.

\n

From the viewpoint of union type, String | NotFound and NotFound | String is equivalent.\nThus we can use exceptions as return value, and return value as exception in Java.

\n
class DividedByZero {}\n\nclass IntRet extends Exception\n{\n\tpublic int value;\n\n\tpublic IntRet(int value)\n    {\n      this.value = value;\n    }\n}\n\nclass CharRet extends Exception\n{\n\tpublic char value;\n\n\tpublic CharRet(char value)\n    {\n\t\tthis.value = value;\n    }\n}\n\npublic class HelloWorld\n{\n\tprivate static DividedByZero divide(int x, int y) throws IntRet, CharRet\n\t{\n\t\tif (y == 0)\n\t\t{\n\t\t\treturn new DividedByZero();\n\t\t}\n\t\telse if (y < 0)\n\t\t{\n\t\t\tthrow new CharRet('N');\n        }\n\t\telse\n\t\t{\n\t\t\tthrow new IntRet(x / y);\n\t\t}\n\t}\n\n\tpublic static void main(String[] args)\n\t{\n\t\ttry\n\t\t{\n\t\t\tDividedByZero err = divide(10, 2);\n\t\t\tSystem.out.println(err); // handle error\n\t\t}\n\t\tcatch (IntRet e)\n\t\t{\n\t\t\tSystem.out.println(e.value);\n\t\t}\n\t\tcatch (CharRet e)\n        {\n\t\t\tSystem.out.println(\"Divided by a negative number is not supported yet.\");\n        }\n\t}\n}\n
\n

This also applies Kotlin.\nUsing exceptions as return values can spare return value for exception.\nThe Kotlin compiler will warn us unused declared variable,\nso this in effect mimics checked exception for a language without checked exception in an exotic and ugly way.

\n
object DividedByZero {}\n\nclass IntRet(val value: Int): Throwable(null, null) {}\n\nfun divide(x: Int, y: Int): DividedByZero\n{\n    if (y == 0)\n    {\n        return DividedByZero\n    }\n    else\n    {\n        throw IntRet(x / y)\n    }\n}\n\nfun main(args: Array<String>) {\n    try\n    {\n        val err = divide(10, 2)\n        println(err) // handle error\n    }\n    catch (e: IntRet)\n    {\n        println(e.value)\n    }\n}\n
","date_published":"Thu, 06 Dec 2018 00:53:57 GMT","date_modified":"Thu, 26 Dec 2019 15:16:30 GMT"},{"id":"https://mmap.page/dive-into/ceylon-kotlin/","url":"https://mmap.page/dive-into/ceylon-kotlin/","title":"Ceylon v.s. Kotlin","content_html":"

Ceylon v.s. Kotlin

\n

void function

\n

Kotlin uses Unit for functions returning nothing, like many functional languages,\nwhile Ceylon uses void keyword.\nvoid functions in Ceylon actually returns Anything.\nThis allows to use other non-void functions when void functions are expected,\nand other non-void functions to accept void function as parameter.

\n

Ceylon's Anything approach is flexible,\nbut it may not fit in a more disciplined coding style.\nIf non-void functions are used when void functions are expected,\nthen we are using side effects with non-void functions.\nBut a non-void function should avoid exposing side effects.

\n

We can declare our own Unit class in Ceylon:

\n
abstract class Unit() of unit {}\nobject unit extends Unit() {}\n\nUnit f() {\n    print(\"hi\");\n    return unit;\n}\n\nshared void run() {\n    f();\n}\n
\n

Like assignment returning a value, Ceylon's behavior may also be influenced by C.\nIn C, any function can be converted to void via (void) f, discarding its return value.

\n

Variadic arguments

\n

Kotlin uses vararg keyword to mark variadic argument, while Ceylon just types\nthem with T* or T+ (at least have an argument). This is an example of\nCeylon's regularity of type system. Kotlin uses Array<T> for vararg p: T\nunderhood but special array types for basic types, e.g. IntArray for vararg p: Int. However, p: Array<T> and vararg p: T behaves differently. In other\nwords, given a function Array<T> -> Unit, we do not know how to invoke it\njust from its signature.

\n

Function reference

\n

Kotlin's function reference syntax is strange:

\n
fun gf(x: Double, f: (Double) -> Double): Double {\n    return f(x)\n}\ngf(2.0, ::findFixPoint)\n
\n

Without :: it will not work.

\n

Languages using special function reference syntax usually saves f for f().\nBut that is not allowed in Kotlin, either.\nInstead, Kotlin saves f for a variable/property f with the same name!

\n
val i = 2\nfun i(): Int { return 2 };\nprint(i)\nprint(i())\n
\n

Still Kotlin compiler cannot resolve the function reference\nif there is a property which has the same name:

\n
fun h(f: () -> Int) {\n    print(f())\n}\nh(::i) // error: overload resolution ambiguity\n
\n

Also, Kotlin only allows reference to Foo::bar\nnot foo::bar.

\n

For anonymous function, there is no ambiguity.\nThus the function reference is normal.

\n
val f = fun(): Int { return 1 }\nh(i)\n
\n

Ceylon's function reference is normal.

\n

Ceylon does not support overloading. And function reference will not work for\nJava overloading functions.

\n

Inline functions

\n

Kotlin supports inline functions.

\n
inline fun foo(inlined: () -> Unit, noinline notInlined: () -> Unit) {}\ninline fun f(crossinline body: () -> Unit) {\n    val f = object: Runnable {\n        // body is called in another context `object: Runnable`,\n        // thus we need the `crossinline` keyword.\n        override fun run() = body()\n    }\n    // ...\n}\n
\n

Kotlin's inline function supports reified generics:

\n
inline fun <reified T> TreeNode.findParentOfType(): T? {\n    var p = parent\n    while (p != null && p !is T) {\n        p = p?.parent\n    }\n    return p as T\n}\n
\n

Ceylon does not support inline functions, and all generics are reified, except\ninteroperation with Java code.

\n

IMO, languages should make function calls cheap, instead of bring in confusing\ninline features.

\n

Object

\n

Kotlin's object looks like class, and provides an invoke method to mimic\nfunction call with object initialization.

\n
object SingletonExample {\n   fun singletonMethod() {\n        return \"We cannot initialize a singleton.\"\n   }\n   operator fun invoke() {\n        return \"`invoke` will be called when we write `SingletonExample()`.\"\n   }\n}\n
\n

I dislike this feature.\nNow every time I see CapsName(something)\nI am not sure it returns an instance of CapsName.\nIt may return anything!

\n

Ceylon's object does not have a invoke method.

\n
shared object consoleWriter satisfies Writer {\n    formatter = StringFormatter();\n    write(String string) => process.write(string);\n}\n
\n

The downside of object (anonymous class) in Ceylon is if we ever need to write\ncode that refers to the concrete type consoleWriter, we must use the very ugly\nsyntax \\IconsoleWriter as the type name.\nA toplevel object in Ceylon is a singleton.

\n

Object (anonymous class) in Ceylon is actually a value constructor:

\n
// object thing {}\nclass \\Ithing {\n    shared new thing {}\n}\n\\Ithing thing => \\Ithing.thing;\n
\n

Kotlin also has object expression.

\n
val adHoc = object {\n    var x: Int = 0\n    var y: Int = 0\n}\nopen class A(x: Int) {\n    public open val y: Int = x\n}\n\ninterface B\n\nval ab = object : A(1), B {\n    override val y = 15\n}\n
\n

Object expression in Ceylon:

\n
return object extends Foo() satisfies Bar {\n    // ...\n};\n
\n

An object expression is basically a shorthand for a local object declaration.

\n
object foo extends Foo() satisfies Bar {\n    // ...\n};\nreturn foo;\n
\n

Kotlin uses component object to mimic Java static methods:

\n
class ExampleClass(val x: Int) {\n    companion object {\n        // still a real object at runtime\n        fun aMethodLooksLikeStaticButNot() = println(\"not static\")\n        @JvmStatic fun aMethodToBeCompiledToStaticMethodOnJVM() {\n            println(\"compiled to static methods on JVM\")\n        }\n    }\n}\nExampleClass.aMethodLooksLikeStaticButNot()\nExampleClass.aMethodToBeCompiledToStaticMethodOnJVM()\n
\n

Ceylon does not support this.

\n

Both Kotlin and Ceylon support top level function declaration,\nsomething like package level static method.

\n

Ceylon 1.3.1 introduces static member.

\n

Also, Kotlin supports extension method.\nExtension method on Kotlin is resolved statically,\nonly providing a way to call with Class.method syntax,\nnot actually modifying the extended class.

\n

Similarly to functions, Kotlin supports extension properties. Again, Ceylon\ndoes not support this.

\n

Final class

\n

Classes in Kotlin are final by default.\nAlso, Kotlin requires explicit open modifier for overridable members.\nAnd a member marked override is itself open.\nAlso, properties declared in Interface are open.

\n
open class OpenClass(x: Int) {\n    open fun overridableMember() {}\n}\nopen class ChildOfOpenClass(x: Int) : OpenClass(x) {\n    override fun overridableMember() {}\n}\n
\n

Ceylon classes are by default open, unless annotated with final.\nHowever, Ceylon also requires explicit annotation for overridable members:

\n\n

Also, attributes in interface are not open by default in Kotlin.\nYou need to explicitly annotate it as formal.

\n

super ambiguity

\n

Kotlin uses super<A>.f().

\n
open class A() {\n    open fun f() { print(\"A\") }\n}\n\ninterface B {\n    // Interface members are open by default.\n    fun f() { print(\"B\") }  // Allowing method implementations, like Java 8.\n}\n\nclass ChildOfAB() : A(), B {\n    // The compiler requires `f()` to be overridden.\n    // So you do not need to remember rules of priorities\n    // and check super class definitions for possible conflicts.\n    override fun f() {\n        super<A>.f()\n        super<B>.f()\n    }\n}\n
\n

Ceylon uses (super of A).f().

\n
class SelfReference() {\n    // Ceylon has keywords `this` and `super`.\n    // To deal with ambiguity of what `super` refers to, use the widening operator.\n    class Impl() extends Class() satisfies Interface {\n    // Suppose Impl inherits two different implementations of `ambiguous`\n    // from Class and Interface.\n        (super of Interface).ambiguous()\n    }\n}\n
\n

getter and setter

\n

Kotlin uses get() and set() functions with optional backing field:

\n
class GettersAndSetters(val x: Int) {\n    var isEmpty: Boolean = null\n        get() = this.x == 0\n        // By convention, the name of the setter parameter is value,\n        // but you can choose a different name if you prefer.\n        set(value) {\n            if (value == null) {\n                // Kotlin provides an automatic backing `field`.\n                field = false\n            } else {\n                // The field identifier can only be used in the accessors of the property.\n                field = value\n            }\n        }\n}\n
\n

Ceylon uses anonymous setter and assign for getter,\nwithout backing field.

\n
class GetterSetterExample() {\n    variable String? rank = null;  // Ceylon never auto initializes to null.\n    variable String? comment = null;\n    shared String review => \"``rank``: ``comment``\";\n    assign review {\n        value tokens = review.split(\":\").iterator();\n        if (is String first = tokens.next()) {  // narrowing down types\n            rank = first;\n        }\n        if (is String second = tokens.next()) {\n            comment = second;\n        }\n    }\n}\n
\n

In Kotlin, immutable variable val does not allow setter.\nCeylon's getter and setter are more flexible.\nIn the above example, we have a setter for immutable review.\nThe setter is valid, since it actually changes value of mutable rank and comment.

\n

const

\n

Kotlin has compile time const:

\n
const val VERSION: String = \"alpha\"\n
\n

const only allows String or a primitive type.

\n

Ceylon does not have this.

\n

I have no idea why this need to be explicitly marked in Kotlin.\nThe compiler cannot automatically optimize this?

\n

late init

\n

Kotlin has lateinit and Ceylon has late annotation.\nBut they are two different things.

\n

Kotlin only allows non-nullable, not-primitive types to use lateinit. Kotlin\nuses the null value to mark that a lateinit property has not been\ninitialized and to throw the appropriate exception when the property is\naccessed. But primitive Java types can't have a 'null' value. In other words,\nthe property must be not nullable in Kotlin level, but nullable in Java level.

\n
public class MyTest {\n    lateinit var subject: TestSubject\n\n    @SetUp fun setup() {\n        subject = TestSubject()\n    }\n\n    @Test fun test() {\n        subject.method()\n    }\n}\n
\n

Ceylon uses late to suppress definite initialization checks.\nIn Ceylon, all declaration is done after initialization,\nwhich may cause problems on circular reference.

\n
class Child(parent) {\n    shared late Parent parent;\n}\n\nclass Parent() {\n    // This won't work,\n    // because `this` refers to an instance of Parent in its own initializer section,\n    // where Parent has not been initialized yet.\n    // shared Child child = Child(this);\n    shared Child child = Child();\n    child.parent = this; // ok, since parent is late\n}\n
\n

declaration-site variance

\n

Both Kotlin and Ceylon uses declaration-site variance <out Bar>.

\n

Ceylon also support use-site variance for interoperation with Java code.\nSo does Kotlin, with a slightly different syntax <out Bar!>!.

\n

Generics constrains

\n

Kotlin uses common T : Upper syntax:

\n
fun <T : Comparable<T>> sort(list: List<T>) {}\n
\n

More than one upper bounds need to be specify in a where clause:

\n
fun <T> cloneWhenGretter(list: List<T>, threshold: T): List<T>\n        where T : Cloneable, T : Comparable {\n    return list.filter{it > threshold}.map{it.clone()}\n}\n
\n

Ceylon has a more consistent syntax,\nand uses intersection type for more than one upper bounds.

\n
Value genericFunction<Value>(Value num, Value denom)\n        given Value satisfies Comparable<Value> & Summable<Value>\n        => if num > denom then num else num + denom;\n
\n

Both Kotlin and Ceylon does not support raw type.\nKotlin has a similar star projection syntax:

\n

Given interface Function<in S, out T>, Function<*, *> is a shortcut for\nFunction<in Nothing, out Any?>

\n

Ceylon just supports explicit Function<in Nothing, out Anything>.

\n

Also note that Ceylon uses Anything instead of Any? in Kotlin.\nAny in Kotlin is not truly Any because it does not hold null.\nCeylon's Anything is an enumerated type:

\n
shared abstract class Anything()\n        of Object | Null {}\n
\n

of Object | Null can be used in generics as enumerated constrain.

\n

Anonymous function

\n

Kotlin has both anonymous function and lambda:

\n
// anonymous function\nfun(): Unit { println(numbers.size) }\n// lambda\n{ n: Int -> n <= 0 }\n// one parameter lambda can be abbreviated,\n// also parameter type can be omitted if it can be inferred by compiler\n{ it <= 0 }\n
\n

The difference between lambda and anonymous function is:

\n\n

Ceylon just have anonymous function.

\n
// Same as lambda in Kotlin, an anonymous function cannot specify return type.\n(Integer n) => n <= 0\n// Except `void`.\nvoid (Integer n, Integer m) => print(m + n)\n// Mark it with `function`\nfunction (Integer n) => n <= 0\n// Like `function`, `void` can be omitted.\n() => print(\"Hi!\")\n// Same as above, with block\n() { print(\"Hi!\"); }\n// Similar to Kotlin's anonymus function\nfunction () { print(\"Hi!\"); }\n
\n

case

\n

Kotlin uses when for both case and cond in Scheme.

\n
when {\n    i == 0 -> false\n    else -> true\n}\nwhen (i) {\n    0 -> false\n    else -> true\n}\n
\n

Ceylon just uses switch for case:

\n
  void printID(String|Integer id) {\n      switch (id)\n      case (is String) {\n          println(id);\n      }\n      case (is Integer) {\n          switch (id)\n          case (0) {\n            println(\"Error\");\n          }\n          else {\n            println(\"id number: ``id``\");\n          }\n      }\n      // No `else` clause since all cases of a union type is exhausted.\n}\n
\n

Ceylon uses switch as statements,\nwhile Kotlin uses when as both statements and expressions.

\n

case must be both disjoint and exhausted in Ceylon.

\n
shared abstract class Comparison(shared actual String string)\n        of larger | smaller | equal {}\nswitch (x<=>y)  //  `<=>`  produces an instance of `Comparison`.\ncase (equal) {\n    print(\"same same\");\n}\ncase (smaller) {\n    print(\"x smaller\");\n}\ncase (larger) {\n    print(\"y smaller\");\n}\n
\n

Cases must be exhausted in Kotlin only in when expression.

\n

In Ceylon, switch can declare a scoped local variable:

\n
switch (name = process.arguments.first)\ncase (null) {\n    print(\"Hello world!\");\n}\nelse {\n    print(\"Hello ``name``!\");\n}\n
\n

This is frequently used in Ceylon,\nbecause Ceylon's case condition does not allow arbitrary expressions.\nOnly conditions like exists, is Type, nonempty\nand literal values of basic types are allowed.

\n

Catch checked exceptions from Java

\n

Kotlin does not have checked exceptions. So, normally, the Java signatures of\nKotlin functions do not declare exceptions thrown. If you want to call them in\ntry catch clause from Java, you need to annotate functions with\n@Throws(IOException::class).

\n

The root of the exception hierarchy in Ceylon is ceylon.language::Throwable,\nUnlike Java's Throwable, ceylon.language::Throwable is sealed and the only\nsubclasses available to users are ceylon.language::Exception and\nceylon.language::AssertionError.

\n

The JVM implementation of ceylon.language::Exception is a\njava.lang.RuntimeException. On the other hand,\nceylon.language::AssertionError is a java.lang.Error at runtime. This means\nthat pure Ceylon code compiled for the JVM can only generate unchecked\nexceptions.

\n

Impure Ceylon (that is, Ceylon code which access Java code) may throw any\nexception that is thrown by that Java code, including checked exceptions. If a\nCeylon function may throw checked exceptions, you need to call it in a try\ncatch clause in Java.

\n

Reassignment of function parameters

\n

Kotlin does not allow reassignment of function parameters,\ni.e. function parameters are always implicitly val,\nlike function parameters are always implicitly let in Swift.

\n

Ceylon disallows this unless the function parameter is annotated as variable.\nThis is consistent with variable declaration.

","date_published":"Thu, 06 Dec 2018 00:53:57 GMT","date_modified":"Tue, 06 Sep 2022 05:05:55 GMT"},{"id":"https://mmap.page/log/","url":"https://mmap.page/log/","content_html":"

Date: 1663086020

\n

TypeScript is less apearing to me.

\n

If I want to write in a dynamic language\nwith a powerful gradual type system.\nThen Python ships with it.

\n

If I want a sound type system for JavaScript,\nthen there is ReScript.

\n

Date: 1663085149

\n

The order form of $JD website has a field to fill in the email address to receive the receipt.

\n

But it turns out they just sent me an email, containing a link to download the receipt from their site.

\n

Date: 1663072643

\n

Bad marketing is mostly harmless to users.

\n

Good marketing can be harmful.\nThe markketing of git, to some extent thanks to Linus and GitHub,\nis so sucessful that so many people are suffering.

\n

Date: 1663055452

\n

I watched spderosso's presentation and skimed the paper on gitless.

\n

I find the summary presentation is much more approachable.\nPaper is like source code.\nPresentation or blog post is like a README.

\n

Date: 1662903070

\n

I used to have a git switch alias pointed to legit switch, and haven't checked the native switch command introduced by recent versions of git till today.

\n

Reading git help switch got me very confused.\nThen after some googling, I understood that basically git switch is just git checkout.

\n

It turns out that in git checkout foo, foo can mean a branch or a file.\nAnd if both branch foo and file foo exist, the branch takes priority.\nRecent versions of git introduces switch and restore to offer a cleaner user interface.

\n

Initially I got confused because I never knew git checkout path till today.\nI always did git checkout rev path before.

\n

Conclusion: git sucks.

\n

Date: 1662883909

\n

The advantage of 11ty is that it works with existing projects.

\n\n

Date: 1662828447

\n

Although deprecated since HTML 2 (1995), the HTML element plaintext is still supported by all major browsers.

\n

https://caniuse.com/?search=plaintext

\n

The backward compatibility of web shines!

\n

Date: 1659874628

\n

Alternatives to homebrew are still alive!

\n

MacPorts supports all the current versions of macOS:\n10.15, 11, and 12.

\n

Fink supports the oldest current version of macOS: 10.15.\nIn other words, it has not supported M1 yet.

\n

pkgsrc built packages against macOS 11 (x86 & M1) and 10.14,\nsuitable for users running recent macOS releases.

\n

Date: 1659844869

\n

A Survey on Social Networks

\n\n

Summary

\n\n

Date: 1659752677

\n

Stacked encryption systems

\n

tl;dr

\n\n

Comparison:

\n\n

For more information, refer to comparisons on websites of gocryptfs\nand cryfs.

\n

Date: 1659752237

\n

Just tried installing EndeavourOS on a virtual machine.

\n

The Caramares installer can configure LUKS full disk encryption\nautomatically. However, when booting the freshly installed system,\nI can only type the encryption passphrase in US qwerty keyboard layout.

\n

frostschutz suggests a workaround:

\n
\n

add the passphrase twice. So the same sequence of key presses will be accepted\nin both US/qwerty layout and whatever you usually use (in my case, DE/qwertz).

\n
\n

Inspired from frostschutz, I configured the installation with qwerty\nlayout. When I input the passphrase for LUKS encryption, I just input\nthe sequence of key presses as the same if I were on a dvorak layout.

\n

When setting up the user password during the installation, I input a\ntemporary password containing only numbers.

\n

After booting into the installed system, I changed the user password and\nthe keyboard layout.

\n

Date: 1642437589

\n

I used to think Dvorak layout is universal,

\n

until recently I became interested in text processors\nand learned that most of them do not support Dvorak layout.

\n

For example, Pomara DM100 does not support Dovark:

\n
\n

Q: DM100のキーボードは「QWERTY配列」だが「Dvorak配列」に変更はできませんか。

\n

A: 変更はできません。

\n
\n

Date: 1640792005

\n

Recently I bought a HP Pavilion laptop.

\n

The setup process is terrible.\nI have to turn off my WiFi router to setup a local account.\nOtherwise it forces me to setup a Microsoft online account.

\n

Also, it requires me to setup a PIN after I have already setup a\npassword.\nHow stupid it is!

\n

Date: 1633121264

\n

I decided to take notes as git commit messages.

\n

Why?

\n\n

Date: 1633119948

\n

Just switched from vim to neovim.

\n

neovim has sensible default configurations.\nThus I only enabled spell checking:

\n
; cat ~/.config/nvim/init.vim\n\" exclude CJK characters from spell checking\nset spelllang=en,cjk\nset spell\n
\n

I also changed neovim to provide the editor/vi/vim command.

\n
sudo update-alternatives --config editor\nsudo update-alternatives --config vi\nsudo update-alternatives --config vim\n
\n

The content above itself is written under neovim.

\n

Date: 1633096028

\n

The version history of Telegram for macOS looks normal on its website. But the release messages of its beta version is very interesting.

\n

For example:

\n
\n

Thought to be lost for decades, Rembrandt’s first portrait “The Farmer and the Service Message Fix” was recently discovered in the attic of a Belgian café.

\n

A spoonful of sugar makes the service message fix go down.

\n

What's cooler, fixes or a cucumber?

\n

I’ve got 99 problems but the fixes ain’t one.

\n

The secret ingredient to a good update is a tablespoon of fixes.

\n

No devs were harmed in the making of the widget/themes in this update.

\n

Mom, where did you put my fixes?

\n

Fixes are in the eye of the beholder.

\n

Fixes are now machine-washable.

\n

Roll a D20 to resist the fixes check.

\n
\n

Date: 1632231803

\n

The ZWJ (Zero Width Joiner) Unicode character can combine multiple emojis to be displayed as a single emoji. However, a platform may or may not include support for certain the emoji ZWJ sequences. For example, 👁‍🗨 is an emoji ZWJ sequence combining 👁 and 🗨. And if an Emoji ZWJ Sequence is not supported on the platform, it will be displayed as individual emojis, e.g. 🏔️‍🦁‍🏁

\n

Date: 1611678565

\n

From 20200702, the Internet has around 16 months to migrate from onion services v2 to v3 once and for all. Now there are less than half a year left, and onion services run by the Tor projec itself still use v2.

\n

Also, the future v2 deprecation will turn all existing v2 tor URLs to dead links. This incompatibility is really bad.

\n

Date: 1611468447

\n

Shell scripting is a very bad programming language. But YAML is worse.

\n

Date: 1611423752

\n

LinkedIn forces me to login & bind my mobile phone number to just view its content. Today I discovered an alternative way to check someone's work & education background, search \"NAME site:rocketreach.co\" or \"NAME COMPANY site:rocketreach.co\" in search engines.

\n

Date: 1608965375

\n

Pop!_OS advertises itself as a developer friendly Linux distribution. However, it uses flatpak, whose sandbox system has a lot of issues with IDEs and editors (they typically need to access system commands and files).

\n

Personally I prefer AppImage. It solves the \"with dependencies packaged in and run on any Linux distributions\" problem in a simple way and does not rely on a centric distribution channel. If I want to use AppImage packaged programs in sandbox, I can use firejail. \"Do one thing and do it well.\" AppImage respects the old unix philosophy.

\n

Date: 1608735948

\n

The fish shell improves user experience a lot, both for interactive usage and scripting usage.

\n

For example, to convert some SVG wallpapers to JPG (I use feh to display wallpapers under the i3 window manage, and feh does not recognize SVG files):

\n
for i in /usr/share/wallpapers/**/1920x1080.svg\n  convert $i (string split \"/\" $i)[5].jpg\nend\n
\n

Concise and clear.

\n

Date: 1608656523

\n

While immature distributions (Arch, Ubuntu, Fedora, etc.) dropped x86 support between 2017-2019, a lot of serious distributions (Slackware, Debian, Gentoo, OpenSUSE, Alpine, etc.) still support old x86 computers.

\n

FYI, CRUX dropped x86 support on 2013.

\n

Date: 1608482666

\n

Fedora Silverblue uses OSTree for its base system, and it is the most mature distribution with an OSTree based base system.

\n

Since the base system is immutable, new software are installed via Flatpak (sandboxed GUI applications with all its dependencies packaged in) or toolbox (command line programs running inside docker like containers). There are a few exceptions (shell, drivers, etc.) need to be installed via layered rpm packages, which require a reboot.

\n

I think this is a cool idea. However, I am still unsure whether it is worth to trade in extra disk space and incompatibilities with some software for the confidence that I can rollback to a usable base system quickly (just reboot) anytime (not require a Internet connection).

\n

Date: 1608480882

\n

Pop!_OS is a Ubuntu based distribution which features:

\n\n

So nothing exciting here. But to be fair, \"just works out of the box\" is a big feature. Particularly, out of the box full-disk encryption is very important for inexperienced users to adapt it.

\n

Pop!_OS is what Ubuntu should have been.

\n

Date: 1608399092

\n

JAMStack is another buzzword targeting clients using LAMP stack (e.g. wordpress) to host their website. Static website generator will not work because it will confuse those clients: \"Static website? Our site was static N years ago and we use FTP to upload those static web pages to the server. Didn't you told us that static website is outdated with limited features? Why go back to a static site?\"

\n

I do not think it is a good idea to switch from one shitty language (PHP) to another shitty language (JavaScript), particularly when this switch usually means more CO2 emissions.

\n

Date: 1608230563

\n

Trying to manually resolve a dependencies conflict broken my KDE desktop. Almost all KDE applicants do not work. It seems that KDE Neon assumes you will never uninstall those preinstalled KDE packages and specifies their dependencies causally. Fortunately I can still log into the i3 session (previously I used i3 as the window manager of the KDE session), but I still miss dolphin (temporarily using nautilus) and konsole (temporarily using hyper).

\n

Maybe this is a good time to try out other distributions or even operating systems, e.g. Pop!_OS?

\n

Date: 1606530944

\n

surge.sh still focuses on static site hosting (Netlify used to focus on static site hosting but they added a lot of dynamic features later), with a command line UI (now.sh (rebranded as vercel now) used to feature this but now their documentation encourages you to do things via their web dashboard).

\n

Date: 1605954392

\n

Q: Why I do not have faith in God?

\n

A: As Larry Wall paraphrased, faith is just two bits away:

\n
\n
    \n
  1. God exists, and
  2. \n
  3. God is good to people who really look for him
  4. \n
\n
\n

I am not able to prove the first bit is true but let me just assume the first bit is true.

\n

The second bit is I have to really look for the God. Jesus said you only have to have faith the size of a mustard seed. But no matter how small the size of the faith is, it is still an opt-in option. If God is really good, then why faith is not an opt-out option?

\n

Because we are sinners. And the sensible default option for sinners is no faith and going to hell. Salvation is a gift from the God.

\n

However, a gift is something declinable by its very definition. Thus I can choose to decline this gift and keep on the default option. I did so.

\n

Although I do not have faith in God, I am still grateful to God. Thank God for allowing such a sinner as I to have the free will to decline his gift.

\n

And what if the first bit is not true? Then I would like to thank god for being nonexistent.

\n

Date: 1605426776

\n

nico is a minimalistic zero-configuration HTTP server. It can be used as a reverse proxy or a static file server, with auto applied SSL certificates. Nico have no options to configure. You can not even specify the ports to listen (it always listen on 80/443).

\n

The binary size on Linux amd64: 6.5 M (for comparison, Caddy is 35 M).

\n

Date: 1603897272

\n

Burmese names do not have surnames. And traditionally Bamars can change their name at will, often with no government oversight. In other words, Burmese names are both screen names and real names.

\n

Date: 1603634286

\n

Why the KISS (Keep it simple, stupid) principle looks so seductive to me? Because the world is too vast to explore.

\n

Date: 1603540199

\n

Macbook Pro 13 (2019) claimed to support \"up to 10 hours wireless web\", but in my daily use (two browsers with dozens of tabs, two IDEs, one electron based editor, one mail client, two IM applications, using both the internal and an external monitor) it can only last about 3 hours.

\n

Date: 1599059053

\n

The English words \"Republic of China\" is still preserved on the redesigned Taiwan passport. They are in a much smaller font wrapping around the national emblem, unnoticeable at a quick glance.

\n

IMHO, keeping it simple and stupid is much better using these creative tricks. The English words \"Republic of China\" and all Chinese words (including \"Republic of China\") should be removed. Also, national emblem can be replaced with Prunus mume (just like the design of the Japanese passport).

\n

Date: 1597769012

\n

There is no options in Google Podcasts to export subscriptions in OPML. Even Google Takeout does not include Google Podcasts subscriptions. (violation of GDPR?)

\n

Date: 1596728115

\n

According to Uniqlo's size chart, the perfect height is around 165 cm and 150 cm. A person of 165 cm height can choose from both Men's Clothing and Women's Clothing, and a person of 150 cm height can choose from both Women's Clothing and Kids' Clothing.

\n

Date: 1596041215

\n

suitezero.archive posted their collection, a pair of fake Nike sneakers on instagram. Unlike most other fake Nike shoes, this pair has its own brand 登云 (meaning climbing the clouds in Chinese) and is produced by 上海皮鞋一厂 (Shanghai No.1 Leather Shoe Factory), a Chinese government-owned enterprise.

\n

\"attached

\n

Date: 1594691578

\n
\n

Also, vertical KDE panel is not supported under i3, so do not buy them.

\n
\n

Oh, I must be very sleepy to write the above sentence. And maybe I dislike KDE subconsciously?

\n

Date: 1594463078

\n

First impression on hey email:

\n
    \n
  1. I cannot write an email in plain text. There are no options in settings. All emails are HTML.
  2. \n
  3. To organize in emails in \"Imbox\"/\"The Feed\"/\"Paper Trail\", I have to manually classify them, or set up that all mails from a certain address go to one of these categories. I expected there will be something fancy magic based on the so called machine learning here, but there is not. And at least in Gmail I can create filters based on more conditions (e.g. subject or body content).
  4. \n
  5. I can select text in email and click \"save clips\". But they are only shown in the clips menu, there is no highlight in the original email. And in the clips page, I cannot click the clipped text to go to the exact position of the original email (I can only go to the beginning of the email). Therefore context is lost during clipping.
  6. \n
  7. I do not think a dedicated new mail services is necessary to implement most of the UX features hey offered.
  8. \n
\n

Date: 1594449386

\n

Shame on me: I had not checked whether the producer violates GPL before buying an ebook reader.

\n

Reddit: Onyx Boox will not share their linux kernel source code

\n

Date: 1593936141

\n

Sinatra in Ruby:

\n
require 'sinatra'\nget '/' do\n      'Hello, World!'\nend\n
\n

In Python (a.k.a. Flask):

\n
from flask import Flask\napp = Flask(__name__)\n\n@app.route('/')\ndef hello_world():\n    return 'Hello, World!'\n
\n

In JavaScript (a.k.a. Express):

\n
const express = require('express')\nconst app = express()\nconst port = 3000\n\napp.get('/', (req, res) => res.send('Hello World!'))\n\napp.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))\n
\n

In Java (a.k.a. Javalin):

\n
import io.javalin.Javalin;\n\npublic class HelloWorld {\n    public static void main(String[] args) {\n        Javalin app = Javalin.create(config -> config.defaultContentType = \"application/json\").start(7000);\n        app.get(\"/\", ctx -> ctx.json(\"Hello, World!\"));\n    }\n}\n
\n

In Go (a.k.a. Gin):

\n
package main\nimport \"github.com/gin-gonic/gin\"\n\nfunc main() {\n        r := gin.Default()\n        r.GET(\"/\", func(c *gin.Context) {\n                c.JSON(200, gin.H{\n                        \"hello\": \"world\",\n                })\n        })\n        r.Run()\n}\n
\n

Date: 1593885469

\n
\n

FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.

\n

-- https://fastapi.tiangolo.com

\n
\n

\"based on standard Python type hints\", so Let's just check the source code:

\n
class FastAPI(Starlette):\n    def __init__(\n        self,\n        *,\n        debug: bool = False,\n        routes: List[BaseRoute] = None,\n        title: str = \"FastAPI\",\n        description: str = \"\",\n        version: str = \"0.1.0\",\n        openapi_url: Optional[str] = \"/openapi.json\",\n        openapi_tags: Optional[List[Dict[str, Any]]] = None,\n        servers: Optional[List[Dict[str, Union[str, Any]]]] = None,\n        default_response_class: Type[Response] = JSONResponse,\n        docs_url: Optional[str] = \"/docs\",\n        redoc_url: Optional[str] = \"/redoc\",\n        swagger_ui_oauth2_redirect_url: Optional[str] = \"/docs/oauth2-redirect\",\n        swagger_ui_init_oauth: Optional[dict] = None,\n        middleware: Sequence[Middleware] = None,\n        exception_handlers: Dict[Union[int, Type[Exception]], Callable] = None,\n        on_startup: Sequence[Callable] = None,\n        on_shutdown: Sequence[Callable] = None,\n        openapi_prefix: str = \"\",\n        root_path: str = \"\",\n        **extra: Dict[str, Any],\n    ) -> None: ...\n
\n

routes, middleware, exception_handlers, on_startup, on_shutdown should be 'Optional', and types of swagger_ui_init_oauth, exception_handlers, on_startup, on_shutdown are inaccurate.

\n

It is 2020 and sadly the only mainstream dynamic programming language with a community which treats typing seriously is JavaScript.

\n

Date: 1593707744

\n

Recently I watched Openbook 2019 talk by Audrey Tang on YouTube. The talk is given in Chinese and here is some notes I have taken.

\n

Assistant Intelligence

\n

Audrey regards AI as Assistant Intelligence instead of Artificial Intelligence.

\n

Reading

\n

Audrey finds the following reading methods help her to understand the content:

\n
    \n
  1. Translation or abstract translation.
  2. \n
  3. Taking notes and doodling with pens.
  4. \n
\n

When not having a pen at hand, Audrey will scan the book or pdf quickly (about 0.2s per page). Then she will rest for a while, maybe drinking some tea, and \"review\" those pages in mind with her eyes closed. If something occurred to her, she will note them down.

\n

When having a lot of materials to read, she will quickly scan them before sleep, and absorb them in sleep. She found out an 8 hour sleep can absorb around 400 pages of material.

\n

Audrey did most of her reading on an iPad Pro (with a pen).\nShe uses the kindle app for iPad, but she converts all books she bought from different channels using calibre.

\n

Emoji as a universal language

\n

Audrey thinks emoji is a more universal language than English.

\n

However, I think while it is cool to making slides in pictures and emoji. It is difficult to express complex ideas only with emoji. For example, can you guess what these slides mean?

\n

Humor over Rumor

\n

Audrey introduces the disinformation definition in Taiwan: intentional harmful untruth (harmful to the public). To counter disinformation, clarification need to take a humorous form, to become a meme spreading faster and wider than the disinformation. Also, humor helps to counter the irrational anger which motivates people to spread the disinformation.

\n

iCloud

\n

Unfortunately, although Audrey is a key sponsor of sandstorm (self hosted platform for open source applications), and introduces sandstorm to Taiwan government, she herself still relies on iCloud to sync personal files.

\n

Date: 1592234620

\n

Go is influenced by Python. Now Go also influences Python, e.g. black (go fmt) and pytest (go test).

\n

Date: 1591974550

\n

It's 2020, and twitter & github still do not support IPv6.

\n

Date: 1590256273

\n

Go 1.14 allows embedding interfaces with identical method names, as long as these methods have identical signatures.

\n

Again, Go avoided to attack the function subtyping problem.

\n

Date: 1589983584

\n

I though TED talks are amazing. Recently I listened a lot of TED talks and found out that TED talks on average are not interesting to me. Previously I have only listened popular TED talks shared on social networks where I only follow people I find interesting. That's why I had this wrong impression.

\n

Date: 1589462469

\n

GitHub action/workflow offers these shells: cmd, sh, bash, power shell, and python.

\n

Date: 1587833983

\n

Combo Pinyin is an interesting Chinese input method, which is similar to chord-typing (pressing multiple keys at the same time to input a character). However, I find it difficult to type. For example, to type guang, I have to type five keys (F-U-K-L-SPC) at the same time, which is very difficult to my fingers.

\n

Date: 1586705014

\n

Haven't checked the RSS reader for two or three years. The RSS reader reported that about fifty RSS feeds are unreachable. By clicking the htmlUrl and googling author name and old post content, I managed to recover 17 blogs.

\n

Date: 1586682753

\n

The opening of Stanford's CS106A is full of propaganda and buzzwords http://web.stanford.edu/class/cs106a/lectures/1-Welcome/1-Welcome.pdf

\n

Date: 1585413708

\n

Just discovered this in Sentry's ToS:

\n
\n
    \n
  1. Restrictions\n... you may not: ... (e) build a competitive product or service, or copy any features or functions of the Site or the Services
  2. \n
\n
\n

Date: 1584724995

\n

The new MacBook Air has the best keyboard in current Apple laptops: scissor mechanism without touchbar.

\n

Date: 1583945292

\n

On Apple laptops released in recent years, every key is a power button, and there is NO WAY to turn it off.

\n

Date: 1579713423

\n

golint is very noisy, and it gives a lot of false positive results. I just switched to the peaceful staticcheck instead.

\n

Date: 1579531891

\n
    \n
  1. Open your browser, click ctrl+L to focus on address bar.
  2. \n
  3. Type data:,anything you plan to do (data and semicolon and comma)
  4. \n
  5. Click ctrl+D to bookmark it.
  6. \n
\n

That't it. A todo manager with browser bookmarks.\nYou can use folders to organize your todos (projects or lists).\nAnd todos can be exported as an HTML file, or get synced with multiple devices (e.g. you can check your todos on the browser of your mobile device).

\n

Bonus: If you need to input non-ascii characters, type data:text/plain;charset=UTF-8,any content instead.

\n

Date: 1578822251

\n

I am a bit uncertain about the future of JetBrains. They put a lot of efforts to ship great IDEs. But new languages are very serious about tooling and development productivity to attract more users. vscode has greater out of box support for TypeScript than WebStrom. And the Rust extension of vscode is developed by the IDE and editors team of the Rust language people (yes, they have a dedicated team for this).

\n

There is a conflict of interest for JetBrains. For new languages, language sever is the way to go. It is very difficult for JetBrains to develop an alternative competitive code intelligence system, particularly when new languages like TypeScript and Rust are evolving very fast. So the only choice of JetBrains is to embrace the language sever. But language server is neutral to all editors and IDEs, thus it will not give JetBrains any advantage. And to earn money from those \"professional\" versions, JetBrains may deliberately remove features from free versions. For example, debugger and profiler for Rust are only available in their nonfree CLion IDE.

\n

The same thing happens to JetBrains' own language, Kotlin. Android Studio/IntelliJ have greatest support for Kotlin, and Eclipse have decent support for Kotlin. But JetBrains people are not willing to support other editors or develop a language server. There is a conflict of interest: to attract more developers to use Kotlin, they need to support more IDEs and editors, while to attract more developers to use their IDEs, they'd better only support their own IDEs.

\n

JetBrains IDEs still have the state of art IDEs for languages such as Java, Python, Go. But their language servers may catch up in future, puting JetBrains IDEs in an awkward situation.

\n

Date: 1578668352

\n

json-diff hung for one day to compare two big json files (~100 MB in file size, and ~40 k objects), while jsondiffpatch finished the comparison in less than 20 seconds.

\n

Date: 1578571754

\n

bellard.org still uses html 4, as debian.org and netbsd.org does. They have an attitude.

\n

Date: 1577539856

\n

It seems that the story writer of MonsterMatch need to learn more physics.\n\"attached

\n

Date: 1576460554

\n

Firefox Notes does not support markdown. It only captures some key presses like # h1 to mimic Markdown but directly pasting # h1 does not work (Yes, the browser distinguishes key press event and text input event). Also there is only three levels of heading. And the worst thing is it does not support code block! :-(

\n

Date: 1576408762

\n

I am not a fan of uniformed code formatting (like gofmt). I do not think issues like CamlCase v.s. snake_case or spaces are important. But I myself use Prettier because I am too lazy to type tabs and semicolons. :-)

\n

Date: 1576330994

\n

The three most popular style guides in JavaScript community (airbnb, standard, google) are all unnecessarily lengthy.

\n

For example, they all contain a lot of rules on spacing. Is spacing that important? If so, why not just use prettier? If not, why bother to list them in a style guide?

\n

Another example is they all tell you to write let arr = []; instead of let arr = new Array(). I personally tend to write [] but if a Java developer writes new Array() instead, what's wrong with that? It is totally harmless.

\n

Style guides should keep focus on a dozen of matters truly important, in other words, pitfalls of JavaScript design, e.g. using === instead of ==.

\n

Date: 1575704213

\n

Years ago I noticed that WebStorm (2016.3) was very slow to detect type errors with Flow, while vscode (with vscode-flow-ide extension) checked error on saving file instantly.

\n

Today I found out that // @ts-check against JSDoc comments works out of box with vscode, while WebStorm (2019.3) cannot recognize @template with @typedef.

\n

This is yet another example that WebStrom is becoming more and more less relevant in JavaScript development these years.

\n

Date: 1575554930

\n

On December 14, 2019, all yahoo groups become private (based on Yahoo Mails), the yahoo groups website will be shutdown and all yahoo groups content will be deleted!

\n

Date: 1575553715

\n

Just downloaded my Translator Toolkit data via Google Takeout. Google Translator Toolkit was shutdown on December 4, 2019. Yet another good service I used to be shutdown by Google.

\n

Date: 1575549745

\n

The ancient Chinese saying \"steal the whole country and they make you a prince, steal a hook and they hang you\" (竊國者侯,竊鉤者誅) probably describes integer overflow. In a system people with a positive sin value will be punished and those with a negative sin value will be rewarded, one who stole the whole country gained a lot of sin value, causing a sin value overflow.

\n

Date: 1574582537

\n

React components and hooks are just functions, nothing magical:

\n
const SimpleReact = (function() {\n    let state\n    return {\n      render(Component) {\n        const C = Component()\n        C.render()\n        return C\n      },\n      useState(initialValue) {\n        state = state || initialValue\n        function setState(newValue) {\n          state = newValue\n        }\n        return [state, setState]\n      }\n    }\n})()\n\nconst useState = SimpleReact.useState\nconst render = SimpleReact.render\n\nfunction useCountCharacters(str) {\n    const [text, setText] = useState(str)\n    const len = text.length\n    return [len, setText]\n}\n\nfunction Component() {\n    const [len, setLen] = useCountCharacters(\"\")\n    return {\n      type: txt => setLen(txt),\n      render: () => console.log({ len })\n    }\n}\n\nlet App = render(Component) // { len: 0 }\nApp.type('hello')\nApp = render(Component) // { len: 5 }\n
\n

Date: 1574526354

\n

Updated the jekyll templates of my personal website to get rid of JavaScript. Now mmap.page on clearnet and zeronet is JavaScript free. ^_^

\n

If you want to deploy a minimalistic JavaScript free site to GitHub Pages and/or ZeroNet, then you can checkout my Jekyll template.

\n

Date: 1573608922

\n

For parsing simplicity, the existential operator from CoffeeScript turns into something like foo ?? bar(), a?.[1], and f.(x) in JavaScript (stage 3), to avoid confusion with ternary expression (a ? [b] :c).

\n

IMO ?? is acceptable, but a?.[1] is really very ugly. And in fact this reveals a fundamental problem of JavaScript:

\n

JavaScript sucks. Thus people add more features as workarounds. But people cannot remove features from it (otherwise it may become a bigger tragedy than Python 2/3). So JavaScript still sucks, and becomes more bloated and uglier at the same time.

\n

Date: 1571248232

\n

Just upgrade to 0net-py3:

\n
    \n
  1. Install from source.
  2. \n
  3. Copy the data directory from my old 0net-py2 directory.
  4. \n
\n

Seemingly it works fine.

\n

Date: 1569035072

\n

Just discovered the Files app (an android app by Google) is translated to Files Geek (文件极客) in Chinese UI.

\n

Date: 1568989787

\n

Sam Hartman sent the Bits from the DPL (August 2019) letter yesterday (Sep 19, 2019). In the letter, Sam talked a lot about the complexity and anxiety on init system diversity within the Debian project.

\n

Date: 1566392824

\n

BitBucket is dropping hg support. This reminds me the time when Macintosh computers dropped PowerPC CPUs.

\n

Date: 1565806393

\n

Just learned a new word \"Xi-ple\" today. To my surprise, this word is ungoogleable.

\n

Date: 1565184664

\n

The IRL podcast by mozilla is not only boring but also burning (it burns RAM very quickly under Firefox).

\n

Date: 1565183145

\n

Touch bar does have some advantages:

\n
    \n
  1. providing context aware UI controls, like buttons, slides, etc
  2. \n
  3. showing explicitly the state of the button, e.g. the mute/unmute button
  4. \n
\n

But there is a long way to go:

\n
    \n
  1. The touch bar need to provide more physical like feedback.
  2. \n
  3. The application need to allow user to configure controls, to keep some common operations in a fixed position, e.g. F5 (refresh) for browsers.
  4. \n
  5. The application need to pay great attention to design the touch bar controls, to offer a consistent and convenient UI. For example, in Spark (an email client on Mac OS X), if I click the move button in the toolbar, the popup menu will list suggested folders first. However, if I press the move button on the touch bar, the touch bar just shows the full list (I have to slide for more folders), and the suggested list is missing.
  6. \n
\n

Date: 1564923584

\n

The dark theme of Spark (a mail client on osx) is a disaster. I've to change the setting to \"always use light theme\". The reason is few mail clients (including those Web Clients) have considered dark background in designing default HTML email templates. And it seems that Spark has not implement some smart algorithm to swap colors.

\n

The old fashioned plain text emails play nicely with dark theme. Another example of simple design is more future proof.

\n

Date: 1564667614

\n

After recent update of KDE Neon, the bluetooth adapter will power off after each hibernation. Unfortunately I need a mouse to turn on the bluetooth in KDE UI, but I use a bluetooth mouse.

\n

Finally, I found a way to turn on bluetooth via command line (I use a wired keyboard), entering power on in the bluetoothctl shell.

\n
; bluetoothctl\n[bluetooth]# power on\n[bluetooth]# exit\n
\n

Date: 1564366037

\n

Looks like the development of Ceylon has ceased. The latest commit is on May 22, 2019, removing words like \"crap\", \"shit\", \"fucked up\" from code comment. And the penultimate commit is on Feb 11, 2019, fixing the CI build.

\n

Date: 1564208313

\n

The current version of IntelliJ (2019.2) has a built-in sublime keymap. And I once heard a JetBrainer referred to ctrl+shift+a as \"command palette\" (although actually IntelliJ introduced the \"find any action\" feature prior to Sublime). FYI, Micosoft released an extension \"Sublime Text Keymap and Settings Importer\" for vscode on 2016.

\n

Such an influential editor, Sublime Text.

\n

Date: 1564069796

\n

How I stop using proxy extension in Firefox?

\n
    \n
  1. Use clash. Usually I'd rather add a rule in clash config, instead of switch proxy.
  2. \n
  3. Occasionally, when I need to switch proxy, I just press alt+home to open the proxy settings, because I have set homepage to chrome://browser/content/preferences/connection.xul.
  4. \n
\n

Date: 1562091224

\n

Future programmers may use different abstractions. Today we can write bytes to a file, and tomorrow we may write to a blob. Whether the blob is ultimately a file or some cloud storage service is just implementation details.

\n

On writing this, it occurred to me that maybe these abstractions are not very different. Afterall, a file itself is quite abstract (e.g. /dev/stderr under Linux).

\n

Date: 1561828723

\n

Just find out that web developer tools of modern browsers (Firefox & Chrome) can recognize webpack and typescript. Debugging on the original typescript source is much easier than on the generated JavaScript code.

\n

Date: 1558103099

\n

This patch to the legacy marriage framework just got approved today and will be merged into the release branch very soon! Congratulations! First patch of this kind in Asia!

\n
     func isMarriable(x Taiwanese, y Taiwanese) bool {\n-      if x.sex == y.sex {\n-        return false\n-      }\n
\n

Date: 1557559590

\n

Do not under stand why Beta users need to accept Confidentiality agreement of keeping special information secret. Isn't beta means public? It seems GitHub redefines Beta.

\n

I sign up for a Beta program because I am an impatient person, not want to wait for the official release. As such an impatient person, I do not bother reading these lengthy and senseless legal terms. I will check it again after it is officially released.

\n

Date: 1557510100

\n
first, *rest = [1, 2, 3]  # first -> 1, rest -> [2, 3]  (1)\nlambda (x, y): (y, x)  # (2)\n
\n

Python 3 supports (1) but not (2), and Python 2 supports (2) but not (1).

\n

What a pity! If there is a python version supports both (Python 6?), I can write something like:

\n
lambda (first, *rest): ...\n
\n

Date: 1557327217

\n

egghand's subtitles are auto generated (at least on some videos I watched), but they are not marked as such confusingly (unlike YouTube).

\n

Date: 1557152038

\n

Just realized that I can look at the bright side of JavaScript's switch structure. JavaScript's switch statement is fall-through, which sounds like a scream: \"Don't break! Return! Wrap me into a function!\"

\n

Date: 1556967006

\n

To those who dislikes systemd:

\n
    \n
  1. Debian/Ubuntu/Fedora/OpenSUSE: try devuan
  2. \n
  3. Arch: try Void Linux
  4. \n
  5. Gentoo: Gentoo uses OpenRC by default
  6. \n
  7. Slackware: Slackware is still systemd free
  8. \n
\n

Date: 1556911623

\n

Just watched the The Tragedy of systemd, which I thought is very misleading.

\n

Particularly, the video tries to justify systemd via connecting it with launchd. But although systemd is inspired by launchd, launchd is not that bloated as systemd. Also, besides macOS, iOS also uses launchd. However the video does not explain why Android (nowadays the majority of linux users are Android users) does not use systemd if systemd is as elegant as the video claims.

\n

And the video also talks about docker and containers, without realizing that containers make systemd irrelevant. On the server side, services are packaged as containers, which are managed by docker, k8s, etc. Technically there is still an init daemon starting the service program inside the container and communicating with docker, but this is somehow implementation detail not interested by developers. And to reduce resource overhaul, a lot of containers use alpine linux as base image, and alpine linux does not use systemd at all. Even if you intend to use Ubuntu or CentOS as base image for your container, Docker recommend you to use pre-built images with the tini init.

\n

To be honest, I like neither android, docker, nor systemd. I am not sure the fact that both android and docker are not in favor of systemd makes me more depressive or less depressive.

\n

Date: 1556714968

\n

It seems the Japanese new era is not very welcome yet:

\n\n

\"attached

\n

Date: 1556290808

\n

Just came across a Q&A on zhihu (a quora clone in CN):

\n
\n

Q: What to do when I encountered a man better than my boyfriend?\nA: Three men living together is pretty good, isn't it?

\n
\n

Brilliant! Never forget to check the presumption under the question first.

\n

Date: 1556210096

\n

React has so many opt-in, legacy, experimental features. Thus I suggest taking a look at ReasonReact first, which has a much smaller API surface. After a glance of ReasonReact, you can probably pick up React quickly by skipping a lot of concepts. I guess this will be faster than learning React directly, particularly when you are already familiar with some static typed functional languages such as OCaml, F#, and Haskell.

\n

Though I do not suggest diving deep into ReasonReact and actually write code in it, since TypeScript has a far more better ecosystem.

\n

Date: 1555779592

\n

And the first koan of \"Kotlin Koans\" from stepik and JetBrains annoyed me again.

\n

It requires to write a function returning \"OK\", given the following hint:

\n
fun start(): String = TODO()\n
\n

So easy (sounds familiar?)

\n
fun start(): String {\n  return \"OK\"\n}\n
\n

No, the EduTools plugin does not allow me to delete =!

\n

So I have to write the expected answer to pass the koan.

\n
fun start(): String = \"OK\"\n
\n

Hmm, stupid auto answer detection system. And I wonder why introduce learners the special single expression function in the very beginning, before the normal and more common used function with block body? A lot of functions are hard, if not impossible, to declare as a single expression function. Besides, learners familiar with other programming languages will pick up the normal function with block body syntax almost immediately. Why burden their progress insanely?

\n

See comments.

\n

Date: 1555778252

\n

Just tried the first three quizs of Python introduction course on stepik, which is included in JetBrains' PyCharm Educational (I tried it with the EduTools plugin on IntelliJ).

\n

The first quiz is:

\n
print(\"Hello, world! My name is type your name\")\n
\n

So easy.

\n
print(\"Hello, world! My name is weakish.\")\n
\n

Failed! It turns out that the auto answer detection system thinks it is wired that my name is weakish.! Obviously the first quiz is to teach you just follow the instruction brainlessly. \"My name ...\" starts with a capital character, so it is a sentence. It is reasonable to end a sentence with a period (.), although this will fail the quiz.

\n

The second quiz introduces comments, without telling the learner comment is used for what.

\n

And the third quiz introduces variable, but its first line is:

\n
a = b = 2\n
\n

What? Introducing chained assignment before normal variable assignment (a = 2)?

\n

Chained assignment is not often used in practice. And I do not think it is necessary to introducing it to beginners.

\n

In fact it is not only unnecessary, but confusing.

\n

A beginner may guess that a = b = 2 is equivalent to:

\n
a = 2\nb = 2\n
\n

For a value 2, they are indeed equivalent, but:

\n
import random\na = b = random.random()\n
\n

is not equivalent to:

\n
a = random.random()\nb = random.random()\n
\n

And programmers from other languages such as C and JavaScript, may think a = b = 2 is equivalent to a = (b = 2) where b = 2 evaluates to 2. But this is not true in Python.

\n

And the course mentioned nothing about these quirks.

\n

I guess the author may think a = 2 is too boringly obvious to introduce, thus turns to introducing chain assignment directly. No! In fact, considering that in Python variables are reassignable, they are not boring for beginners at all.

\n

Considering the following lines:

\n
a = 2\na = 3\n
\n

This is not boring for a beginner. How can a be equal to both 2 and 3? Seems mathematically impossible!

\n

This is what the author really have to talk about, not chain assignment.

\n

I myself learned Python via reading the A Byte of Python book years ago. I am not sure if I should recommend it to beginners. Compared to HtDP for the exotic Scheme language and the outdated Why's Guide to Ruby, it is somehow a boring book. And Python's official tutorial is well written. But at least it does not have such flaws.

\n

Date: 1555771622

\n

Just came across a video titled Learn Python Programming Language in 2 Hours.

\n

The speaker argues that the first reason to use Python is:

\n
\n

Solve complex problems in less time and fewer lines of code

\n
\n

with the following example:

\n
C# str.Substring(0, 3)\nJavaScript str.substr(0, 3)\nPython str[0:3]\n
\n

I do not want to talk about technical details like C# 8.0 supports slicing notation (str[0..3]) and substr is a legacy function in JavaScript (use slice instead). What I want to say is that all of the three languages take one line of code to solve the problem, and with a decent editor/IDE, all three lines take equal time to type. Even assuming we all do programming with a basic text editor like Notepad on Windows or Leafpad in Linux, this example still has nothing to do with solving complex problems in less time. This problem is not complex at all. And most time of programming is not spent on typing.

\n

Currently this video has 411k views, 8.1k upvotes (less than 200 downvotes) on YouTube. I think this is a good example of why learning to code is hard: so many poor and popular teaching materials on Internet.

\n

\"attached

\n

Date: 1555769700

\n

Android's Messages app does not provide a \"delete all\" function. Fortunately, most popular third-party sms apps all support \"delete all\" or \"select all then delete\", e.g. chompSMS, Handcent Next SMS, Textra.

\n

Considering the fact that in early versions of Android, the messaging app does have this feature, my conspiracy theory is Google do not like us to delete our SMS, which could be analyzed by Google to build smarter AI and sell more ads.

\n

Date: 1555739252

\n

I complained about Flask's official documentation lacks a dedicated page for REST APIs and suggested to use Flask-RESTful extension instead.

\n

But without using the extension, it is still possible to learn enough Flask to write your first REST API service in Flask within 30 minutes.

\n
    \n
  1. The sample code showing how to do REST API and test it.
  2. \n
  3. path variable
  4. \n
  5. request method and parameters
  6. \n
  7. implement API exceptions
  8. \n
  9. launch the application
  10. \n
\n

Unfortunately, figuring out these five sections in three chapters (\"quickstart\", \"testing\", \"pattern\") are the relative pieces for a quick start of REST API service already costs me more than 30 minutes. :-(

\n

Date: 1555231105

\n

Most web video player lacks the feature of full browser window. Fortunately, with xrandr under Linux, we can split the physical monitor into multiple virtual monitors.

\n

For example, given a monitor 1920x1080 (476mm x 268mm) connected as HDMI-1, the following commands will split into two virtual monitors:

\n
xrandr --setmonitor left 960/254x1080/286+0+0 HDMI-1\nxrandr --setmonitor right 960/254x1080/286+960+0 none\n
\n

Note that not all window managers respect this setting though. For example, I have no luck with KWin (KDE) and Mutter (Gnome). On the other hand, xfce and openbox do respect this.

\n

Date: 1555097373

\n

https://defend.wikileaks.org/2019/04/11/emergency-julian-assange-has-been-arrested/

\n

Date: 1553940393

\n

Briefly tried Manjaro:

\n

The installation is smooth and it works out of the box.

\n

But it is problematic with package dependencies:

\n
    \n
  1. The dependencies declaration of Arch package is less rigid, compared to Debian/Fedora/Opensuse, etc.
  2. \n
  3. New arch packages are postponed to enter Manjaro's repository, which causes missing dependencies.
  4. \n
\n

Date: 1553823420

\n

Recently I learned a new notion (or buzzword, if you prefer), edge computing:

\n
\n

Edge computing brings memory and computing power closer to the location where it is needed.

\n
\n

Hmm, this let me rethink the statement that ZeroNet is uncensored.

\n

Maybe ZeroNet is not uncensored, instead, it is edge censored.

\n

Let me cite the definition of censorship from Wikipedia:

\n
\n

Censorship is the suppression of speech, public communication, or other information, on the basis that such material is considered objectionable, harmful, sensitive, or \"inconvenient\".

\n
\n

Such material is objectionable, harmful, sensitive, or \"inconvenient\" to who? To me, the content consumer. So, inspired by the idea of edge computing, the censorship system should bring memory and computing power closer to me, the location where censorship is needed.

\n

That is what ZeroNet does, edge censorship. Let the user/client/node/hub decide to mute and ban what content and which content producer.

\n

Date: 1553821959

\n

The download page of Manjaro offers 11 favors, xfce, kde, cinnamon, openbox, awesome, budgie, mate, I3, Architect (text), Deepin, Gnome. And there are tabs (it turns out these are actually pretended checkboxes) like \"beginner-friendly\", \"resource-efficient\", \"traditionally-workflow\".

\n

I clicked the \"resource-efficient\" tab, and there are 10 favors. In other words, only Gnome is considered as resource inefficient!

\n

So, according to Manjaro, all Linux Graphical Desktop Environments are efficient (and none Graphical Desktop Environment is also efficient, of course), except for Gnome.

\n

This must be joking.

\n

(I used KDE for two or three years and haven't used recent versions of Gnome, so I am unsure if Gnome is resource inefficient nowadays. If it is, then the resource inefficient Gnome is joking; if it is not, then Manjaro is making a joke about Gnome. That's why this must be joking. ;-)

\n

Date: 1553794194

\n

manjaro's advertise for developers features Godot, KDevelop, Geany.

\n

solus's advertise for developers features Atom, Idea, GNOME Builder, Qt Creator, Visual Studio Code.

\n

Seems there are two different groups of developers under Linux desktop.

\n

Date: 1553694861

\n

Although Flask is widely used to build REST API servers, its official documentation still cannot afford a dedicated page for REST APIs.

\n

I recommend go direct to check the full example of the quick start guide of Flask-RESTful extension. Take a look at the code example and start coding within 15 minutes.

\n

Life is short. Pick up tools and libraries fast.

\n

Date: 1553439182

\n

With the pyright extension, vscode can check type annotations of Python code.

\n

Date: 1553407876

\n

Finally gandi.net added support for ALIAS.

\n

Date: 1552832899

\n

Just read an insightful blog post by André Staltz talking about the dying web replaced by the GOOG-FB-AMZN Trinet.

\n

Actually the web is dying faster in China, where FB = Tencent, AMZN = Ali. Baidu tries to follow Google's strategy, shifting from a search oriented company to an AI oriented one. But apparently it is a failure.

\n

Reasons why web is dying faster in China:

\n
    \n
  1. As a developing country, mobile phones are the only devices to connect to Internet for a lot of people. And a lot of people first go online through mobile applications. And most likely these mobile applications are directly owned by Tencent or Ali, or by companies controlled by Tencent or Ali.
  2. \n
  3. Mobile payment is far more ubiquitous in China. (Unsurprisingly, the two most popular mobile payment methods are Ali's Alipay and Tencent's WeChat Pay.)
  4. \n
  5. Both Tencent and Ali make their products very inconvenient to use on the web, lacking a lot of important features. They force user to use the mobile application instead. And there is no regulation preventing them to do so.
  6. \n
  7. On the other side, regulation requires every user to bind a mobile phone number to use every web service.
  8. \n
  9. And obviously the authority dislike the open and free web. It is inconvenient and somehow dangerous to host an ordinary website. Want to host a forum? Even harder. Want to host a video site? No way! (Well, technically it is possible if you are a giant company or have strong connections with government.)
  10. \n
\n

Date: 1552746926

\n

In golden old days, a simple web page has an index.html, linking to an index.js. I can just open the index.html in a web browser to see the effect. And after some edits of index.html or index.js, I just refresh the page to see the effect. Once I am satisfied, I can copy the directory to any static hosting space.

\n

Nowadays, a simple web application has an index.html, liking to an index.js, which may import a lot of npm packages. Assuming these npm dependencies are already fulfilled (via npm install --save), parcel bring me back to the golden old time:

\n
parcel index.html\n
\n

Then I can just check the effect at http://localhost:1234/. And once I made an edit to index.html or index.js, it will get rebuilt and refresh automatically.

\n

Once the development is done, I just run parcel build index.html, then deploy/copy the dist/ directory to any static hosting space.

\n

And if I get bored, I can replace index.js with index.ts, and start coding in TypeScript. This works out of box with parcel. This also applies to CoffeeScript, or Elm, or even Rust (via WebAssembly).

\n

None of webpack, browserify, and rollup is as zero configuration as parcel.

\n

Date: 1552723275

\n

Hmm, just noticed that w3.org still uses \"old-fashioned\" XHTML 1.0 Strict.

\n

Date: 1552206417

\n

Saw this piece of Go code when watching Advanced Testing With Go by Mitchell Hashimoto:

\n
func testChdir(t *testing.T, dir string) func() {\n  old, err := os.Getwd()\n  // change directory and handle potential errors\n  return func() { os.Chdir(old) }\n}\n\nfunc TestThing(t *testing.T) {\n  defer testChdir(t, \"/other\")()\n  // ...\n}\n
\n

defer testChdir(t, \"/other\")() is a clever trick:

\n
    \n
  1. defer got testChdir(t, \"/other\")(), and to figure out what to register, testChdir(t, \"/other\") got evaluated. This let side effects contained in testChdir executed now.
  2. \n
  3. After the evaluation, defer registered the anonymous function testChdir returns, whose execution will be deferred.
  4. \n
\n

Just one line, brief and clever. But I think this is too brief and too clever.

\n

A quick google revealed that someone else already pointed out this pattern (defer db.connect()()) as bad practice. Besides, they also listed other 14 gotchas of defer.

\n

This makes me wondering whether the benefit of introducing defer justify its confusion and complexity.

\n

BTW, another reason that defer testChdir(t, \"/other\")() smells to me is it is error-prone. What if forget to type ()? After all, defer f() looks quite innocent during a code review.

\n

The 15 gotchas author suggested an alternative style, which is clearer and less error-prone:

\n
close := db.connect()\ndefer close()\n
\n

But I do not feel nature that connect() should return a function on how to closing it. Thus I prefer the dumb way:

\n
db.connect()\ndefer db.close()\n
\n

Date: 1552110906

\n

GraalVM's native image feature is impressive to me:

\n
; du -sh default*\n11M     default  # stand alone\n2.8M    default.jar # not counting the size of JVM\n; bench '/usr/bin/java -jar default.jar' './default'\nbenchmarking bench//usr/bin/java -jar default.jar\ntime                 118.3 ms   (115.1 ms .. 120.1 ms)\n                     1.000 R²   (0.999 R² .. 1.000 R²)\nmean                 120.4 ms   (119.3 ms .. 122.7 ms)\nstd dev              2.331 ms   (1.086 ms .. 3.812 ms)\nvariance introduced by outliers: 11% (moderately inflated)\n\nbenchmarking bench/./default\ntime                 1.512 ms   (1.493 ms .. 1.531 ms)\n                     0.999 R²   (0.999 R² .. 1.000 R²)\nmean                 1.502 ms   (1.495 ms .. 1.511 ms)\nstd dev              26.17 μs   (20.76 μs .. 34.28 μs)\n
\n

The startup time of a Java program is faster than a Python script, at the same level of Lua and Go.

\n

Currently GraalVM only supports amd64 linux/osx (there is preview distribution for Windows). No FreeBSD, no arm, etc.

\n

Also, native image for JVM languages other than Java are primitive. In fact the default.jar above is a Ceylon hello world program (generated via ceylon fat-jar). And the native image is generated from the following command:

\n
native-image --report-unsupported-elements-at-runtime --static -jar default.jar\n
\n

(This is undocumented at GraalVM's official documentation. Thanks to Lucas Werkmeister to supply the command.)

\n

However, currently this only works for simple Ceylon programs.

\n

But graal does looks promising to me.

\n

Date: 1552066645

\n

I read the first 4 items of Effective Java 2nd. edition several years ago, and had an impression that the book better renamed to Ineffective Java. There are 78 items total in the Effective Java 2nd. editon. Today I just learned that Effective Java updated to 3rd. edition on the end of 2017, targeting Java 9 (2nd. edition is target at Java 6). Now there are 90 items in the book. I am wondering does this imply that Java is more ineffective now? Or maybe People have finally discovered far more pitfalls of Java, thus although recent versions of Java fixed some issues, the net known ineffectiveness increases?

\n

Date: 1551619332

\n

Go advertises itself as having first class functions:

\n
return alternativeImpl(\n    x, y,\n    func (a int, b int) int { return a + b },\n    func (a int64, b int64) int64 { return a + b },\n    big.NewInt(0).Add)\n
\n

With operator function and overloading/generics, this could have been shortened to:

\n
return alternativeImpl(x, y, +, big.NewInt(0).Add)\n
\n

BTW:

\n\n

Date: 1551369924

\n

Currently I'm using a tree based todo manager, roughly something like:

\n
[task1\n  [subtask1\n   subtask2\n     subsubtask1\n  ...]]]\n task 2\n ...]\n
\n

I'm quite satisfied with it for a few months, and found that it is much more expressive than former flat todo managers I've used.

\n

But today I find out that I need to express something like this:

\n
[task1\n  (cond1\n      [subtask1\n       subtask2\n          (cond1.1\n             [subsubtask1\n              subsubtask2]\n             [othersubtask1\n              othersubtask2])\n       subtask3]\n      [othersubtask1\n       othersubtask2\n...\n
\n

Hmm, tree based todos are cool. But eventually I will need an AST (abstract syntax tree) to manage todos?

\n

Date: 1551194474

\n

Looks like there will be no more compact mobile phones. :-(

\n

Well, at least there are compact pad (Huawei Mate X) and compact camera/audio player (Sony Xperia 1) in 2019.

\n

Date: 1551031294

\n

小学时候写篇 300 字作文,常常绞尽脑汁,觉得怎么字数还不够啊,现在却为了把豆瓣短评控制在 350 字内大费周章(考虑空格和标点,大概等价于小学时代的 300 字)。

\n

Alita: Battle Angel (2019) 短评(恰好 350 字):

\n

尽管神还原了原作中的许多经典画面,但恰如并不 Scrap 的 Iron City 一般,整部电影明快的调子,完全不同于 Gun Dream 的阴郁风味。强行分明善恶,操作粗暴,改编也有太多草率之处,甚至留下不少漏洞,比如原作中心脏仅为大脑提供养分,所以 Alita 用自己的心连接 Hugo 的头颅情理之中,而电影中将心脏改为发动机,实在让人很难假设它还有一个没交代的提供大脑养分的辅助功能;原作 Grewishka 有赏格,一众猎人只是畏其实力不敢出手,电影改成受上层庇护,那么 Hugo 被工厂通缉时,Alita 本应先质疑工厂是否弄虚作假;最后 Hugo 向上攀爬,电影中 Alita 劝解的话分明是对原作中执念破灭、一心求死的 Hugo 而说,对电影中逃避通缉求生的 Hugo,只需简单交代有防御轮即可。幸赖 CG 视效硬拉上五星,避免本片沦为 Ghost in the Shell 2017 一样的平庸之作。

\n

Date: 1550941813

\n

Google Play Store lacks the \"ignore this update/version of app\" function.

\n

Date: 1550219881

\n

The abandonware nuclide has a distinct feature \"Remote Development\" (use a remote machine as the workspace for compiling/building and language services via ssh).

\n

Unfortunately none of Atom, VS Code and JetBrains IDEs has support for this feature yet.

\n

Date: 1549985272

\n

RubyGems has a so-called twiddle-wakka shortcut ~>. Therefore, assuming in a semver setup, you can write ~> 2.2 instead of the verbose ['>= 2.2.0', '< 3.0']. Seems neat, isn't it?

\n

However, later Alice reported a bug about the software, and Bob found out that the bug is caused by a bug from the library it depends, which has already be fixed in 2.2.2. So Bob changed the dependency to ~> 2.2.2. The bug was gone, all tests passed, and everything looked great.

\n

However, ~> 2.2.2 is not equivalent to ['>= 2.2.2', '< 3.0'] (Bob thought so), but ['>= 2.2.2', '< 2.3.0']!

\n

Date: 1548356219

\n

Recently the term \"headless CMS\" and \"decoupled CMS\" gain a lot of popularity. But these two terms are rather confusing to me.

\n

To me, \"headless CMS\" sounds like some system mainly intended to be used with curl etc. on command line, like ix.io the headless pastebin. However, obviously most people use the term \"headless CMS\" in a different way.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
What people sayWhat I would call it
headless CMSdecoupled CMS
decoupled CMSdecoupled CMS with default UI and templates
\n

BTW, I wish the next generation of website will be both frontend agnostic and gateway agnostic. That is, a user of a website can directly access those micro-services. And optionally they may provide some default gateways and/or frontends. Just like a user of a programming library/framework can directly access those low-level functions/classes. And optionally the library/framework may provide some high level APIs and/or examples.

\n

Date: 1547256529

\n

I use the fish port of z (alternative to autojump) and remap the command name to h (set -U Z_CMD \"h\"). h is easier to type (on dvorak keyboard layout) and remember (\"head to\").

\n

Date: 1544101685

\n

Wrote a simple script (zerome2md) to dump ZeroMe posts to a markdown file (for backup or publish eleswhere).

\n

Images are supported. Comments are not supported yet (patch welcome).

\n

The \"exported\" markdown file can be consumed by static site builders like Jekyll, e.g. a static mirror of my ZeroMe posts on clearnet: mmap.page/log/

\n

Date: 1543935924

\n

The image support of ZeroMe feels quite hacky to me:

\n
{\n  \"post_id\": ...,\n  \"body\": \"...\",\n  \"date_added\": ...,\n  \"meta\": \"{\\\"img\\\":\\\"900,600,bddbaaedafc5ea9db5b85b97eba543766888111965754446,01233014420125671882171769A111BABCDC9BAABB7CEC9DAAAA69AC9AAABBA9FF9BBB\\\"}\"\n},\n
\n

Date: 1542433791

\n

It is such a surprise for me that GitHub does not have any public available issue tracker for itself!

\n

Some users have created one (isaacs/github). To use it, you need to open an issue on it and email a copy to support@github.com, then manually post replies from github staff. :-(

\n

Date: 1542433143

\n

Two exotic project ideas occurred to me on the bed. After getting up and turning on the computer, I found out that I had already forgot one of them.

\n

Date: 1542391958

\n

Ansible advertises itself as agent-less, but:

\n
    \n
  1. The agent/client machine still needs to have a (compatible version of) python preinstalled.
  2. \n
  3. SaltStack supports an equivalent server-only model (also requiring python). And SaltStack is more flexible since it also supports server-agent and agent-only models.
  4. \n
\n

On the other hand, Patchwork (based on fabric) is true agentless (sending shell calls). Its functions is quite limited and it lacks high-level abstractions though.

\n

BTW, the cloud provider modules from both Ansible and SaltStack are disorderly and unsystematic. Some use cloud providers' SDK, some use libcloud (a unified interface for different cloud APIs), and some directly use requests.

\n

Date: 1542376879

\n

Flickr will limit free users' photos to 1000 (extra photos will get deleted in next year). Upon hearing this I am quite depressed, because downloading photos and uploading to a new platform (provided that I can find an alternative) will take a lot of time and effort.

\n

Later I learned that flickr will not delete old photos licensed under Creative Commons. Thank goodness! Almost all my photos on flickr are under cc-by-sa or public domain.

\n

Today I just checked my flickr account and found out that I only have less than five hundreds photos there...

\n

Date: 1541249463

\n

Upgraded KDE Neon from 16.04 to 18.04 today via its built-in \"Distribution Upgrade\" GUI. The whole process is mostly smooth, except it reports a mysterious error \"installArchives() Failed\" before restart. I just ignored it and had not discovered anything wrong.

\n

The system feels the same, without any dramatic change. I have not noticed any difference until I decided to change the wallpaper:

\n
    \n
  1. Plasma Wallpaper now allows to use Bing's Picture of the Day.
  2. \n
  3. Plasma Mouse Actions now supports configuring all mouse buttons.
  4. \n
\n

I used to rebind middle key to forward button (so I can press it via my thumb, instead of clicking the hard-to-press wheel) via xinput set-button-map. I knew I had to add it to my startup script, but because: 1) I am lazy; 2) I seldom restart my computer these days; I did not write it. Now I do not need to write it -- another example of advantage of \"lazy evaluation\". ;-)

\n

Date: 1541247161

\n

IBM bought RedHat as a cloud computing company, thus irrelevant projects originally sponsored by RedHat may not receive bandwidth from IBM in future. Fortunately:

\n
    \n
  1. Ceylon: it begins to migrate to Eclipse last year
  2. \n
  3. Cygwin: nowadays WSL seems a better option (if I have the opportunity to use Windows in future)
  4. \n
  5. Gnome: I switched to KDE last year
  6. \n
\n

Date: 1541245426

\n

I've seen a lot of note applications/services' export function does not support exporting attachments. Vivaldi Browser is just another example (its sync all feature does not include attachments of notes).

\n

Date: 1540394823

\n

The new palm phone reveals how ugly big today's phones are.

\n

3.3-inch, 445-ppi LCD display, 62.5 grams weight, IP68, cool! Type C, Android 8.1, 3GB RAM, 32GB storage, O.K. $349.99, expansive but still acceptable. Verizon Only, ShareNumber only, BAD!

\n

Photo credit: theverge.com\n\"attached

\n

Date: 1536929070

\n

Oops, python -m SimpleHTTPServer does not support range request.

\n

The following three lines (not counting import statements etc.) of Go turns out to support range request out of box:

\n
func main() {\n  err := http.ListenAndServe(\":8000\",\n    http.FileServer(http.Dir(os.Getwd())))\n  log.Fatal(err)\n}\n
\n

Date: 1536759116

\n

Go advertises first-class function, but to pass a function, you have to match the exact signature. No sub-typing of functions. Yes, even Java supports covariant return result (no contravariant parameter though), but Go supports neither.

\n

Date: 1536678777

\n

Programming needs practice. And I think \"how many lines of source code I have deleted\" estimates my experience on programming better (than how many lines I have written).

\n

A shell-fu to calculate how many lines I have deleted in a git repository:

\n
git log --shortstat --no-merges --author=$(whoami) | grep 'files\\? changed' | awk '{deleted+=$6} END {print deleted}'\n
\n

Date: 1535774560

\n

Refactoring with statically typed code (using Python's type hint) is an enjoyable process. To switch an upstream library, I just replaced one import statement, one type definition, and one invoking statement. Then I just fix all the typing problems reported by PyCharm. After that, I run the program and find out that it just works! No \"find usage\" or \"search and replace\". And the project does not have any test (I am too lazy to write one.) Static typing is the preservative to slow down the inevitable decaying of code.

\n

Date: 1535038856

\n

Gists are second class citizen of GitHub. For example, GitHub API does not support searching gists (in both old v3 REST API and the new v4 GraphQL API).

\n

Date: 1535037615

\n

When will Java have \"real\" function type? What Java uses interface to mimic is nominal, not structural.

\n

Date: 1534597565

\n

Learning ML/Haskell deepened my understanding of typing.

\n

Date: 1534051076

\n

vscode does not have built-in syntax highlighting for Haskell, while it does support F# out of the box.

\n

Date: 1533967519

\n

Google Photo's \"free up device space\" (delete already backed up photos from device) and recover storage (compress already uploaded photos from original to high quality) applies to ALL photos. I cannot free up / recover storage selectively, for example, only archived photos or photos within certain albums.

\n

Date: 1533955428

\n

Not sure when GitHub changed its front page (they call it dashboard), slow to load. I miss the old GitHub front page, loaded almost instantly.

\n

Date: 1533921116

\n

I want to install an extension of JupyterLab (toc), then I found out that installing JupyterLab extensions requires nodejs (because JupyterLab extensions are npm packages). So I install nodejs via conda, which automatically downgrading my JupyterLab from v0.33 to v0.28. After all of this, I am about to install the extension, but it turns out it requires JupyterLab v0.33! :-( The Jupyter blog said JupyterLab is ready for users on Feb. 2018 ...

\n

Date: 1532952443

\n

Not sure whether BDFL's retirement is good or bad, but personally I dislike PEP 572 (I dislike a lot of aspects of Python, though).

\n

Date: 1532783984

\n

languagedetective.com predicts your native language with English text you wrote as input. I tested with one of my blog post and the result is: 70.6% Native, 29.4% Non-Native. Bingo!\nBut it is not good at predicting my native language: 37.9% Arabic, 16.1% Korean, 14.7% Hindi, 11.1% Chinese, 8.6% German, 6.5% Turkish, 2.1% Japanese, 1.6% French, 0.7% Italian, 0.7% Spanish.

\n

My native language is Chinese.

\n

Date: 1529854155

\n

Suddenly I wanted to eat tempura, but it is unavailable from the menu of the izakaya I went. So I ate some fried salmon sushi instead.

\n

Date: 1529138055

\n

My Razer DeathAdder has blue LED on wheel and logo, feeling very disturbing to me. Thanks to razercfg, I can turn them off under Linux.

\n

(I am not a game player. I bought this mouse just because there are not many left hand mouse available on my area.)

\n

Date: 1528815034

\n

I am really confused with those color modes with monitors. Cannot them show color temperature instead?

\n

Date: 1528733744

\n

How not to waste time on matching socks, i.e. O(1) to pick out socks to wear? Make all socks the same. How?

\n
    \n
  1. Buy only one kind of socks.
  2. \n
  3. Shift your mind to realize that all socks are the same, regardless of their shapes and colors.
  4. \n
\n

I myself had shifted my mind and treated all socks equally without discrimination, from the beginning of my undergraduate.

\n

Date: 1528202901

\n

Microsoft is acquiring GitHub. GitHub in fact has an (maybe unintended) use: as a bootstrap mechanism to download tunnel software/tools to bypass firewall. After acquired by Microsoft, I doubt those tunnel software/tools may be unavailable within the firewall.

\n

Date: 1526298916

\n

Recently I found out that MUJI French Linen shirts/pants have raw (undyed) color for adults.

\n

Date: 1524061534

\n

Just figured out why some people are so excited about Flutter (a mobile framework for Android/iOS in Dart by Google).

\n

Because Dart's FAQ said \"Isn’t Dart a lot like Java\", thus Dart ~= Java.

\n

If Dart is counted as Java, then Java becomes an alternative full stack language:

\n\n

(To me, this is not excited at all, though. ;-)

\n

Date: 1523902414

\n
\n

God made a woman from the rib he had taken out of the man (Genesis 2:22)

\n
\n

So heterosexual intercourse is excitation of one's own body part, i.e. self-gratification?

\n

Date: 1523630163

\n

My personal choices to score movies:

\n
    \n
  1. WTF
  2. \n
  3. I do not want to waste my time on this
  4. \n
  5. to kill some time
  6. \n
  7. I probably will not watch it again, but I am not object to
  8. \n
  9. I will watch it again
  10. \n
\n

So forgive me for being harsh to a lot of movies,\nI am poor, thus:

\n\n

However, I still watch quite a lot of movies after all.\nThanks to my just the right amount of poverty, I can afford buying movie tickets, and cannot afford some other more expensive forms of entertainment. In fact I am not sure, movie is entertainment to me. Maybe it is rather a form of escaping of the desert of reality? Or, maybe all forms of entertainment are ways of escaping to me?

\n

Date: 1523201921

\n

Both \"Three Billboards Outside Ebbing, Missouri\" and \"The Third Murder\" talk about the problems of the environment and the feeling of hopelessness, though in distinct (American/Japanese) ways.

\n

Date: 1522629606

\n

Digg Reader was dead at the end of last month (March 2018).

\n

Date: 1522245247

\n

debian.org is not available in CN (not sure whether it has been blocked by the great firewall or just some routing issue).

\n

Date: 1522083867

\n

Almost all smart phones today use a non-removable battery. And most smart phones do not use all-day battery. What an insane design combination!

\n

Date: 1521376411

\n

Saw \"novel blockchain gameplay\" in an elevator ad of a browser game. This reminds me of a time when a lot of products advertise themselves using \"novel nano-meter technology\".

\n

Date: 1521037402

\n

I learnt typing on a typewriter, so membrane keyboards, especially membrane keyboards with short key travel, feel unnatural to me. However, I found out that my fingers are more tired when typing a lot on mechanical keyboards. (Have not tried Topre keyboards.)

\n

Date: 1520956541

\n

One of my favorite poem of Li Ch'ing-chao (李清照) is \"As in a Dream\" (如夢令).

\n

Light rain and gusty wind last night. (昨夜雨疏風驟)\nSound sleep did not dispel the slight drunkenness. (濃睡不消殘酒)\nI ask the one rolling up the curtain, (試問卷簾人)\nbut she answers: \"The cherry-apple trees are the same.\" (卻道海棠依舊)\n\"Don't you know? Don't you know? The red should languish while the green should plump.\" (知否,知否,應是綠肥紅瘦)

\n

(I am a native speaker of Chinese but not a native speaker of English. I tried my best to translate it. Any feedback on translation is welcome.)

\n

\"The red should languish while the green should plump\" reveals the tenderness of the poet, while \"should\" implies the firmness of the poet.

\n

\"Don't you know? Don't you know?\" That is the reality distortion field of a groggy poet.

\n

Date: 1520670847

\n

Very pessimistic about mobile phones I would have to buy in future:

\n\n

Date: 1520617250

\n

Just published my first Firefox extension: arxiv-url, a Firefox addon to replace arxiv pdf links to corresponding abstract links.

\n

Writing a firefox extension is actually easier than I thought. If you'd like to write one yourself, just follow mozilla's doc.

\n

Note:

\n
    \n
  1. If you do not want to install web-ext (it depends on node and some npm packages) for web-ext build, you can just zip your extension.
  2. \n
  3. Submit the zip file to AMO directly. No need to web-ext sign it (if you did so, the signature will be replaced with AMO after all.)
  4. \n
\n

Date: 1520607766

\n

Compared to wine and tea, chocolate is inexpensive. The most expensive chocolate I've eaten is Amedei CRU, which is still affordable.

\n

Date: 1519995238

\n

extensiontest.com (test if a chrome extension is compatible with firefox) is not 100% accurate. Just encountered an chrome extension passing extensiontest.com but not usable in Firefox.

\n

Date: 1519744209

\n

Backing up to USB 3 external hard disk with borg create -C lz4 is very fast.

\n

Date: 1519205841

\n

Moving one icon on my mobile phone, all icons between the old place and the new place of the moved icon, will shift their places.

\n

I am really upset by this.

\n

Image in an insane programming lanuage, there is a list, say,

\n
l = [a, b, c, d, e, f, g]\n
\n

And when you eval l[0] = l[6], the list becomes:

\n
l = [g, a, b, c, d, e, f]\n
\n

What a big surprise!

\n

In such a programming language, imaging how many statements you have to write to accomplish simple tasks such as swaping a and g.

\n

On the other side, in any sane programming language, to swap a and g, you just need to write something like:

\n
tmp = l[0]\nl[0] = l[6]\nl[6] = tmp\n
\n

That is basically the behavior of desktop shortcuts of old-fashioned desktop operating systems.

\n

I encountered this design fault on iOS devices before.\nAnd now it infects my Android phone.\n(Not sure whether Android 8.0 or the mobile phone producer introduced this design fault.)

\n

My workaround: Only put icons most frequently used on the first screen. Put all other icons in folders. And arrange those folders by their names, pretending that they cannot be arranged freely.

\n

Date: 1507309298

\n

Recently I started to read a book during wait time when I had taken a bag with me (a thin book is light and there is no more worries for short of battery), or just let my mind fly away when I had not. A win-win strategy for the life of my neck and the life of mobile phone battery.

\n

Date: 1506863469

\n

tutanota client side source code contains Flow type definition for Mithril.

\n

Date: 1506253651

\n

Microsoft had suspended my outlook mail account for several weeks , saying my account is used to send a lot of junk mails, or violates their TOS in unspecified way.

\n

I totally have no idea what violates their TOS (I had not sent mails using this account, let alone junk mails). To unblock my account, I need a cellphone. I am very upset about the assumption that you have to have a cellphone.

\n

And to get help from Microsoft support for my locked account issue I need to have a working account. This is a deadlock. Thus I decide to stop use Microsoft account.

\n

Then I asked myself what will happen if the same thing happens to my gmail account? Then I realized the fact that I did not bother set up my own domain for emails put me into danger.

\n

Date: 1505399377

\n

I always prefer a small screen mobile device, which is easier to carry. I do not read/browse/view a lot with the mobile phone, since either neck or shoulders are in an unnatural angle.

\n

Date: 1505298765

\n

iPhone X shows that machine learning can be done on client side, without talking to a remote server. This is encouraging for privacy concerned services and users.

\n

I am not sure about the long term impact of animoji. Will it make people's countenance more exaggerated in real life?

\n

iPhone {X, 8, 8P, 7, 7P, 6S, 6SP, SE}. Consumers need to choose one from eight models. Not sure if this is good or bad for consumers, but this is definitely not the Apple way.

\n

Date: 1505198726

\n

I found out that I could not understand some code I wrote 8 months ago.

\n

Then I checked the git commit message 8 months ago.\nThe commit message said

\n
\n

I hope I implemented the algorithm right.

\n
\n

So this is the fault of the previous version of me myself. If the previous version of me myself truly understood the algorithm, then I would have resumed or reinvented the algorithm quickly now.

\n

Date: 1504997063

\n

Years passed, and Google Contact still does not support exporting contacts. It still redirects me to the \"old version\" for exporting.

\n

Date: 1504960007

\n

I think sometimes a ML/Haskell like syntax may be a better alternative for math notation than lisp. Lisp is unambiguous but slightly harder to type manually (I am too lazy to use the lisp IDE/mode and copy-paste, or extend the editor to support auto completion in code blocks.) Compared to C like syntax, ML/Haskell saves some typing of commas and parenthesis.

\n

Date: 1504847037

\n

The intuition behind Curry-Howard correspondence:

\n
    \n
  1. Staring from propositions (types of parameters), we construct proof (function) to get other proposition (type of return value).
  2. \n
  3. The rule to construct proof (function) is called logic (type system).
  4. \n
  5. It is hard to construct a proof (function). But once the proof (function) has been constructed, it is easy to verify the proof is valid (the function does return the value of specified type).
  6. \n
\n

Notes:

\n
    \n
  1. In practice, the verification of proof is not always easy, because real word proof tends to omit a lot of implicit knowledge and intermediate steps.
  2. \n
  3. The verification of returned type of function is so easy that we do not need to verify that manually, the interpreter/compiler will verify that for us automatically.
  4. \n
  5. The Curry-Howard correspondence is the basis of theorem prover such as Coq.
  6. \n
\n

Date: 1504597757

\n

Baidu Map iOS keeps requesting location on background when location info is not available, draining batteries and heating device very quickly.

\n

Date: 1504540170

\n

Now mail.google.com redirects to www.google.com/gmail/about/, which has a fancy design. I miss the simple UI with a login form and storage space counter.

\n

Date: 1504422932

\n

To stop EME (Encrypted Media Extension) from entering W3C Standard, FSF asked people to dial up Tim Berners-Lee. First, asking people to dial up a person is not protest but DDOS. Second, no one cares W3C standard today. If Apple (safari), Google (chrome), Mozilla (firefox) and Microsoft (Edge) were dead-set, then the story is over. Neither W3C nor Tim Berners-Lee can do anything about it. (Fortunately Mozilla is not dead-set on EME, although Firefox Desktop has implemented it years ago.)

\n

Date: 1504338200

\n

MIT scheme taught me a chuunibyou way to say goodbye: \"Moriturus te saluto.\"

\n

Date: 1504276342

\n

Powershell aliases still do not support tab completion.

\n

Date: 1503905257

\n

Finally, concepts such as polymorphism, generics, type variable/parameter, overloading, and type class are united in my brain.

\n

Date: 1503845426

\n

Failed to understand the fmap signature in Haskell in about 15 minutes:

\n
class Functor f where\n    fmap :: (a -> b) -> f a -> f b\n
\n

It took me about 15 minutes to realize that\nI have seen too many curried functions\nso my brain instantly parses

\n
(a -> b) -> f a -> f b\n
\n

as

\n
((a -> b), f(a)) -> f(b)\n
\n

instead of the intended

\n
(a -> b) -> (f(a) -> f(b))\n
\n

So I have to:

\n
    \n
  1. either admit that my brain is blunt
  2. \n
  3. or profess that the currying way of ML/Haskell languages is confusing
  4. \n
\n

As an ignorant person, obviously I chose 2.

\n

Date: 1503815372

\n

about.me has not been about me for a long time.

\n

about.me was a simple profile page before 2016.

\n

Now it is supposed to direct bandwidth to the site matters most to the user. about.me called it \"personal pages with a purpose\". While this feature may be useful, this is not the original about.me anymore. The original purpose of about.me is you can insert a about.me/you link in bios of other sites, less to type and easier to update.

\n

Date: 1503633800

\n

\"Go to definition\" does not work for shell scripts in vscode. * (from vscodevim extension) can be used as a workaround.

\n

Date: 1503630583

\n

sh is the only language I am using that has dynamic scoping for variables. (Privacy leaked: I do not use Emacs.)

\n

Date: 1503359848

\n

A recent Windows update forced me to re-select options like no personalized ad, ruined my registry key for a customized keyboard layout (dvorak and swap esc & caps), and pined the Mail app on my taskbar. This is more like a regression than an update to me. (To be fair, it does allow me to launch some Windows applications under WSL.)

\n

Date: 1485507471

\n

Lantern only provides binary package in deb format for Linux. To install lantern on rpm based Linux distributions, first install rpmbuild, alien (to convert deb to rpm) and libappindicator3-1 (lantern's dependency), then use alien to convert the deb to rpm, and finally install the converted rpm.

\n

Date: 1485431319

\n

Used openSUSE Leap 42.2 for a few days. You have to add a few repositories to install things like mp3, flash, and input methods. You have to configure mounting NTFS partitions yourself (via YaST or manually editing /etc/fstab). Default fonts setting for Chinese is terrible. Other things work out of the box mostly. KDE Plasma 5.8.2 roughly catches up the polishness of recent versions of Windows.

\n

Date: 1485262536

\n

Encountered ads with only one sentence \"Only bricks produced by The Lego Group are Lego ® bricks.\" and one Lego logo. This is advertising of silliness. No sense and no design.

\n

Date: 1485079755

\n

cdrtools author's viewpoint on controversy of cdrtools license compatibility.

\n

Date: 1484756523

\n

A programmer's client (a local cinema) website got hacked, with racist messages posted. The policy suspected the programmer hacked the site, and got a warrant to seize the programmer's computer. Then they sent 21 armed polices, 3 of them to seize the computer, and 18 of them as witness.

\n

On early morning, these polices broke in the programmer's home, and shot dead the programmer when he is talking to his lawyer on the phone (4 shots on chest and face).\nAnd the 18 witness polices witnessed that the programmer fired a crossbow bolt at one of them (that police was protected by Kevlar thus slightly injured).

\n

This is not something happening in a magic realism novel or an absurdist movie. This is what happened on December 23rd 2016, London, Ontario, Canada.

\n

The programmer is Sam Maloney, the creator of morphis (a free open source p2p distributed datastore), a husband and a father of two children.

\n

News reports:

\n
    \n
  1. first news report on nationalpost.com
  2. \n
  3. more recent report on Motherboard (ZeroNet mirror)
  4. \n
\n

Date: 1484574248

\n

The so called whatsapp 'backdoor' was documented in the blog post of Open Whisper Systems on 05 Apr 2016.

\n

I think the notification on security code for a contact changing should be \"opt out\" instead of \"opt in\". I guess Facebook made this \"opt in\" so users having no idea of public key encryption will not get confused by the security code change notification. They could make it \"opt out\" with a detailed explanation on first notification of security code change instead, in my own opinion.

\n

I would rather call it a less secure design choice. Anyway, no matter you think it is a backdoor or not, it is not news.

\n

Date: 1484052490

\n

Sign and publish your posts/comments from command line:

\n
zeronet.py siteSign site-address-of-other-people --inner_path data/users/address-of-myself/content.json --publish\n
\n

It will asks the private key,\nunless you happen to be the site owner,\nfill in your cert's auth key.

\n

For example, if you are signed in with you@zeroid.bit, then you can find certs->zeroid.bit->auth_privatekey in data/users.json.

\n

Thanks to @nofish for this tip.

\n

Date: 1483966944

\n
\n

the ideas enshrined in the Ubuntu Manifesto:\nthat software should be available free of charge,\nthat software tools should be usable by people in their local language\nand despite any disabilities,\nand that people should have the freedom to customize and alter their software\nin whatever way they see fit.

\n
\n

This is what Ubuntu put on its front page about 10 years ago.

\n

Nowadays these words are missing from the entire site of ubuntu.com\n(the only place left is the handbook of LTS, maybe no one bothered to update the preface of the handbook?)

\n

And this is what now on the front page of ubuntu.com:

\n
\n

Ubuntu is an open source software platform that runs from the cloud, to the smartphone, to all your things.

\n
\n

Mark Shuttleworth used to think \"the next big thing\" is \"build a platform so people can share free (as in freedom) things such as software, music, etc\".

\n

Later \"the next big thing\" of Ubuntu gradually changed to \"universal user experience on all devices\", which is less uncertain since Apple has already been a successful example.\n(Apple is determined to make Mac OS X more and more like iOS, and make Apple laptops more and more like iPads.)

\n

Not know how well Ubuntu will do in next 10 years.\nAnywhere, \"universal user experience\" has nothing to do with the original Nguni Bantu word \"Ubuntu\".

\n

Date: 1483873500

\n

Install ZeroNet as an auto-start service on FreeBSD:

\n
pkg install zeronet\nsysrc zeronet_enable=\"YES\"\nservice zeronet start\n
\n

Run ZeroNet command:

\n
su -m nobody zeronet siteCreate\n
\n

Date: 1483798686

\n

vscode's refactoring is still much less powerful than WebStorm, even for TypeScript.

\n

Date: 1483701866

\n

\"A Little Java, A Few Patterns\" uses a special coding style to remark mutability:

\n

Put semicolon on its own line.

\n

For example:

\n
x = x + 1\n; // Future references to `x` after this line reflect the change.\nanArray.append(1)\n; // Same as above.\n
\n

Date: 1483614089

\n

new History().repeat

\n

There is no first class functions in Java, so to pass functions, we wrap functions in classes. Now there is no first class function types in TypedRacket, so to predicate function types, we wrap functions in structs.

\n

P.S. Same applies to TypeScript, Flow, Kotlin, and Swift. Ceylon's function type is first class, though.

\n

Date: 1483533112

\n

If you run ZeroNet on a remote machine, the doc recommends enabling UiPassword. But if your are using an unsafe network (public wifi, evil ISP, etc), password is transferred over insecure HTTP protocol. So for safety, you need to configure a reverse proxy with SSL for ZeroNet.

\n

Alternatively, you can just start ZeroNet on remote machine as normal,\nwithout --ui_ip, UiPassword, reverse proxy, SSL, etc.\nAnd run this command at local machine:

\n
ssh -L 43110:127.0.0.1:43110 -N username@remote\n
\n

Then you can just access http://127.0.0.1:43110/ on your local machine, securely.

\n

Date: 1483439543

\n

Miss finally or defer in C.

\n

Date: 1483358343

\n

Yoda expressions are useful for tests in C, such as in assert(true == ... and assert(false == ....

\n

Date: 1483252068

\n

Just found some old notes on K&R C book.

\n

The ink (I used a cheap ballpoint pen) is fading but still readable with some efforts. Most notes are tricky parts of C, which are somehow irrelevant now (either being familiar with them or found out I rarely use them). Some notes I cannot agree now, e.g. \"Union really looks like a dirty hack on struct.\" on p. 125. However, on p.89, there is a note on while (*s++ = *t++) saying \"Take me minutes to understand.\" Currently it would still take me minutes to understand it. Proud of it.^W^W^W

\n

Date: 1483158324

\n

Apache Portable Runtime is originally supporting library for Apache web server. Thus it uses memory pool heavily. So it may not be suitable to use APR as a standard library for general C programming.

\n

Date: 1482929840

\n

USB 3 external disks are 10-20% slower on VirtualBox.

\n

Date: 1482853228

\n

The confusing^W smarty Kotlin

\n

What would be the type of f in the following line?

\n
val s: Int = f(1, 2, 3)\n
\n

Not considering subtyping and generic,\nthe type f may be one of:

\n
    \n
  1. (Int, Int, Int) -> Int, the most intuitive one
  2. \n
  3. (IntArray) -> Int, a variadic function
  4. \n
  5. f, an object named f with an invoke method
  6. \n
\n

Date: 1482573034

\n

Just fried some peanuts, which increased the PM 2.5 by 8 ug/m^3 in kitchen. So frying will not be a source of local air pollution if you have extractor hood opened and keep the oil temperature low.

\n

Date: 1482501352

\n

Opened software manager in OpenSUSE and found in \"rpm groups\" there are application and applications, developement and development.

\n

Date: 1482419450

\n

PyCharm 2016.3 claims to support Python 3.6's f-strings (formatted literal). But in fact it just supports syntax highlight. All PyCharm's intelligent features are not enabled for code embedded in f-strings.

\n

Date: 1482325338

\n

Beaker is similar to ZeroNet. Their difference:

\n\n

Also, because Beaker requires a customized browser:

\n\n

(These are not substantial differences since anyone can make a customized browser for Zeronet.)

\n

Other differences are technical details, like ZeroNet is written in Python, while Beaker is written in JavaScript, and ZeroNet uses base58 encoded site address (compatible with bitcoin), while Beaker uses hex encoded address.

\n

Date: 1482236480

\n

Problems of Sia:

\n
    \n
  1. It supports proof of storage but not proof of bandwidth.
  2. \n
  3. The Sia developers mined the first 100 blocks of Sia.
  4. \n
  5. 3.9% of all successful storage contract payouts go to Siafund, of which 87.5% is owned by Sia's parent company.
  6. \n
\n

Date: 1482152061

\n

Problems of StorJ:

\n\n

Date: 1482056747

\n

Just launched 0git.bit, a list of git repositories on ZeroNet.

\n

I wrote it based on the ZeroChat tutorial on ZeroBlog.

\n

Features:

\n\n

Its source code is hosted at ZeroNet, browsable and cloneable.

\n

P.S. editing posts is not implemented yet.

\n

Date: 1481907901

\n

Currently FaceBook Message and Google Allo has optional end to end encryption. And WhatsApp has end to end encryption enabled for all messages. On the other hand, WeChat still uses http. #ThisIsChina

\n

Date: 1481815829

\n

SetupList now has its .bit domain setuplist.0web.bit.

\n

P.S. If you want to register a .bit domain, but do not want to setup a full namecoin node on your machine, you may get a .bit domain for your zeronet site at 0web.bit for 0.001BTC/0.1XMR.

\n

Date: 1481718944

\n

Yandex mail smtp refuses to send a GPG encrypted mail saying it looks like spam...

\n

Date: 1481539922

\n

Visual Studio Code only provides 32 bit downloads for Windows.

\n

Date: 1481456773

\n

Lesson learned: when your data.json local copy is outdated (e.g. rollback to an old version manually because of file system issue), do not post new content to the zite that outdated data.json belongs to. Otherwise you will publish your \"deletions\".

\n

Date: 1481373014

\n

When the function parameter is a function pointer, CLion (2016.3) cannot auto complete function name as parameter, like IntelliJ Idea for Java.

\n

Date: 1481288689

\n

Go back to use paper to manage my todos. (Some todos are still in WunderList, e.g. shopping list, cause I do not want to bring paper and pencil to supermarkets.)

\n

Date: 1481203503

\n

C is a hacky language. For example, string in C. If you think string in C is an array of characters, then you cannot put some characters in string (such as Unicode character) and you can put some noncharacters into string. If you think string is an an array of bytes, like a buffer, then you cannot put the byte \\0 into string. So string in C is inconsistent viewed from both high level and low level.

\n

Go, advertised as modern C, inherits C's hacky mindset:

\n\n

Date: 1481108543

\n

@zeronetuseri6293 asked how to explain Systemd is bad \"like I am five\". I just prepare some text to brainwash five-year-old \"Systemd is bad\":

\n

You are five. You do not know how to cook pasta, how to bake bread, and how to clean the window, etc. Fortunately there are a lot of volunteers to help you to do all these things.

\n

The problem is these volunteers tend to commit suicide because of intrinsic depression. (They think helping a five year old may helps to reduce depression.) And you are lazy and shy. You do not want to manage them yourself. There is a magician called Sysfive. When you go to sleep, Sysfive will kill those volunteers (not let them go home to avoid traffic jam), and when you awake, Sysfive will reborn those volunteers. Also if you find some volunteer killed themselves, you can ask Sysfive to reborn them.

\n

These volunteers speak a language named Gnome. You happen to speak this language, too. And all those volunteers are from the same nation Debian. Debian is located at a continent called Linux. The continent Linux is located at a planet called unix.

\n

Your friends have volunteers speaking different languages like KDE and Xfce, from different places like OpenSUSE (also on Linux continent) and FreeBSD (on the BSD continent), and different magicians like OpenRC and RunIt (one magician can work for a lot of children.) You talked with your friends, and found out that you can find volunteers speaking Gnome from any nation and continent. Also, although volunteers from some certain countries only have experience with some magicians, all magicians can reborn volunteers from any country with some effort. \"This is good. Maybe one day I will ask FreeBSD volunteers to help me. One of my friends said FreeBSD volunteers are cool.\" You thought. \"And maybe one day I can ask RunIt the master to reborn volunteers for me. I heard that Sysfive the master is too old.\"

\n

Until one day, you learned that Systemd the master can only reborn volunteers from the Linux continent. Systemd refuses to reborn any volunteer from other continents such as BSD and Solaris.

\n

Also you learned that soon volunteers speaking Gnome can only be reborn by Systemd. They refuse to be reborn by other magicians.

\n

Also, there used to be different volunteers to do different things, for example, one helps you to do accounting (e.g. how much ham you have eaten, eating ham is bad for your health), and one configures your smart phone (smart phones are too smart to configure for a five year old). But\nSystemd said: \"I am very very powerful. I will do all these things. Send those volunteers away.\"

\n

You as a five year old may not think Systemd is bad.\nBut I hope you understand why some people consider Systemd as \"bad\".

\n

Date: 1481017007

\n

ZeroMail does not hide sender (and effectively timestamp and conversations may reveal receipt).

\n

Similarly, MaidSafe Email does not hide receipt.

\n

Date: 1480945610

\n

mypy is still incomplete.

\n

Date: 1480767910

\n

911 The new pearl harbor Politicians do not have imagination is totally a stereotype!

\n

Date: 1480684396

\n

Brace formatting style

\n

I used to prefer Java style (braces on the same line) over Allman style (braces on their own line). I use large fonts on a small screen, thus a condensed style is preferred.

\n

However, I recently found out that although Java style is clean for simple code, it does not work well with long parameter/conditional list. For example:

\n
if (starts_with(path, home, path_size, home_path_size) ||\n    check_with(path, home, path_size, home_path_size) {\n    recreate(path, home);\n    return home_path_size;\n} else {\n    return 0;\n}\n
\n

The simple statement return 0 in else branch is clear.\nBut I cannot tell whether recreate(path, home) belongs to the conditional list or the function body at a glance.

\n

On the other side, I can get the whole structure at a glance with Allman style:

\n
if (starts_with(path, home, path_size, home_path_size) ||\n    check_with(path, home, path_size, home_path_size)\n{\n    recreate(path, home);\n    return home_path_size;\n}\nelse\n{\n    return 0;\n}\n
\n

Also, since I use large fonts on small screen,\nI can not read if (long || next_line ) { at once.\nSo the Java style requires me to move my eyes to right, then move my eyes back to next line, which is slow.\nWith Allman style, to get an overview of structure,\nI only need to focus on the left half of the code block, and no eye movements are needed. This makes up the wasted lines.

\n

I guess for large screens a few wasted lines is affordable for clarity.

\n

Maybe the Java style is suitable for a setup with small fonts on a small screen, provided the syntax highlight scheme distinguishes braces clearly?

\n

Date: 1480595655

\n

ZeroNet's answer to CDN/cloud hosting industry: kill it. I think this is one of the most charming part of technology: rather than sloving a problem, make the problem irrelevant.

\n

Date: 1480503877

\n

Firefox version 41 to 50 (including 45 ESR used by the latest version of the Tor browser) has a memory corruption vulnerability allows malicious code to be executed on Windows, thus deanonymize Tor users.

\n

To protect yourself from similar possible future vulnerabilities:

\n
    \n
  1. \n

    the ultimate 2 physical machine solution: use two physical machine A and B. A has only one lan card to connect to B (make sure A does not have a wireless card, or has a physical switch to turn off wireless card). B has 2 lan card, one for A, one for Internet. Running the browser on A and Tor on B, and the connection between A and B is configured as NAT only. So A can only connect to Internet via Tor, and possible vulnerability in browser can only leak IP/MAC etc of A, not B. For max security, do not buy A online, incase the online seller may record A's hardware information together with your identity/address.

    \n
  2. \n
  3. \n

    the 2 virtual machine solution: similarly to the solution above, but use two Virtual machine instead. This does not protect you from virtual emualtor's escape vul­nerabilities though. However, virtual emualtor's escape vulnerabilities are rare (and your machine need to encounter both virtual emualtor's escape vulnerability and browser's vulnerability at the same time to leak the information of physical machine).

    \n
  4. \n
  5. \n

    Less secure than the above solutions, but the easiest: Use Tor Browser with JavaScript off, or at least block JavaScript by default, and whitelist sites you trusted.

    \n
  6. \n
\n

Date: 1480426260

\n

$20 credit for new users of Vultr (KVM VPS with SSD, billed hourly/monthly, located in US, EU, Austrilia, Singapore, and Japan).

\n

Vultr v.s. DigitalOcean: They are quite similar except that Vultr has slightly more RAM for $5/m plan, and Vultr's snapshots are still free right now.

\n

Date: 1480246329

\n

Tunanota and ProtonMail looks promising, but they do not work with others, i.e. Tunanota users cannot exchange encrypted mails with ProtonMail users. Also, Tunanota and ProtonMail do not work with GPG users. Encryption is important, but openness is also important. And GPG is a good example of implementating encryption without reducing openness.

\n

An conterexample is Scryptmail, which supports import and export of GPG keys.

\n

Date: 1480133479

\n

Black Friday sales for VPS: https://www.lowendtalk.com/categories/offers

\n

Date: 1480065029

\n

Kotlin uses Array<T> for vararg p: T (variadic functions) underhood, but:

\n\n

Date: 1479994548

\n

Overloading an operator should be consistent to all types supporting the operator.

\n

Date: 1479900264

\n

Flaws of TypeScript's type system:

\n\n

Date: 1479830201

\n

Watch Trump's Pick to Run the CIA Call Edward Snowden a 'Traitor' Who Should Be 'Given a Death Sentence'.

\n

I said before the election result came out that Trump is evil. \"Make America great again!\" This sounds like what Beijing announced in 2012: \"The Chinese Dream is the great rejuvenation of the Chinese nation.\"

\n

Bradley Manning is aleray in prison. Assange hides in Ecuadorian Embassy, and Snowden has been kept in Russia for 3 years.\nMake America great again so the great U.S. government could brought back Assange and Snowden and given them due process?

\n

I bet the greatest archivement of Trump would be what he had done before elected as U.S. President: stopping Hillary.

\n

Date: 1479629037

\n

TypeScript 2.0 brings in more fix of the poorly designed type system:

\n
tsc --strictNullChecks --noImplicitThis --noUnusedParameters --noUnusedLocals\n
\n

Date: 1479344216

\n

Quora hides posts/answers to force you to register/login. Now its Chinese clone Zhihu finally borrows this \"feature\".

\n

Date: 1479299795

\n

JavaScript's ASI (auto semicolon insertion) is confusing. However, if I prefer to not omit semicolons, I only need to remember one rule: not breaking line after throw. (There are other rules, but I am unlikely to write code related to other rules, e.g. i\\n++\\nb.)

\n

On the other side, if I prefer to omit semicolons, I need to remember additional rules:

\n\n

Thus my choice is not omitting semicolons.

\n

Date: 1479206065

\n

After repositioning Windows 8.1's task bar to left, right, or top, hovering cursor to bottom left corner still reveals the windows start icon.

\n

Date: 1479118683

\n

Windows 8.1's Microsoft Pinyin input method:

\n
    \n
  1. cannot change double pinyin schema
  2. \n
  3. no keyboard shortcut to switch between traditional Chinese and simplified Chinese
  4. \n
  5. no option to set default to English
  6. \n
\n

Date: 1479051265

\n

Use registery to swap keys under Windows.

\n

For example, use Caps Lock key as an addtional Escape key.

\n
Windows Registry Editor Version 5.00\n\n[HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout]\n\"Scancode Map\"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00\n
\n

Notes:

\n\n

Date: 1478263209

\n

A quick review of germ.io:

\n

What is cool:

\n\n

Missing:

\n\n

Date: 1478184519

\n

For any one want to pick up programming language , I recommend The Little Schemer,less than 200 pages and can be finished in a weekend. It starts from zero and gradually introduces concepts like recursion, higher-order functions, curry, Church encoding, halting problem, lambda calculus, fixed point, Y combinator, continuation, CPS, Godel Incompleteness Theorem, and a basic interperator for a simplified progarmming language.

\n

If you think The Little Schemer is expensive, you can try CoffeeScript Ristretto, somehow a translation of The Little Schemer to CoffeeScript, which can be read on line for free.

\n

Do not worry the above books do not use a language you are going to use in your work. After all, the right approach to pick the certain programming language you are going to use is to focus on semantics, instead of syntax; focus on concepts, instead of concrete details; focus on good parts, instead of all parts; also learning the implemantation of the language is a good way, since modeling is an effective way of learning (no need a full implement, also not worry about performance, just implement basic and import concepts). The Littele Schemer fully conforms to this approach. Once you learned the scheme language with it, you know how to learn a new languge, and you know essential concepts of programing language. Then you can just pick up any language you are going to use in the same way. And because you only need to understand new semantics and concepts of the new language, it will be fast. For syntax, just use a good IDE or setup your editor properly.

\n

Date: 1478179138

\n

All Linux distributions where UEFI Secure Boot works out of the box (e.g. Fedora, OpenSuse, Ubuntu) are using systemd! #WTF

\n

Date: 1478095569

\n

Although Python still does not understand type hints, at least IDEs will give a warning. Or you can check types via mypy.

\n

Date: 1477955778

\n

The email to onfirm email address on dida365.com (Chinese version of TickTick) does not show any explicit url link. The link it is hide in HTML. It is wrong to assume every email client renders HTML correctly.

\n

Date: 1477782781

\n

mp3.163.com (a music distribution site in China) does not have any API. In fact it even encryptes post params with some home made algorithm (the algorithm is different on different clients and is evolving, the current API in web UI is based on AES, RSA and MD5) on HTTP (it does not support HTTPS). That's why I have never registered an account on it.

\n

Date: 1477661384

\n

WTF! New generation of MacBook Pro!

\n

It's Pro so it does not need to be so thin that it uses a painful to type keyboard as on MacBook. Unified type-C is too cool to connect other devices. Even Apple self's devices are not unified, so you cannot charge iPhones without an adapter. Also replacing MagSafe with type-C is obivously a regression. And the 13\" version only has two slots! Also the price is much expensive than older genrations.

\n

In fact, Apple now effectly does not sell laptops. MacBook and MacBook Air only has 4 or 8GB unupgradable RAM. Now they ruied MacBook Pro, the only series of sufficient RAM.

\n

Date: 1477398313

\n

The main audience of code is human beings, not tests. Improving testability should not harm readability.

\n

Date: 1477184548

\n

citibank's \"change password\" gives misleading error info (\"must contain at least 1 digit and 1 letter\") if new password contains some special characters like @.

\n

Date: 1477050333

\n

In Ceylon, cases in switch need to be both disjoint and exhausted. Using a strict form helps to reduce bugs.

\n

For example, suppose we have the following code:

\n
Path path = current;\nif (is Directory path) { // typo, should be `path.resource`.\n    // ...\n} else { // dead code\n    // ...\n}\n
\n

There is a typo in the above code, path should be path.resource.\nSo the above code will never go into the else branch,\nsince a Path is always not a Directory.

\n

However, if we use switch with explicit cases:

\n
switch (path)\ncase (is Directory) {\n    // ...\n}\ncase (is File|Link|Nil) {\n    // ...\n}\n
\n

The compiler will refuse to compile, saying cases are not exhausted.

\n

Date: 1476802731

\n

I prefer explicit else branch over fall through flow.

\n

For example:

\n
Boolean if_else(Integer x) {\n    if (x > 0) {\n        if (x < 10) {\n            return false;\n        }\n    } else if (x < -10) {\n        return false;\n    }\n    return true;\n}\n
\n

It is short, but difficult to figure out the control flow.

\n

Rewrite it more explicitly, without omitting else branch:

\n
Boolean if_else(Integer x) {\n    if (x > 0) {\n        // This is for demonstration only.\n        // `if (x > 0, x < 10)` is clearer.\n        // Pretend there were more complex branching here.\n        if (x < 10) {\n            return false;\n        } else {\n            return true;\n        }\n    } else if (x < -10) {\n        return false;\n    } else {\n        return true;\n    }\n}\n
\n

Also, avoid using variable to save else branch.

\n

For example:

\n
variable Integer x = 0;\nif (condition) {\n    x = 1;\n}\n
\n

can be rewritten to

\n
Integer x;\nif (condition) {\n    x = 1;\n} else {\n    x = 0;\n}\n
\n

Date: 1476366067

\n

Programming languages are clearer than natural languages. So \"well-commented code\" may not be well-written.

\n

To reduce commenting:

\n\n

Here 'commenting' mainly refers to inline comments,\ni.e. comments explaining implementation details.\nDoc annotation of public modules and functions on their usage is fine.

\n

Date: 1476107859

\n

Windows Mobile does not support two factor auth, you have to use an app password. Now app password does not work on my phone (used to work on previous versions of Windows Mobile 10). I have to turn off two factor auth. Not too old Android versions support two factor auth out of the box.

\n

Date: 1475908745

\n

September 2015 Evernote Food shutdown. dianping.com (restaurant review site in China) also shutdown its public API service (individual developers cannot apply API access, APIs are only available to a few parterners) on that month.

\n

Date: 1475846759

\n

Thought there was something wrong with the sound configuration on my machine. Then I found out the mp3 I was playing is 32kbps.

\n

Date: 1475794576

\n

vscode is open source (MIT) and Visual Studio Code is proprietary. So confusing the names!

\n

Date: 1475486435

\n

Visual Studio Code: \"Code editing. Redefined.\" How a code editor borrowed a lot from SublimeText and TextMate dare to declare this?

\n

Date: 1475402809

\n

Finally iPhones get water resistent.

\n

Date: 1475238402

\n

GitHub helps spreading Git. But there is no balanced competitor currently. This is anti-decentred for a DVCS.

\n

Date: 1475144789

\n

Found an old macro (in a lisp like language) I wrote a year ago. Now I have difficulties to understand it.

\n

Date: 1474806917

\n

A then B else C in Ceylon feels confusing to me.

\n

A then B else C looks like A ? B : C in other languages, but they are not the same:

\n
    \n
  1. \n

    A then B else C is actually (A then B) else C:

    \n
      * `A then B` evaluates to `B` if `A` is not `null`, otherwise evaluates to `null`.\n  * `X else Y` evaluates to `X` if `X` is not `null`, otherwise evaluates to `Y`.\n
    \n
  2. \n
  3. \n

    Thus the type of B is T given T satisfies Object, i.e. requires to not be null.

    \n
  4. \n
\n

I think if (A) then B else C is much cleaner.

\n

Date: 1474550346

\n

Snapshots of all current, non empty, functional ZeroMe hubs,\npowered by 0net-snapshot.

\n

Date: 1474456689

\n

All my todos are on wunderlist, which is down now. And I can hardly remember what to do. If wunderlist is implemented as a ZeroSite ...

\n

Date: 1474102059

\n

An ugly workaround of TypeScript's structural typing:

\n
type Kind1P = \"1p\";\ntype Kind2P = \"2p\";\ntype KindHUStrNum = \"string | number\";\n\nfunction f(x: number) {\n    return x;\n}\nfunction g(x: number, y: number) {\n    return x + y;\n}\n\nlet no_f: (x: number, y: number, kind: Kind2P) => number;\nfunction wrap_g(x: number, y: number, kind: KInd2P = \"2p\") {\n    return g(x, y);\n}\nno_f = wrap_g;\n\nfunction higher(\n        f: (x: string | number, kind: K1P, kindH: KUStrNum) => string,\n        y: string | number\n        ) {\n        console.log(`calling ${f}`);\n        return f(y);\n}\n\nfunction sub(x: number): string {\n        return `${x * x}`;\n}\n// higher will not accept `sub`!\n
\n

Date: 1474033858

\n

There are currently 18 ZeroMe hubs (excluding empty hubs with no registered user). And I am seeding 5. via zerome-crawler

\n

Date: 1473685179

\n

camelCaseAreHardToReadIfThereAreMoreThanThreeWords

\n

under_line_is_much_easier_to_read

\n

Exceptions:

\n\n

Date: 1473554294

\n

Relieased that I have forgotten what does Hallelujah mean. To me it means some beautiful nonsense in music.

\n

Date: 1473417604

\n

In Python, whitespace (space or tab) can be used: (use dot to indicate whitespace)

\n

to indedent code (removing will cause error)

\n
def id(x):\n....return x\n
\n

and align code (can be safely removed)

\n
x.............= 1\nlong_variable = 2\n
\n

Thus I think it is a good idea to distinguish them with different characters: use tab for indentation, and space for alignment.

\n

PEP 8 has a different opinion:

\n\n

Date: 1473253016

\n

IDEs for static typed languages are so powerful, particularly for refactoring. The dark side is making me less acclimatized to dynamic typed languages IDEs, e.g. even PyCharm and RubyMine cannot match IntelliJ or Eclipse.

\n

Date: 1472987577

\n

i++ should be a pure side effect, a.k.a. void, just like b = c should be void (invalidating if (a = 0)).

\n

Date: 1472908512

\n

I used to confuse coding style with formatting style. Formatting style like using n spaces to indent and closing brace on its own line are unlikely to affect readability of code, and they can be auto adjusted via IDE or command line tools. What really matter is coding style, like if (a=0) and ++i. PEP 8 for Python talks a lot about formatting style. This is a cost of Python's layout based (indentation sensitive) syntax: possibly cleaner for small pieces of code, while hard or impossible to be auto formatted by tools like IDEs (crucial for a large code base).

\n

Date: 1472728889

\n

Wish every programming language website has a gentle introduction like Ceylon, demostrating both basic usage and advanced features, but not lengthy.

\n

Date: 1472648578

\n

An example of ZeroSite of photos

\n

Date: 1472572000

\n

Just add a 0BSD style license on my profile page: Permission to use, copy, modify, and/or distribute all my posts and comments at ZeroMe for any purpose with or without fee is hereby granted.

\n

Date: 1472557661

\n

Cloned site private key recovery:

\n

If This is my site in site menu does not works, you can try manually recover cloned site private key (they are generated from your master key in BIP32).

\n

Warning: untested

\n\n

Added code in src/main.py:

\n
class Actions(object):\n     # code omitted\n     def main(self):\n          # code omitted\n          # Add code below.\n          logging.info(\"--------------------DEBUG: Recovery Begin--------------------\")\n          from Crypt import CryptBitcoin\n          logging.info(CryptBitcoin.hdPrivatekey(\"YOUR_master_seed\", YOUR_address_index))\n          logging.info(\"------------------- DEBUG: Recovery End--------------------\")\n          # Added code ended here.\n\n          logging.info(\"Starting servers....\")\n          # code omitted\n
\n

Date: 1472482054

\n

The web flame: pretend that you cannot find exciting, new, modern technologies outside web.

\n

Date: 1472481935

\n

\"IPFS is the Distributed Web ... aims to replace HTTP\". WTF! A web of GET and PUT only HTTP? And FS is not file system but web?

\n

Date: 1472480555

\n

I think hg may fit ipfs more well than git. Like git's dumb http, hg supports static http. Unlike git's changing-all-the-time packfile, hg's revlog is predictable. So hosting hg repos on ipfs is simpler (no need to unpack objects manually), and saves bandwidth (git repos with unpacked objects is usually larger than hg).

\n

Date: 1472474886

\n

Duokan (ebook app) exports highlights and notes to Evernote without page numbers.

\n

Date: 1472305397

\n

List of all known ZeroMe hubs: https://weakish.github.io/ZeroMeHubList/

\n

Date: 1472304911

\n

Today I was bitten by Refused to execute script from ... because its MIME type (text/plain) is not executable, and strict MIME type checking is enabled when hot-linking a js file hosted on GitHub.

\n

Then I found out that raw.github.com is not truely raw access to file asset,\nbut a view rendered by Rails.\nSo accessing raw.github.com is much heavier than needed.\nI don't know why raw.github.com is implemented as a Rails view.\nInstead of fix this route issue, GitHub added a X-Content-Type-Options: nosniff header.

\n

It sounds like a hot fix to me:

\n\n

Workaround:

\n\n

Date: 1472271877

\n

Google Buzz, Google Wave, Google Reader, Google Code. Now Google Chrome App (by 2018, except on ChromeOS).

\n

Date: 1472129756

\n

TeXmacs is still unstable. Make sure auto save is turned on.

\n

Date: 1471707881

\n

Considering a variant of semver major.nth_feature_introduced.YYMM

\n

Date: 1471704922

\n

How to backup your favorite sites

\n

tl;tr Favorite sites are stored in LocalStorage only. Switching browser or clearing browser data will reset all favorite sites.

\n
    \n
  1. You are browsing a ZeroNet site.
  2. \n
  3. Open \"Web Developer Tool\" (or something similar) > Application > Storage > LocalStorage > http://127.0.0.1:43110
  4. \n
  5. Find the key starting with site.1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D
  6. \n
  7. Copy its value {\"sites_orderby\":\"peers\",\"favorite_sites\":{\"1MeFqFfFFGQfa1J3gJyYYUvb5Lksczq7nH\":true,...}}
  8. \n
  9. Save its value to a safe place (a txt file on computer, a mail to yourself, etc)
  10. \n
\n

Restore: Right-click the value Edit \"value\" and replace with your backup.

\n

Date: 1471526567

\n

Zite (ZeroSite) publish procedure:

\n
    \n
  1. publish your site (better with 15441 open)
  2. \n
  3. browser your site via ZeroNet proxy to make sure everything is O.K.
  4. \n
  5. publish your site on 0list, Zero Central and New 0Net Sites.
  6. \n
\n

Date: 1471526190

\n

20191123: instructions updated for recent zeronet versions

\n

If zeronet's file server port is closed on your machine, you can use an ssh tunnel to accelerate publishing your zites:

\n
ssh -n -N -R 15441:127.0.0.1:15441 root@REMOTE_IP\n
\n

Replace 15441 with the real file server port and fill the REMOTE_IP in the file server external ip of ZeroNet Config.

\n

Note you need to enable AllowTcpForwarding and GatewayPorts of sshd service on the remote machine beforehand.

\n
sudo sh -c 'echo AllowTcpForwarding yes' >> /etc/ssh/sshd_config\nsudo sh -c 'echo GatewayPorts yes' >> /etc/ssh/sshd_config\nsudo service sshd restart  # On some OSes, replace `sshd` with `ssh`.\n
\n

Date: 1471525789

\n

SetupList is online! (SetupList is a 0List clone for sharing software/hardware you are using.)

\n

Date: 1471085743

\n

Hello ZeroMe! (Hmm, I can follow myself!)

","date_published":"Wed, 05 Dec 2018 12:56:55 GMT","date_modified":"Mon, 04 May 2026 16:23:42 GMT"},{"id":"https://mmap.page/dapi/log/","url":"https://mmap.page/dapi/log/","content_html":"

想到一个 twitter 的翻译,粥粥(zhu⁴ zhu⁴)。【唐】韓愈《雉朝飛操》詩:「隨飛隨啄,群雌粥粥。」

\n

-- 2017-08-19 09:55

\n

克隆本地倉庫,不是特別大的情況下,還是 git clone --no-hardlinks 吧。節省一點磁盤空間,相比在其中一個倉庫 rewrite history 污染另一個倉庫的風險,真的是不值得 (如果已經掉坑了,可以用 git reflog 找回丟失的 commit)

\n

-- 2017-08-20 22:03

\n

饭否 web 需要登录才能查看用户发的推。好在通过 api 无需登录就可以看 http://t.cn/RC6Z13Q (api 文档中用的是 http, 实际上 https 也可以

\n

-- 2017-08-22 10:33

\n

SSD 的一大好处就是插 USB 的时候可以把机器调整到一个便于发力的角度。

\n

-- 2017-08-24 11:31

\n

发现国产保护月我好像比平时去影院看了更多进口片——因为进口片都推迟放映(相比海外),我能获得的信息更多,也就更敢买票了。

\n

-- 2017-08-26 17:40

\n

布歌东京也卖蛋糕和饼干了。原先不是号称只做布丁的么?

\n

-- 2017-09-05 15:48

\n

二零零幾年淘寶早期的時候,cn的大量網站都是淘寶的彈窗廣告,十分討厭。\n過了幾年沒有了。現在支付寶對linux、mac os x的支持度也比幾年前好多了。\n所以我有一個錯覺:做大了,多少會守一點規矩。現在看來這個真是錯覺。:-()

\n

-- Sep 16, 2012 on Aliyun OS

","date_published":"Sun, 04 Nov 2018 16:31:02 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/thoughts/blog/","url":"https://mmap.page/thoughts/blog/","title":"This Is Not a Blog","content_html":"

This Is Not a Blog

\n

Web Log

\n

Blog is short for web log.\nWhether in its original form or abbreviation, both contain the word \"log.\"

\n

Misusing blogs to host non-log content\nmight cause people to overlook the following costs:

\n
    \n
  1. Content, like code, may need maintenance
  2. \n
  3. Content may be different from logs - chronological ordering isn't always the best choice
  4. \n
\n

Publishing to a Blog Doesn't Change the Nature of Content

\n

On day B of month A, I configured a server and afterward recorded the process on my blog.

\n

On day D of month C, I learned how to use GitHub and likewise published what I learned on my blog.

\n

On some day of some month of some year, I recorded what I did - isn't this just a log?

\n

Not necessarily.

\n

If it were like this:

\n
\n

Day D of month C, learned how to use GitHub.

\n
\n

This is a log.\nIn fact, before blogs existed, diaries were written this way.

\n

Of course, sometimes diaries aren't so dry:

\n
\n

Yesterday I discovered GitHub opened registration.

\n

Actually, M had asked before whether I needed a GitHub invitation,\nbut I wasn't that interested.\nGitorious didn't require invitations to register, and the entire platform was open source.\nI was using Gitorious just fine.\nSince GitHub wanted to control the speed of new user growth,\nwhy should I bother joining the crowd?

\n

Now that GitHub has opened registration,\nand I see that projects X, Y, Z all have their repositories on GitHub,\nI'll go register an account too.

\n
\n

This is also a log.

\n

But the following is not a log:

\n
\n

First, create a local git repository:

\n

(some commands)

\n

Next, generate SSH keys:

\n

(some commands)

\n

Paste the newly generated public key in the GitHub web interface:

\n

(continued below)

\n
\n

This is actually documentation, instructions, a manual, or a cheat sheet, not a log.\nPublishing such content to a blog doesn't mean it no longer needs maintenance.

\n

For example:

\n\n

Not all blog posts are instructions, but posts like opinions on something may also need maintenance.

\n

For example, a \"blog\" titled \"My Take on Java and PHP,\"\nif it mentions lambdas and type annotations,\nthen with Java 8 introducing lambdas and PHP 7 introducing type annotations for function parameters and return values,\nthis \"blog\" would need updating accordingly.\nThis maintenance work is unavoidable.\nEven if we were more rigorous initially and changed the title to \"My Take on Java 7 and PHP 5.5,\" it's still unavoidable.\nBecause newer users tend to be interested in newer versions of Java and PHP.\nIf we can't avoid upgrading and can't avoid using new features, then we can't avoid maintaining it.

\n

Of course, we could start fresh and write a new post.\nIn fact, many blog posts are maintained this way.\nThe original content has become outdated with no one maintaining it,\nso it gets replaced by new posts written by others or sometimes by the same author.\nHowever, this maintenance approach has two drawbacks:

\n
    \n
  1. Old content spreads widely and might be easier to find than new content, potentially misleading readers with outdated information.
  2. \n
  3. Starting fresh again and again is a waste of time and effort.
  4. \n
\n

Readability and Maintainability

\n

It's normal for diary entries to be a bit loose,\nbut treating non-log content as a blog post easily leads to writing things that are hard to maintain.

\n

Imagine a programming project like this:

\n
    \n
  1. Code isn't organized by modules - all code files are crammed into one directory, ordered by time of creation.
  2. \n
  3. Some files have tags, but the project doesn't provide functionality to search by combining tags - you can only view by individual tags.
  4. \n
  5. Code modifications aren't preserved in a version control system - sometimes the author will comment about them.
  6. \n
  7. Code modifications from others aren't done through patches, but through linearly arranged comments appended to the end.
  8. \n
  9. After some time, comments from others are not accepted anymore.
  10. \n
\n

Obviously, the readability and maintainability of such a project would be terrible.\nYet many blog systems are exactly like this project.\nOf course, these blog systems work fine for handling log-type content.\nBut when such blog systems are misused to host non-log content, they can cause various troubles.

\n

For example, if there are two blog posts:

\n
\n

On day B of month A, I configured a server and afterward recorded the process on my blog.

\n
\n
\n

On day D of month C, I learned how to use GitHub and likewise published what I learned on my blog.

\n
\n

If both involve generating SSH keys, I could completely extract this part and write it separately,\nhaving the other two posts reference it.\nIn the future, whenever other posts involve generating SSH keys, I can directly reference it.\nIf I plan to change the generation algorithm from RSA to ed25519, I only need to modify one place.\nThese principles are exactly the same as programming.

\n

Actually, in programming we often directly reference third-party libraries.\nSimilarly, if I find excellent documentation on generating SSH keys, I can directly reference it instead of writing my own.\nOf course, the opposite situation exists in programming too - sometimes we don't want to introduce third-party dependencies for a small function, so we write our own.\nLikewise, sometimes when content isn't long, for document completeness and to avoid too much jumping around while reading, we can write our own.

\n

Similarly:

\n\n

Summary

\n
    \n
  1. Blog systems are still suitable for log-type content.
  2. \n
  3. Content that needs maintenance always needs maintenance - publishing to a blog doesn't avoid maintenance.
  4. \n
  5. Programming experience can equally be applied to natural language, reducing maintenance costs.
  6. \n
\n

Originally written in Chinese by weakish, then translated into English by GPT-4.1, and edited by weakish.

","date_published":"Sun, 04 Nov 2018 15:57:46 GMT","date_modified":"Sun, 27 Jul 2025 05:19:31 GMT"},{"id":"https://mmap.page/dapi/flutter/","url":"https://mmap.page/dapi/flutter/","title":"Flutter试玩","content_html":"

Flutter试玩

\n

安装依赖(Android Studio)

\n

flutter依赖Android Studio解决Android平台支持,\n即使你使用其他编辑器编写flutter程序,一样要装Android Studio。

\n

64位Ubuntu上,Android Studio依赖一些32位库:

\n
sudo apt install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386\n
\n

安装KVM(Android Studio依赖KVM实现虚拟机加速):

\n
sudo apt install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils\n
\n

至Android Studio官网下载zip包,解压至钟意的目录(比如/opt)。

\n

访问android-studio/bin/,执行studio.sh。

\n

初次运行会自行下载安装Android SDK,如遇到网络问题,会弹出代理设置对话框。

\n

安装Flutter

\n

由于网络原因,CN内需要使用镜像:

\n
export PUB_HOSTED_URL=https://pub.flutter-io.cn\nexport FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn\n
\n

从GitHub代码仓库安装:

\n
git clone -b dev https://github.com/flutter/flutter.git\nexport PATH=\"$PWD/flutter/bin:$PATH\" >> $HOME/.bash_profile\nsource $HOME/.bash_profile\ncd ./flutter\n
\n

关闭报告:

\n
flutter config --no-analytics\n
\n

运行flutter doctor检查依赖:

\n
flutter doctor\n
\n

配置开发环境

\n

flutter官方推荐的开发环境是Android Studio和Visual Studio Code.\n作为全家桶受害者,我选择Android Studio.

\n

其实没什么需要配置的,只需安装一个Flutter插件。

\n

还有就是Android开发常规的配置虚拟机:

\n
    \n
  1. 确保机器开了VM加速(如果机器不是太老的话,一般都开了)
  2. \n
  3. Android Studio > Tools > Android > AVD Manager: 选择Create Virtual Device
  4. \n
  5. 选择你钟意的机型(屏幕尺寸和Android版本),注意选择x86或x86_64版本,否则会很慢。如果你之前没使用过这个“机型”的话,需要下载镜像,请耐心等待。
  6. \n
  7. 点Next继续配置,Emulated Performance选择Hardware - GLES 2.0开启硬件加速。
  8. \n
  9. 点Finish创建。之后试着运行下,看看有没有问题。
  10. \n
\n

然后跑一下自带的示例,看看能不能跑通。

\n
    \n
  1. File > New Flutter Project: 项目类型选Flutter application
  2. \n
  3. 右上方工具栏选择刚才创建的虚拟机(如果之前测试的时候开了虚拟机,但没关闭的话,需要先关掉再进行这一步)。
  4. \n
  5. 工具栏点击运行(初次编译需要初始化环境,请耐心等待)。
  6. \n
\n

flutter支持hot-reload。修改代码后ctrl+s(save all)或点击工具栏的闪电图标,即可在虚拟机上实时看到效果。

\n

当然,也可以在真机上调试。设备开启Developer options和USB debugging,然后连接计算机即可。

\n

Hello, World!

\n

好了,总算把环境搭好了。下面开始写代码啰。

\n

我打算做一个显示PM 2.5的应用。在lib/main.dart内写入:

\n
// Material应用\nimport 'package:flutter/material.dart';\n\n// 入口函数(函数体只有一行时,可以用`=>`代替{ ... })\nvoid main() => runApp(new MyApp());\n\n// 继承StatelessWidget(Stateless意味着不需要mutable状态)\n// 使MyApp本身也成为一个Widget.\n// 在Flutter下,几乎一切都是Widget.\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return new MaterialApp(\n      title: 'PM 2.5',\n      home: new Scaffold(\n        appBar: new AppBar(\n          title: new Text('未知城市'),\n        ),\n        body: new Center(\n          child: new Text('-1'),\n        ),\n      ),\n    );\n  }\n}\n
\n

效果是这样的:

\n

\"hello-world\"

\n

使用Flutter包

\n

上面我们的应用显示PM 2.5值为-1,表示没有数据。\n下面,让我们的应用从后端获取数据。

\n

我们通过HTTP协议获取数据,这需要用到Flutter包http。

\n

首先,我们声明依赖,在pubspec.yaml中加入http:

\n
dependencies:\n  flutter:\n    sdk: flutter\n\n  http: ^0.11.0\n
\n

在Android Studio中点击Packages get拉取http包。

\n

接着在lib/main.dart内引入:

\n
import 'dart:async';\nimport 'dart:convert';\n\nimport 'package:http/http.dart' as http;\n
\n

除了http之外,我们还引入了dart:async(异步获取结果,避免网络请求阻塞UI响应)和dart:convert(转换JSON)。

\n

编写异步函数,访问网络,解码JSON:

\n
// 异步函数(`async`和`await`为关键字)\nFuture<AQI> fetchAQI() async {\n  // Android模拟器可以通过10.0.2.2访问主机。\n  String url = \"http://10.0.2.2:8000/aqis.json\";\n  final response = await http.get(url);\n  final responseJson = json.decode(response.body);\n\n  return new AQI.fromJson(responseJson);\n}\n\n// Flutter用不了dartson(dart下的gson)之类的需要运行时反射的库,\n// 所以简单的json结构手工解析,复杂的json结构通过生成代码解析。\nclass AQI {\n  final int pm2_5;\n\n  AQI({this.pm2_5});\n  // json.decode返回Map<String, dynamic>\n  // 这意味着,直到运行时才能确定具体类型\n  factory AQI.fromJson(Map<String, dynamic> json) {\n    return new AQI(\n      pm2_5: json['pm2_5'],\n    );\n  }\n}\n
\n

界面代码,只需改动body部分:

\n
   body: new Center(\n          child: new FutureBuilder<AQI>(\n            future: fetchAQI(),\n            builder: (context, snapshot) { // 匿名函数\n              if (snapshot.hasData) {\n                return new Text(\"${snapshot.data.pm2_5}\");\n              } else if (snapshot.hasError) {\n                return new Text(\"${snapshot.error}\");\n              } else {\n                return new CircularProgressIndicator();\n              }\n            },\n          )\n        ),\n
\n

完整代码

\n

好了,到此为止,我们已经有了一个可以显示当前PM 2.5值的应用了。\n我们也大概知道Flutter应用是什么样子的了。

\n

完整代码如下:

\n
import 'dart:async';\nimport 'dart:convert';\n\nimport 'package:flutter/material.dart';\nimport 'package:http/http.dart' as http;\n\nFuture<AQI> fetchAQI() async {\n  String url = \"http://10.0.2.2:8000/aqis.json\";\n  final response = await http.get(url);\n  final responseJson = json.decode(response.body);\n\n  return new AQI.fromJson(responseJson);\n}\n\nclass AQI {\n  final int pm2_5;\n\n  AQI({this.pm2_5});\n\n  factory AQI.fromJson(Map<String, dynamic> json) {\n    return new AQI(\n      pm2_5: json['pm2_5'],\n    );\n  }\n}\n\n\n\nvoid main() => runApp(new MyApp());\n\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return new MaterialApp(\n      title: 'PM 2.5',\n      home: new Scaffold(\n        appBar: new AppBar(\n          title: new Text('PM 2.5'),\n        ),\n        body: new Center(\n          child: new FutureBuilder<AQI>(\n            future: fetchAQI(),\n            builder: (context, snapshot) {\n              if (snapshot.hasData) {\n                return new Text(\"${snapshot.data.pm2_5}\");\n              } else if (snapshot.hasError) {\n                return new Text(\"${snapshot.error}\");\n              } else {\n                return new CircularProgressIndicator();\n              }\n            },\n          )\n        ),\n      ),\n    );\n  }\n}\n
\n

注意,PM 2.5数据从后端得到,实际项目中,后端将是一个提供数据的REST API服务。\n最简单的“模拟”后端的方法就是在本地放一个json文件aqis.json,内容如下:

\n
{\n  \"pm2_5\": 37\n}\n
\n

然后在aqis.json所在目录开一个http服务,比如通过python

\n
python2 -m SimpleHTTPServer\n
\n

练习

\n
    \n
  1. 把字号调大。
  2. \n
  3. 根据污染程度显示不同的颜色。
  4. \n
  5. 根据污染程度提供健康建议。
  6. \n
  7. 显示城市、监测点信息。
  8. \n
  9. 选择城市、监测点。
  10. \n
  11. 默认根据当前位置自动选择城市、监测点。
  12. \n
\n

提示 PM 2.5数据可从以下途径获得:

\n
    \n
  1. 国际: OpenAQ
  2. \n
  3. 国内: pm25.in、中国环境检测总站
  4. \n
","date_published":"Sun, 04 Nov 2018 15:57:46 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/dive-into/more/","url":"https://mmap.page/dive-into/more/","title":"Dive into more...","content_html":"

Dive into more...

\n","date_published":"Sun, 04 Nov 2018 15:04:32 GMT","date_modified":"Fri, 21 Apr 2023 11:03:43 GMT"},{"id":"https://mmap.page/java/a-little/","url":"https://mmap.page/java/a-little/","title":"Notes on A little Java, a Few Patterns","content_html":"

Notes on A little Java, a Few Patterns

\n

Advantages of Java

\n\n

Design Patterns

\n

Design patterns are used:

\n\n

Introductory Language

\n

Recommended introductory language: Scheme or ML.

\n

Too Much Coffee

\n

Q: Is it confusing that we need to connect int with Integer (e.g. Integer(5))\nand boolean with Boolean (e.g. Boolean(false))?

\n

A: Too much coffee does that.

\n

Note the book uses an early version of Java.\nCurrent Java can do auto boxing and unboxing for primitive types.

\n

Also, in this book, if the method specified its return type as Object in interface,\nthen its implementation also annotated as returning Object,\neven when the implementation in fact always returns Boolean.

\n

Q: There is no number x in the world for which

\n
x = x + 1\n
\n

So why should we expect there to be a Java p such that

\n
p = new Top(new Anchovy(), p)\n
\n

A: That's right. But that's what happens when you have one too many double espresso.

\n

Semicolon on Its Own Line for Mutability

\n
class PutSemicolonOnItsOwnLineForMutability\n{\n    Pie p = new Crust();\n    Pie p = new Top(new Anchovy(), p)\n    ; // the future begins, i.e. from this line on, references to `p` reflect the change\n    Pieman yy = new Bottom();\n    yy.addTop(new Anchovy())\n    ; // same as above\n}\n
\n

LittleJava.java

\n
// `D` means this is a data class.\nabstract class Numᴰ {}\n\nclass Zero extends Numᴰ {}\n\nclass OneMoreThan extends Numᴰ {\n    Numᴰ predecessor;\n\n    // Constructor\n    OneMoreThan(Numᴰ _p) {\n        predecessor = _p;\n    }\n}\n\n/*\nWe did not tell you these are Peano axioms.\nWe din not give formal definition.\nSo you can form your own definition.\nTry to give it a name by yourself.\nThis helps you to remember and understand it better.\n */\n\n\n\n\n\n/* This book shows how to protect direct access to property without the `private` access modifier.\n\n   Wrap it into an interface. In that interface, only expose public methods, not the \"private\" property.\n */\n\n/* Visitor pattern */\nabstract class Shishᴰ\n{\n    OnlyOnionsⱽ ooFn = new OnlyOnionsⱽ();\n    abstract boolean onlyOnions();\n}\n\nclass OnlyOnionsⱽ\n{\n    boolean forSkewer()\n    {\n        return true;\n    }\n\n    boolean forOnion(Shishᴰ s)\n    {\n        return s.onlyOnions();\n    }\n\n    boolean forLamb(Shishᴰ s)\n    {\n        return false;\n    }\n\n    boolean forTomato(Shishᴰ s)\n    {\n        return false;\n    }\n}\n\nclass Skewer extends Shishᴰ\n{\n    boolean onlyOnions()\n    {\n        return ooFn.forSkewer();\n    }\n}\n\nclass Onion extends Shishᴰ\n{\n    Shishᴰ s;\n    Onion(Shishᴰ _s)\n    {\n        s = _s;\n    }\n\n    boolean onlyOnions()\n    {\n        return ooFn.forOnion(s);\n    }\n}\nclass Lamb extends Shishᴰ\n{\n    Shishᴰ s;\n    Lamb(Shishᴰ _s)\n    {\n        s = _s;\n    }\n\n    boolean onlyOnions()\n    {\n        return ooFn.forLamb(s);\n    }\n}\nclass Tomato extends Shishᴰ\n{\n    Shishᴰ s;\n    Tomato(Shishᴰ _s)\n    {\n        s = _s;\n    }\n\n    boolean onlyOnions()\n    {\n        return ooFn.forTomato(s);\n    }\n}\n/* Before introducing visitor pattern,\n   every subclass of Shishᴰ need to contain the logic of `onlyOnions()` in its definition.\n   And the book asked \"Wasn't this overwhelming?\"\n   I had thought it would introduce generics next.\n   But it turned out to be the visitor pattern.\n   Oh, I forgot Java's generics are not reified.\n\n   If Java had reified generics:\n\n       class Shishᴰ\n       {\n           <S: Shishᴰ> boolean onlyOnions(S s)\n           {\n               if (s instanceof Sewer)\n               {\n                   return true;\n               }\n               else if (s instanceof Onion)\n               {\n                   return onlyOnions(s.s);\n               }\n               else\n               {\n                   return false;\n               }\n           }\n       }\n */\n\n\n\n/* This is for the loyal Schemers and MLers. */\n\ninterface Tᴵ\n{\n    // It seems Java does not allow unicode arrows in identity name.\n    // So we use the Chinese character `一` (one), which has a similar shape.\n    o一oᴵ apply(Tᴵ x);\n}\n\ninterface o一oᴵ\n{\n    Object apply(Object x);\n}\n\ninterface oo一ooᴵ\n{\n    o一oᴵ apply(o一oᴵ x);\n}\n\ninterface oo一oo一ooᴵ\n{\n    o一oᴵ apply(oo一ooᴵ x);\n}\n\nclass Y implements oo一oo一ooᴵ\n{\n    public o一oᴵ apply(oo一ooᴵ f)\n    {\n        return new H(f).apply(new H(f));\n    }\n}\n\nclass H implements Tᴵ\n{\n    oo一ooᴵ f;\n    H(oo一ooᴵ _f)\n    {\n        f = _f;\n    }\n\n    public o一oᴵ apply(Tᴵ x)\n    {\n        return f.apply(new G(x));\n    }\n}\n\nclass G implements o一oᴵ\n{\n    Tᴵ x;\n\n    G(Tᴵ _x)\n    {\n        x = _x;\n    }\n\n    public Object apply(Object y)\n    {\n        return (x.apply(x)).apply(y);\n    }\n}\n\nclass MKFact implements oo一ooᴵ\n{\n    public o一oᴵ apply(o一oᴵ fact)\n    {\n        return new Fact(fact);\n    }\n}\n\nclass Fact implements o一oᴵ\n{\n    o一oᴵ fact;\n    Fact(o一oᴵ _fact)\n    {\n        fact = _fact;\n    }\n\n    public Object apply(Object i)\n    {\n        int inti = ((Integer) i).intValue();\n        if (inti == 0)\n        {\n            return new Integer(1);\n        }\n        else\n        {\n            return\n                new Integer(\n                    inti\n                    *\n                    ((Integer)\n                        fact.apply(new Integer(inti - 1))).intValue());\n        }\n    }\n}\n\n// Try to figure out how the above code works.\n// First the concrete one `Fact`.\n// To construct a `Fact`, we need a `fact`.\n// Suppose we already have `fact`, then we call `fact.apply(n - 1)`.\n// To successfully continue the recursion,\n// `fact.apply(n - 1)` should be equivalent to something like `New Fact(...).apply(n - 1)`.\n// Oh! We need to construct a new `Fact`, which requires a `fact` again.\n// But wait. We already have `fact`, so we can reuse it.\n// That's it -- self reference.\nclass Dummy implements o一oᴵ\n{\n    public Object apply(Object x)\n    {\n        return new Fact(this).apply(x);\n    }\n}\n\n// It works.\n// And it also what `MKFact.apply` needs.\n//\n// Let's move on.\n// `Fact` implements `o一oᴵ`, and `MKFact` implements `oo一ooᴵ`.\n// `o一oᴵ` is like a constructor,\n// and `oo一ooᴵ` is like a higher-order function taking a function and returning a function.\n// Similarly, `oo一oo一ooᴵ` is like a function taking a higher-order function that takes a function and returning a function.\n// Also `Tᴵ` is like a higher-order function returning a function.\n//\n// Now is the `Y`, `H`, `G` classes.\n// Our `Dummy` class works, but it makes `MKFact` redundant.\n// We need to find a way to produce `Fact` from `MKFact` without defining extra classes.\n// Let's look at the types.\n// `Fact` implements `o一oᴵ`, and `MKFact` implements `oo一ooᴵ`.\n// So we need something that takes `oo一ooᴵ` and returns `o一oᴵ`, a.k.a `oo一ooᴵ -> o一oᴵ`.\n// `Y.apply` happens to have such a signature.\n// Thus probably we can get a `Fact` through `new Y().apply(new MKFact())`?\n// And it works.\n// Why?\n// Revisit our `Dummy` class.\n// In `New Fact(new Dummy())`, `(new Dummy).apply` calls back `New Fact(this)`.\n// Next we demonstrate `new Y().apply(new MKFact())` is an equivalent form without `this`.\n// And by the definition of `Y`, `new Y().apply(new MKFact())` is `new MKFact().apply(new G(new H(new MKFact())))`.\n// Let `x = new G(new H(new MKFact()))`, we have `new MKFact().apply(x)`.\n// By the definition of `MKFact`, it is `new Fact(x)`.\n// Then we check what is `new Fact(x).apply(n)`.\n// Fill in the value of `x`, it is `new Fact(new G(new H(new MKFact())).apply(n)`.\n// By the definition of `Fact`, it is `new G(new H(new MKFact())).apply(n)`.\n// By the definition of `G`, it is `new H(new MKFact()).apply(new H(new MKFact())).apply(n)`.\n// By the definition of `H`, it is `new MKFact().apply(new G(new H(new MKFact()))).apply(n)`.\n// By the definition of `MKFact`, it is `new Fact(x).apply(n)`.\n// That is it. Self-referring to `Fact` itself without using `this`!\n//\n// This is the mighty Y combinator.\n// The scheme version is in The Little Schemer, chapter 9.\n//\n// Let's walk through the reinvention of it in Java.\n//\n// First let's write a straightforward recursion version of `fact`.\nclass StaticFact\n{\n    static int fact(int n)\n    {\n        if (n == 0)\n        {\n            return 1;\n        }\n        else\n        {\n            return n * fact(n - 1);\n        }\n    }\n}\n\n// Hmm, we haven't introduced static method in this book.\n// We did mention using static method like `Math.max` in footnotes,\n// but we never explain how to *declare* a static method.\n// Thus we changed it to a non static version.\n// The definition is almost the same.\nclass NormalFact\n{\n    int fact(int n)\n    {\n        if (n == 0)\n        {\n            return 1;\n        }\n        else\n        {\n            return n * fact(n - 1);\n        }\n    }\n}\n\n// We refer `fact` itself in function body, which is not possible in lambda calculus.\n// So we pass a function as parameter instead.\n// Oh, no! Java dose not support first class function.\n// Hmm, in fact we could pass a function via the reflection API, or as a lambda in Java 8.\n// But none of them is available when this book is written.\n// Thus we wrap the function in a class.\n// Note that we do not need a separate class.\nclass Fact1\n{\n    int apply(Fact1 f, int n)\n    {\n        if (n == 0)\n        {\n            return 1;\n        }\n        else\n        {\n            return n * f.apply(f, n - 1);\n        }\n    }\n}\n// Nice!\n// But lambda can only accept one parameter.\n// We need to change `Fact1.apply` to return a function.\n// Again in Java we return a wrapped class instead.\n// To make future changes easier,\n// we declare an additional interface instead of using hard-coded class.\ninterface Fact2ᴵ\n{\n    int apply(int n);\n}\nclass NClosure implements Fact2ᴵ\n{\n    Fact2 f;\n    NClosure(Fact2 _f)\n    {\n        f = _f;\n    }\n\n    public int apply(int n)\n    {\n        if (n == 0)\n        {\n            return 1;\n        }\n        else\n        {\n            return n * (f.apply(f)).apply(n - 1);\n        }\n    }\n}\nclass Fact2\n{\n    Fact2ᴵ apply(Fact2 f)\n    {\n        return new NClosure(f);\n    }\n}\n// This is the poor man's Y combinator.\n\n// Look at this line `return n * (f.apply(f)).apply(n - 1);`,\n// if it is `g.apply(n - 1)` then it would be similar to the original recursion version.\n// Let's `g = f.apply(f)`:\nclass GG implements Fact2ᴵ\n{\n    Fact3 f;\n    GG(Fact3 _f)\n    {\n        f = _f;\n    }\n\n    public int apply(int n)\n    {\n        return (f.apply(f)).apply(n);\n    }\n}\nclass Fact3\n{\n    Fact2ᴵ apply(Fact3 f)\n    {\n        return new GClosure(f);\n    }\n}\n\nclass GClosure implements Fact2ᴵ\n{\n    Fact3 f;\n    GG g;\n    GClosure(Fact3 _f)\n    {\n        f = _f;\n        g = new GG(f);\n    }\n\n    public int apply(int n)\n    {\n        if (n == 0)\n        {\n            return 1;\n        }\n        else\n        {\n            return n * g.apply(n - 1);\n        }\n    }\n}\n\n// We are almost done.\n// `GClosure.apply()` is the recursion definition we want.\n// Let's create something that takes a `GClosure`.\nclass YY\n{\n    Fact2ᴵ f;\n    YY(Fact2ᴵ _f)\n    {\n        f = _f;\n    }\n\n    int apply(int n)\n    {\n        return f.apply(n);\n    }\n}\n// Hmm, the problem is we still need `Fact3`, whose definition hard coded reference to `GClosure`.\n// We could made the constructor of `Fact3` taking `GClosure` as a parameter.\n// That is, to construct a `Fact3`, we need a `GClosure`,\n// and to construct a `GClosure`, we need a `Fact3`.\n// Now if we make `Fact3` and `GClosure` one thing, it will be self-referral.\nclass Fact0 implements Fact2ᴵ\n{\n    Fact2ᴵ g;\n    Fact0(Fact2ᴵ _g)\n    {\n        g = _g;\n    }\n\n    public int apply(int n)\n    {\n        if (n == 0)\n        {\n            return 1;\n        }\n        else\n        {\n            return n * g.apply(n - 1);\n        }\n    }\n}\n// Now the tricky part is constructing `Fact0(_f)`.\n// Again this smells like self-reference.\n// Just as we introduced an additional function as parameter before,\n// to construct `Fact0(_f)` we probably need an additional function.\nclass MKFact0\n{\n    Fact2ᴵ apply(Fact2ᴵ fact2ᴵ)\n    {\n        return new Fact0(fact2ᴵ);\n    }\n}\n// Now we need to define `Y0` such that `new Y0().apply(new MKFact0())` will construct a `Fact0`.\n// It is hard to write the `apply` method of `Y0`.\n// Let's go back to last iteration.\n// `GG` is not abstract. It has `Fact3` hard coded in its definition.\n// Let's refactor it.\nclass G0 implements Fact2ᴵ\n{\n    Fact2ᴵ g;\n    G0(Fact2ᴵ _g)\n    {\n        g = _g;\n    }\n\n    public int apply(int n)\n    {\n        return (g.apply(g)).apply(n);\n    }\n}\n// Oops! `g.apply(g)` is invalid.\n// From here we may try to rewrite `G0`.\n// Or we may try to rewrite `Fact2ᴵ`, `int -> int` is too restrictive,\n// i.e. if we cannot solve a specific problem,\n// try to solve its more general form.\n\n// Rewrite `Fact2ᴵ`, substitute `int` with `Object`, we get `o一oᴵ`.\n// Change `Fact0` and `MKFact0` accordingly, we get `Fact` and `MKFact`.\n// `Fact` implements `o一oᴵ`, we need to define an interface for `MKFact` as well. That is `oo一ooᴵ`.\n// Now we try to rewrite `G0`.\n// We find that `g.apply(g)` still cause type mismatch.\n// `g` cannot be an ordinary `Object`, which may no have an `apply` method defined.\n// Also `g` cannot be an `o一oᴵ`, which cannot take itself (`o一oᴵ`) as a parameter.\n// Thus we need a new type (interface).\n// An interface whose `apply` method takes anything (an `Object`) and returns an `o一oᴵ`.\n// Thus we have `Tᴵ`.\n// Then we look at `Y`.\n// We still dose not know how to write its `apply` method, but we know the signature of it.\n// It takes `MKFact`, a.k.a. `oo一ooᴵ`, and returns `Fact`, a.k.a. `o一oᴵ`.\n// Thus we have `oo一oo一ooᴵ`.\n//\n// We try to pass `MKFact` to `G`, `new G(new MKFact())`.\n// Not possible. We need a bridge to connect `oo一ooᴵ` and `Tᴵ`,\n// i.e. something takes a `MKFact` a.k.a. `oo一ooᴵ` and produces a `Tᴵ` for `G`.\nclass H implements Tᴵ\n{\n    oo一ooᴵ f;\n    H(oo一ooᴵ _f)\n    {\n        f = _f;\n    }\n\n    public o一oᴵ apply(Tᴵ x)\n    {\n        return ...;\n    }\n}\n// Now we need to fill in the missing `apply` definition for `H`.\n// It returns `o一oᴵ`. Do we have something returns `o一oᴵ`?\n// `f.apply` happens to produce `o一oᴵ`.\nclass H implements Tᴵ\n{\n    oo一ooᴵ f;\n    H(oo一ooᴵ _f)\n    {\n        f = _f;\n    }\n\n    public o一oᴵ apply(Tᴵ x)\n    {\n        return f.apply(...);\n    }\n}\n// `f.apply()` takes an `o一oᴵ`. Do we have something to transform `Tᴵ` to `o一oᴵ`?\n// The `apply` method of `Tᴵ`.\n// Do we have some class implements `Tᴵ`, except `H` itself?\n// No.\n// So we need to implement one?\n// Wait. `G` implements `o一oᴵ` and its construction method takes `Tᴵ` as parameter.\n// So `new G(x)` fills in the gap.\nclass H implements Tᴵ\n{\n    oo一ooᴵ f;\n    H(oo一ooᴵ _f)\n    {\n        f = _f;\n    }\n\n    public o一oᴵ apply(Tᴵ x)\n    {\n        return f.apply(new G(x));\n    }\n}\n// In fact, this is the very definition given in the book.\n//\n// At last, let's complete `Y`.\nclass Y implements oo一oo一ooᴵ\n{\n    public o一oᴵ apply(oo一ooᴵ f)\n    {\n        return ...;\n    }\n}\n// We need something takes `oo一ooᴵ` and produces `o一oᴵ`.\n// `H` takes `oo一ooᴵ` in its construction method, and produces `o一oᴵ` by its `apply` method.\nclass Y implements oo一oo一ooᴵ\n{\n    public o一oᴵ apply(oo一ooᴵ f)\n    {\n        return new H(f).apply(...);\n    }\n}\n// The parameter of `H(f).apply()` need to be a `Tᴵ`.\n// Do we have something implements `Tᴵ`?\n// `H` itself.\n// So\nclass Y implements oo一oo一ooᴵ\n{\n    public o一oᴵ apply(oo一ooᴵ f)\n    {\n        return new H(f).apply(new H(f));\n    }\n}\n// The very definition given in the book.\n\n// If you still have difficulties to understand it in Java,\n// try use another language.\n// For example,\n//\n// ```js\n// // Poor man's Y combinator\n// ((f => n => n == 0 ? 1 : n * f(f)(n - 1))\n//   (f => n => n == 0 ? 1 : 0 * f(f)(n - 1))\n//   3)\n// ```\n//\n// It would be perfect if it is `f(n -1)` instead of `f(f(n)(n - 1))`.\n// Let `g = f(f)`:\n//\n// ```js\n// ((f => ((g => n => n == 0 ? 1 : n * g(n - 1)) f(f))\n//   # same as above\n//   3)\n// ```\n//\n// Hmm, `(g => n => n == 0 ? 1 : n * g(n - 1)` is just what we want!\n// Let `h = (g => n => n == 0 ? 1 : n * g(n - 1)`:\n//\n// ```js\n// (((h =>\n//    (f => h(f(f)))\n//    (f => h(f(f))))\n//      (g => n => n == 0 ? 1 : n * g(n - 1))\n//      3)\n// ```\n//\n// Look! The factorial logic is factor out: `(g => n => n == 0 ? 1 : n * g(n - 1))`.\n// And this is the Y combinator.\n//\n// ```js\n// Y =\n//   (h =>\n//    (f => h(f(f)))\n//    (f => h(f(f))))\n// ```\n//\n// To construct `fact` with Y combinator: `Y(g => n => n == 0 ? 1 : n * g(n - 1))`.\n//\n// Hope this helps to understand those `Y`, `H`, `G` classes in Java.\n\npublic class LittleJava\n{\n    public static void main(String[] args)\n    {\n        Fact fact = new Fact(new Dummy());\n        System.out.println(fact.apply(new Integer(5)));\n        MKFact mKFact = new MKFact();\n\n        Fact newFact = (Fact) mKFact.apply(new Dummy());\n        System.out.println(newFact.apply(new Integer(5)));\n\n        Fact yFact = (Fact) new Y().apply(new MKFact());\n        System.out.println(yFact.apply(new Integer(5)));\n\n        System.out.println(\"static recursion version\");\n        System.out.println(StaticFact.fact(5));\n\n        System.out.println(\"normal version\");\n        NormalFact normalFact = new NormalFact();\n        System.out.println(normalFact.fact(5));\n\n        System.out.println(\"Fact1\");\n        Fact1 fact1 = new Fact1();\n        System.out.println(fact1.apply(fact1, 5));\n\n        System.out.println(\"Fact2: poor man's Y combinator\");\n        Fact2 fact2 = new Fact2();\n        System.out.println((fact2.apply(fact2)).apply(5));\n\n        System.out.println(\"Fact3: g = f(f)\");\n        Fact3 fact3 = new Fact3();\n        System.out.println((fact3.apply(fact3)).apply(5));\n\n        System.out.println(\"YY\");\n        YY yy = new YY(new GClosure(new Fact3()));\n        System.out.println(yy.apply(5));\n    }\n}\n
","date_published":"Sat, 25 Aug 2018 09:07:39 GMT","date_modified":"Sun, 05 Jul 2020 05:52:55 GMT"},{"id":"https://mmap.page/dive-into/go/","url":"https://mmap.page/dive-into/go/","title":"Quick Introduction to Go","content_html":"

Quick Introduction to Go

\n

We're going to try to quickly show you enough of Go 1.17 to actually try it out.

\n

A Syntax Derived from C

\n

The main difference to C is type annotation after identifier.

\n
package main\nimport \"fmt\"\n\ntype Point struct {\n\tx float64\n\ty float64\n}\nfunc distance(from Point, to Point) float64 {\n\treturn math.Pow(math.Pow(from.x-to.x, 2)+math.Pow(from.y-to.y, 2), 0.5)\n}\n// You can only declare a method with a receiver defined in the same package.\nfunc (point Point) Dist(other Point) float64 {\n    return math.Pow(math.Pow(point.x-other.x, 2)+math.Pow(point.y-other.y, 2), 0.5)\n}\n\nfunc main() {\n    var point Point = Point{0.0, 0.0}\n    var zero float64 = distance(Point{0.0, 0.0}, Point{2.0, 3.0}) - point.Dist(Point{2.0, 3.0})\n    fmt.Println(\"The entry point of an executable must be a function named `main` in a package named `main`.\")\n
\n

Slice

\n
names := []string{\"Tom\", \"Dick\", \"Harry\"} // inferred type `[]T`\n\n// Go reuses `:=` instead of a dedicated keyword `in`.\n// `_` is called blank identifier,meaning we are not interested in indices of the slice.\n// BTW, if we are not interested in the loop values, we can just write `for range names`.\nfor _, name := range names {\n    // Go does not have access modifiers.\n    // Exported (public) names begin with a capital letter.\n\tfmt.Println(\"Hello, \" + name + \" !\")\n}\n
\n

The slice uses an underlying array to store data.\nThe length of an array [n]T is part of its type, so arrays cannot be resized.\nThus, slices are much more common than arrays.

\n
type slice struct {\n    array unsafe.Pointer\n    len   int // current length\n    cap   int // capacity, the length of the underlying array\n}\n
\n

Go has a built-in append function to add elements to a slice, modifying the underlying array directly, or replacing the underlying array with a new one with a larger capacity.

\n
// pesudo code (pretend Go supports generics)\nfunc append(slice []T, elements ...T) []T {\n    for element := range elements {\n        slice.len += 1\n        if slice.len <= slice.cap {\n            slice[len-1] = element\n        } else {\n            new_slice := make([]T, (slice.len+1)*2)\n            copy(new_slice, slice)\n            slice = new_slice\n            slice[len-1] = element\n        }\n    }\n    return slice\n}\n
\n

To create a new slice:

\n
    \n
  1. Use the slice expressions on an existing array: a[n:m], a[:m], a[n:], and a[:].
  2. \n
  3. Slice expressions can also specify capacity, a[n:m:k] or a[:m:k]. k must be less than or equal to the capacity of the source slice or array.
  4. \n
  5. The make allocates a zeroed array and returns a slice that refers to that array, e.g. s := make([]int, 2, 5).
  6. \n
  7. var s []T returns nil, the zero value of a slice. It has a length and capacity of 0 and has no underlying array.
  8. \n
\n

Similarly, the zero value of a map is also nil (var m map[K]T).\nAnd make(map[K]T) returns a map initialized and ready for use.

\n

Since re-slicing a slice doesn't make a copy of the underlying array, the full underlying array will be kept in memory until it is no longer referenced.\nOccasionally this can cause the program to hold all the data in memory when only a small piece of it is needed.\nIn that case, copy the data over to another new slice via copy or append.

\n

make and new

\n

Normally Go has two ways to create a non-primitive:

\n
    \n
  1. Composite literals, e.g. []int{1, 2, 3}, which creates an instance, are mostly used.
  2. \n
  3. new(T) creates a zero value of T and returns a pointer *T, equivalent to &T{}.
  4. \n
\n

However, slices are special.\nAs shown above, composite literals like []int{1, 2, 3} work well with slices.\nBut new([]int) is rarely useful, since it only returns a pointer with zero value of a slice nil.\nHowever, unlike other structures, a slice is not ready to use with its zero value.\nTo prepare a slice, we need to first create its underlying array.\nAlso, since slices are cheap and expensive as explained in next section, and modifying a slice automatically modifies its underlying array,\na pointer to a slice is rarely used.\nThus Go introduces a new built-in function make for this purpose.\nmake([]int, 10, 100) creates a slice ready to use, with underlying array allocated with zero values, and returns a slice, not a pointer to a slice.

\n

Same applies to maps and channels.\nAnd make applies only to slices, maps, and channels.

\n

Unsafe Pointer

\n

The array field of the slice does not point to the underlying array.\nInstead, it points to the first element of the underlying array.\nThis makes slicing as cheap and efficient as passing around explicit indexes.

\n

However, this also means slice cannot utilize array's compile time bound checks.\nIndex out of range error with slices can only be checked at runtime.

\n

Strings have the same issue since strings in Go are effectively slices of bytes.

\n

Note that Go Slices: usage and internals on The Go Blog mentioned slice consists of a pointer to the array, the length of the segment, and its capacity.\nInstead, slice contains a pointer to the first element of the array.\nThe illusion below is correct (ptr *Elem).\nIn C, a pointer to an array is actually a pointer to the first element of an array.\nSo a pointer to an array and a pointer to the first element of an array are equivalent in C.\nBut this does not apply to Go.

\n

Variadic Functions

\n

Go supports variadic functions (splats arguments): (ns ...int).

\n

Flow Control

\n

for

\n

for is the only looping construct in Go.

\n
sum := 0\nfor i := 0; i < 10; i++ { // `i++` is a statement, not an expression.\n\tsum += i\n}\nfor sum < 1000 {\n\tsum += sum\n}\nfor {\n    sum += sum\n    if sum >= 1000 {\n        break\n    }\n}\n
\n

if and switch

\n

Like for, if and switch statements can start with a short statement to execute before the condition.\nThis is mainly used to declare variables to limit their scope until the end of the if (including else blocks).

\n
if v := math.Pow(x, n); v < lim {\n\treturn v\n}\nswitch os := runtime.GOOS; os {\n    case \"darwin\":\n        fmt.Println(\"macOS.\")\n    case \"linux\":\n        fmt.Println(\"Linux.\")\n    default:\n        fmt.Printf(\"%s.\", os)\n}\n
\n

defer

\n

A defer statement defers the execution of a function until the surrounding function returns.

\n
file, _ := os.Open(path)\ndefer file.Close()\n
\n

The deferred call's arguments are evaluated immediately, though.

\n

Multiple deferred function calls are pushed onto a stack.\nWhen a function returns, its deferred calls are executed in last-in-first-out order.

\n

defer breaks the rule of natural order of execution.\nThus it should be restricted for cleanup operations.\nAbusing defer disturbs the execution flow thus harming readability.

\n

Basic Types

\n\n

The expression T(v) converts the value v to the type T.

\n

Constants are declared with the const keyword, they can be character, string, boolean, or numeric values.\nNumeric constants are high-precision values.\nAn untyped constant takes the type needed by its context.

\n
const Pi = 3.14\n
\n

Type Aliases and Defined Type

\n
type Boolean = bool\n
\n

Now Boolean is an alternative spelling of bool.\nThey both denote the same type.

\n

Be aware the difference between type aliasing and type declaration.\nFor example, these are type declarations:

\n
type IsPositive bool\ntype IsNegative bool\n
\n

IsPositive and IsNegative are named types or defined types, with bool as their underlying type.\nIsPositive and IsNegative are new types, different from any other type, including their underlying type bool.\nAlso, IsPositive and IsNegative are not assignable to each other,\nbecause both of them are defined types.

\n
\n

A value x is assignable to a variable of type T (\"x is assignable to T\") if one of the following conditions applies:\n...\nx's type V and T have identical underlying types and at least one of V or T is not a defined type.

\n
\n

This is a great feature.\nIn many programming languages, it is best practice to name a boolean type with its \"direction\":

\n
var sex bool // bad\nvar isMale bool // good\n
\n

In Go, I can go further:

\n
type IsMale bool\nvar isMale IsMale\n
\n

And if I accidentally assign an unrelated boolean value or opposite directed boolean value to IsMale, the compiler will refuse to compile it.

\n

Multiple Return Values

\n

A function can return any number of results, which is mostly used in error handling:

\n
val, err := someFunction()\nif err != nil {\n    return err\n}\ncodeUsing(val)\n
\n

To handle errors with multiple return values conveniently,\nGo introduces two hacky features:

\n

First, when err is not nil, val is assigned to the zero value of its type.\nFor problems on zero values, see next section.

\n

Second, instead of writing

\n
val, err := f()\nvar newVal T\nnewVal, err = g()\n
\n

Go allows us to 'reuse' the err variable:

\n
val, err := f()\nnewVal, err := g() // `err` is **re-assigned** here\n
\n

Because in a := declaration a variable v may appear even if it has already been declared, provided:

\n\n

Introducing an unusual, inconsistent rule to support one use case is doubtful.\nTogether with other problems of using multiple return values to model exceptions, this implies a poor design of error handling.

\n

Note some built-in structures can produce one or multiple value.\nWe have seen range slice returns two values (index and element) before.\nIf you only want the index, just write for i := range names.

\n

Similarly, we have element := m[key] and element, present := m[key].\nIn both cases, element is the zero value for the map's element type if key is not present in the map (present is false in the later case).

\n

Similar to the issue with errors, the zero value element may be a valid value, making missing a key undistinguishable.

\n

Also note that the evaluation order of multiple return values is uncertain.\nNever assume the evaluation order of multiple return values is from left to right.

\n

Another issue is Go functions can only consume multiple values returned by another function in a whole.\nFor example, given three functions f() (int, int), g(int, int), h(int, int, int),\ng(f()) compiles while h(f(), 1) and h(1, f()) do not.

\n

Zero Values

\n

Variables declared without an explicit initial value are given their zero value:

\n\n

Using 0, fales, and \"\" for numbers, bools, and strings is confusing.\nAnd the compiler cannot check declaration without assignment errors.

\n

Using nil as zero values has the same problem with nullability in other languages.

\n

To make things worse:

\n\n

Functions as Values

\n

Functions are values too.\nThey can be passed around just like other values.

\n
func sortStringsByLength(s []string) {\n    sort.Slice(\n            s,\n            // Anonymous functions are closures.\n            func(i int, j int) bool { return len(s[i]) < len(s[j]) })\n}\n
\n

However, it only matches exact function signature.\nIt does not support subtyping of functions, since Go does not support covariance and contravariance.\nEven covariant return type is not supported, which is supported by Java.

\n

Pointers

\n

Unlike C, Go has no pointer arithmetic.\nAnd accessing the field via a struct pointer will derefer the pointer implicitly.\nAlso, methods with a pointer/value receiver also accept its value/pointer as the receiver when they are called.

\n
func (point *Point) Scale(f float64) { /* ... */ }\npoint := Point{x: 1.0, y: 2.0}\npointer := &point // the `&` operator generates a pointer\nfmt.Println(pointer.x) // same as (*pointer).x, where the `*` operator denotes the underlying value\npoint.Scale(10) // same as pointer.Scale(10)\n
\n

We are cheating in the definition of Scale.\nThe definition of Scale does not check nil value of *Point.\nAs mentioned before, nil is zero value of a pointer, in other words, all pointers are nullable in Go.\nThe compiler accepts nil as a valid receiver of Scale, which is in fact invalid.

\n
var n *Point // nil\nn.Scale(10) // The compiler does not check nullability.\n
\n

n.Scale(10) compiles, but triggers a runtime error: invalid memory address or nil pointer dereference.\nDue to the auto indirection of a value receiver, even a method accepting a value of a type not accepting nil may take a nil receiver argument.

\n

Thus I prefer to declare a function instead.\nMethods are only used to implement interfaces.

\n

Interfaces

\n

Implicitness

\n

Interfaces are implemented implicitly.

\n
type I interface {\n\tM()\n}\n// Type T implements the interface I, without explicit declaration.\nfunc (t T) M() {\n\tfmt.Println(t.S)\n}\n
\n

Empty Interface

\n

Because Go does not have generics,\nyou are forced to use empty interface interface{} for generic code.\ninterface{} is similar to void* in C, breaking type safety.

\n

t := i.(T) asserts i holding T and assigns the underlying T value, triggering a panic if i does not hold T.\nt, ok := i.(T) avoids triggering a panic if i does not hold T.\nswitch t := i.(type) permits several type assertions in series.

\n

An interface can be considered as a pair of (ConcreteType, Value).\nThus while an interface can be nil (for example, zero value), an interface holding a nil concrete value is itself non-nil.

\n
var i interface{} = nil // i == nil\nvar j []string = nil\ni = j // i != nil\n
\n

Check Implementation

\n

To check if a value satisfies an interface at run time, use type assertion:

\n
m, ok := val.(json.Marshaler)\n
\n

To get the type and underlying value of an interface value at rut time, use reflect.TypeOf(x) and reflect.ValueOf(x).\nBoth reflect.Type and reflect.Value have a Kind method that returns a constant indicating what sort of item is stored:\nreflect.Uint, reflect.Float64, reflect.Slice, and so on.\nreflect.Value also has an Interface method, which packs the type and value information back into an interface representation and returns the result.

\n

To change the underlying value of reflect.Value, we can use reflect.SetT.

\n
var x float64 = 3.4\nv := reflect.ValueOf(&x)\nv.SetFloat(7.1)\n
\n

Note that we pass &x instead of x to reflect.ValueOf.\nOtherwise v would store a copy of x, and v.SetFloat would be illegal.\nThe CanSet method of reflect.Value reports the settability of it.

\n

Be careful with reflections.\nReflections involves type assertion and value copying.\nThus it may cause performance issues.

\n

To make sure that a type implementing the required interface at compile time:

\n
var _ json.Marshaler = (*RawMessage)(nil)\n
\n

Here we use a pointer instead of new(RawMessage) because if RawMessage is a big array or struct, calling new may allocate unnecessary memory.

\n

Embedded Interfaces

\n

Interface type name can be used in place of a method specification.

\n
type ComplexInterface interface {\n    EmbeddedInterface\n    AnotherEmbeddedInterface\n    AMethod() int\n}\n
\n

The method set of ComplexInterface is the union of its embedded interfaces and its explicitly declared methods.\nIf there are interface methods have identical names, they must have identical signatures.

\n

Struct

\n

Structs can embed interfaces.

\n
// Job has all the methods of `*log.Logger`.\ntype Job struct {\n    Command string\n    *log.Logger // same as Logger *log.Logger\n}\n
\n

Stringer

\n

One of the most ubiquitous interfaces is Stringer\ndefined by the fmt package.

\n
type Stringer interface {\n    String() string\n}\n
\n

The print functions from fmt utilizes the Stringer interface.

\n

error

\n

The other ubiquitous interface is the built-in error interface:

\n
type NullPointerException struct {\n    Message string\n}\n\n// satisfies `error` interface\nfunc (e *NullPointerException) Error() string {\n    return e.Message\n}\n
\n

If we do not want to declare our own error type, we just use a general error with a string via errors.New or fmt.Errorf.

\n

error.Is and error.As

\n

Besides New, errors also provides two functions: Is and As.

\n

errors.Is compares an error to a value.\nThere are two differences between using errors.Is(err, value) and comparing via err == value directly:

\n
    \n
  1. errors.Is will invoke the Is method of the error if available.
  2. \n
  3. errors.Is will examine all the wrapped errors on the chain.
  4. \n
\n

For example:

\n
type NonExistError struct {\n    Code int\n    Err error\n}\nfunc (e *NonExistError) Error() string { return strconv.Itoa(e.Code) }\n// If e1.Unwrap() returns e2, then e1 wraps e2, and we can unwrap e1 to get e2.\n// e2 itself may implement an Unwrap method returning its underlying error (error chain).\nfunc (e *NonExistError) Unwrap() error { return e.Err }\nfunc (e *NonExistError) Is(target error) bool {\n    t, ok := target.(*NonExistError)\n    if ok {\n        return e.Code == t.Code\n    } else {\n        return false\n    }\n}\n
\n

Similarly, there is an errors.As method, examining all the wrapped errors on the chain, using As method defined on errors when available.

\n
var err *NonExistError\nvar ok bool = errors.As(e, &err)\n
\n

%w

\n

Besides defining the Unwrap method explicitly, fmt.Errorf with %w verb present returns an error with an Unwrap method returning the argument of %w.\nThus the argument of %w must be an error.\nIn other aspects, %w is identical to %v.

\n
e2 := errors.New(\"wrap me\")\ne1 := fmt.Errorf(\"wraps %w\", e2)\n
\n

Wrapping an error will expose the underlying error, thus making the wrapped error part of the API.\nTherefore abusing wrapping will break abstraction and expose implementation details unnecessarily.

\n

panic and recover

\n

As an alternative to return an error, we can panic instead.

\n

To regain control of a panicking execution, we can use the built-in recover function.

\n
func f(v interface{}) {\n    // anonymous function\n    defer func() {\n        if r: = recover(); r != nil {\n            log.Fatal(\"Recovered in f\", r)\n        }\n    }()\n    func() {\n        panic(\"panic\")\n    }()\n    fmt.Println(v)\n}\n
\n

Goroutines

\n

Goroutines are user level continuation, more lightweight than system level continuation (threads).

\n
func sum(s []int, c chan<- int) { // `chan<-` only receive values; `<-chan` only send values\n\tsum := 0\n\tfor _, v := range s {\n\t\tsum += v\n\t}\n\tc <- sum // send sum to c\n}\nfunc calc(s []int, c chan int) int { // `chan` has no direction (can receive and send values)\n\tgo sum(s[:len(s)/2], c)\n    go sum(s[len(s)/2:], c)\n    return <-c + <-c\n}\nfunc main() {\n\ts := []int{7, 2, 8, -9, 4, 0}\n\tc := make(chan int, 2) // no race conditions, thus we create a buffered channel\n    fmt.Println(calc(s, c))\n}\n
\n

Closing a Channel

\n

A sender can close a channel to indicate that no more values will be sent: close(c).\nSending on a closed channel will cause a panic.\nThus only the sender should close a channel, never the receiver.

\n

Channels aren't like files; you don't usually need to close them.\nClosing is only necessary when the receiver must be told there are no more values coming, such as to terminate a range loop.

\n
func fibonacci(n int, c chan<- int) {\n\tx, y := 0, 1\n\tfor i := 0; i <= n; i++ {\n\t\tc <- x\n\t\tx, y = y, x+y\n\t}\n\tclose(c)\n}\n\nfunc main() {\n\tc := make(chan int) // unbuffered channel\n\tgo fibonacci(10, c)\n\tfor i := range c {\n\t\tfmt.Println(i)\n\t}\n}\n
\n

Receivers can test whether a channel has been closed by assigning a second parameter to the receive expression v, ok := <-c.

\n

Select

\n

The select statement lets a goroutine wait on multiple communication operations.

\n

A select blocks until one of its cases can run, then it executes that case.\nIt chooses one at random if multiple are ready。

\n
func fibonacci(c chan<- int, end <-chan bool) {\n\tx, y := 0, 1\n\tfor {\n\t\tselect {\n\t\tcase c <- x:\n\t\t\tx, y = y, x+y\n\t\tcase <-end:\n\t\t\treturn\n\t\t}\n\t}\n}\n\nfunc main() {\n\tc := make(chan int)\n\tend := make(chan bool)\n\tgo func() {\n\t\tfor i := 0; i < 10; i++ {\n\t\t\tfmt.Println(<-c)\n\t\t}\n\t\tend <- true\n\t}()\n\tfibonacci(c, end)\n}\n
\n

The default case in a select is run if no other case is ready.

\n

Name Conventions

\n

Package

\n

By convention, packages are given lower case, single-word names; there should be no need for underscores or mixedCaps.\nAnother convention is that the package name is the base name of its source directory, for example encoding/base64.

\n

By the way, to import a package only for its side effect (init()), use a blank identifier import _ packageName.

\n

Getter

\n

It's neither idiomatic nor necessary to put Get into the getter's name.\nIf you have a field called owner (lower case, unexported), the getter method should be called Owner (upper case, exported), not GetOwner.\nThe use of upper-case names for export provides the hook to discriminate the field from the method.\nA setter function, if needed, will likely be called SetOwner.

\n

Interface

\n

By convention, one-method interfaces are named by the method name plus an -er suffix or similar modification to construct an agent noun: Reader, Writer, Formatter, CloseNotifier etc.

\n

MixedCaps

\n

The convention in Go is to use MixedCaps or mixedCaps rather than underscores to write multiword names.

\n

Why?

\n

First, set_owner (unexported names in Go) is easier to read because we are already familiar with set owner in natural languages.\nWe Are not Familiar with Compound words and Similar structures Like this.\nThus Set_owner (exported names in Go) does not feel nature.

\n

Second, Go prefers brevity over for clarity.\nEffective Go suggested that:

\n
\n

Long names don't automatically make things more readable.\nA helpful doc comment can often be more valuable than an extra long name.

\n
\n

Thus mixedCaps will probably not get long enough to reduce readability, e.g. isSomeoneElseJustFinishedWriting.

\n

Testing

\n

To test Go code, write testing functions as TestXxx(*testing.T).

\n
package main\n\nimport \"testing\"\n\nfunc TestSum(t *testing.T) {\n    total := Sum(1, 1)\n    if total != 2 {\n       t.Errorf(\"Sum(1, 1) got: %d, expected: %d.\", total, 2)\n    }\n}\n
\n

Put those testing functions in a file whose name ends with _test.go within the package.\nThe file will be excluded from regular package builds but will be included when the go test command is run.

\n

Benchmark

\n

Functions of the form BenchmarkXxx(*testing.B) are benchmarks, which will be executed by go test -bench.

\n
func BenchmarkHello(b *testing.B) {\n    doSomeExpensiveSetup()\n    b.ResetTimer()\n    for i := 0; i < b.N; i++ {\n        fmt.Sprintf(\"hello\")\n    }\n}\n
\n

The output

\n
BenchmarkHello    10000000    282 ns/op\n
\n

means that the loop ran 10000000 times at a speed of 282 ns per loop.

\n

The times are adjusted until the benchmark function lasts long enough to be timed reliably.

\n

If a benchmark needs to test performance in a parallel setting, it may use the RunParallel helper function; such benchmarks are intended to be used with the go test -cpu flag:

\n
func BenchmarkTemplateParallel(b *testing.B) {\n    templ := template.Must(template.New(\"test\").Parse(\"Hello, {.}!\"))\n    b.RunParallel(func(pb *testing.PB) {\n        var buf bytes.Buffer\n        for pb.Next() {\n            buf.Reset()\n            templ.Execute(&buf, \"World\")\n        }\n    })\n}\n
\n

Examples

\n

Example functions may include a concluding line comment that begins with Output: and is compared with the standard output of the function when the tests are run.\nThe comparison ignores leading and trailing space.

\n
func ExampleHello() {\n        fmt.Println(\"hello\")\n        // Output: hello\n}\n\nfunc ExampleSalutations() {\n        fmt.Println(\"hello, and\")\n        fmt.Println(\"goodbye\")\n        // Output:\n        // hello, and\n        // goodbye\n}\n
\n

Example functions without output comments are compiled but not executed.

\n

Fuzzing

\n

TODO introduced in Go 1.18

\n

Subtests and Sub-benchmarks

\n

The Run method allows defining subtests and sub-benchmarks,\nwithout having to define separate functions for each.\nThis enables uses like table-driven benchmarks and creating hierarchical tests.\nIt also provides a way to share common setup and tear-down code:

\n
func TestFoo(t *testing.T) {\n    // <setup code>\n    t.Run(\"one\", func(t *testing.T) { ... })\n    t.Run(\"two\", func(t *testing.T) { ... })\n    t.Run(\"B=1\", func(t *testing.T) { ... })\n    // <tear-down code>\n}\n
\n

The argument to the -run and -bench command-line flags\nis an unanchored regular expression that matches the test's name.

\n
go test -run Foo     # Run top-level tests matching \"Foo\", such as \"TestFooBar\".\ngo test -run Foo/B=  # For top-level tests matching \"Foo\", run subtests matching \"B=\".\ngo test -run /B=1    # For all top-level tests, run subtests matching \"B=1\".\n
\n

Subtests can also be used to control parallelism.\nA parent test will only complete once all of its subtests complete.

\n
func TestGroupedParallel(t *testing.T) {\n    for _, tc := range tests {\n        tc := tc // capture range variable\n        t.Run(tc.Name, func(t *testing.T) {\n            t.Parallel()\n        })\n    }\n}\n
\n

Main

\n

It is sometimes necessary for a test program to do extra setup or teardown before or after testing.\nIt is also sometimes necessary for a test to control which code runs on the main thread.\nTo support these and other cases, if a test file contains a function:

\n
func TestMain(m *testing.M)\n
\n

then the generated test will call TestMain(m) instead of running the tests directly.\nTestMain runs in the main goroutine and can do whatever setup and teardown is necessary around a call to m.Run.\nIt should then call os.Exit with the result of m.Run.\nWhen TestMain is called, flag.Parse has not been run.\nIf TestMain depends on command-line flags, it should call flag.Parse explicitly.

\n

A simple implementation of TestMain is:

\n
func TestMain(m *testing.M) {\n\t// flag.Parse()\n\tos.Exit(m.Run())\n}\n
\n

Helper functions

\n

When testing, to print location of a call to the helper function,\ninstead of a line in the definition of the helper function, invoke Helper method in the definition of the helper function.

\n

For example:

\n
func assertTrue(t *testing.T condition bool) {\n    // This marks assertTrue a helper function.\n    // Without it, if something is wrong,\n    // `go test` will always print the line number of `t.Fail()` below.\n    t.Helper()\n    if !condition {\n        t.Fail()\n    }\n}\n\nfunc TestFoo(t *testing.T) {\n    // Since assertTrue is marked as a helper function,\n    // `go test` will print the line number of the following line.\n    assertTrue(t, 1 + 1 == 1)\n}\n
\n

testing/iotest implements Readers and Writers useful mainly for testing.

\n

Tooling

\n

Module

\n

Initialize a module:

\n
go mod init yourname.github.com/hello`\n
\n

This will create a go.mod file,\nwhere dependencies will be listed.

\n

Update go.mod based on Go source files,\nand install missing dependencies automatically:

\n
go mod tidy\n
\n

The specific dependency versions installed will be recorded in go.sum.

\n

Formatting

\n

go fmt formats your code.\nIt has no line length limit.

\n

Documentation

\n

TODO Go 1.19 changes doc comments syntax.

\n

go doc processes Go source files to extract documentation.\nComments that appear before top-level declarations, with no intervening newlines, are extracted along with the declaration.

\n

Every package should have a package comment, a block comment preceding the package clause.\nFor multi-file packages, the package comment only needs to be present in one file, and any one will do.

\n

Comments do not need extra formatting such as banners of stars.\nThe comments are uninterpreted plain text, except that indented text will be display in a fixed-width font, suitable for program snippets.

\n

godoc does not support cross reference.

\n

Inside a package, every exported (capitalized) name in a program should have a doc comment.

\n

The first sentence of a doc comment should be a one-sentence summary that starts with the name being declared.\nThis is because godoc is stupid.\nIt does not offer a search function.\nTo search for a function, we have to use grep:

\n
go doc regexp | grep parse\n
\n

Effective Go pointed out:

\n
\n

If all the doc comments in the package began, \"This function...\",\ngrep wouldn't help you remember the name.

\n
\n

This approach has three issues:

\n

First, beginning a comment with \"This function... may be redundant, but just omitting the function name like Returns the source text used to compile the regular expression. is more succinct.

\n

Second, although this approach does support a hacky way to search for function names, it does not provide an important information, the function signature, which is crucial for a static typed language.

\n

Third, in fact neither godoc nor grep has a concept of sentence.\nThus the \"first sentence\" is actually the \"first line\".\nThe go doc regexp | grep parse example given in the Effective Go demonstrates how ineffective this approach.\ngo doc regexp | grep parse finds Compile, but fails to find MustCompile and MustCompilePOSIX:

\n
MustCompile is like Compile but panics if the expression cannot be\nparsed.\n\nMustCompilePOSIX is like CompilePOSIX but panics if the expression\ncannot be parsed.\n
\n

Because \"parsed\" does not fit into the first line,\ngo doc regexp | grep parse fails to find these two related functions.

\n

This is a typical example of a poor design that roots in the unix philosophy \"pass everything as text\".

\n

godoc should have parsed the comments into structures consist of signature, summary, description, etc., and either provided a built-in search command, or produced an AST for other tools to consume.

\n

Unsupported

\n

Go does not have generics.

\n

TODO Go 1.18 introduces generics.

\n

Go does not distinguish reassignable and irreassignable variables, even function parameters and method receiver are reassignable (just like a local variable).

\n

Go does not have immutable collection types in its standard library.

\n

Go does not support optional parameters or overloading, except for some built-in functions like append and make.

\n

Style and Conventions

\n
    \n
  1. Error strings should not be capitalized (unless beginning with proper nouns or acronyms) or end with punctuation, since they are usually printed following other context.
  2. \n
  3. Avoid renaming imports except to avoid a name collision; good package names should not require renaming. In the event of collision, prefer to rename the most local or project-specific import.
  4. \n
  5. Words in names that are initialisms or acronyms have a consistent case. For example, xmlHTTPRequest or XMLHTTPRequest. Code generated by the protocol buffer compiler is exempt from this rule.
  6. \n
  7. Go interfaces generally belong in the package that uses values of the interface type, not the package that implements those values. The implementing package should return concrete (usually pointer or struct) types: that way, new methods can be added to implementations without requiring extensive refactoring.
  8. \n
  9. Prefer synchronous functions over asynchronous ones. If callers need more concurrency, they can add it easily by calling the function from a separate goroutine. But it is quite difficult - sometimes impossible - to remove unnecessary concurrency at the caller side.
  10. \n
  11. In tests, the order is actual != expected, and the message uses that order too. For example, if got != tt.want {t.Errorf(\"Foo(%q) = %d; want %d\", tt.in, got, tt.want)} Some test frameworks encourage writing these backwards: 0 != x, \"expected 0, got x\", and so on. Go does not.
  12. \n
\n

See https://github.com/golang/go/wiki/CodeReviewComments for more information.

\n

References

\n

This introduction is based on the following materials:

\n
    \n
  1. A Tour of Go
  2. \n
  3. Effective Go
  4. \n
  5. Go by Example
  6. \n
  7. Go Slices: usage and internals
  8. \n
  9. Defer, Panic, and Recover
  10. \n
","date_published":"Sat, 25 Aug 2018 02:30:57 GMT","date_modified":"Mon, 05 Sep 2022 15:35:49 GMT"},{"id":"https://mmap.page/dive-into/ocaml/","url":"https://mmap.page/dive-into/ocaml/","title":"OCaml Basic","content_html":"

OCaml Basic

\n

Types

\n\n

Operators

\n\n

Wrapping an operator in parentheses to form a function:

\n
(+) 1 2;;\n
\n

Names

\n\n

Pattern Matching

\n
match x with\n  | 0 | 1 -> 1\n  | _ -> x\n
\n

Pattern matching multiple values:

\n
match x, y with\n  | 0, 0 -> true\n  | _, _ -> false\n
\n

Nested pattern matching:

\n
match x with\n  | 0 ->\n    begin match y with\n      | 0 -> 0\n      | _ -> x\n    end\n  | 1 -> 1\n
\n

begin ... end is a syntax sugar for ( ... ).

\n

Guarded patterns:

\n
match x with\n  | x when x <= 0 -> 1\n  | _ -> x * f (x - 1);;\n
\n

Alias patterns (as):

\n
let rec fib = function\n  | (0 | 1) as i -> i\n  | i -> fib(i-2) + fib(i-1);;\n
\n

Matching character intervals:

\n
let alphanum c = match c with\n  | 'a'..'z' | 'A'..'Z' -> \"letter\"\n  | '0'..'9' -> \"number\"\n  | _ -> \"other\";;\n
\n

Matches should be exhaustive and reachable,\notherwise the compiler will emit a warning.

\n

Matching against floating-point values is rarely used\nbecause of numerical issues.

\n

Also, name binding (let) uses pattern matching under the hood.

\n
let (a,b,c) = (1, true, 'A');;\n
\n

Functions

\n\n

Optional parameters use pattern match under the hood:

\n
let f ?x y =\n  let x = match x with None -> 1 | Some n -> n in\n    x - y;;\n\nf ?x:(Some 3) 2;;\n
\n

This 'raw' syntax can be used to delegate default behavior\nfrom a wrapper function to the wrapped function:

\n
let f' ?x y = f ?x y\n
\n

Optional parameters are always called as named parameters.\nTo support partial application (currying),\noptional parameters should always be followed by not-optional parameters in declaration.

\n

Because optional parameters applications reuse\nthe syntax of named parameters,\nthe type of a higher-order function may be ambiguous.\nThe compiler will always prefer to infer that a parameter is labeled, not optional.\nIf optional parameter is wanted, type need to be specified explicitly.

\n

Types

\n\n

Unlike functions, type declaration is recursive by default.

\n

Exception

\n\n

Mutability

\n

Reference

\n\n

Array

\n\n

Loop

\n\n

Lazy

\n\n

Module

\n\n

Example: set.mli

\n
(* Abstract type *)\ntype 'a set\n(* Concrete type to make it explicit what is a choice,\nsince simply writing\n\n    type 'a choice\n\nis not informative.\nAlso, exposing concrete implementation allows client code\nto pattern match against choice.\n\n`set.ml` must repeat this definition.\n*)\ntype 'a choice =\n  | Element of 'a\n  | Empty\n(* declare types for public values *)\nval empty : 'a set\nval contains : 'a set -> 'a -> bool\n(* optional and labeled parameters *)\nval add : ?elem:'a -> a_set:'a set -> 'a set\nval choose : 'a set -> 'a choice\n
\n

Or embed modules in a file:

\n
module Set : sig\n  type t\n  val ...\nend = struct\n  type t = ...\n  let ...\nend\n
\n

Or separate signature and implementation (allow different implementations):

\n
module type Set = sig\n  include (module type of OtherModule)\n  type ...\n  val ...\nend\n\nmodule type ListBackend = struct\n  include OtherModule\n  type ...\n  let ...\nend\n\nmodule SetOnList : Set = ListBackend\n
\n

By convention, the primary type of a given module M is called t.\nAnd functions in M that take a value of M.t takes it as their first argument.

\n

Get Started

\n

Install

\n
sudo apt-get install ocaml-nox opam curl build-essential m4\n
\n

Compile

\n

For a single file:

\n
ocamlopt -strict-sequence -o x x.ml\n
\n

-strict-sequence forces the left-hand part of each sequence to have type unit,\nthus a; b; c is equivalent to:

\n
let () = a in\nlet () = b in\nc\n
\n

For debugging, compile to byte-code,\nwhich is also faster to compile,\nalso turning on all warnings\nand adding debug information\n(required to run ocamldebug and to print stack backtraces)

\n
ocamlc -wA -g -o x x.ml\nocamldebug ./x\n
\n

For a project (automatically finding modules, etc.):

\n
ocamlbuild -strict-sequence x.native\n
\n

OPAM

\n

Initialize (run once):

\n
opam init\n
\n

Standard Library

\n

OCaml's Standard Library is developed for use in bootstrapping the compiler,\nand is purposefully kept small and simple.

\n

The general-purpose 'standard' library is\nthe Core distribution provided by Jane Street.

\n
opam install core\n
\n

REPL

\n

The built-in repl opam lacks features such as history and completion.\nUse utop instead (shipped with core):

\n
utop\n
\n

Editors

\n

Merlin is an editor service that provides modern IDE features:

\n\n

Install it via opam:

\n
opam install merlin\n# Auto configure Emacs and Vim\nopam user-setup install\n
\n

Supported editors:

\n\n

ocp-indent can indent opam code automatically\n(available via opam).

\n

Code Example

\n
(* FUNCTIONS *)\n\n(* Floats use different operators. *)\nlet pi = 4.0 *. atan 1.0\n\n(* Global type inference. *)\nlet square = fun x -> x *. x\n\n(* Functions are by default non-recursive.\nRecursion need to be explicit (with `rec`).\n*)\nlet rec fact = fun n ->\n  match n with (* pattern matching *)\n  | 0 | 1 -> 1\n  | _ -> n * fact (n - 1)\n(* The compiler will emit a warning if\npattern matching is not exhaustive,\nor contains unreachable matches.\n*)\n\n(* Mutually recursion with function declaration shortcuts. *)\nlet rec sort = function\n  | [] -> []\n  | first :: rest -> insert first (sort rest)\nand insert element a_list = match a_list with\n  | [] -> [element]\n  | first :: rest ->\n    if element <= first then\n      element :: a_list\n    else (* the else clause has the same type as the then clause *)\n      first :: insert element rest\n(* `sort` and `insert` is polymorphic.\nThey can be applied to lists of any type,\nand returns a list with the same type.\n\n`sort` and `insert` does not modify their input list.\nLists are immutable, like most data structures in OCaml.\n*)\n\n(* OCaml provides the `|>` operator to flip function and its parameter.*)\nlet rec fact' = function\n  | 0 | 1 -> 1\n  | n ->\n    n\n    |> (-) 1 (* Convert infix operator to prefix function call. *)\n    |> fact\n    |> ( * ) n (* Spaces to avoided be recognized as comments. *)\n(* It can easily be defined as a higher-order function. *)\nlet (|>) f x = x f\n\n(* `|>` operator makes refactoring (changing numbers and order of argument) harder,\nthus intemediate variables are often preferred. *)\n\n(* TYPES *)\n\n(* Type Aliases *)\ntype boolean = bool\ntype integer = int\ntype double = float\ntype character = char\ntype sequence_of_bytes = string\n\n(* Records *)\ntype point = {x: float; y: float}\nlet new_point x y = {x; y}\n\n(* Here type annotations can be omitted.\nHowever, it is a good practice to annotate types for records in real projects,\nbecause OCaml infer record types from field names.\n\nIn real projects, declaration of the distance function may be far from\nthe declaration of the point type.\nAnd later declaration of a new record with the same field names may be added\nbetween the declaration of type point and function distance,\nwhich will cause type error of the distance function\nif the fields of the new record have different types,\nor change the semantics of function distance silently\nif the fields of the new record have same types as type point.\n*)\nlet distance (from: point) (target: point) =\n  ((from.x -. target.x) ** 2.0 +. (from.y -. target.y) ** 2.0) ** 0.5\n\n(* We cannot make function new_point also accepts integer values (will be converted to floats.\nOCaml's type system does not allow this.\nHowever, types can be wrapped/tagged with a type constructor,\nand the wrapped/tagged types can be combined to disjoint unions.\nThis is called polymorphic variants.\n*)\ntype number = [`Integer of int | `Float of float]\nlet new_point_polymorphic (x: [< number]) (y: [< number]): point =\n  match x, y with\n    | `Integer m, `Integer n -> {x = float_of_int m; y = float_of_int n}\n    | `Integer m, `Float n -> {x = float_of_int m; y = n}\n    | `Float m, `Integer n -> {x = m; y = float_of_int n}\n    | `Float m, `Float n -> {x = m; y = n}\n\n(* Unlike the closed [< `A | `B], [> `A | `B] is structural typing,\nopening to any type that can at least match `A and `B.\nBoth of them can only be denoted directly, not be given a name via `type`.\nAnd [`A | `B] is fixed type.\n\n- [< `A | `B | `C]: [< `B | `A | `C], [< `C | `A], [`A | `B | `C], [`B]\n- [> `A | `B ]: [> `A | `C | `B], [`A | `B | `C], [> `A | `B], [`B | `A]\n- [`A | `B]: [`B | `A]\n\nA | B is normal variant type:\n\n- It cannot be denoted directly. To use it, it has to been given a name.\n- Once the name is given, A and B is assigned to a unique type. In other words,\n  `type one_name = A | B` and `type another_name = A | B` are not compatible.\n\nNormal variants are slightly lighter than polymorphic variants,\nsince static information allows for more optimizations.\nHowever noticeable differences would only appear on huge data structures.\n*)\n\n(* Recursive Types *)\ntype 'a binary_tree = (* 'a is a type variable, and stands for any given type. *)\n  | Leaf\n  | Node of 'a * 'a binary_tree * 'a binary_tree\n  (* The `*` character is used\n  because the set of all pairs of type `t * s`\n  corresponds to the Cartesian product of\n  the set of elements of type `t` and the set of elements of type `s`.\n  *)\n\n(* IMPERATIVE FEATURES *)\n\nlet increse_array arr =\n  let length = min (Array.length arr) 3 in\n  let incresements = [|1; 2; 3|] in\n  let result = Array.make length 0 in (* 0.0 is initial value *)\n  for i = 0 to length - 1 do\n    result.(i) <- arr.(i) + incresements.(i)\n  done; (* `a ; b` returns `b` *)\n  result\n\ntype mutable_point = { mutable x: float; mutable y: float }\nlet translate p dx dy =\n  p.x <- p.x +. dx; p.y <- p.y +. dy;;\n\n(* OCaml standard library provides references, which mimics mutable variables. *)\ntype 'a reference = { mutable contents: 'a }\nlet ref initial_value = { contents = initial_value }\nlet (:=) r new_value = r.contents <- new_value\nlet (!) r = r.contents\n\n(* Store a polymorphic function as a mutable field in a record. *)\ntype idref = { mutable id: 'a. 'a -> 'a }\n\n\n(* MODULE *)\n\n(* OBJECT *)\nclass point_1d init =\n  object (self)\n    val mutable x = init\n    method get_x = x\n    method move d = x <- x + d\n    (* Private methods can only be invoked from other methods of the same object. *)\n    method private move_one = self#move 1\n    (* Initializer is an anonymous hidden method\n    Initializers cannot be overridden.\n    On the contrary, all initializers are evaluated sequentially.\n    *)\n    initializer print_string \"new 1d point at \"; print_int x; print_newline ()\n  end\n\nclass positive_1d_point init =\n  object (self)\n    inherit point_1d init\n    (* Private methods are inherited (they are by default visible in subclasses),\n    unless they are hidden by signature matching.\n    *)\n    method virtual move_one : _\n    (* Private methods can be made public in a subclass. *)\n    method is_positive = self#get_x > 0\n  end\n\nlet strings = ref []\n\n(* Immediate objects are like anonymous classes in Java. *)\nlet immediate_object =\n  object (self) (* `self` could be any identifier. It is a convention to use `self`. *)\n    val mutable x = \"Immediate objects are like anonymous classes in Java.\"\n    method get_x = x\n    method set_x new_value = x <- new_value\n    method print = print_string self#get_x\n    method register = strings := self :: !strings\n    (* Putting self into an external reference is not allowed,\n    as it would forbid extending the class through inheritance.\n    However, since immediate objects are not extensible,\n    there is no such restriction for immediate objects.\n    *)\n  end\n\n(* Virtual classes are like abstract classes in Java.\nVirtual classes cannot be instantiated.\n*)\nclass virtual abstract_number init =\n  object (self)\n    val mutable virtual x : int\n    method virtual get_x : int\n    method virtual move : int -> unit\n    method print = print_int self#get_x\n  end\n\n(* Multiple Inheritance *)\nclass painter (name: string) = object\n  val mutable name = name\n  method get_name = name\n  method draw = print_string \"I am painting.\"\nend\n\nclass cowboy (name: string) = object\n  val mutable name = name\n  method get_name = name\n  method draw = print_string \"I am fighting.\"\nend\n\nclass painter_and_cowboy (init: string) = object\n  inherit painter (init ^ \" as a painter\") as painter\n  (* cowboy overrides variable name and method draw of painter.\n  Thus `inherit!` is used instead of `inherit`.\n  *)\n  inherit! cowboy (init ^ \" as a cowboy\") as cowboy\n  method dual_draws =\n    painter#draw;\n    cowboy#draw\nend\n\n(* Parameterized Classes *)\n\n(* Classes stores its value as a reference under the hood,\nthus it should be monomorphic or parametric.\nThe painter and cowboy classes above are monomorphic.\n*)\n\nclass ['a] (* Class type parameters are listed between [ and ]. *) parametric_class\n  (init: 'a) = object\n    val mutable x = init\n    method get_x = x\n    method set_x new_value = x <- new_value\n  end\n\n(* Constraints *)\nclass ['a] circle (c: 'a) (r: float) = object\n  constraint 'a = #point_1d\n  val mutable center = c\n  method move = center#move\n  method perimeter = 2.0 *. pi *. r\nend\n\n(* Polymorphic Methods *)\n\nclass ['a] intlist (l : int list) =\n    object\n      method empty = (l = [])\n      method fold f (accu : 'a) = List.fold_left f accu l\n    end\n\n(* Objects themselves are not polymorphic,\nso first use of `fold` fixes its type.\n*)\n\n(* To make `fold` polymorphic, annotate its type explicitly: *)\nclass intlist' (l : int list) =\n    object\n      method empty = (l = [])\n      method fold : 'a. ('a -> int -> 'a) -> 'a -> 'a =\n        fun f accu -> List.fold_left f accu l\n    end\n\n(* However, type annotation can be omitted if it is already known,\nfor example, through type constraints on self.*)\nclass type ['a] iterator = object\n  method fold : ('b -> 'a -> 'b) -> 'b -> 'b\nend\n\nclass intlist'' l =\n    object (self : int #iterator) (* implements iterator interface *)\n      method empty = (l = [])\n      method fold f accu = List.fold_left f accu l\n    end\n\n(* Another example of interfaces. *)\n\nclass type point0 = object\n  method get_x : int\nend\n\nclass distance_point x =\n    object\n      inherit point_1d x\n      (* Unlike Java, the type of `other` cannot be `#point0` directly,\n      since the HM type system OCaml uses has difficult to infer subtypes.\n      Just like using parametric types to mark subtyping expilicitly,\n      here `'a. (... as 'a)` is used to mark the extensible part of `#point0`.\n      *)\n      method distance : 'a. (#point0 as 'a) -> int =\n        fun other -> abs (other#get_x - x)\n    end\n\n(* Credit: this section uses code examples from OCaml manual. *)\n\n(* In Ocaml, inheritance does not imply subtyping.\nCoercions are required for inherited types,\nas for uninherited types.\n*)\n\n\n(* Labeled Arguments *)\n\nlet named_arguments ~x ~y = x + y\n\n(* Functions with labeled arguments are nominal, not structral.\nThus `2 |> (fun ~x -> x)` does not work.\nSame applies to functions with optional arugments (see below),\nexcept that OCaml can auto transform them\nby passing `None` for all optional arguments.\n*)\n\n(* Optional Arguments *)\n\nlet inc_multiple_times ?(times=1) x = x + 1 * times\n\n(* To avoid ambigulity with partital application,\noptional arguments must be followed by at least one non optional argument.\n*)\n\nlet dummy_argument ?(x=1) () = x\n\n\nlet () = (* To ensure the body is side-effect only, i.e. returning unit. *)\n  let a_point = new point_1d 42 in\n  print_int a_point#get_x; print_newline ();\n  a_point#move 1;\n\n  let john = new painter_and_cowboy \"john\" in\n  print_string john#get_name (* cowboy *); print_newline ();\n  john#draw (* cowboy *); print_newline ();\n  john#dual_draws; print_newline ();\n\n  (* Labeled arguments must always be applied with its name. *)\n  let four = named_argumests ~y:2 ~x:2\n\n  (* Optional arguments must be either omitted or applied with its name. *)\n  let two = inc_multiple_times 1;\n  let five = inc_multiple_times ~times:5 1;\n  let one = dummy_argument ();\n  let three = dummy_argument ~x:3 ();\n\n  exit 0\n
","date_published":"Sat, 18 Aug 2018 13:22:33 GMT","date_modified":"Sun, 24 May 2020 13:58:17 GMT"},{"id":"https://mmap.page/dive-into/haskell/","url":"https://mmap.page/dive-into/haskell/","title":"Haskell: Laziness, Type Class, and Monad","content_html":"

Haskell: Laziness, Type Class, and Monad

\n

Laziness

\n
\n

A function is strict in an argument\nif the result is undefined\nwhenever an undefined value is passed to this argument.\nFor instance, (+) is strict in both arguments,\nwhile (&&) is strict in its first only.\nRecall that it is defined by

\n
True && x = x\nFalse && x = False\n
\n

...

\n

If a function is not strict in an argument,\nwe say that it is non-strict or lazy in that argument.

\n
\n

-- Haskell: The Craft of Function Programming (3e):517

\n

Infinite List

\n
fibs ::[Integer]\nfibs = 0 : 1 : zipWith (+) fibs (tail fibs)\ntake 3 fibs\n
\n

Mutual Recursion

\n

Unlike OCaml, mutual recursion in Haskell does not need to use let rec (because of laziness).

\n
isEven :: Int -> Bool\nisEven 0 = True\nisEven n = isOdd (n - 1)\n\nisOdd :: Int -> Bool\nisOdd 0 = False\nisOdd n = isEven (n - 1)\n
\n

Type Class

\n
quickSort :: Ord a => [a] -> [a]\n\nquickSort []     = []\nquickSort (x:xs) = quickSort [e|e<-xs,e<=x] ++ [x] ++ quickSort [e|e<-xs, e>x]\n
\n

Ord is a type class (interface),\nand [e|e<-xs,e<=x] is list comprehension.

\n

Function signatures defined in type class are similar to overloading in other languages.

\n
class Eq a where\n  (==) :: a -> a -> Bool\n
\n

instance of type class is similar to classes implemented interface in other languages.

\n
instance Monad Maybe where\n    return x = Just x\n    Nothing >>= f = Nothing\n    Just x >>= f  = f x\n    fail _ = Nothing\n
\n

But what is Monad? Read on.

\n

Monad

\n

Monad is like a box.\nIt keeps tracking of some extra content and makes code cleaner (but not necessary clearer).

\n

Maybe Monad

\n

The Maybe monad chains (>>=) sequences of operations and hides failure handling (extra context) in a monad.

\n

Let's revisit the definition of Maybe from this perspective:\n(-- starts a comment in Haskell)

\n
instance Monad Maybe where\n    -- `return` is a function to wrap x as `Just x`.\n    return x = Just x\n    -- As soon as one fails, the rest are ignored and the final result is `Nothing`.\n    Nothing >>= f = Nothing\n    -- Only apply `f` when x is `Just x`, not `Nothing`.\n    Just x >>= f  = f x\n    -- Throw a failure.\n    fail _ = Nothing\n
\n

Monadic Classes

\n

The type class of Monad is defined as below:

\n
class Monad m where\n    -- core functions of Monad\n    (>>=)  :: m a -> (a -> m b) -> m b\n    return :: a -> m a\n\n    -- other functions\n    (>>)   :: m a -> m b -> m b\n    m >> k = m >>= \\_ -> k -- `\\_ -> k` is a lambda\n\n    fail   :: String -> m a\n    fail s = error s\n
\n

fail is like throw in other languages.\nHaskell uses it to in pattern matching to enable failure.\nWe do not write them explicitly in code.

\n

>> is a syntax sugar to throw away the result of m a.\nThus putStr \"foo\" >== \\_ -> putStr \"bar\" can be expressed as\nputStr \"foo\" >> putStr \"bar\".

\n

>>= chains tow computations,\npassing the result of the first computation to the second computation,\nby wrapping the second computation in a function,\nand passing the first result as its parameter.

\n

Unlike other languages, in Haskell, return wraps date in a monad.

\n

Let's revisit the definition of Maybe monad under the perspective of monadic class.

\n
instance Monad Maybe where\n    return :: a -> Maybe a\n    return x = Just x\n    >>= :: Maybe a -> (a -> Maybe b) -> Maybe b\n    Nothing >>= f = Nothing\n    Just x >>= f  = f x\n    fail :: String -> Maybe a\n    fail _ = Nothing\n
\n

Do Notation

\n
helloWorld :: IO ()\nhelloWorld =\n    do\n        putStr \"Hello\"\n        putStr \" \"\n        putStrLn \"world!\"\n
\n

Haskell syntax is layout sensitive,\nin other words, it conforms to offside rule.\nAlthough Haskell does support braces and semicolons,\nthis alternative style is rare in the Haskell community.

\n
do { putStr \"Hello\"; putStr \" \"; putStrLn \"world!\"; }\n
\n

Within a do notation, <- binds the result to a name.

\n
echo :: IO ()\necho =\n    do\n        line <- getLine\n        putStrLn line\n
\n

In fact, do notation is an alternative syntax for monad:

\n
putStr \"Hello\" >> putStr \" \" >> putStrLn \"world!\"\n\necho :: IO ()\necho = getLine >>= putStrLn\n
","date_published":"Sat, 18 Aug 2018 12:01:19 GMT","date_modified":"Thu, 26 Dec 2019 15:16:30 GMT"},{"id":"https://mmap.page/dive-into/jupyter-lab/","url":"https://mmap.page/dive-into/jupyter-lab/","title":"JupyterLab Guide","content_html":"

JupyterLab Guide

\n

This guide is outdated and unmaintained.

\n

JupyterLab is the next generation UI of Jupyter Notebook (formly known as IPython Notebook).

\n

Installation

\n

JupyterLab can be installed via conda, pip, and pipenv.

\n

For example, to install with conda:

\n
conda install -c conda-forge jupyterlab\n
\n

Once installed, you can start it with:

\n
jupyter lab\n
\n

To shut down JupyterLab,\nfirst shut down all kernels via Kernel menu,\nthen type ctrl-c.

\n

Notebooks

\n

Jupyter notebooks combines:

\n
    \n
  1. live runnable code cells
  2. \n
  3. text cells (Markdown, LaTeX equations, images, interactive visualizations)
  4. \n
\n

Multiple view(tabs) can be opened for the same notebook,\nwith synced content.

\n

The blue collapse button on left of each cell can trigger collapsing and expanding cells.

\n

Right-click on a notebook and select \"New Console for Notebook\" can attach to the notebook kernel.\nThis provides a log of all computations done in the kernel (in the order in the order in which they were done),\nand a place to interactively inspect kernel state without changing the notebook.

\n

Raw HTML

\n

IPython kernel provides a variety of convenience classes for displaying rich output, including HTML:

\n
from IPython.display import display, HTML\ndisplay(HTML('<del>Hello World</del>'))\n
\n

or

\n
from IPython.display import display\ndisplay({'text/html': '<del>Hello World</del>'}, raw=True)\n
\n

MIME types supported by default:

\n\n

Other Jupyter kernels offer similar APIs.

\n

Keymap

\n

Keyboard shortcuts can be viewed in menu, context menu, and command palette (Commands tab of sidebar).

\n

Keyboard shortcut for command palette: Ctrl+Shift+c

\n

Code Cell/Console

\n\n

Image File Viewer

\n\n

Mouse

\n

Besides keyboard, mouse is also useful.\nDrag and drop cells within one notebook to rearrange them;\ndrag and drop cells within notebooks to copy content;\ndrag and drop tabs to arrange their layout.

\n

Extensions

\n

JupyterLab extensions are npm packages.

\n

To install extensions, first install nodejs.\nFor example, via conda:

\n
conda install -c conda-forge nodejs\n
\n

Then use jupyter labextension to manage extensions,\nvia invoking subcommands like list, install/uninstall, enable/unable.

\n

Tools and Services

\n

nbdime

\n

nbdime provides tools for diffing and merging of Jupyter Notebooks.

\n\n

nbconvert

\n

nbconvert allows you to convert a Jupyter .ipynb notebook document file into another static format including HTML, LaTeX, PDF, Markdown, reStructuredText, and more.

\n

nbviewer is a free web service based on nbconvert to share static html versions of notebook files.

\n

Binder

\n

Binder is a free web service to turn a GitHub repo into a collection of interactive notebooks:

\n
    \n
  1. Enter an URL to a GitHub repo of Jupyter notebooks.
  2. \n
  3. Binder builds a Docker image for the repository, based on requirements.txt or environment.yml in repository's root directory.
  4. \n
  5. Binder launches a JupyterHub server. It provides a reusable/shareable link to live repository.
  6. \n
","date_published":"Sat, 11 Aug 2018 06:43:25 GMT","date_modified":"Mon, 05 Sep 2022 14:05:34 GMT"},{"id":"https://mmap.page/web/html-history/","url":"https://mmap.page/web/html-history/","title":"History of HTML through Linux/BSD Websites","content_html":"

History of HTML through Linux/BSD Websites

\n

This is a breif overview of HTML versions examplified with some Linux/BSD websites.

\n

All the screen shots are captured on 2018-02-20.

\n

Slackware

\n

\"slackware\"

\n

Slackware still uses tarballs for packaging,\nand its website is also old-fashioned,\nwith html tags capitalized,\nusing tables for layout.

\n
<HTML>\n<TITLE>\nThe Slackware Linux Project</TITLE>\n<BODY BACKGROUND=\"/grfx/shared/background.jpg\" BGCOLOR=\"#fefefe\"\n\t\t         TEXT=\"#000000\" LINK=\"#000000\" VLINK=\"#000000\"\n\t\t         ALINK=\"#000000\">\n<CENTER>\n\n<TABLE BORDER=\"0\" WIDTH=\"85%\" CELLSPACING=\"0\" CELLPADDING=\"0\">\n<TR>\n\t<TD COLSPAN=\"3\">\n\t\t<TABLE WIDTH=\"95%\" CELLSPACING=\"0\" CELLPADDING=\"0\">\n\t\t<TR>\n\t\t\t<TD ALIGN=\"center\" VALIGN=\"bottom\" WIDTH=\"55%\">\n\t\t\t\t<TABLE WIDTH=\"80%\" CELLPADDING=\"0\"><TR><TD BGCOLOR=\"#000000\">\n\n\t      <TABLE WIDTH=\"100%\" CELLPADDING=\"6\">\n\t      <TR><TD BGCOLOR=\"#fefefe\">\n\t\t\t\t<CENTER><B>\n\t\t\t\tThe Slackware Linux Project\t\t\t\t</B></CENTER>\n\t\t\t\t</TD></TR></TABLE>\n</TD></TR></TABLE>\t\t\t</TD>\n\t\t\t<TD VALIGN=\"bottom\" ALIGN=\"right\">\n\t\t\t\t<TABLE CELLPADDING=\"0\"><TR><TD BGCOLOR=\"##000000\">\n\t\t\t\t<TABLE CELLPADDING=\"0\"><TR><TD BGCOLOR=\"#ffffff\">\n\t\t\t\t<A HREF=\"/index.html\"><IMG SRC=\"/grfx/shared/slackware_traditional_website_logo.png\" ALT=\"Slackware Logo\" BORDER=\"0\"></A>\t\t\t\t</TD></TR></TABLE>\n\t\t\t\t</TD></TR></TABLE>\n\t\t\t</TD>\n\t\t</TR>\n      <TR>\n         <TD COLSPAN=\"2\"><BR></TD>\n      </TR>\n\t\t</TABLE>\n\t</TD>\n</TR>\n<TR VALIGN=\"top\">\n\t<TD WIDTH=\"10%\">\n\t\t<TABLE WIDTH=\"100%\" CELLPADDING=\"0\"><TR><TD BGCOLOR=\"#000000\">\n\n\t      <TABLE WIDTH=\"100%\" CELLPADDING=\"14\">\n\t      <TR><TD BGCOLOR=\"#fefefe\">\n<FONT SIZE=\"-1\"><B>\n<A HREF=\"/index.html\">News</A><P>\n</B></FONT>\n</TD></TR></TABLE>\n</TD></TR></TABLE><TABLE WIDTH=\"100%\" CELLPADDING=\"0\"><TR><TD BGCOLOR=\"#000000\">\n\n\t      <TABLE WIDTH=\"100%\" CELLPADDING=\"14\">\n\t      <TR><TD BGCOLOR=\"#fefefe\">\n<FONT SIZE=\"-1\"><B>\n<A HREF=\"/security/\">Security Advisories</A><P><A HREF=\"/faq/\">FAQ</A><P><A HREF=\"/book/\">Book</A><P><A HREF=\"/info/\">General Info</A><P><A HREF=\"/getslack/\">Get Slack</A><P><A HREF=\"/install/\">Install Help</A><P><A HREF=\"/config/\">Configuration</A><P><A HREF=\"/packages/\">Packages</A><P><A HREF=\"/changelog/\">ChangeLogs</A><P><A HREF=\"/~msimons/slackware/grfx/\">Propaganda</A><P><A HREF=\"/ports/\">Ports</A><P><A HREF=\"/links/\">Other Sites</A><P><A HREF=\"/support/\">Support</A><P><A HREF=\"/contact/\">Contact</A><P><A HREF=\"/lists/\">Mailing Lists</A><P><A HREF=\"/about/\">About</A></B></FONT>\n
\n

Debian

\n

\"debian\"

\n

As one of two oldest Linux distributions still alive today,\n(the other is Slackware),\nDebian is also quite old fashioned.\nIts website uses HTML 4.01.\nHowever, the Debian website uses HTML 4.01 Strict,\ninstead of HTML 4.01 Transitional (used to be much more popular).\nDebian is famous for its strictness on software licences.\nI do not think these two factors are related. ;-)

\n
\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html lang=\"en\">\n<head>\n  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n  <title>Debian -- The Universal Operating System </title>\n  <link rel=\"author\" href=\"mailto:webmaster@debian.org\">\n  <meta name=\"Description\" content=\"Debian is an operating system and a distribution of Free Software. It is maintained and updated through the work of many users who volunteer their time and effort.\">\n  <meta name=\"Generator\" content=\"WML 2.0.12 (16-Apr-2008)\">\n  <meta name=\"Modified\" content=\"2018-02-20 03:50:42\">\n  <meta name=\"viewport\" content=\"width=device-width\">\n  <meta name=\"mobileoptimized\" content=\"300\">\n  <meta name=\"HandheldFriendly\" content=\"true\">\n<link rel=\"alternate\" type=\"application/rss+xml\"\n title=\"Debian News\" href=\"News/news\">\n<link rel=\"alternate\" type=\"application/rss+xml\"\n title=\"Debian Project News\" href=\"News/weekly/dwn\">\n<link rel=\"alternate\" type=\"application/rss+xml\"\n title=\"Debian Security Advisories (titles only)\" href=\"security/dsa\">\n<link rel=\"alternate\" type=\"application/rss+xml\"\n title=\"Debian Security Advisories (summaries)\" href=\"security/dsa-long\">\n<link href=\"./debhome.css\" rel=\"stylesheet\" type=\"text/css\">\n  <link href=\"./debian-en.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\">\n  <link rel=\"shortcut icon\" href=\"favicon.ico\">\n  <meta name=\"Keywords\" content=\"debian, GNU, linux, unix, open source, free, DFSG\">\n<link rel=\"search\" type=\"application/opensearchdescription+xml\" title=\"Debian website search\" href=\"./search.en.xml\">\n</head>\n<body>\n<div id=\"header\">\n   <div id=\"upperheader\">\n   <div id=\"logo\">\n  <a href=\"./\" title=\"Debian Home\"><img src=\"./Pics/openlogo-50.png\" alt=\"Debian\" width=\"50\" height=\"61\"></a>\n  </div> <!-- end logo -->\n\t<div id=\"searchbox\">\n\t\t<form name=\"p\" method=\"get\" action=\"https://search.debian.org/cgi-bin/omega\">\n\t\t<p>\n<input type=\"hidden\" name=\"DB\" value=\"en\">\n\t\t\t<input name=\"P\" value=\"\" size=\"27\">\n\t\t\t<input type=\"submit\" value=\"Search\">\n\t\t</p>\n\t\t</form>\n\t</div>   <!-- end sitetools -->\n </div> <!-- end upperheader -->\n
\n

FreeBSD

\n

\"freebsd\"

\n

FreeBSD website uses XHTML 1.0 Transitional with CSS.\nHowever, it does not work well with small screens as shown above.\nIronically, Slackware website layouted with tables work well under small screens.

\n

Compared to HTML 4.01, XHTML is quite \"new\".\nHowever, these days no one cares about XHTML any more.\nTo some extent, this is just like that among the BSD families FreeBSD has the fastest paces of developing and integrating new technologies and features.\nBut outside the BSD family...

\n
\n<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:db=\"http://docbook.org/ns/docbook\">\n  <head>\n    <title>The FreeBSD Project</title>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\n    <link rel=\"shortcut icon\" href=\"./favicon.ico\" type=\"image/x-icon\" />\n    <link rel=\"stylesheet\" media=\"screen,print\" href=\"./layout/css/fixed.css?20130112\" type=\"text/css\" />\n    <script type=\"text/javascript\" src=\"./layout/js/google.js\"></script>\n  </head>\n  <body>\n    <div id=\"containerwrap\">\n      <div id=\"container\">\n        <span class=\"txtoffscreen\"><a href=\"#content\" title=\"Skip site navigation\" accesskey=\"1\">Skip site navigation</a> (1)\n  <a href=\"#contentwrap\" title=\"Skip section navigation\" accesskey=\"2\">Skip section navigation</a> (2)\n</span>\n        <div id=\"headercontainer\">\n          <div id=\"header\">\n            <h2 class=\"blockhide\">Header And Logo</h2>\n            <div id=\"headerlogoleft\">\n              <a href=\".\" title=\"FreeBSD\">\n                <img src=\"./layout/images/logo-red.png\" width=\"457\" height=\"75\" alt=\"FreeBSD\" />\n              </a>\n            </div>\n
\n

Gentoo

\n

\"gentoo\"

\n

The cutting edge Gentoo website uses HTML5.\nBy the way, another cutting edge Linux distribution Arch also uses HTML5 on its web site.

\n
<!DOCTYPE html>\n<html>\n  <head>\n  <meta charset=\"utf-8\">\n  <title>Welcome – Gentoo Linux</title>\n  <meta name=\"description\" content=\"The website of Gentoo, a flexible Linux or BSD distribution.\">\n  <meta name=\"theme-color\" content=\"#54487a\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n  <meta property=\"og:title\" content=\"Welcome – Gentoo Linux\">\n  <meta property=\"og:image\" content=\"https://www.gentoo.org/assets/img/logo/gentoo-g.png\">\n  <meta property=\"og:description\" content=\"The website of Gentoo, a flexible Linux or BSD distribution.\">\n  <meta name=\"twitter:image\" content=\"https://www.gentoo.org/assets/img/logo/gentoo-g.png\">\n  <link rel=\"apple-touch-icon\" href=\"https://www.gentoo.org/assets/img/logo/icon-192.png\">\n  <link rel=\"icon\" sizes=\"192x192\" href=\"https://www.gentoo.org/assets/img/logo/icon-192.png\">\n  <link href=\"https://assets.gentoo.org/tyrian/bootstrap.min.css\" rel=\"stylesheet\" media=\"screen\">\n  <link href=\"https://assets.gentoo.org/tyrian/tyrian.min.css\" rel=\"stylesheet\" media=\"screen\">\n  <link href=\"/assets/css/screen.css\" rel=\"stylesheet\" media=\"screen\">\n\n  <link rel=\"icon\" href=\"/favicon.ico\" type=\"image/x-icon\">\n  <link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"https://www.gentoo.org/search/www-gentoo-org.xml\" title=\"Gentoo Website\">\n  <link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"https://www.gentoo.org/search/forums-gentoo-org.xml\" title=\"Gentoo Forums\">\n  <link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"https://www.gentoo.org/search/bugs-gentoo-org.xml\" title=\"Gentoo Bugzilla\">\n  <link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"https://www.gentoo.org/search/packages-gentoo-org.xml\" title=\"Gentoo Packages\">\n  <link rel=\"search\" type=\"application/opensearchdescription+xml\" href=\"https://www.gentoo.org/search/archives-gentoo-org.xml\" title=\"Gentoo List Archives\">\n  <link rel=\"alternate\" type=\"application/atom+xml\" title=\"Gentoo Linux news\" href=\"/feeds/news.xml\">\n</head>\n\n  <body class=\"\">\n    <header>\n  <div class=\"site-title\">\n    <div class=\"container\">\n      <div class=\"row\">\n        <div class=\"site-title-buttons\">\n          <div class=\"btn-group btn-group-sm\">\n            <a href=\"https://get.gentoo.org/\" role=\"button\" class=\"btn get-gentoo\"><span class=\"fa fa-fw fa-download\"></span> <strong>Get Gentoo!</strong></a>\n            <div class=\"btn-group btn-group-sm\">\n              <a class=\"btn gentoo-org-sites dropdown-toggle\" data-toggle=\"dropdown\" data-target=\"#\" href=\"#\">\n                <span class=\"fa fa-fw fa-map-o\"></span> <span class=\"hidden-xs\">gentoo.org sites</span> <span class=\"caret\"></span>\n              </a>\n              <ul class=\"dropdown-menu dropdown-menu-right\">\n                <li><a href=\"https://www.gentoo.org/\" title=\"Main Gentoo website\"><span class=\"fa fa-home fa-fw\"></span> gentoo.org</a></li>\n                <li><a href=\"https://wiki.gentoo.org/\" title=\"Find and contribute documentation\"><span class=\"fa fa-file-text-o fa-fw\"></span> Wiki</a></li>\n                <li><a href=\"https://bugs.gentoo.org/\" title=\"Report issues and find common issues\"><span class=\"fa fa-bug fa-fw\"></span> Bugs</a></li>\n                <li><a href=\"https://forums.gentoo.org/\" title=\"Discuss with the community\"><span class=\"fa fa-comments-o fa-fw\"></span> Forums</a></li>\n
","date_published":"Tue, 20 Feb 2018 12:33:49 GMT","date_modified":"Sun, 24 May 2020 14:51:37 GMT"},{"id":"https://mmap.page/dive-into/osx/","url":"https://mmap.page/dive-into/osx/","title":"macOS Survival Guide","content_html":"

macOS Survival Guide

\n

Create a Bootable Installer

\n

I created a bootable installer to install macOS offline,\nin case that something went wrong.\nAlthough macOS can be installed from Internet in recovery mode, it is unreliable and slow.\nI first tried a Sandisk 16GB USB drive, and it failed during copying the installer content.\nThen I tried a Toshiba 32GB USB drive, and the creation succeeded.\nI am not sure if 16GB is too small or macOS installer is fussy on USB drive models.

\n

I also set secure boot to medium security, to avoid connecting to Apple servers when installing operating systems.

\n

Enable TouchID for sudo

\n

Add auth sufficient pam_tid.so in /etc/pam.d/sudo_local.

\n

Set Timezone to GMT

\n

I am frustrated to dealing with timezones.\nWhy not everyone uses UTC+0?

\n
sudo systemsetup -settimezone GMT\n
\n

And got a -99 error.\nBut it seems that the timezone has changed to GMT.

\n
; sudo systemsetup -gettimezone\nTime Zone: GMT\n
\n

For safety, I unselect the \"Set time zone automatically using current location\" option in \"System Preferences > Date & Time > Time Zone\".

\n

Keyboard

\n

In System Preference > Keyboard > Modifier Keys, I set CapsLock as Esc.

\n

By the way, OS X has native system-wide support for some Emacs keybinds, e.g.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
CommandKeyAlternatives
beginning-of-line^a<D-Left>
end-of-line^e<D-Right>
previous-line^p<Up>
next-line^n<Down>
forward-char^f<Right>
backward-char^b<Left>
delete-char^dN/A
backward-delete-char^h<Delete>
transpose-char^tN/A
kill-line^kN/A
yank-line^yN/A
insert-line^oN/A
page-down^v<Fn+Down>
recenter^lN/A
\n

And there are some keybinds slightly different the original Emacs keybinds:

\n\n

My keyboad has arrow keys and I feel using arrow keys are more nature.

\n

Trackpad

\n

In System Preferences > Trackpad:

\n\n

Turn off Internal Display

\n

When the power adapter is connected:

\n
    \n
  1. Close the lid to put laptop to sleep.
  2. \n
  3. Reactivate laptop via external input devices, e.g. keyboard.
  4. \n
\n

Window Management

\n

I feel the window management under macOS weird.

\n

Stage Manager

\n

I do not use stage manager.\nIt is inaccessible from keyboard shortcuts.\nBesides, it causes latency when switching between windows.

\n

Tiling

\n

By default, macOS only supports tiling two windows vertically.\nI want to tile windows via keyboard shortcuts.\nTherefore, in Settings > Keyboard > Keyboard Shortcuts > App Shortcuts,\nI add the following two shortcuts under \"All Applications\":

\n\n

Virtual Desktops

\n

Press Ctrl-Left/Right or swipe three fingers from left to right to switch among virtual desktops.

\n

Press Ctrl-Up to show an overview of desktops.

\n

Fn-f will turn the focused application to full screen.\nAll full screen application will occupy an entire virtual desktop,\nwhich will be created and destroyed upon the application entered and exited full screen.

\n

Ctrl-Down shows all windows of the current application\nand ``Cmd-``` switches among windows of the current application.\nBoth of them only apply to windows in the current virtual desktop.\nTherefore, full screen applications do not work with them.

\n

There is no such concept called maximize under recent versions of macOS.\nThe most similar thing is \"zoom\", which sometimes maximizes the window,\nsometimes not, depending on the type of the window and its content.\nSimilarly to tilling, I added keyboard shortcut for it:

\n\n

Also, I enabled Ctrl-Num shortcuts under\nSettings > Keyboard > Keyboard shortcuts > Mission Control > Mission Control.\nHowever, this only works for virtual desktops I created by myself,\nnot automatically managed desktops for full screen applications.

\n

Finder

\n

By default, ~/Library is hidden.\nTo reveal it in Finder temporarily,\nhold the Option key, then click the Go menu,\nand the Library folder is revealed in the dropdown menu.

\n

To permanently reveal the Library folder in Finder, run the following command:

\n
chflags nohidden ~/Library/\n
\n

BTW, most applications' user configuration files are in ~/Library/Application Support.

\n

Safari

\n

To enable developer tools, select \"Show Develop menu in menu bar\" in Safari > Preferences > Advanced.\nYou can also change the default encoding to UTF-8.

\n

There are several vi shortcuts extensions for safari, for example, vimari.

\n

Due to the limitation of Safari, vimari has fewer key bindings than similar extensions for other browsers.\nAlso, by default it binds w/q for next/previous tab, which I feel hard to remember.\nVimium uses J/K, which I also hard to remember.\nThus, I just remove them and use Safari native keyboard shortcuts.\nAlso, I find myself more frequently open links in new tabs,\nso I swapped f and F, using f to toggle links for opening the link in background tab.

\n
\"hintToggle\": \"shift+f\",\n\"newTabHintToggle\": \"f\",\n
\n

Google

\n

Google accounts can be added to the Mail.app.\nBesides gmail, other osx applications can also sync with Google account:

\n","date_published":"Wed, 24 Jan 2018 17:43:01 GMT","date_modified":"Sat, 03 Feb 2024 12:35:21 GMT"},{"id":"https://mmap.page/dive-into/jetbrains/","url":"https://mmap.page/dive-into/jetbrains/","title":"Dive into JetBrains IDEs","content_html":"

Dive into JetBrains IDEs

\n

Appearance

\n\n

Keymaps

\n

I use Sublime Text keymap with a few tweaks:

\n\n

Fn

\n

I bind frequently used actions to F keys, so they are easier to reach.\nThe \"Sublime\" field refers to the default keyboard shorts for the real Sublime Text editor, not the Sublime Text keymap for JetBrains IDEs.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
KeyDefaultSublimeMeRationale
F1helpn/afind actioninspired by vscode
F2next errornext bookmarkrefactor: renameinspired by file managers and vscode
F3next occurrencenext occurrencenext occurrenceconvention
F4jump to sourcenext results in find allgo to declaration/usagemore powerful than \"jump to source\"
F5refactor: copyn/aquick documentationnear F4
F6refactor: movetoggle spell checkgo to symbolinspired by go to address bar in web browser
F7debug: step intobuildfind usageconsistent with Ctrl+F7 (find usage in current file)
F8debug: step outn/alast edit locationnear F9
F9debug: resumesort linestoggle bookmarkInspired by Yin Wang.
F10menu (os)menu (os)menu (os)
F11toggle fullscreentoggle fullscreentoggle fullscreenconvention
F12go to declaration/usagego to definitionterminalAlready bind go to declaration/usage to F4 and inspired by web browser (F12 for the console).
\n

Other Tweaks

\n","date_published":"Wed, 24 Jan 2018 17:37:19 GMT","date_modified":"Fri, 21 Apr 2023 06:31:30 GMT"},{"id":"https://mmap.page/dapi/law-labor/","url":"https://mmap.page/dapi/law-labor/","title":"劳动法","content_html":"

劳动法

\n

劳动关系和劳务关系

\n

注意劳动关系和劳务关系的区别。

\n

劳动关系存在的原因:

\n
    \n
  1. 劳动力交易成本
  2. \n
  3. 历史惯性
  4. \n
\n

仲裁时效

\n

劳动仲裁的时效为 1 年。

\n

例外:劳动关系存续期间因拖欠劳动报酬发生争议的,时效延长至劳动关系终止后 1 年。

\n

例外的例外:由于法律规定用工单位只需保存劳动者的加班工资支付记录 2 年时间,\n因此在 2 年内追诉加班工资的,举证具体加班时间的责任在用工单位。\n而追诉 2 年前的加班工资,劳动者需要自行举证自己的加班时间。

\n

劳动仲裁是 CN 劳动争议解决的诉前必经程序。

\n

招聘

\n

虚假招聘广告

\n

法律层面,劳动者应对虚假招聘广告并没有什么有效的方法:

\n
    \n
  1. \n

    劳动合同法 s.8 规定用人单位有如实告知的义务,但是并没有规定不如实告知的责任。除非用人单位极其过分,会被认定为欺诈。

    \n
  2. \n
  3. \n

    就业服务与就业管理虽然规定 s. 14 禁止用人单位提供虚假招聘信息,发布虚假招聘广告,但是相应的责任只是「劳动保障行政部门责令改正,并可处以一千元以下的罚款;对当事人造成损害的,应当承担赔偿责任。」(s. 67) 也就是说用人单位基本上只要改正就可以了,运气不好也就是承担 1k 以下的罚款,不痛不痒。而劳动者要举证自己因为虚假招聘广告受到损害,难度很大。

    \n
  4. \n
  5. \n

    合同法 s. 15 虽然规定「商业广告的内容符合要约规定的,视为要约」,但一般而言招聘广告都是要约邀请,很难认定为要约。因为要认定为要约,除了内容具体确定外(大多数招聘广告都没详细具体到这个程度),还要「表明经受要约人承诺,要约人即受该意思表示约束」(合同法 s. 14)

    \n
  6. \n
\n

所以,被虚假招聘广告坑了,在法律层面,劳动者也只能向劳动保障行政部门举报下,虽然即使举报成功了也并没有什么卵用。

\n

歧视

\n

法律层面,歧视不能放到台面上来,\n或者说,可以 implicit 地歧视,不能 explicit 地歧视。

\n
    \n
  1. 招聘广告不得带有歧视内容
  2. \n
  3. 招聘过程中不得明确告知劳动者不符合歧视性的录用条件
  4. \n
\n

告知义务

\n

用人单位需要主动告知,劳动者在用人单位要求时才告知。

\n

劳动者的告知范围仅限于与劳动合同直接相关的基本情况,无关情况有权拒绝告知。

\n

工作内容、条件、地点、职业危害、安全生产状况、劳动报酬等内容,用人单位需要主动告知。

\n

其他情况,劳动者如果要求了解,用人单位没有拒绝告知的权利,除非涉及商业秘密。

\n

注意,这里用人单位告知虚假情况,使劳动者在违背真实意思的情况下订立或者变更劳动合同的,可能被认定为欺诈(劳动合同法 s. 26)。\n法律对此的打击力度和虚假招聘广告完全不同。

\n

录用通知书

\n

录用通知书只是用人单位的要约,和劳动合同是两回事。\n用人单位反悔,单方面撤销要约,属于预期违约,劳动者可以要求用人单位就其损失承担赔偿责任。

\n

订立合同

\n

据劳动合同法 s. 17, 劳动合同的必备条款如下:

\n
    \n
  1. \n

    用人单位的名称、住所和法定代表人或者主要负责人。

    \n

    名称为注册登记时所登记的名称。

    \n

    用人单位办事机构的所在地的具体地址。

    \n
  2. \n
  3. \n

    劳动者的姓名、住址和居民身份证或者其他有效身份证件号码。

    \n

    劳动者的住址,以其户籍所在的居住地为住所,其经常居住地与住所不一致的,经常居住地视为住所。

    \n
  4. \n
  5. \n

    劳动合同期限。

    \n

    固定期限、无固定期限、以完成一定工作任务为期限。

    \n
  6. \n
  7. \n

    工作内容和工作地点。

    \n

    工作内容包括劳动者从事劳动的工种、岗位和劳动定额、工作的任务等。

    \n
  8. \n
\n

  工作地点,是指劳动者可能从事工作的具体位置。

\n
很多地方的司法实务中规定,超过地级市行政区域的工作地点变更,劳动者有权拒绝。\n
\n

5. 工作时间和休息休假。

\n
休息日安排加班,可以安排劳动者补休,也可以支付加班工资。\n法定节假日安排加班,不能以调休代替加班工资。\n\n带薪年休假,5/10/15 天(跨单位工作年限 1/10/20 年)。\n\n休息休假期间照常支付工资(劳动法 s. 51, 工资支付暂行规定 s. 11)\n\n探亲假待遇仅限国家机关、人民团体和全民所有制企业、事业单位工作的职工。\n\n婚假遇法定节假日和休息日能否顺延,各地政策不一样。如上海规定遇法定节假日顺延。(上海市计划生育奖励与补助若干规定 s. 2) 如果地方性政策不支持的话,只能通过提前申请或延后申请避免法定休假冲掉婚假的问题。\n\n再婚同样享受婚假(劳动和社会保障部《关于对再婚职工婚假问题的复函》)。\n\n晚婚假限于初婚。一方初婚,另一方再婚,或者双方初婚,一方符合晚婚年龄,另一方不符合的,不符合晚婚条件的一方不能被认定为晚婚,符合晚婚条件的一方是否能认定为晚婚取决于当地的计划生育条例(如北京要求双方初婚,上海未限定双方初婚)。\n\n工作时间不限于实际工作时间。工作时间的范围,不仅包括作业时间,还包括准备工作时间、 结束工作时间以及法定劳动消耗时间。其中,法定非劳动消耗时间是指劳动者自然中断的时间、工艺需中断时间、停工待活时间、女职工哺乳婴儿时间、出差时间等。此外,工作时间还包括依据法律、法规或单位行政安排离岗从事其他活动的时间。\n
\n

6. 劳动报酬。

\n
以货币形式支付给劳动者的工资。\n\n《工资支付暂行规定》规定,用工单位必须在约定的日期支付工资。\n如遇节假日或休息日,应提前在最近的工作日支付。\n工资至少每月支付一次。\n\n国家统计局发布的《关于工资总额组成的规定》规定股票期权不列入工资范畴。(s. 11) 当然,行权时税务机关会按照工资、薪金所得给你算个人所得税的(国家税务总局《关于个人股票期权所得征收个人所得税问题的通知》)。\n\n病假期间(规定的医疗期内)可以减工资,最多可以减到当地最低工资标准的 80% (关于贯彻执行《中华人民共和国劳动法》若干问题的意见 s. 59)。部分地方另有规定,比如深圳规定不得低于 `max(本人正常工作时间工资 * 0.6, 最低工资 * 0.8)`(深圳市员工工资支付条例 s. 23)\n\n事假期间,可以不支付工资。例外:1) 部分地区有特别规定 2) 用工单位不扣工资,事假达到一定天数后冲抵年休假\n
\n

7. 社会保险。

\n
养老保险、失业保险、医疗保险、工伤保险、生育保险五项,政府强制参加。\n\n另外,住房公积金也是强制参加,但地位比上述五险低。\n五险是《劳动法》强制的,公积金是国务院《住房公积金管理条例》强制的。\n
\n

8. 劳动保护、劳动条件和职业危害防护。

\n
    \n
  1. \n

    法律、法规规定应当纳入劳动合同的其他事项。

    \n

    给《劳动合同法》以外的法律法规留的扩展接口。

    \n
  2. \n
\n

基本上,[1, 2, 3, 4, 6] 比较重要,其他的都可以 fallback 到相关法律法规规定。\n其实 3 理论上也可以 fallback, 不过一般用工单位并不愿意 fallback 到无固定期限。

\n

规章制度

\n

规章制度的制定有程序上的要求,\n没有通过民主程序制定和公示的规章制度,依法不能成为处理劳动纠纷的处理依据。\n(劳动合同法 s.4)

\n

但是,法律并没有规定用工单位和劳动者无法就规章制度达成一致时如何处理。\n此问题的裁量取决于法院。\n有一些地方性的 patch,\n比如《深圳市中级人民法院关于审理劳动争议案件若干问题的指导意见(试行)》 s. 79 规定

\n
\n

《劳动合同法》第四条第二款规定的“平等协商确定”主要是指程序上的要求,\n如果平等协商无法达成一致,最后决定权在用人单位。\n如该规章制度违反法律法规的规定,给劳动者造成损害的,\n劳动者可依据《劳动合同法》第八十条寻求救济。

\n
\n

另外,有些含糊其辞的规章制度并没有什么卵用,\n比如「由于员工失职或营私舞弊给公司造成重大损失的,公司可以解除合同,并要求赔偿」之类的,由于「重大损失」没有明确定义,基本上没什么用。

\n

解除合同

\n

劳动者

\n

提前 30 日书面通知用人单位(试用期内提前 3 日)。(劳动合同法 s. 37)

\n

当然,用人单位有特定过错的,劳动者可以直接解除合同,不用提前 30 日通知。(劳动合同法 s. 38, s. 26)\n最容易抓的小辫子是工资不当月发,拖到下个月发,或者因为财务的问题超过约定日期好久才发。\n但一般用人单位不是有意侵犯劳动者权利的,也没有必要为了省那些交接的时间揪用人单位的小辫子。

\n

另外,小辫子也不是都能让劳动者直接解除合同的。\n有的违法行为,劳动者只能向当地劳动监察部门举报,\n如果举报成功,用人单位的责任也是改正和罚款,并不能免除劳动者提前通知的义务。\n而且最终结果取决于当地的执法力度,\n如果执法力度不够,劳动者只能起诉相关部门行政不作为。

\n

用人单位

\n

非过失性解雇

\n

非因劳动者过错,\n但根据劳动者健康状况、工作能力、情势变更而导致劳动合同不能或无法履行的,\n(具体情形见劳动合同法 s. 40)\n用人单位提前 30 日书面通知劳动者或者额外支付一个月工资后,\n解除劳动合同。

\n

健康状况:患病或非因工负伤,取决于总工作年限和本单位工作年限,有 3 个月到 2 年的医疗期。医疗期满后,如果不能从事原工作,用工单位还得设法另行安排工作,仍然不行的,用工单位才能解除合同。

\n

工作能力:用工单位还需要培训或者为其调整工作岗位,\n经过一定期间的培训或重新安排的工作也不胜任的,才能解除合同。\n关于如何评定不能胜任,\n单一领导的结论、末尾淘汰制、同一群体不同标准是不能成立的,\n其他取决于法院的裁量。

\n

情势变更:需要是重大变化,比如被兼并、合并、分立、转产、重大技术改造,使员工的原工作岗位不复存在,且当事人协商不能达成协议。

\n

还有一个批量解除合同的方法是裁员,但裁员的条件和程序都相当复杂,\n除了依照企业破产法进行重整比较容易裁员外,其他裁员的条件认证都比较困难。

\n

迫使员工自愿离职

\n
    \n
  1. \n

    降薪

    \n

    降薪属于变更劳动合同的必备条款,需要经劳动者同意才行,并不能单方面降薪。

    \n
  2. \n
  3. \n

    调岗

    \n

    和降薪一样,需要和劳动者协商,调岗后收入水平比原岗位大大降低的,以及侮辱性的调岗,需承担违法责任。

    \n
  4. \n
  5. \n

    减少加班或不安排加班

    \n

    只对部分低工资的行业有效。

    \n
  6. \n
  7. \n

    放假

    \n

    首先,必须有停工、停产的事实。其次,需要支付工资(停工、停产在一个工资支付周期以内)及生活费(长期停工、停产)。

    \n
  8. \n
  9. \n

    威胁以后碰到背调说员工坏话

    \n

    员工不一定把这段工作经历写到简历里,即使写入,一家用工单位的评价和其他用工单位的评价不一致的话,新单位很可能不采信。

    \n
  10. \n
\n

违法解雇

\n

违法解雇需要支付经济补偿。

\n

总之,劳动者无过错的情况下,用工单位要解雇劳动者,成本不低。\n换句话说,政府提倡用工单位尽量避免解雇劳动者。\n否则劳动者预期自己随时可能被解雇,可能就不敢背房贷买房了。

\n

试用期

\n

工资

\n
// 加班工资、保险、福利待遇不作为最低工资的组成部分。\ndouble 最低工资;\ndouble 本单位同岗位最低档工资或合同约定工资;\ndouble 试用期工资;\n\n// 劳动合同法 s. 20\nassert 试用期工资 >= 最低工资;\nassert 试用期工资 >= 0.8 * 本单位同岗位最低档工资或合同约定工资;\n
\n

期限

\n
// 劳动合同法 s. 19\nPeriod 合同期限;\nPeriod 试用期;\nboolean 试用过;\n\nif (试用过) {\n    throw new Exception(\"同一用人单位与同一劳动者只能约定一次试用期\");\n}\n} else if (合同期限 < Period.ofYears(1)) {\n    assert 试用期 <= Period.ofMonths(1);\n} else if (合同期限 < Period.ofYears(3)) {\n    assert 试用期 <= Period.ofMonths(2);\n} else {\n    assert 试用期 <= Period.ofMonths(6);\n}\n
\n

经济补偿

\n
// 劳动合同法 s. 47\nclass 经济补偿 {\n    private Period 工作年限;\n    private double 月工资; // 合同解除或终止前 12 个月平均\n    // 用人单位所在直辖市、设区的市级人民政府公布的本地区上年度职工平均工资\n    private double 平均工资;\n\n    public 经济补偿(int year, double salary, double averageSalary) {\n        this.工作年限 = Period.ofYears(year);\n        this.月工资 = salary;\n        this.平均工资 = averageSalary;\n    }\n\n    public get补偿() {\n        if (月工资 > 3 * 平均工资) {\n            if (工作年限 < Period.ofMonths(6)) {\n                return 3 * 平均工资 * 0.5;\n            } else if (工作年限 >= Period.ofMoths(6) && 工作年限 < Period.ofYears(1)) {\n                return 3 * 平均工资;\n            } else if (工作年限 < Period.ofYears(12)) {\n                return 3 * 平均工资 * 工作年限;\n            } else {\n                return 3 * 平均工资 * 12;\n            }\n        } else {\n            if (工作年限 < Period.ofMonths(6)) {\n                return 月工资 * 0.5;\n            } else if (工作年限 >= Period.ofMoths(6) && 工作年限 < Period.ofYears(1)) {\n                return 月工资;\n            } else {\n                return 月工资 * 工作年限;\n            }\n        }\n    }\n}\n
\n

经济补偿金不能在劳动者工资中预发,\n作为法定的强制经济补偿措施,当事人不得自行决定。

\n

其他

\n

劳务派遣

\n

坑比较多,立法也很不完善,争议性问题较多,法规本身也不稳定,执法倾向地区性差异很大。如果有纠纷,是三方纠纷,比一般的劳资纠纷复杂多了。

\n

慎重选择。

\n

不安排公休

\n

单位确因工作需要不能安排职工休年休假的,经职工本人同意后,\n可以不安排其公休,按照日工资 300% 支付应休未休的报酬。

\n

如果放假宅家尚可接受,\n但如果打算旅游的话,节假日旅行多付出的花费远远超过应休未休的补偿。

\n

用工单位无故不批准劳动者申请年休假,劳动者又执意休假未上班的,\n是否视为旷工,法律上没有规定,可能取决于地方性规定。

\n

劳动者以个人原因辞职,用工单位尚未安排年休假的,是否应支付未休年假工资,\n法律上同样没有规定,可能取决于地方性规定。

\n

员工违纪罚款

\n

用工单位是否可以通过依法制定的规章或劳动合同约定的途径进行罚款,\n各地的规定和司法惯例不同。

\n

值班

\n
    \n
  1. 安排值班不需要经工会和劳动者双重协商程序
  2. \n
  3. 如何值班、一次值多久不受《劳动法》约束,由用工单位内部规章制度规定(虽然理论上来说内部规章制度也需要公示并与劳动者协商,但这个主要是程序上的规定)
  4. \n
  5. 值班没有加班费,待遇由用工单位内部规章制度规定,唯一的保障是值班报酬的标准需要一致(劳动法 s. 46 同工同酬)
  6. \n
\n

不定时工作制

\n
    \n
  1. 需要注册地区县劳动部门批准,且审批难度较大。
  2. \n
  3. 需先经员工同意。
  4. \n
  5. 原则上每天工作 8 小时,每周至少休息 1 天。
  6. \n
  7. 无加班工资,节假日除外。
  8. \n
\n

用人单位变动

\n
    \n
  1. 非组织实体变动(名称、法人代表、地址等)不影响劳动合同履行。 (劳动合同法 s.33)
  2. \n
  3. 分立、合并后,如履行条件发生变化,用人单位和劳动者可以对原劳动合同进行协商变更。(民法通则 s. 44; 劳动合同法 s. 34)
  4. \n
\n

服务期

\n

注意只有用工单位为劳动者提供专项培训费用,对其进行专业技术培训,才可以约定服务期。

\n

以下服务期和违约金的规定不受法律保护:

\n
    \n
  1. 适应性培训
  2. \n
  3. 上岗和转岗培训
  4. \n
  5. 高薪
  6. \n
  7. 解决户口
  8. \n
  9. 分配住房、轿车
  10. \n
\n

另外,服务期的约定是否对用工单位也有约束力,\n即约定的服务期长于劳动合同期限的,是否视为对劳动合同期限的延长,\n法律上有争议。\n有些区域通过地方性规定 patch 了,有些区域则处于不确定状态。

\n

未订立劳动合同

\n

用工之日起 1 个月内应当订立书面劳动合同。

\n

如果用工单位超期未订立合同,用工单位应支付双倍工资,(劳动合同法实施条例 s. 7)\n但相应的劳动者也需要收集证据证明劳动关系的存在。\n对于这种不及时订立劳动合同的用工单位,还是尽早抽身为妙,\n没有必要贪图那一点双倍工资先干着,事后再耗费时间精力谈判或仲裁。

\n

如果劳动者经用工单位书面通知后,不与用工单位订立书面劳动合同,\n用工单位应书面通知劳动者终止劳动关系,并依法向劳动者支付其实际工作时间的劳动报酬。(劳动合同法实施条例 s. 5)\n出现这种情况,一般是双方就合同条款不能达成一致。

\n

倒签劳动合同

\n

用工单位超期未订立合同,为了规避风险,在补签合同时将签字日期倒签在法定界限之内。\n这时候劳动者如果签字了,是否视为劳动者放弃要求用人单位支付双倍工资的权利,在法律上有争议。

\n

单独试用合同

\n

试用期只能在劳动合同内约定。\n单独试用合同会被认定为一份固定期限劳动合同。(劳动合同法 s.19)\n由于试用期一般不会太长,因此用工单位签一次自以为的「试用合同」,\n结束试用期后再签一次正式的劳动合同,\n就达成了「连续订立二次固定期限劳动合同」的条件,\n按劳动合同法规定,已经属于应当订立无固定期限劳动合同的情形。\n到时如果劳动者不主动提出订立固定期限劳动合同的话,\n用工单位就比较尴尬了。

\n

另外,试用期也需要办理五险一金,如果用工单位不办的话,\n(搞这种合同的单位未必有这个意识)\n将面临被责令补缴等法律责任,\n同时面临被劳动者以此为理由直接解除劳动合同并要求支付补偿的风险。

\n

所以说搞这种合同的用工单位都是在作死,避开为妙。

\n

再就业培训补贴

\n

城镇登记失业人员中由就业转失业人员,可享受免费再就业培训,或申请职业培训补贴。

\n

不过那些培训的质量么。。。

\n

集体协商、工会、集体合同

\n

在 CN 能动用这个内耗很高的机制的话,说明劳资矛盾已经极其尖锐了,\n也就是说雇主完全不知道自己在干什么。\n(当然也有小部分可能是大部分雇员不知道自己在干什么,\n但雇主招这么多不知道自己在干什么的雇员,也是不知道自己在干什么。)

\n

还有一种情况,是政府部门推区域性集体合同或行业性集体合同。\n区域性集体合同因为缺少针对性,基本只有某些特别的小镇能推行。\n行业性集体合同主要针对建筑业、采矿业、餐饮服务业等。

","date_published":"Thu, 05 Oct 2017 01:49:28 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/dapi/law-rent/","url":"https://mmap.page/dapi/law-rent/","title":"房屋租赁","content_html":"

房屋租赁

\n

合同

\n

商品房屋租赁管理办法 s. 7 规定,\n房屋租赁合同的内容由当事人双方约定,一般应当包括以下内容:

\n
    \n
  1. \n

    房屋租赁当事人的姓名(名称)和住所

    \n

    出示身份证原件,留存复印件

    \n
  2. \n
  3. \n

    房屋的坐落、面积、结构、附属设施,家具和家电等室内设施状况

    \n

    业主出示房产证、土地证,留存复印件。房本没下来的,出示购房合同。

    \n

    特别是家电,需要试用,并将状况记录在合同中。

    \n
  4. \n
  5. \n

    租金和押金数额、支付方式

    \n

    争取银行转账而不是现金支付,记录银行账号。\n银行转账有转账记录,也能避免出租人拒绝收租反以租客不交租为由解除合同。

    \n

    明确退还押金的条件,避免出租人以含糊理由在合同期满后扣除押金。

    \n
  6. \n
  7. \n

    租赁用途和房屋使用要求

    \n
  8. \n
  9. \n

    房屋和室内设施的安全性能

    \n
  10. \n
  11. \n

    租赁期限

    \n

    租赁期限六个月以上的,应当采用书面形式。当事人未采用书面形式的,视为不定期租赁。(合同法 s. 215)

    \n

    租赁期间届满,承租人继续使用租赁物,出租人没有提出异议的,原租赁合同继续有效,但租赁期限为不定期。(合同法 s. 236) 当事人可以随时解除合同,但出租人解除合同应当在合理期限之前通知承租人。(合同法 s. 232)

    \n
  12. \n
  13. \n

    房屋维修责任

    \n

    出租人应当履行租赁物的维修义务,但当事人另有约定的除外。(合同法 s. 220)

    \n

    承租人在租赁物需要维修时可以要求出租人在合理期限内维修。出租人未履行维修义务的,承租人可以自行维修,维修费用由出租人负担。因维修租赁物影响承租人使用的,应当相应减少租金或者延长租期。(合同法 s. 221)

    \n

    承租人未经出租人同意,对租赁物进行改善或者增设他物的,出租人可以要求承租人恢复原状或者赔偿损失。(合同法 s. 223)

    \n
  14. \n
  15. \n

    物业服务、水、电、燃气等相关费用的缴纳

    \n

    水、电、燃气表读数

    \n
  16. \n
  17. \n

    争议解决办法和违约责任

    \n

    租赁物危及承租人的安全或者健康的,即使承租人订立合同时明知该租赁物质量不合格,承租人仍然可以随时解除合同。(合同法 s. 233)

    \n

    当事人以房屋租赁合同未按照法律、行政法规规定办理登记备案手续为由,请求确认合同无效的,人民法院不予支持。\n(最高人民法院关于审理城镇房屋租赁合同纠纷案件具体应用法律若干问题的解释 s. 4)

    \n

    房屋租赁合同无效,当事人请求参照合同约定的租金标准支付房屋占有使用费的,人民法院一般应予支持。\n(最高人民法院关于审理城镇房屋租赁合同纠纷案件具体应用法律若干问题的解释 s. 5)

    \n

    出租人就同一房屋订立数份租赁合同,在合同均有效的情况下,承租人均主张履行合同的,人民法院按照下列顺序确定履行合同的承租人:

    \n
      \n
    1. 已经合法占有租赁房屋的;
    2. \n
    3. 已经办理登记备案手续的;
    4. \n
    5. 合同成立在先的。
    6. \n
    \n

    不能取得租赁房屋的承租人请求解除合同、赔偿损失的,依照合同法的有关规定处理。\n(最高人民法院关于审理城镇房屋租赁合同纠纷案件具体应用法律若干问题的解释 s. 6)

    \n
  18. \n
  19. \n

    其他约定

    \n
  20. \n
  21. \n

    房屋被征收或者拆迁时的处理办法

    \n
  22. \n
\n

合同当面签署,超过 1 页的,每页均加签名(或仅签姓)。

\n

转租

\n

次承租人的风险

\n
    \n
  1. \n

    转租未经出租人同意

    \n

    承租人未经出租人同意转租的,出租人可以解除合同。(合同法 s. 224)

    \n

    承租人未经出租人书面同意转租的,出租人可以解除租赁合同,收回房屋并要求承租人赔偿损失。(商品房屋租赁管理办法 s. 11)

    \n

    出租人知道或者应当知道承租人转租,但在六个月内未提出异议,其以承租人未经同意为由请求解除合同或者认定转租合同无效的,人民法院不予支持。\n(最高人民法院关于审理城镇房屋租赁合同纠纷案件具体应用法律若干问题的解释 s. 16)

    \n
  2. \n
  3. \n

    转租人丧失承租权

    \n

    次承租人的承租权依附于承租人的承租权。

    \n
  4. \n
\n

救济

\n
    \n
  1. \n

    转租人因欠租导致出租人解除合同

    \n

    因承租人拖欠租金,出租人请求解除合同时,次承租人请求代承租人支付欠付的租金和违约金以抗辩出租人合同解除权的,人民法院应予支持。但转租合同无效的除外。\n(最高人民法院关于审理城镇房屋租赁合同纠纷案件具体应用法律若干问题的解释 s. 17)

    \n

    次承租人代为支付的租金和违约金超出其应付的租金数额,可以折抵租金或者向承租人追偿。\n(最高人民法院关于审理城镇房屋租赁合同纠纷案件具体应用法律若干问题的解释 s. 17)

    \n
  2. \n
\n

转租人的风险

\n
    \n
  1. \n

    次承租人无力支付租金或拖欠租金时,转租人仍需向出租人付租金。

    \n

    承租人转租的,承租人与出租人之间的租赁合同继续有效。(合同法 s. 224)

    \n
  2. \n
  3. \n

    次承租人对租赁物造成损失,转租人需先承担责任,再设法向此承租人追偿。

    \n

    第三人对租赁物造成损失的,承租人应当赔偿损失。(合同法 s. 224)

    \n
  4. \n
\n

所有权变动

\n

租赁期间所有权变动,房屋受让人继续履行原租赁合同。例外:

\n
    \n
  1. 当事人另有约定
  2. \n
  3. 房屋在出租前已设立抵押权,因抵押权人实现抵押权发生所有权变动的
  4. \n
  5. 房屋在出租前已被人民法院依法查封的
  6. \n
\n

出租人出卖房屋,或与抵押权人协议折价、变卖租赁房屋偿还债务的,\n应当在合理期限内通知承租人。

\n

出租人委托拍卖人拍卖租赁房屋,应当在拍卖5日前通知承租人。

\n

(最高人民法院关于审理城镇房屋租赁合同纠纷案件具体应用法律若干问题的解释 ss. 20-23)

\n

群租

\n

商品房屋租赁管理办法 s. 8 规定:

\n
\n

出租住房的,应当以原设计的房间为最小出租单位,\n人均租住建筑面积不得低于当地人民政府规定的最低标准。

\n
\n
\n

厨房、卫生间、阳台和地下储藏室不得出租供人员居住。

\n
\n

因此群租的法律风险取决于:

\n
    \n
  1. 政策变动(当地规定的最低人均面积)
  2. \n
  3. 执法力度(「违反本办法第八条规定的,由直辖市、市、县人民政府建设(房地产)主管部门责令限期改正,逾期不改正的,可处以五千元以上三万元以下罚款。」商品房屋租赁管理办法 s. 22)
  4. \n
","date_published":"Mon, 02 Oct 2017 12:01:38 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/dapi/chufenger/","url":"https://mmap.page/dapi/chufenger/","content_html":"

楚风儿(一首)

\n

苏州二题选一

\n

袅袅烟青四五家,竹炉细雨坐烹茶。此身只合苏州老,短巷横斜栀子花。

\n

(网人七绝三百首)

\n

【笺注】

\n

身 一身。

\n

只合苏州老 【唐】韦庄《菩萨蛮》「人人尽说江南好,游人只合江南老。春水碧于天,画船听雨眠。垆边人似月,皓腕凝霜雪。未老莫还乡,还乡须断肠。」

\n

短巷 今苏州犹存短巷。

\n

横斜 【宋】林逋《山园小梅》「疎影横斜水清浅,暗香浮动月黄昏。」林逋早岁游江淮间,后归杭州,隐居西湖孤山二十年。种梅养鹤,时称「梅妻鹤子」。《宋史》云「逋不娶,無子,教兄子宥,登進士甲科」。林正秋《林净因和中日饮食文化交流》(杭州师院学报(社会科学版),1986-06)谓林逋有后代 2 支,一在浙江奉化,一在日本,日本馒头创制者林净因即林逋后裔。

\n

栀子 【唐】彦谦《离鸾》「庭前佳树名梔子,试结同心寄谢娘 。」

","date_published":"Mon, 25 Sep 2017 12:12:02 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/dapi/law/","url":"https://mmap.page/dapi/law/","title":"An Introduction to Law for Programmers","content_html":"

An Introduction to Law for Programmers

\n

预备知识和技能

\n\n

书籍

\n

法律方面有很多粗制滥造的书籍,\n一个幼稚的辨别方法是排除以下 4 类书籍:

\n
    \n
  1. 面向普通大众的书(反正你们也不懂,我搞一个 quick and dirty 的东西就行,剩下的是营销的活)
  2. \n
  3. 面向司法考试的书(教辅书本来就是粗制滥造的重灾区,而且出于应试需要,严重偏向司法考试出题人的学术倾向,较少照顾实际层面的惯例)
  4. \n
  5. 各种学术会议的砖头书(有的注水严重,有的离实际层面的问题较远)
  6. \n
  7. 纯法律条文书(没法跳转到定义,没有相关的 patch 信息,读起来效率太低)
  8. \n
\n

当然会有误杀的情况,但总体来说效果很好。

\n

推荐以下 2 类书籍:

\n
    \n
  1. 最近出版的法学专业的教材(帮助提炼领域知识的精华)
  2. \n
  3. 面向法务工作者(比如律师、企业法务人员、HR 等)的手册(实务中的坑以及填坑、绕坑的经验)
  4. \n
\n

法学理论

\n

具有XX特色的社会主义法学理论,类似XX语言是程序员最好的朋友,都是广告。

\n

学东西光看广告是不行的,还是要多读书提高一下知识水平。

\n
\n

这都是些初步意见,还没有作最后决定,以后可能不算数。\n刘伯承同志经常讲一句四川话:\n「黄猫、黑猫,只要捉住老鼠就是好猫。」\n我们之所以能够打败蒋介石,\n就是不讲老规矩,不按老路子打,一切看情况,打赢算数。

\n
\n

-- 邓小平《怎样恢复农业生产》

\n

法律文本的结构

\n

这里的法律文本,指成文法(statutes)。

\n

由大到小,依次为编、章、节、条、款、项、目。(立法法 s. 54)

\n

编

\n

篇幅很大的法律有这个。

\n

比如民事诉讼法分四编(part):

\n
    \n
  1. 总则
  2. \n
  3. 审判程序
  4. \n
  5. 执行程序
  6. \n
  7. 涉外民事诉讼程序的特别规定
  8. \n
\n

章

\n

大部分法律直接由章(chapter)构成,跳过编这个层级。

\n

节

\n

篇幅较长的章分节(section).

\n

注意,这里的 section 是一般英文文本中的 section.\n某些英语国家法律语境下的 section 是有特定含义的:

\n
\n

Section: a subdivision of a statute or document ...\nMost statutes and codes are divided into sections.

\n
\n

-- A Dictionary of the Law (Clapp, 2000, p. 389)

\n

也就是说,这 section 其实对应中文法律语境下的「条」。

\n

条

\n

这个是法律最基本的结构,粒度大概相当于程序语言中的函数或方法。

\n

条翻译为 article, 但如前所述,其实很多时候翻译为 section 可能更有助于交流。

\n

因为这个是最基本的结构,所以引用法律条文往往注明条的序数,\n比如前面引用《立法法》,就用s. 54标明是第 54 条。\n除了s.以外,习惯上更常用§ 54的形式。\n个人偏好s., 因为输入起来比较方便。

\n

款

\n

长的条会分成款(paragraph)。款的开头缩进两格,末尾换行。\n这和长的函数定义用空行划分段落的做法类似。

\n

项

\n

翻译为 subparagraph, 但其实相当于 HTML 中的ol.

\n

前面我们已经提到了中文和英文里 section 的错位,\n其实款和条也有错位,台湾的法律文本,款和项是倒过来的,\n台湾的「项」其实是 paragraph, 而「款」才是 subparapraph,\n台湾目前的这个用法,是沿用了中华民国时期的做法。\n最早可能是借鉴了日本法律文本的结构。

\n

目

\n

翻译为 item, 也是一种ol.

\n

「项」与「目」的区别

\n\n

例子

\n

民法通则 s. 134

\n
承担民事责任的方式主要有:     // 第一款\n    (一)停止侵害;          // 第一款第一项\n    (二)排除妨碍;\n    (三)消除危险;\n    (四)返还财产;\n    (五)恢复原状;\n    (六)修理、重作、更换;\n    (七)赔偿损失;\n    (八)支付违约金;\n    (九)消除影响、恢复名誉;\n    (十)赔礼道歉。\n    以上承担民事责任的方式,可以单独适用,也可以合并\n适用。                                            // 第二款\n    人民法院审理民事案件,除适用上述规定外,还可以予以训\n诫、责令具结悔过、收缴进行非法活动的财物和非法所得,并可\n以依照法律规定处以罚款、拘留。\n
\n

作用

\n

下面举两个例子,分别说明法律文本的结构如何帮助/阻碍我们理解法律。

\n

个人合伙

\n

《民法通则》里,「个人合伙」属于第二章「自然人」,\n不属于第三章「法人」,\n「个人合伙」前面一节是「个体工商户、农村承包经营户」。

\n

所以,不用读具体的条文,或者其他细法(部门法),\n从结构上就能看出,合伙企业和其他企业不同,并不属于法人。\n合伙企业其实是将家庭经营的个体工商户模式推广到家庭之外的产物。

\n

诉讼时效

\n

《民法通则》第七章《诉讼时效》可读性不是很好,\n这是法律文本结构的限制。\n法律文本只有章、条、项这些东西,表达力是很差的。\n所以有时候把法律文本改写成表格、流程图或者伪代码要容易理解一点。\n另外,改成伪代码也更容易暴露法条中一些含糊的地方\n(其中包括法条本身表述不明确及表述明确但自己没理解两种情况)。

\n
class 民事权利 {\n    private Period 诉讼时效;\n    private Period 完整诉讼时效;\n    LocalDate 知道或应当知道被侵权;\n    LocalDate 被侵权;\n    boolean 当事人自愿履行;\n\n    public 民事权利(LocalDate 知道, LocalDate 被侵, boolean 自愿) {\n        this.完整诉讼时效 = Period.ofYears(2);\n        this.诉讼时效 = this.完整诉讼时效;\n        this.知道或应当知道被侵权 = 知道;\n        this.被侵权 = 被侵;\n        this.当事人自愿履行 = 自愿;\n    }\n\n    public Period get诉讼时效() {\n        return this.诉讼时效;\n    }\n    public void set诉讼时效(Period p) {\n        this.诉讼时效 = p;\n    }\n\n    public boolean is有效期内() {\n        if (当事人自愿履行) {\n            return true;\n        }\n        else {\n            // 民法通则 s. 137 规定有特殊情况的,人民法院可以延期。\n            // 实际诉讼中这个一般要援引司法解释具体 patch 的情况才能延期。\n            // 因此下面不考虑这个情况。\n            LocalDate today = LocalDate.now();\n            // 1988 年最高法关于执行通则的意见明确了 20 年期限不适用中止、中断的规定。(s. 175)\n            if (Period.between(被侵权, today) > Period.ofYears(20)) {\n                return false;\n            } else if (Period.between(知道或应当知道被侵权, today) > this.诉讼时效) {\n                return false;\n            } else {\n                return true;\n            }\n        }\n    }\n\n    public boolean 中止(boolean 因不可抗力或其他障碍无法行使请求权,\n                        LocalDate 中止原因消除) {\n        if (因不可抗力或其他障碍无法行使请求权) {\n            if (诉讼时效 <= Period.ofMonths(6)) {\n                Period 中止期间 = Period.between(LocalDate.now(), 中止原因消除);\n                this.诉讼时效 += 中止期间;\n                return true;\n            } else {\n                return false;\n            }\n        } else {\n            return false;\n        }\n    }\n\n    public boolean 中断(boolean 提起诉讼, boolean 提出要求, boolean 同意履行) {\n        if (提起诉讼 || 提出要求 || 同意履行) {\n            this.诉讼时效 += this.完整诉讼时效;\n            return true;\n        } else {\n            return false;\n        }\n    }\n}\n\nclass 身体伤害 extends 民事权利 {\n    public 身体伤害(LocalDate 知道, LocalDate 被侵, boolean 自愿) {\n        super(知道,被侵,自愿);\n        this.完整诉讼时效 = Period.ofYears(1);\n        this.诉讼时效 = this.完整诉讼时效;\n    }\n}\n// 同理可定义 `class 质量不合格商品`, `class 延付拒付租金`, `class 寄存财物丢失损毁`,\n// 此处省略。\n\nabstract class 另有规定 extends 民事权利 {\n    @Override public boolean is有效期内();\n}\n
\n

Patch

\n

法律文本的麻烦之处是 Patch 是分开来发表的,\n而且后来的 Patch 并不包括以前的 Patch.

\n

因此工具书很重要。

\n

同理,不建议直接看法条。

\n

如果一时找不到靠谱的工具书,不得已直接读法条,\n那要保持高度警惕,特别要注意 2 点:

\n

1. 含糊的地方。

\n

比如《民法通则》s. 153

\n
\n

本法所称的「不可抗力」,是指不能预见、不能避免并不能克服的客观情况。

\n
\n

这句话是很含糊的。\n阅读判例的时候可以帮助理解法官的思路,\n但想凭此主张自己不承担责任难度很大。\n还是要找细法里的具体规定以及司法解释。

\n

2. 过时的地方。

\n

比如 1988 年最高法出的执行民法通则的意见第 118 条规定:

\n
\n

出租人出卖出租房屋,应提前三个月通知承租人,\n承租人在同等条件下,享有优先购买权;\n出租人未按此规定出卖房屋的,承租人可以请求人民法院宣告该房屋买卖无效。

\n
\n

1988 年时候房屋买卖还不频繁。而现在房屋买卖是很频繁的。\n同时,有些地方因为房价波动厉害,因此往往希望尽快成交。\n要求每笔买卖都拖上 3 个月并不符合现在的实际情况。

\n

因此 2009 最高法就出 patch 更新了,先把 3 个月改成了更灵活的「合理期限」,\n其次把没有及时通知的违约责任由买卖无效改成了赔偿损失。\n(最高人民法院关于审理城镇房屋租赁合同纠纷案件具体应用法律若干问题的解释, s. 21)

","date_published":"Fri, 15 Sep 2017 10:10:30 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/cli/test/","url":"https://mmap.page/cli/test/","title":"Command Line Interface Testing","content_html":"

Command Line Interface Testing

\n

assert.sh

\n

Example:

\n
. assert.sh\n\n# `echo test` is expected to write \"test\" on stdout\nassert \"echo test\" \"test\"\n# exit code of `true` is expected to be 0\nassert_raises \"true\"\n# exit code of `false` is expected to be 1\nassert_raises \"false\" 1\n# end of test suite\nassert_end examples\n
\n

Pros:

\n\n

Cons:

\n\n

You can implement your own assert_contains function.

\n

ts

\n

It is similar to assert.sh.

\n

Differences:

\n\n

roundup

\n

Example:

\n
#!/usr/bin/env roundup\n\ndescribe \"group tests\"\n\nit_displays_the_title() {\n    first_line=$(rup roundup-5 | head -n 1)\n    test \"$first_line\" \"=\" \"roundup(5)\"\n}\n\nit_exists_non_zero() {\n    status=$(set +e ; rup roundup-5 >/dev/null ; echo $?)\n    test 2 -eq $status\n}\n\nit_survives_edge_cases() {\n    rup edge\n}\n
\n

Differences to assert.sh:

\n\n

I think these differences add readability.

\n

Cons are similar to assert.sh.

\n

rnt

\n

Save output of commands to *.actual, then compare them with *.expected via diff.

\n

Cons are similar to assert.sh, plus:

\n\n

cmdtest

\n

Like rnt, cmdtest also uses a lot of files.\nBut it adds support for standard error and setup/teardown.

\n
   foo.script\n          a script to run the test (this is required)\n\n   foo.stdin\n          the file fed to standard input\n\n   foo.stdout\n          the expected output to the standard output\n\n   foo.stderr\n          the expected output to the standard error\n\n   foo.exit\n          the expected exit code\n\n   foo.setup\n          a shell script to run before the test\n\n   foo.teardown\n          a shell script to run after test\n\n   setup-once\n          a shell script to run once, before any tests\n\n   setup  a shell script to run before each test\n\n   teardown\n          a shell script to run after each test\n\n   teardown-once\n          a shell script to run once, after all tests\n
\n

Cons:

\n\n

urchin

\n

urchin is similar to rnt, but it does use separate output files.\nInstead, exit 0 passes tests.

\n
tests/\n  setup\n  setup_dir\n  bar/\n    setup\n    test_that_something_works\n    teardown\n  baz/\n    jack-in-the-box/\n      setup\n      test_that_something_works\n      teardown\n    cat-in-the-box/\n      fixtures/\n        things.pdf\n      test_thingy\n  teardown\n
\n

Cons are similar to rnt except for 'Separate expected output'.

\n

Cram

\n

Tests look like documents:

\n
This is a comment.\n\n  $ echo 'Lines beginning with two space followed by $ is a test.'\n  $ echo 'Multiline test\n  > exit 0 passes tests.'\n\n  $ cram -h\n  [Uu]sage: cram \\[OPTIONS\\] TESTS\\.\\.\\. (re)\n\n  [Oo]ptions: (re)\n    -h, --help          show this help message and exit\n    -V, --version       show version information and exit\n    -q, --quiet         don't print diffs\n    -v, --verbose       show filenames and test status\n    -i, --interactive   interactively merge changed test output\n    -y, --yes           answer yes to all questions\n    -n, --no            answer no to all questions\n    -E, --preserve-env  don't reset common environment variables\n    --keep-tmpdir       keep temporary directories\n    --shell=PATH        shell to use for running tests\n    --indent=NUM        number of spaces to use for indentation\n\nLines beginning with two space not followed by $ or > is output.\nOutput lines ending with a space and (re) are matched against PCRE.\n
\n

Cons:

\n\n

shelltestrunner

\n
# optional comment\na one-line shell command\n<<<\nzero or more lines of standard input\n>>>\nzero or more lines of expected standard output (or /REGEXP/ added to the previous line)\n>>>2\nzero or more lines of expected standard error output (or /REGEXP/ added to the previous line)\n>>>= STATUS (or /REGEXP/)\n
\n

Cons:

\n\n

tf

\n

Example:

\n
## User comments start with double #\n## command can be writen in one line with multiple tests:\ntrue # status=0; match=/^$/\n## or tests can be placed in following lines:\nfalse\n# status=1\n
\n

Cons:

\n\n

Bricolage

\n

Example:

\n
# A test is a function. $T is a variable where test keeps its internal files\nmytest() {\n    # ok is the only assertion helper\n    # It uses `test` to check the condition, so syntax is common\n    ok 1 -eq 1\n    ok foo = foo\n    foo=\"Foo bar\"\n    ok \"$foo\" = \"Foo bar\"\n\n    # You can use `spy` to make a wrapper over a command.\n    spy date\n\n    date\n\n    # Command output will be written into <spy>.stdout file:\n    ok \"$(cat $T/spy.date.stdout)\" = \"foo\"\n\n    # Fake spy output can be specified in the <spy> file:\n    echo foo > $T/spy.date\n    date\n\n    # You can assert it using tail, sed, awk and other common unix tools\n    ok \"$(tail -n 1 $T/spy.date.stdout)\" = \"foo\"\n}\n\n# You may override test reports as you need\npass() { echo PASS $* }\nfail() { echo FAIL $* }\n\n# You have to run your tests manually\nbricolage mytest\n\n# Clean test data\nrm -rf $T\n
\n

Pros:

\n\n

Cons:

\n","date_published":"Thu, 24 Aug 2017 14:15:21 GMT","date_modified":"Thu, 24 Jul 2025 12:16:07 GMT"},{"id":"https://mmap.page/dive-into/ruby/","url":"https://mmap.page/dive-into/ruby/","title":"Quirks of Ruby","content_html":"

Quirks of Ruby

\n

Foreword

\n

Ruby advertises its \"The Least Surprise\" principle.\nIf you are unsure about something on Ruby,\nyou can guess and try, and it usually works,\nexcept for some quirks mentioned below.

\n

If you prefer reading a tutorial before diving into Ruby,\nI would recommend why's guide to Ruby,\nwhich may be outdated,\nbut definitely poignant.

\n

begin ... end while

\n
begin puts \"code executed\" end while false\nputs \"code not executed\" while false\n
\n

This is really anti-intuitive.\nAnd the creator of Ruby said not using this.

\n
\n

Don't use it please. I'm regretting this feature,\nand I'd like to remove it in the future if it's possible.

\n
\n

-- matz

\n

Unfortunately, this feature still exists in Ruby 3.3.

\n

Proc.new

\n

The return statement in proc created by Proc.new will not only return control just from itself, but also from the method enclosing it.

\n
def some_method\n\tmyproc = Proc.new {return \"End.\"}\n\tmyproc.call\n\n\tputs \"This will not get executed!\"\nend\nsome_method\n
\n

Well, you can argue that Proc.new inserts code into the enclosing method, just like block.\nBut Proc.new creates an object, while block are part of an object.

\n

And there is another difference between lambda and Proc.new.\nThat is their handling of (wrong) arguments.\nLambda complains about it, while Proc.new ignores extra arguments or considers absence of arguments as nil.

\n
irb(main):021:0> l = -> (x) { x.to_s }\n=> #<Proc:0x8b63750@(irb):21 (lambda)>\nirb(main):022:0> p = Proc.new { |x| x.to_s}\n=> #<Proc:0x8b59494@(irb):22>\nirb(main):025:0> l.call\nArgumentError: wrong number of arguments (0 for 1)\n        from (irb):21:in `block in irb_binding'\n        from (irb):25:in `call'\n        from (irb):25\n        from /usr/bin/irb:11:in `<main>'\nirb(main):026:0> p.call\n=> \"\"\nirb(main):049:0> l.call 1, 2\nArgumentError: wrong number of arguments (2 for 1)\n        from (irb):47:in `block in irb_binding'\n        from (irb):49:in `call'\n        from (irb):49\n        from /usr/bin/irb:11:in `<main>'\nirb(main):050:0> p.call 1, 2\n=> \"1\"\n
\n

BTW, proc in Ruby 1.8 creates a lambda, while in Ruby 1.9+ behaves like Proc.new, really confusing.

\n

def does not create closures.

\n

Closures are simple in Python:

\n
def a(x):\n  def b():\n    return x\n  b()\n
\n

This won't work in Ruby.

\n
def a(x)\n  def b\n    x\n  end\n  b\nend\na(1) # in `b': undefined local variable or method `x' for main (NameError)\n
\n

In Ruby, def starts a new scope, without access to outer variables.\nOnly @var and $var can be accessed.\nAnd no extern keyword like in C.

\n

Lambda and define_method do create closure though:

\n
def a(x)\n  b = ->{ x }\n  b.call\nend\na(1) # 1\n\ndef c(x)\n  define_method(:d) { x }\n  d\nend\nc(1) # 1\n
\n

In Ruby 1.9, define_method is not available in main Object, you can\nuse define_singleton_method instead.

","date_published":"Thu, 24 Aug 2017 14:08:34 GMT","date_modified":"Mon, 14 Jul 2025 20:20:32 GMT"},{"id":"https://mmap.page/dive-into/pry/","url":"https://mmap.page/dive-into/pry/","title":"Dive into Pry","content_html":"

Dive into Pry

\n

This note was written for Ruby < 2.0, thus outdated now.

\n

Input

\n\n

Special locals

\n\n

Browsing code

\n

Use cd to move into an object or scope.\nAs in UNIX shells use cd .. to go\nback, cd / to return to Pry top-level and cd - to toggle between last two\nscopes. Complex syntax (e.g cd ../@x/@y) also supported.

\n

Use whereami(alias @) to show code surrounding the current context.

\n

Use show-source(alias $ or show-method) and show-code(alias ?).

\n

Use find-method to recursively search for a method within a class/module or the current namespace.

\n

Use stat method_name for basic method information.

\n

Use ls to get a list of variables in current scope\nYou can also use ls Class/Module, or ls variable.

\n

Use watch to watch the value of an expression and print a notification whenever it changes.

\n

cat automatic syntax highlighting for a number of file types.

\n

cat accepts the following options:

\n\n

Editing code

\n

edit brings you to EDITOR.\nIt accepts the following options:

\n\n

Being run without any arguments, the edit command modifies the last input expression.

\n

History

\n

hist to display Pry history.

\n

It accepts the following options:

\n\n

Debug

\n

Write binding.pry as a breakpoint in your code. When executing, it\nwill stop here and open a Pry console.

\n

Gems

\n\n

Customization

\n

For current session:

\n
Pry.config.[option]\n
\n

You can store Pry.config.[option] in .pryrc (project or global ~/.pryrc).

\n

Plugins

\n

pry-byebug

\n

Use byebug (Ruby debugger) with pry.

\n

I don't use it due to this bug.\nBesides, most of time, I just need pry-rescue.

\n

pry-coolline

\n

By default, code gets highlighted after you end your input.\nThis plugin supports real time highlight.

\n

pry-macro

\n

Record and play macros.\nYou can save macros to a file.

\n

pry-rescue

\n

Whenever an unhandled exception happens in your program, pry-rescue opens an interactive pry shell right at the point it was raised.

\n

Install it together with pry-stack_explorer, then run rescue file.rb instead of ruby file.rb.

\n

In the rescue Pry session, use up and down to move around the stack, and use wtf? or cat --ex to examine stack traces and the associated code.\nAfter identifying the problem, use edit-method (alias $) to fix the code, and try-again to verify the fix worked.

\n

cd-cause lets you rewind back the previously raised exception. So, if you've rescued one exception, and then raised another (it happens…) you can jump back to the original cause of the problem.

\n

You can also call Pry::rescue to control over which parts of your code are rescued:

\n
require 'pry-rescue'\n\ndef test\n  raise \"foo\"\nrescue => e\n  raise \"bar\"\nend\n\nPry.rescue do\n  test\nend\n
\n

You can also use Pry::rescue in the rescue clause:

\n
def test\n  raise \"foo\"\nrescue => e\n  Pry::rescued(e)\nend\n\nPry::rescue{ test }\n
\n

Testing

\n
rspec
\n
rescue rspec\n
\n
MiniTest
\n

Add the following to your test_helper.rb or to the top of your test file

\n
require 'minitest/autorun'\nrequire 'pry-rescue/minitest'\n
\n

It works perfectly with yard-doctest in terminal, but not is\nsublime-text.

\n

Themes

\n

In a pry session, run pry-theme list to list all installed themes.

\n

Try a theme:

\n
pry-theme try pry-modern-256\n
\n

If the theme is not installed, you can install it:

\n
pry-theme install theme-name\n
\n

You can use uninstall to uninstall it.

\n

Show current theme:

\n
pry-theme current\n
\n

You can edit a theme:

\n
pry-theme edit\n
\n

After you have decided your theme, write it in .pryrc:

\n
Pry.config.theme = \"pry-modern-256\"\n
\n

You can get more themes at Pry theme collection.

","date_published":"Thu, 24 Aug 2017 14:05:03 GMT","date_modified":"Sun, 23 Apr 2023 04:25:20 GMT"},{"id":"https://mmap.page/dive-into/gh-pages/","url":"https://mmap.page/dive-into/gh-pages/","title":"Build a Micro Static Site With GitHub Pages","content_html":"

Build a Micro Static Site With GitHub Pages

\n

tl;tr

\n

In repository settings, enable GitHub Pages for the master branch.

\n

Now you can access your site at https://your-username.github.io/your-repo-name

\n

Done. Period.

\n

How

\n

GitHub Pages will use README.md as index page.\nAnd your project probably already have one.\nThere is no need to write index.html or index.md.

\n

Why

\n

Focus on content, not the site design and configuration.

\n

We use README.md and master branch.\nThis makes updating project site easier.\nJust update README.md without the hassles of sync documentation between master and gh-pages branches.

\n

Bonus

\n

Your project may have some additional documentary pages.\nThey are welcome by GitHub Pages.

\n

For example:

\n
README.md\n...\ndocs/\n    README.md\n    quick-start.md\n    install/\n        linux.md\n        osx.md\n        bsd.md\n        win.md\n
\n

URL paths will be:

\n
/index.html\n/docs\n/docs/quick-start.html\n/docs/install/linux.html\n/docs/install/osx.html\n/docs/install/bsd.html\n/docs/install/win.html\n
\n

And you can link them as [quick start](quick-start.md),\nso the link will work on both GitHub and GitHub Pages.

\n

Conclusion

\n

Yes. You can have a site powered by GitHub Page up and running\nwithout writing a single line of\nyaml configuration, html template, css, javascript, etc.

","date_published":"Thu, 24 Aug 2017 14:04:26 GMT","date_modified":"Wed, 26 Apr 2023 09:13:36 GMT"},{"id":"https://mmap.page/dive-into/flow/","url":"https://mmap.page/dive-into/flow/","title":"Dive into Flow","content_html":"

Dive into Flow

\n

Peek at the type system

\n\n

Built-in types

\n

Boolean

\n

JavaScript specifies many implicit conversions,\nwhich provide boolean semantics to values of other types.\nFlow allows this in conditional of if statements etc.

\n

Note that in JavaScript Boolean(0) and new Boolean(0) are different.\nThe formal is converting 0 to the boolean primitive type via the Boolean function,\nthe later is initialize a Boolean wrapped object, which is rarely used.\nSame thing applies to number/Number and string/String.

\n

Number

\n

JavaScript has a single number type, which is IEEE 754 floating point numbers.

\n

Literal types

\n

true, false, any number, and any string is a literal type.

\n

let wrong: false = true && false is valid\nsince a type checker can infer that for t typed true and f typed false, t && f is typed false,\njust like a type checker can infer that for m and n typed number, m + n is typed number.\nUnlike boolean, literal types of number and string has infinite members,\na type checker cannot infer if the sum of two number typed as literal type has another specific literal type.\nSo let two: 2 = 1 + 1 is invalid.

\n

Declaration files

\n

Flow's declaration files are like C's header files.

\n

A declaration file of foo.js is named foo.js.flow:

\n
/* @flow */\n\ndeclare export function isLeapYear(year: string): boolean;\ndeclare export let DEBUG: boolean;\n\ndeclare export class Counter {\n  val: number;\n  increase(): void;\n}\n\ndeclare export type Response = 'yes' | 'no' | 'maybe';\n\ndeclare export interface Stack<T> {\n  push(item: T): void;\n  pop(): T;\n  isEmpty(): bool;\n}\n
\n

Declaration files supports mixin,\nwhich can also be used in implementations, for example,

\n
/* @flow */\n\ndeclare class MyClass extends Child mixins MixinA, MixinB {}\ndeclare class MixinA {\n  a: number;\n  b: number;\n}\n// Mixing in MixinB will NOT mix in MixinBase\ndeclare class MixinB extends MixinBase {}\ndeclare class MixinBase {\n  c: number;\n}\ndeclare class Child extends Base {\n  a: string;\n  c: string;\n}\ndeclare class Base {\n  b: string;\n}\n\nvar c = new MyClass();\n(c.a: number); // Both Child and MixinA provide `a`, so MixinA wins\n(c.b: number); // The same principle holds for `b`, which Child inherits\n(c.c: string); // mixins does not copy inherited properties,\n               // so `c` comes from Child\n
\n

Problems

\n

Interfaces use structural typing.

\n

Go's FAQ suggests to add an additional method to doc implementations:

\n
type Fooer interface {\n    Foo()\n    ImplementsFooer()\n}\n
\n

This is a simple workaround for documentation,\nwhich prevents accidental implementation of interfaces.\nHowever, it does not prevent a later modification of implementation of Fooer\nto remove Foo() and make ImplementsFooer() not correct any more.

\n

With JavaScript, a much better workaround is possible (mentioned in #2376):

\n
/* @flow */\ninterface A {\n  foo(): number;\n}\n\nclass AImpl {\n  constructor(): A {\n    return this;\n  }\n  foo(): number {\n    return 1\n  }\n}\n
\n

So flow's structural typed interface is not as hopeless bad as Go.

\n

Implicitly type casting number to string with +.

\n

The number + string idiom is fairly common, so flow accepts it, like TypeScript.

\n

With this patch, flow will reject number + string:

\n
Error: main.js:3\n  3:    return 1 + \"s\"\n               ^ number. This type cannot be added to\n  3:    return 1 + \"s\"\n                   ^^^ string\n
\n

Hegel

\n

Hegel has a more sound type system than Flow,\nand it does not have the two problems mentioned above:

\n
    \n
  1. It does not support interface.
  2. \n
  3. No type coercion for number + string.
  4. \n
\n

It borrows Flow's syntax for type annotation, thus JavaScript can be generated via Flow tools (@babel/preset-flow or flow-remove-types).\nHowever, it uses TypeScript d.ts files for library definition, because TypeScript has a much larger ecosystem than Flow.\nNote some types are not supported, for example, Flow's interface and TypeScript's conditional typing.

\n

Its vscode extension is still in development.

","date_published":"Thu, 24 Aug 2017 14:03:05 GMT","date_modified":"Mon, 05 Sep 2022 12:59:54 GMT"},{"id":"https://mmap.page/dapi/lingfeng/","url":"https://mmap.page/dapi/lingfeng/","title":"《铃丰的恋物语与剑道社》「用感觉来写」的文学追求:以语法特征分析为中心","content_html":"

《铃丰的恋物语与剑道社》「用感觉来写」的文学追求:以语法特征分析为中心

\n

摘要

\n

本文以初音《铃丰的恋物语与剑道社》《简介》、《序章》《第一话》语法特征分析为基础,\n揭示了「感觉」、「你」特殊用法背后「用感觉来写」的文学追求。

\n

《简介》

\n
\n

铃丰是个剑道社的社长,\n他家里面还有个妹妹,是天依,你是妹妹是个厨师,

\n
\n

用「你」指代前面提及的人物,视为「我」对指代人物说的话,即「天依,你是妹妹,是个厨师」。这里「我」是作者。「天依是妹妹是个厨师」只是平常的陈述,而「你是妹妹是个厨师」,突出了「妹妹」、「厨师」是作者的设定,同时给人作者正在进行设定的感觉。这种用法体现了强烈的虚构色彩,读者仿佛在现场亲历作者给出人设的场景。正如作者反驳读者评论「恕我直言,这语言障碍症不轻啊。」所言「我是写文学作品的」。

\n

注:「有个妹妹,是天依」用「是」分隔同位语。类似地,《第一话》「天气是阳光明媚」,分隔主语、谓语。(与本文主题无关,为帮助理解引文的说明,以「注:」标识。)

\n
\n

铃丰社团四个成员,是小林、小海、小冰、灰哥是剑道社副社长,你一起打进比赛朋友吗。

\n
\n

「你」这里指代「铃丰」,凸显了作者给主角设定了一个朋友。

\n

注:这里的「是」仍然是分隔同位语「灰哥」和「剑道社副社长」。「吗」为语气词,不表疑问,为陈述语气。

\n
\n

铃丰在学校里面喜欢女同学,你叫未来,是在班上喜欢的。

\n
\n

这里「你」指代女同学,「是在班上喜欢的」补充说明「在学校」。\n注意这里「未来」用了「你」,而前一句没有用「你」。\n「铃丰,你在学校里面喜欢女同学」,会突出铃丰喜欢女同学是作者设定,\n而作者并不想突出这一点,所以没用「你」。\n也就是说,虽然作者喜欢用「你」突出虚构性,\n但是铃丰作为第一主角,作者将自己代入了,如作者本人所说「铃丰感觉,就是我的感觉」。\n因此不希望铃丰的感情是虚构的。\n对比前文天依、灰哥,可见妹妹、朋友只是设定,并不是作者最关心的。

\n

第一话

\n
\n

... 未来感觉大家好想和我一起坐“救命啊,可以不要太多一起坐”,

\n
\n

「感觉」引出主语的心理活动。引号用于标识心理活动中的内心独白。

\n

注:「未来」为女主角人名。「救命啊,可以不要太多一起坐」体现了异于通常语法的省略。

\n
\n

她感觉感觉看到男生“真的好帅气”“老师你叫什么名字”,

\n
\n

第一个「感觉」引出主语的心理活动,第二个「感觉」强调是主观感觉。\n表面重复,其实不重复。

\n

这里的「你」指代看到的男生(实为男主),而不是老师。\n这里「(帅气男生)你叫什么名字」中的「我」不是作者本人,而是女主「未来」。\n女主实际会说「老师他叫什么名字,以免老师误以为是问老师自己的名字,\n但是在文本是写为「你」,这一语法体现了女主虽然表面是问老师,实际心里是在和男主「对话」。

\n

这两个语法特征都是突出心理活动的。正如作者本人所说「我是把心理面,全部写出来」。

\n

当然,还有一种可能成立的解释,女主实际也说「老师你叫什么名字」,\n在现实中可能导致误解,但因为女主和老师都是作者虚构的人物,当然知道对方在说什么。\n用「你」指代男主,仍体现女主心里是在和男主「对话」。

\n
\n

老师感觉“你说是谁”,

\n
\n

这里的引号标识的是说出来的话,前面的「感觉」,表明这话正是老师心里所想,\n换言之,是说出来的内心独白。\n老师作主语,与未来对话,从老师的角度,当然用「你」。\n这种一致性说明老师说出来的话和其内心话语是一致的。

\n
\n

未来感觉不知道我说什么“我指给你看”,就指了过去,老师感觉看到未来手指头,就知道是谁

\n
\n

这里的「感觉」突出「看到未来手指头,就知道是谁」是老师的想法

\n
\n

老师感觉“是不是好想铃丰坐在一起”,未来感觉“没有啊,我只是想知道你的名字”\n老师感觉看到好想没什么位子,就说道:“不要啊,你真的帅了”,

\n
\n

这里的「你」仍指男主,表明老师也真心觉得男主帅,表面对女主说,心里是对男主说。

\n

注:「不要啊」省略「不想和铃丰坐在一起」。

\n
\n

... 未来感觉想写告白,因为我想在舞台上和铃木告白,\n你写出歌名,还在继续写歌词了。

\n
\n

这里「你」强调作者在进行设定。\n上一句用「我」,突出告白是未来自己的意愿(不想在此处突出女主喜欢男主是作者设定),\n写歌由于和人设密切相关,所以用「你」。

\n

同类的例子有《序章》第一句话:

\n
\n

铃丰感觉“我叫铃丰,是高一学生,也是学校里面的老同学”\n铃丰感觉没有一个在学校的女同学知道你是肌肉的身体和台湾的脸型,\n在你们女生面前,我就是一个男神“真的好帅气”,也不知道有多少女同学喜欢上我,

\n
\n

这里肌肉身体、台湾脸型,用「你」突出是人设。\n「在你们女生面前,我就是一个男神」,和「不知道有多少女同学喜欢上我」同样是不想突出男神是作者设定。\n「高一学生,也是学校里面的老同学」本来是设定,但因为前面是「我叫铃丰」,也连带不用「你」了,\n这样也更像内心独白的自我介绍。姓名和个人密切相关,例如「张三」给人虚构的感觉,因此不用「你」。

\n

如前所述,不想用「你」突出虚构性是为了避免影响代入性。\n实际上,这一语法也起到了区分可代入部分和难代入部分的作用。\n很多男性读者会代入「男神」,「不知道有多少女同学喜欢上我」,较少代入「肌肉身体」,很少代入「台湾脸型」。

\n

结论

\n

《铃丰的恋物语与剑道社》独特的语法,很多只是作者的习惯,例如作者在评论(接近日常语言)中说「在学校同学,对我说不喜欢话」,一般习惯在「在学校」后断句,作者在「同学」后断句,说明作者习惯上认为主语和谓语间隔较远,作品中用「是」区隔主语、谓语正体现作者这一习惯。

\n

但用「感觉」引出心理活动,用「你」展现人物的内心话语,则体现了作者对「心理面」描写的注重。\n用「你」体现人设的虚构性,起到区分可代入与难以代入成分的作用,可视为对读者「心理面」的描写。

\n

作者在回复《铃丰的恋物语与剑道社》读者评论时提出了对日本轻小说的文学批评:

\n
\n

我自己一开始看日本轻小说,什么看的吗,\n用了三种方法,第一个看到,第二个想到,第三个是感觉。\n我用三种方法去看,发现日本轻小说,是用感觉来写的轻小说的。

\n
\n

姑且不论这一批评观是否合理,至少能说明「用感觉来写」是作者的文学创作追求,「用感觉来读」是作者认可的阅读方法。

\n

用「感觉」引出心理活动,用「你」展现人物的内心话语,注重对人物「心理面」的描写,体现了作者「用感觉来写」的文学创作追求;用「你」体现人设的虚构性,起到区分可代入与难以代入成分的作用,可视为对读者「心理面」的描写,是作者促使读者「用感觉来读」文学创作尝试,与「用感觉来写」相呼应。

","date_published":"Thu, 24 Aug 2017 13:13:54 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/dapi/jyqxz3-gumu/","url":"https://mmap.page/dapi/jyqxz3-gumu/","title":"金庸群侠传3古墓版攻略","content_html":"

金庸群侠传3古墓版攻略

\n

建立角色篇

\n

删除名字,姓名会成为隐藏【半瓶神仙醋】,基础属性附加额外5点属性值。\n如果不喜欢这个名字可以不改,反正后来学了玉女心经各属性会补满的。

\n

由于《玉女心经》研习不加福缘,因此为了入古墓派,福缘要大于 69,\n如果不想辛苦钓鱼的话,分配属性点和回答问题时要注意了。\n如果希望属性全满,分配属性时确保福缘 28(分配属性点,不够或者超过的\n重选属性点,有金2存档时福缘 18)。

\n

注:常见的攻略都说福缘大于 80,其实是 69.\n在 root.swf/DefineSprite2754/frame185 中有

\n
if(_root.body[19] > 69)\n{\n    gotoAndStop(188);\n}\nelse\n{\n    gotoAndStop(186);\n}\n
\n

回答问题

\n

1.【半瓶神仙醋】 基本属性 +2,福缘 30.\n2. 保留存档时,【不知道】或【当然保留着】,基本属性 +10、武功属性 +5、银两 +1000、修为点 +10.\n3.【极端的工作狂人】 修为点 +1\n4. 随便\n5. 选【寒冰真气】,侠义 -10,选其他练习经验会减少。由于玉女心经招式以自创为基础,因此不要选【自创】。\n6. 选 1-4项,对应角色好感度 -20.\n7. 有存档且第 2 题正确回答,选 1,现有的基本拳、指、剑、刀、暗 10 级;选 2,龟息功 1 级;选 3,随机武器;\n选4,得皮甲。\n8. 选【家道中落,流浪街头】,福缘 +20,福缘 50.\n9. 选【拳掌】,【拳掌】属性 +15-25. 因研习玉女心经后武功属性都会补满。而研习前在古墓学两种拳掌、一种暗器。\n10. 不要选【福缘】,否则浪费。\n11. 选【资质异常低劣】,福缘 +50, 福缘 100.\n12. 选 1 侠义 -15,选 2 定力 -8,选 3 侠义 -30、悟性 +3,选 4 侠义 -10,悟性 +1.\n13. 选 1 定力 -8,选 2 武功属性各 -2,选 3 基本属性 -5,选 4 悟性 -6. 不要选 3,否则福缘不满了。\n14. 选 1 侠义 -5、定力 -5,选 2 悟性 -3,选 3 金钱 -500,选 4 福缘 -20, 选 5, 生命减去1/3.\n不要选 4, 否则福缘不满。建议选 3,只有第一天能进全真,钱多了无用,除非要买吃的给乞丐丙(黄蓉)。\n15. 相应角色好感度增加 20.\n16. 选 1 失去所有金钱和物,只剩下金钱100 (超级存档的物品不受影响,金钱照样扣);选 2 侠义 -50;\n选 3 武功属性 -4、2;选 4 悟性 -20.

\n

入全真

\n

第一天午时至酉时是入全真的唯一机会,不要睡觉。

\n

砍树消磨时光:砍树加力道,捕猎抓够一定毒虫可找何红药得蜈蚣爪和千蛛手,基本来不及,而且这两门武功无用,\n除非你想连六脉神剑,需要搜集指法加指力),钓鱼钓到特殊鱼加福缘,然而福缘已经满了,而且砍树只要狂点即可(游戏有 bug,看着时机点反而不如狂点效果好),比捕猎、钓鱼快。

\n

午时至酉回村遇官差敲诈事件,上前阻挡被秒杀,力道、根骨减半。

\n

丘处机出现,醒来后马上去树林找他,加入全真派。

\n

回答问题,除了最后一个最下流无耻的选赵志敬以外,其他全不选赵志敬,这样赵志敬只给你全真心法,不会传全真剑法。\n也不要找赵志敬切磋连胜 10 次得全真剑法。学了全真剑法就去不了古墓了。可找甄志丙学金雁功,这个学了没关系,学了\n也没什么大用。

\n

到大殿找丘处机不断养生,算好时机,剩下的时间休息,3 月 1 日(只要是 3 月就可以,选 1 日可以在全真少呆点\n几日,在古墓多呆点时间)比武,第一个随便,第二个必须输。

\n

入古墓

\n

输后争吵、逃跑、被玉蜂蜇,醒后选择以死相逼,成为古墓派弟子。

\n

因某些古墓功夫需前置武功达到一定级别才传授,而升级只能与小龙女切磋。因此先修炼寡欲至顶级,\n再研习全真心法,升到顶级,装备。这样生命、内力较高,切磋时可以支持得较久。

\n

小龙女传天罗地网掌,切磋至 9 级,传捕雀功。捕雀功升到 5 级并装备,传掷针术。\n掷针术 7 级传美女拳法。

\n

继续与小龙女切磋,磨练天罗地网掌与美女拳法。胜利后小龙女实力增强,有 1/5 概率得玉蜂浆。

\n

随着切磋不断获胜,小龙女实力也不断增强,直到无法战胜的程度。这时可以再修炼寡欲,虽然寡欲等级不会再提升,\n但是等级会随之提升。只是要注意算好时间,12 月 15 日后李莫愁会来古墓。若想在古墓多呆 15 日,可以在 12 月\n14 日修炼寡欲 15 天。

\n

出古墓

\n

与李莫愁一战,不论输赢,小龙女都会说打不过师姐快走。

\n

然后会获得玉女心经。玉女心经到手,闯荡江湖、通关无忧。这时选离开便能出古墓,否则会在石棺得到半部九阴真经,\n同时看到密道提示,提示有三种:

\n
    \n
  1. 【东.东.西.北.东.西】
  2. \n
  3. 【西.东.南.北.东.西】
  4. \n
  5. 【南.北.南.北.东.西】
  6. \n
\n

最后一个需赌 1/2 的可能性:

\n
    \n
  1. 东或北
  2. \n
  3. 东或西
  4. \n
  5. 南或北
  6. \n
\n

出古墓后被传送到聚贤庄,然后研习玉女心经,脱胎换骨。自此以后随意:如果想通关,可以马上征服一批门派攒够声望,\n上华山之巅即可;如果想做公告任务,那就做。

\n

注: 常见的攻略有的说最后一个是随机的,其实固然是随机的,却不是 4 个方向随机。还有的说东、北概率较大,确实如此,但不够精确:若是第 2 种,则断不会是北;若是第 3 种,则断不会是东。

","date_published":"Thu, 24 Aug 2017 13:06:40 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/dapi/jyqxz3-cheat/","url":"https://mmap.page/dapi/jyqxz3-cheat/","title":"金庸群侠传 3 作弊教程","content_html":"

金庸群侠传 3 作弊教程

\n

修改原理

\n

金庸群侠传3是 Flash 游戏,修改 SOL(Flash Shared Object) 存档。

\n

SOL 存档的位置(Windows):

\n
C:\\Documents and Settings\\用户名\\Application Data\\Macromedia\\Flash Player\\\n#SharedObjects\\随机字母数字\\游戏网址目录\\JY1.sol\n
\n

Linux:

\n
~/.config/google-chrome/Default/Pepper Data/Shockwave Flash/\nWritableRoot/#SharedObjects/随机字母数字/游戏网址目录/JY1.sol\n
\n

如下载到本地玩,游戏网址目录是 localhost 或 #localhost。

\n

修改工具

\n

tl;tr

\n

会 Python 的用 pyamf,不会 Python 的学一下或者组合使用以下工具:

\n\n

金庸3人物属性修改器

\n

针对金庸群侠传3的修改器,阿平工作室出品。

\n

缺陷

\n
    \n
  1. 点击保存后实未保存,需退出程序方保存成功。
  2. \n
  3. 只能修改本地存档(在线存档可通过移动复制的方法修改)。
  4. \n
  5. 只能修改姓名、等级、经验、名望、侠义值、属性、金钱等。
  6. \n
  7. 姓只能修改为单字。
  8. \n
\n

soleditor

\n

.sol editor 是开源的 SOL 修改器。

\n

缺陷

\n
    \n
  1. 修改保存后 SOL 文档载入游戏后黑屏。
  2. \n
  3. 无查找功能。
  4. \n
\n
测试环境
\n\n

minerva

\n

minerva 是在线 SOL 编辑器。

\n

缺陷

\n\n

flash游戏存档修改器

\n

flash游戏存档修改器是由 cordy 开发的修改器,目前最新版本为 v1.5.

\n

缺陷

\n
    \n
  1. 不支持 Windows 8.
  2. \n
  3. 所有变量一张表,无层级显示,不支持按路径排序,不支持按路径搜索。
  4. \n
  5. 无法删除变量。
  6. \n
\n

窍门

\n

如已知变量路径及类型,可直接添加变量,原变量数值将被覆盖,不必辛苦翻找修改。

\n

flash游戏修改大师

\n

flash游戏修改大师同样由 cordy 开发,目前最新版本为 3.2.

\n

缺陷

\n
    \n
  1. SOL 修改功能比flash游戏存档修改器还弱,除了无层级显示、不支持按路径排序、不支持按路径搜索外,无法新增删除变量。
  2. \n
  3. flash 文件修改功能不兼容金庸群侠传3 贺岁版。
  4. \n
\n

pyamf

\n

pyamf 是可以读写 SOL 的 Python 模块。

\n

示例代码

\n

pyamf 使用很简单,只需掌握 load 和 save 两个方法,具体例子看官方教程

\n

下面给出用 Hy 写的例子:

\n
(import [pyamf [sol]])\n(import os)\n(require hy.contrib.anaphoric)\n# 存档路径\n(setv path (+\n  (get os.environ \"HOME\")\n  \"/.config/google-chrome/Default/Pepper Data/Shockwave Flash/WritableRoot/#SharedObjects/U5KVCX46/#localhost\"))\n(setv jy1_path (+ path \"/JY1.sol\"))\n# 读取存档一\n(setv jy1 (sol.load jy1_path))\n# 经脉齐通\n(setv jm (get jy1 \"n\"))\n(ap-each jm (assoc jm it 1))\n# 保存\n(sol.save jy1 jy1_path)\n
\n

soltool

\n

soltool 是一个基于 pyamf 的命令行 SOL 读写工具。

\n

缺陷

\n

no attribute 'amf0' 错误:

\n
Traceback (most recent call last):\n  File \"~/bin/soltool\", line 328, in <module>\n    main()\n  File \"~/bin/soltool\", line 320, in main\n    ns.cmd(ns)\n  File \"~/bin/soltool\", line 203, in _view\n    name, values = pyamf.sol.decode(stream)\n  File \"/usr/local/lib/python2.7/dist-packages/pyamf/sol.py\", line 64, in decode\n    decoder = pyamf.get_decoder(stream.read_uchar())\n  File \"/usr/local/lib/python2.7/dist-packages/pyamf/__init__.py\", line 518, in get_decoder\n    return _get_decoder_class()(*args, **kwargs)\n  File \"/usr/local/lib/python2.7/dist-packages/pyamf/__init__.py\", line 508, in _get_decoder_class\n    amf0 = _get_amf_module(AMF0, use_ext=use_ext)\n  File \"/usr/local/lib/python2.7/dist-packages/pyamf/__init__.py\", line 493, in _get_amf_module\n    return getattr(module, module_name)\nAttributeError: 'module' object has no attribute 'amf0'\n
\n

估计是因为 soltool 比较老,和现在的 pyamf 不兼容。

\n

ruby_sol

\n

ruby_sol 是一个读写 SOL 的 Ruby Gem。

\n

缺陷

\n\n

示例代码

\n
require 'ruby_sol'\n\n# 存档路径\npath = \"#{ENV['HOME']}/.config/google-chrome/Default/Pepper Data/Shockwave Flash/WritableRoot/#SharedObjects/U5KVCX46/#localhost\"\n# 读取存档一\njy1 = RubySol::read_sol(File.new(\"#{path}/JY1.sol\").read)\n# 已知 `Hp` 为生命,查询还有哪些值与生命相关。\njy1.each do |k, v|\n  # 注意 ruby_sol 使用类哈希表而非列表\n  if v.is_a? RubySol::Values::TypedHash\n    v.each do |kk, vv|\n      if vv == jy1['Hp']\n        puts \"jy1['#{k}']['#{kk}'] => #{vv}\"\n      end\n    end\n  end\nend\n# 经脉齐通\njingmai = jy1['n']\n# 注意,ruby_sol 使用哈希表浮点数而非整数\njingmai.each_key do |k| jingmai[k] = 1.0 end\n# 保存后的存档读取后无法习得武功。\nopen(\"#{path}/JY2.sol\", 'w') do |f|\n  f.write(RubySol::create_sol(jy1))\nend\n
\n

变量列表

\n

个人基本资料

\n

个人基本资料储存在列表 m.

\n
1 姓\n2 名\n3 经验 (平时为数字,封顶为字符串`经验封顶`)\n4 等级 (游戏中 100 封顶,实际可改为任意值)\n5 修为点 (类似金钱,可贯通经脉、转化内力生命属性、修炼武功)\n8 门派 (可改为任意值)\n9 门派位阶 (可改为任意值)\n10 门派技能 (可改为任意值)\n11 技能等级 (10 封顶,超过 10 显示不正常)\n12 师承 (可改为任意值)\n13 妻室 (可改为任意值)\n14 名望\n15 侠义\n16 力道 (16-37 100 封顶)\n17 根骨\n18 悟性\n19 福缘\n20 灵敏\n21 定力\n22 拳掌之功\n23 弹指之力\n24 御剑之术\n25 耍刀之法\n26 舞棍之能\n27 内功修为\n28 拆招卸力\n29 搏击格斗\n30 闪躲纵跃\n31 轻身之法\n32 施毒之术\n33 医疗之术\n34 暗器技法\n35 读书识字\n36 交易之道\n37 烹饪之道\n41 是否阉割(0 未阉割,1 阉割)\n42 正在研习的秘籍\n50 自创武功名称\n52-55 四名队友 (可为任意 npc,npc 列表见下,可为同一人)\n67 休息前最后使用的招式\n110 金钱\n120 年 (数字,最大 10)\n121 月 (数字)\n122 日 (数字,每月均为 30 日)\n123 时辰 (数字)\n124 时刻 (数字)\n128 当前场景帧 (直接跳转到事件,注意某些数值可能错误,例如生命 undefiend,招式无法使用等,休息后恢复正常)\n139 游戏进程 (例如`序幕2`、`初入少林`、`叛出全真`、`聚贤庄`等)\n140 地点 (例如`酒 店`、`少林派`、`聚贤庄`等)\n147-150 每月公告任务 (代号见后)\n
\n

生命、内力、等级

\n

由于某些内功可增加生命、内力,因此修改生命内力时需装备不加生命、内力的内功,例如自创。\n然后修改以下数值为 99999.

\n\n

玩家当前生命、内力 99999 封顶。生命、内力若恰好为 99999,则受伤害、耗内力会正常扣血、内力。\n一旦生命、内力超过 99999 (例如 100000),则生命、内力锁定为 99999,换言之,受伤害、耗内力后\n瞬间回复至 99999。战斗时开着人物面板,有时能看到受伤害生命值 99999 抖动。唯一一个例外,损耗超过\n99999,则打破锁定。因此对方一击带来的伤害超过 99999,则立时致死。暂时没碰到实力如此强悍的敌人,\n故 99999+ 基本等于锁定。只是我把己方队友属性改到了 900,因此切磋时若闪避、拆招皆不成功立死。\n同理,我自己配玉女、凌波,五属性也有 99x,因此队友若闪拆不成亦立死。总之战斗的情况是要不闪避、要不\n个位数伤害、要不一招致命。

\n

生命原始值为 100000,配上加生命的内功会溢出,一受轻微伤害即死。故生命原始值当改为 99999。

\n

每个等级对应的经验储存在数组 d 中。所有拥有过的江湖绰号储存在列表 e 中。

\n

回到开始

\n\n

物品

\n

背包中的物品储存在列表 f 中。每种物品的数量储存在列表 g 中。

\n

例如,f[0] = 29; g[29] = 2 表示背包第一格中有倚天剑 2 把。

\n

物品快捷储存在列表 i 中。

\n
2 木剑\n3 假倚天剑\n4 玉箫剑\n5 铁剑\n6 纯钢剑\n7 西洋剑\n8 碧水剑\n9 龙泉剑\n10 冷凝剑\n11 凝碧剑\n12 火龙剑\n13 松纹剑\n14 紫薇软剑\n15 白剑\n16 黑剑\n17 秦王剑\n18 龙渊剑\n19 白龙剑\n20 君子剑\n21 淑女剑 (可赠小龙女,游戏中有 bug,对话中要求馈赠淑女剑,实际收取的是君子剑)\n22 金蛇剑\n23 楚王剑\n24 夫差剑\n25 真武剑\n26 工布剑\n27 巨阙剑\n28 玄铁剑\n29 倚天剑 (除特定剑法宝剑组合外,威力最强)\n\n30 菜刀\n31 生锈铁刀\n32 单刀\n33 柳叶刀\n34 雁翎刀\n35 斩马刀\n36 九环刀\n37 屠牛刀\n38 破风刀\n39 天竺弯刀\n40 鬼头刀\n41 龙王刀\n42 穿云刀\n43 百辟刀\n44 金背大刀\n45 紫金八卦刀\n46 金貂刀\n47 血刀\n48 绿波香露刀\n49 金刀\n50 银弧刀\n51 狮头宝刀\n52 百炼宝刀\n53 虎头金刀\n54 冷月宝刀\n55 屠龙刀\n\n56 木棍\n57 狼牙棒\n58 盘龙棍\n59 打狗棒\n60 黄金杵\n61 西毒蛇杖\n62 杀狮杖\n\n63 飞镖\n64 柳叶飞刀\n65 金钱镖\n66 毒菱\n67 玉蜂针\n68 黑血神针\n69 生死符\n70 金蛇锥\n71 霹雳雷火弹\n72 火枪\n\n73 皮甲\n74 鳄鱼皮甲\n75 软猬甲\n76 乌蚕衣\n77 金丝背心\n78 布衣\n79 乞丐服\n80 虎裙皮\n81 棉衣\n82 将军甲衣\n83 黄金甲\n84 明教服饰 (征服门派时穿戴各派服饰可乔装混进直接找掌门)\n85 女装\n86 全真服饰\n87 日月教服饰\n88 少林派服饰\n89 神龙教服饰\n90 武当道袍\n91 夜行衣 (可混进少林寺藏经阁)\n\n92 葵花宝典 (武功可直接修改,不必修改物品再研习)\n93 辟邪剑法\n94 易筋经\n95 紫霞秘籍\n96 六脉神剑\n97 九阳真经\n98 胡家刀法\n99 金蛇秘笈\n100 神照经\n101 太极拳经\n102 毒经\n103 五毒秘传\n104 武穆遗书\n105 血刀秘笈\n106 药王神篇\n107 子午针灸图\n108 凌波微步\n109 北冥神功\n110 铁掌掌谱\n111 神木王鼎\n112 八荒六合功\n113 七伤拳谱\n114 乾坤大挪移\n115 少林绝技\n116 十八泥偶\n117 千金方\n118 九阴上卷\n119 九阴下卷\n120 峨眉九阳功\n121 玉女心经(可赠小龙女)\n122 斗转星移\n123 先天功\n124 少林九阳功\n125 武当九阳功\n126 龙象波若功\n127 梯云纵\n128 一苇渡江\n129 漫天花雨\n130 青字九打\n131 修罗刀法\n132 松风剑法\n133 狂风刀法\n134 玉女素心剑\n135 回风拂柳剑\n136 柴刀十八路\n137 峨眉心法\n138 华山心法\n139 全真心法\n140 武当心法\n141 太极劲\n142 神龙心法\n143 苗家剑法\n144 玉女十九剑\n145 神门十三剑\n146 绕指柔剑\n147 密宗内功\n148 段氏心法\n\n149 八宝肥鸭\n150 醋溜鱼\n151 洱海工鱼干\n152 咕噜肉\n153 煎豆腐\n154 煎饺\n155 佛跳墙\n156 好逑汤\n157 酱爆牛肉\n158 椒盐排骨\n159 叫花鸡\n160 烤玉米\n161 口菇鸡脚汤\n162 口菇焖鸡\n163 老鸭汤\n164 馒头\n165 烧饼\n166 双禽炒白菜\n167 素三鲜\n168 汤圆\n169 天麻鸽脯\n170 虾仁芝麻卷\n171 鲜笋炒豆芽\n172 香烹蜈蚣\n173 扬州炒饭\n174 银耳莲子粥\n175 油条\n176 玉笛听落梅\n177 鸳鸯五珍烩\n178 月饼\n179 炒鳝丝\n180 炸田鸡腿\n181 蒸豆腐\n182 蒸饺\n183 炙牛肉条\n184 煮鸡蛋\n185 粽子\n186 醉蟹\n187 关外白酒\n188 女儿红\n189 葡萄酒\n190 高粱酒\n191 百草美酒\n192 状元红\n193 梨花酒\n194 烧刀子\n195 玄冰碧火酒\n196 三锅头汾酒\n197 玉露酒\n198 五宝花蜜酒\n199 迷春酒\n200 毒酒\n201 洞庭碧螺春\n202 武夷黄金桂\n203 安溪铁观音\n204 黄山毛峰\n205 六安瓜片\n206 银针白毫\n207 西湖龙井\n208 大红袍\n209 太平猴魁茶\n210 君山毛尖\n211 安溪毛蟹\n212 朱睛冰蟾\n213 天山雪莲\n214 大蟠桃\n215 千年人参\n216 寒塘白鱼\n217 蛇胆\n218 熊胆\n219 玉真散\n220 三黄宝腊丸\n221 天心解毒丸\n222 六阳正气丸\n223 玉灵散\n224 大还丹\n225 无常丹\n226 九花玉露丸\n227 田七鲨胆散\n228 天香断续胶\n229 白云熊胆丸\n230 回阳五龙膏\n231 玉洞黑石丸\n232 九转灵宝丸\n233 九转熊蛇丸\n234 玉蜂浆 (可赠小龙女)\n235 雪参玉蟾丸\n236 牛黄血竭丹\n237 黄连解毒丸\n238 腊八粥\n239 小还丹\n240 镇心理气丸\n241 茯苓首乌丸\n242 生生造化丹\n243 续命八丸\n244 黑玉断续膏\n\n245 笑傲江湖曲谱\n246 正红旗\n247 镶红旗\n248 正蓝旗\n249 镶蓝旗\n250 正黄旗\n251 镶黄旗\n252 正白旗\n253 镶白旗\n254 黑木令\n255 五岳令牌\n256 西山行旅图\n257 呕血谱\n258 率意帖\n259 广陵散\n260 圣火令\n261 赏善罚恶令\n262 七宝指环\n263 七星海棠\n264 闯王宝藏\n265 唐诗选辑\n266 可兰经\n267 宝箱\n268 镖物\n269 书信1\n270 书信2\n271 书信3\n272 书信4\n273 龙脉宝藏\n274 擂鼓山请帖\n275 人皮面具\n\n276 银两\n277 弓箭\n278 剥皮刀\n279 锄头\n280 柴火\n281 铁镐\n282 鱼竿\n283 十香软筋散\n284 断肠草\n285 金银小蛇\n286 蝮蛇\n287 五彩蜘蛛\n288 莽牯朱蛤\n289 冰蚕\n290 小金蛇\n291 蝎子\n292 蜈蚣\n293 毒蛛\n294 蟾蜍\n295 大公鸡\n296 羊羔坐臀\n297 小猪耳朵\n298 小牛腰子\n299 獐腿肉\n300 兔肉\n301 荷花\n302 笋尖\n303 樱桃\n304 白菜\n305 鸭掌\n306 火腿\n307 豆腐\n308 华山蜈蚣\n309 鱼干\n310 铁矿\n311 铜矿\n312 红晶矿\n313 蓝晶矿\n314 白晶矿\n315 玄铁矿\n316 蓝宝石\n317 红宝石\n318 蚯蚓\n319 河蚌\n320 海螺\n321 草鱼\n322 鲤鱼\n323 娃娃鱼\n324 黄金鱼\n325 螃蟹\n326 鳖\n327 鹿皮\n328 虎皮\n329 熊掌\n330 虎掌\n331 野猪肉\n332 熊皮\n333 野猪皮\n334 油\n335 盐\n336 醋\n
\n

武功

\n

类似背包,武功被存放于以下列表:

\n
o 掌拳\np 指法\nq 剑法\nr 刀法\ns 棍法\nt 暗器\nu 内功 (自创武功在游戏界面中位于【其他】,其实属于内功)\nv_1 轻功\nw 其他\n
\n

类似物品数量,轻功、内功等级储存于列表 x 中,除了轻功、内功、其他之外的武功经验值储存于列表 v 中,\n内功招式经验值亦储存于列表 v 中。

\n

列表 v 中的经验值建议改为 999,再大效果不明显。

\n

列表 x 为等级,游戏中 5 级封顶,升级至 5 级后无法再升级。实际可改得更大,\n修改为超过 5 级后可在游戏中升级。

\n

招式快捷键存放于列表 h 中。

\n

特别地,h[7] 可以改为无招式内功代号,如此则会显示相应内功图片(默认无招式内功不显示图片),\n若按快捷键,则出现招式 undefined,然后开始飘樱花(无实际效果)。\n或者,h[7] 可以修改为招式(先前装备的内功仍然有效),若内功无招式,可多出一个招式。\n不过一旦在游戏中装备内功,则 h[7] 会自动更新。

\n

此外,h中的代码为内功代表内功中的招式,所以装备多内功不可能,但是可以使用多种内功的招式:\n例如招式中包括加血的龟息功、复活的神照、吸内力的北冥、群攻的八荒等等。

\n

武功效果:游戏的 skill 文件夹下是每种武功的画面效果,通过复制、重命名的方法可以修改武功效果。

\n

掌拳

\n
66.黯然销魂掌 67.白虹掌 68.白驼雪山掌 69.般若掌 70.碧波清掌 71.冰蚕神掌\n72-75.长拳 76.赤炼神掌 77.抽髓掌\n78.春蚕掌法 79.摧心掌 80.大力金刚掌 81.寒冰绵掌 82.化骨绵掌 83.火焰刀\n84.基本拳掌 85.降龙十八掌 86.金蛇游身掌 87.空明拳 88.灵蛇拳 89.罗汉拳\n90.落英神剑掌 91.美女拳法 92.美女三招 93.绵掌 94.南山掌法 95.劈空掌\n96.七伤拳 97.如来千叶手 98.三化聚顶掌 99.太极拳 100.天长掌法\n101.天罗地网掌 102.天山六阳掌 103.天山折梅手 104.铁掌 105.铜锤手\n106.五罗轻烟掌 107.五行六合掌 108.逍遥游(掌法) 109.须弥山掌\n110.野狐拳法 111.英雄三招(拳法) 112.震山铁掌 113.重阳神掌\n
\n

指法

\n
114.参合指 115.大力金刚指 116.分筋错骨手(指法) 117.虎爪绝户手(指法) 118.基本指法\n119.九阴白骨爪(指法) 120.兰花拂穴手 121.六脉神剑 122.龙爪功 123.拈花指 124.凝血神抓\n125.千蛛万毒手 126.三阴蜈蚣爪 127.锁喉擒拿手 128.无相劫指 129.一阳指 130.鹰爪擒拿手\n
\n

剑法

\n
33.百变千幻云雾剑法 34.辟邪剑法 35.冰雪剑法 36.达摩剑法 37.独孤九剑 38.段家剑法\n39.夺命连环三仙剑 40.华山剑法 41.回风拂柳剑 42.回风落雁剑 43.基本剑法 44.金蛇剑法\n45.快慢十七路 46.狂风剑法 47.苗家剑法 48.灭绝剑法 49.慕容剑法 50.宁氏一剑\n51.全真剑法 52.绕指柔剑 53.神门十三剑 54.松风剑法 55.太极剑法 56.太岳三青峰 57.躺尸剑法\n58.万花剑法 59.五大夫剑 60.五岳剑法 61.玄铁剑法 62.玉女剑法 63.玉女素心剑 64.玉萧剑法 65.越女剑法\n
\n

刀法

\n
10.柴刀十八路 11.胡家残刀 12.胡家刀法 13.火焰刀\n14.基本刀法 15.狂风刀法 16.慕容刀法 17.奇门三才刀\n18.燃木刀法 19.五虎断刀门 20.修罗刀法 21.玄虚刀法 22.血刀刀法\n
\n

棍法

\n
23.打狗棍法 24.伏魔杖法 25.基本棍法 26.叫化棍法 27.金刚降魔杵\n28.灵蛇杖法 29.慕容棍法 30.太祖棍 31.韦陀杖法 32.无上大力杵法\n
\n

暗器

\n
2.弹指神通 3.腐尸毒 4.基本暗器 5.满天星 6.漫天花雨 7.慕容暗器 8.掷针术 9.青字九打\n
\n

内功

\n
131.八荒六合唯我独尊功 132.北冥真气 133.蛤蟆功 134.龟息功\n135.化功大法 136.混元功 137.金刚不坏神功 138.九阳神功\n139.自创 140.葵花神功 141.龙象般若功(13) 142.乾坤大挪移(6)\n143.神龙心法 144.神照经 145.狮吼功 146.太玄经 147.吸星大法\n148.小无相功 149.紫霞神功 150.闭穴术 151.纯阳无极功 152.斗转星移\n153.段氏心法 154.峨眉九阳功 155.华山心法 156.叫化内功 157.逆转经脉\n158.九阴真经心法 159.罗汉伏魔功 160.密宗内功 161.全真心法\n162.少林九阳功 163.太极劲 164.桃花岛心法 165.武当功 166.先天功\n167.易筋经 168.玉女心经 169.紫薇心法\n
\n

(括号内为金庸小说中该武功的最高等级,其实和游戏设定无关。)

\n

注意:

\n\n

轻功

\n
170.八步赶蟾 171.北斗仙踪 172.捕雀功 173.飞檐走壁 174.华山身法\n175.金雁功 176.凌波微步 177.少林身法 178.神行百变 179.四象步法\n180.踏雪无痕 181.梯云纵 182.一苇渡江 183-186 undefined\n
\n

注意:

\n\n

其他

\n
187.毒雾 188.驱蜂术 189.星宿解毒术 190.左右互搏\n
\n

修改修为方法未知,可能无法修改。

\n

NPC 专用武功

\n

191.普通攻击 192.火枪术 193.混元掌 194.玄冥神掌 195.五轮大法\n196.阴阳捣乱刃 197.三僧鞭法 198.芷若鞭法 199. 易筋神功

\n

经验储存在列表 v 中。

\n

经脉

\n

经脉储存于列表 n 中,1 通,0 未通。

\n

最强武功

\n

单体:辟邪配倚天,玄铁剑法配玄铁剑,金蛇剑法配金蛇剑,胡家刀法配冷月宝刀,打狗棒法配打狗棒。

\n

其中辟邪速度最快,只需 1.5 格。

\n

剑、刀、棍可通用,甚至韦陀杖法配倚天优于配蟠龙棍。

\n

群体:独孤配倚天,六脉神剑次之。

\n

实际上属性改成 100-99x,内力改成 99999+,内功等级改成 10+,随便什么武功都是一招灭敌。

\n

唯一需要注意的是,改一个群体攻击的武功,这样人多的时候也可以秒杀。

\n

不配内功,属性值99、100,经验值999,配倚天剑,攻击萧峰,辟邪 6xxx、独孤 5xxx,\n八荒九阳易筋经 3000 出头、葵花 27xx、太玄 3500 出头,都差不多,画面效果八荒最美,易筋经最炫。\n自创秒杀,伤害溢出,具体原因未明。

\n

所有武功威力

\n

前十项为等级 1-10 时的威力,倒数第一个数字是内力消耗值,倒数第三个数字是攻击范围。

\n
Skills[2] = new Skill(\"弹指神通\",0.26,0.52,0.78,1.04,1.3,1.56,1.82,2.58,3.34,4.5,55,14,42,84,140,210,294,392,504,630,0,630,2,2,32,\"主角指1\",\"攻击\");\nSkills[3] = new Skill(\"腐尸毒\",0.18,0.36,0.54,0.72,0.9,1.08,1.26,1.44,1.62,2.5,45,9,29,58,97,146,205,273,352,440,0,440,2,0,17,\"主角指1\",\"攻击\");\nSkills[4] = new Skill(\"基本暗器\",0.13,0.26,0.39,0.52,0.65,0.78,0.91,1.04,1.17,1.8,35,6,18,37,62,93,130,174,224,280,0,280,2,0,12,\"主角指1\",\"攻击\");\nSkills[5] = new Skill(\"满天星\",0.15,0.3,0.45,0.6,0.75,0.9,1.05,1.2,1.35,2.2,60,11,34,69,115,173,242,323,416,520,0,520,5,0,26,\"主角指1\",\"攻击\");\nSkills[6] = new Skill(\"漫天花雨\",0.23,0.46,0.69,0.92,1.15,1.38,1.61,1.84,2.07,3,60,11,34,69,115,173,242,323,416,520,0,520,5,0,35,\"主角指1\",\"攻击\");\nSkills[7] = new Skill(\"慕容暗器\",0.16,0.32,0.48,0.64,0.8,0.96,1.12,1.28,1.44,2.8,35,9,29,58,97,146,205,273,352,440,0,440,2,0,23,\"主角指1\",\"攻击\");\nSkills[8] = new Skill(\"掷针术\",0.52,0.92,1.36,1.78,2.1,2.52,2.94,3.36,3.78,4.3,35,9,29,58,97,146,205,273,352,440,0,440,2,0,29,\"主角指1\",\"攻击\");\nSkills[9] = new Skill(\"青字九打\",0.21,0.42,0.63,0.84,1.05,1.26,1.47,1.68,1.89,2.8,35,9,29,58,97,146,205,273,352,440,0,250,2,2,25,\"主角指1\",\"攻击\");\nSkills[10] = new Skill(\"柴刀十八路\",0.14,0.28,0.42,0.56,0.7,0.84,0.98,1.12,1.36,3.6,45,9,29,58,97,146,205,273,352,440,0,440,2,0,17,\"主角刀1\",\"攻击\");\nSkills[11] = new Skill(\"胡家残刀\",0.16,0.32,0.48,0.64,0.8,0.96,1.12,1.28,1.44,3.8,55,11,34,69,115,173,242,323,416,520,0,520,2,0,15,\"主角刀2\",\"攻击\");\nSkills[12] = new Skill(\"胡家刀法\",0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,4.8,40,18,56,113,188,283,396,528,680,850,0,850,2,0,42,\"主角刀2\",\"攻击\");\nSkills[13] = new Skill(\"火焰刀\",0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,3.8,60,14,42,84,140,210,294,392,504,630,0,630,2,0,35,\"主角刀3\",\"攻击\");\nSkills[14] = new Skill(\"基本刀法\",0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,2,35,6,18,37,62,93,130,174,224,280,0,280,2,0,12,\"主角刀1\",\"攻击\");\nSkills[15] = new Skill(\"狂风刀法\",0.21,0.42,0.63,0.84,1.05,1.26,1.47,1.68,1.89,3.3,25,11,34,69,115,173,242,323,416,520,0,520,2,0,27,\"主角刀1\",\"攻击\");\nSkills[16] = new Skill(\"慕容刀法\",0.13,0.26,0.39,0.52,0.65,0.78,0.91,1.04,1.17,2.5,35,9,29,58,97,146,205,273,352,440,0,440,2,0,23,\"主角刀2\",\"攻击\");\nSkills[17] = new Skill(\"奇门三才刀\",0.19,0.38,0.57,0.76,0.95,1.14,1.33,1.52,1.71,2.2,55,9,29,58,97,146,205,273,352,440,0,440,2,0,18,\"主角刀2\",\"攻击\");\nSkills[18] = new Skill(\"燃木刀法\",0.24,0.48,0.72,0.96,1.2,1.44,1.68,1.92,2.16,2.7,50,14,42,84,140,210,294,392,504,630,0,630,2,0,37,\"主角刀3\",\"攻击\");\nSkills[19] = new Skill(\"五虎断门刀\",0.17,0.34,0.51,0.68,0.85,1.02,1.19,1.36,1.53,2.9,55,9,29,58,97,146,205,273,352,440,0,440,2,0,22,\"主角刀3\",\"攻击\");\nSkills[20] = new Skill(\"修罗刀法\",0.21,0.42,0.63,0.84,1.05,1.26,1.47,1.68,1.89,3.3,45,11,34,69,115,173,242,323,416,520,0,520,2,0,25,\"主角刀1\",\"攻击\");\nSkills[21] = new Skill(\"玄虚刀法\",0.24,0.48,0.72,0.96,1.2,1.44,1.68,1.92,2.16,3.7,65,14,42,84,140,210,294,392,504,630,0,630,2,0,30,\"主角刀2\",\"攻击\");\nSkills[22] = new Skill(\"血刀刀法\",0.28,0.56,0.84,1.12,1.4,1.68,1.96,2.14,2.42,4.1,40,16,50,100,166,250,350,466,600,750,0,750,2,0,38,\"主角刀3\",\"攻击\");\nSkills[23] = new Skill(\"打狗棒法\",0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,3,4.9,65,18,56,113,188,283,396,528,680,850,0,850,2,0,42,\"主角棍1\",\"攻击\");\nSkills[24] = new Skill(\"伏魔杖法\",0.18,0.36,0.54,0.72,0.9,1.08,1.26,1.44,1.62,3,60,14,42,84,140,210,294,392,504,630,0,630,2,0,27,\"主角棍2\",\"攻击\");\nSkills[25] = new Skill(\"基本棍法\",0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,2,35,6,18,37,62,93,130,174,224,280,0,280,2,0,12,\"主角棍1\",\"攻击\");\nSkills[26] = new Skill(\"叫化棒法\",0.16,0.32,0.48,0.64,0.8,0.96,1.12,1.28,1.44,2.8,40,9,29,58,97,146,205,273,352,440,0,440,2,0,20,\"主角棍3\",\"攻击\");\nSkills[27] = new Skill(\"金刚降魔杵\",0.21,0.42,0.63,0.84,1.05,1.36,1.57,1.78,1.99,3.4,55,14,42,84,140,210,294,392,504,630,0,630,2,0,28,\"主角棍2\",\"攻击\");\nSkills[28] = new Skill(\"灵蛇杖法\",0.27,0.54,0.81,1.08,1.35,1.62,1.89,2.16,2.43,4,40,11,34,69,115,173,242,323,416,520,0,520,2,0,30,\"主角棍2\",\"攻击\");\nSkills[29] = new Skill(\"慕容棍法\",0.13,0.26,0.39,0.52,0.65,0.78,0.91,1.04,1.17,2.5,35,9,29,58,97,146,205,273,352,440,0,440,2,0,23,\"主角棍3\",\"攻击\");\nSkills[30] = new Skill(\"太祖棍\",0.16,0.32,0.48,0.64,0.8,0.96,1.12,1.28,1.44,2.8,40,9,29,58,97,146,205,273,352,440,0,440,2,0,17,\"主角棍2\",\"攻击\");\nSkills[31] = new Skill(\"韦陀杖法\",0.21,0.42,0.63,0.84,1.05,1.36,1.57,1.78,1.99,3.4,40,11,34,69,115,173,242,323,416,520,0,520,2,0,18,\"主角棍2\",\"攻击\");\nSkills[32] = new Skill(\"无上大力杵法\",0.24,0.48,0.72,0.96,1.2,1.44,1.68,1.92,2.16,3.7,55,14,42,84,140,210,294,392,504,630,0,630,2,0,38,\"主角棍3\",\"攻击\");\nSkills[33] = new Skill(\"百变千幻云雾十三剑\",0.24,0.48,0.72,0.96,1.2,1.44,1.68,1.92,2.16,3.7,58,14,42,84,140,210,294,392,504,630,0,630,2,0,29,\"主角剑1\",\"攻击\");\nSkills[34] = new Skill(\"辟邪剑法\",0.28,0.56,0.84,1.12,1.4,1.68,1.96,2.14,2.42,4.1,20,18,56,113,188,283,396,528,680,850,0,850,2,0,48,\"主角剑1\",\"攻击\");\nSkills[35] = new Skill(\"冰雪剑法\",0.21,0.42,0.63,0.84,1.05,1.26,1.47,1.68,1.89,3.3,45,9,29,58,97,146,205,273,352,440,0,440,2,5,17,\"主角剑2\",\"攻击\");\nSkills[36] = new Skill(\"达摩剑法\",0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,3.8,50,14,42,84,140,210,294,392,504,630,0,630,2,0,29,\"主角剑1\",\"攻击\");\nSkills[37] = new Skill(\"独孤九剑\",0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,3.1,4,45,18,56,113,188,283,396,528,680,850,0,850,5,0,25,\"主角剑1\",\"攻击\");\nSkills[38] = new Skill(\"段家剑法\",0.13,0.26,0.39,0.52,0.65,0.78,0.91,1.04,1.17,2.5,35,9,29,58,97,146,205,273,352,440,0,440,2,0,18,\"主角剑2\",\"攻击\");\nSkills[39] = new Skill(\"连环三仙剑\",0.22,0.44,0.66,0.88,1.1,1.32,1.54,1.76,1.98,3.5,40,14,42,84,140,210,294,392,504,630,0,630,2,0,29,\"主角剑3\",\"攻击\");\nSkills[40] = new Skill(\"华山剑法\",0.13,0.26,0.39,0.52,0.65,0.78,0.91,1.04,1.17,2.5,35,9,29,58,97,146,205,273,352,440,0,440,2,0,17,\"主角剑1\",\"攻击\");\nSkills[41] = new Skill(\"回风拂柳剑\",0.21,0.42,0.63,0.84,1.05,1.36,1.57,1.78,1.99,3.4,45,9,29,58,97,146,205,273,352,440,0,440,2,0,25,\"主角剑2\",\"攻击\");\nSkills[42] = new Skill(\"回风落雁剑\",0.22,0.44,0.66,0.88,1.1,1.32,1.54,1.76,1.98,3.5,48,14,42,84,140,210,294,392,504,630,0,630,2,0,29,\"主角剑3\",\"攻击\");\nSkills[43] = new Skill(\"基本剑法\",0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,2,35,6,18,37,62,93,130,174,224,280,0,280,2,0,12,\"主角剑3\",\"攻击\");\nSkills[44] = new Skill(\"金蛇剑法\",0.28,0.56,0.84,1.12,1.4,1.68,1.96,2.14,2.42,4.1,60,16,50,100,166,250,350,466,600,750,0,750,2,0,35,\"主角剑2\",\"攻击\");\nSkills[45] = new Skill(\"快慢十七路\",0.22,0.44,0.66,0.88,1.1,1.32,1.54,1.76,1.98,3.5,70,9,29,58,97,146,205,273,352,440,0,440,2,0,29,\"主角剑1\",\"攻击\");\nSkills[46] = new Skill(\"狂风快剑\",0.23,0.46,0.69,0.92,1.15,1.38,1.61,1.84,2.07,3.6,30,9,29,58,97,146,205,273,352,440,0,440,2,0,32,\"主角剑1\",\"攻击\");\nSkills[47] = new Skill(\"苗家剑法\",0.27,0.54,0.81,1.08,1.35,1.62,1.89,2.16,2.43,4,55,16,50,100,166,250,350,466,600,750,0,750,2,0,40,\"主角剑2\",\"攻击\");\nSkills[48] = new Skill(\"灭绝剑法\",0.22,0.44,0.66,0.88,1.1,1.32,1.54,1.76,1.98,3.5,50,14,42,84,140,210,294,392,504,630,0,630,2,0,33,\"主角剑3\",\"攻击\");\nSkills[49] = new Skill(\"慕容剑法\",0.11,0.22,0.33,0.44,0.55,0.66,0.77,0.88,0.99,2.3,35,9,29,58,97,146,205,273,352,440,0,440,2,0,23,\"主角剑3\",\"攻击\");\nSkills[50] = new Skill(\"宁氏一剑\",0.18,0.36,0.54,0.72,0.9,1.08,1.26,1.44,1.62,3,45,9,29,58,97,146,205,273,352,440,0,440,2,4,27,\"主角剑2\",\"攻击\");\nSkills[51] = new Skill(\"全真剑法\",0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,2.1,65,9,29,58,97,146,205,273,352,440,0,440,2,0,22,\"主角剑2\",\"攻击\");\nSkills[52] = new Skill(\"绕指柔剑\",0.16,0.32,0.48,0.64,0.8,0.96,1.12,1.28,1.44,2.8,70,11,34,69,115,173,242,323,416,520,0,520,2,0,26,\"主角剑1\",\"攻击\");\nSkills[53] = new Skill(\"神门十三剑\",0.21,0.42,0.63,0.84,1.05,1.36,1.57,1.78,1.99,3.4,65,14,42,84,140,210,294,392,504,630,0,630,2,0,32,\"主角剑1\",\"攻击\");\nSkills[54] = new Skill(\"松风剑法\",0.16,0.32,0.48,0.64,0.8,0.96,1.12,1.28,1.44,2.8,55,9,29,58,97,146,205,273,352,440,0,440,2,0,21,\"主角剑2\",\"攻击\");\nSkills[55] = new Skill(\"太极剑\",0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,4.5,75,16,50,100,166,250,350,466,600,750,0,750,2,0,22,\"主角剑2\",\"攻击\");\nSkills[56] = new Skill(\"太岳三青峰\",0.22,0.44,0.66,0.88,1.1,1.32,1.54,1.76,1.98,3.5,50,9,29,58,97,146,205,273,352,440,0,440,2,0,34,\"主角剑1\",\"攻击\");\nSkills[57] = new Skill(\"躺尸剑法\",0.14,0.28,0.42,0.56,0.7,0.84,0.98,1.12,1.36,2.6,60,9,29,58,97,146,205,273,352,440,0,440,2,0,22,\"主角剑3\",\"攻击\");\nSkills[58] = new Skill(\"万花剑法\",0.21,0.42,0.63,0.84,1.05,1.26,1.47,1.68,1.89,3.3,58,14,42,84,140,210,294,392,504,630,0,630,2,0,33,\"主角剑2\",\"攻击\");\nSkills[59] = new Skill(\"五大夫剑\",0.22,0.44,0.66,0.88,1.1,1.32,1.54,1.76,1.98,3.5,70,14,42,84,140,210,294,392,504,630,0,630,2,0,33,\"主角剑1\",\"攻击\");\nSkills[60] = new Skill(\"五岳剑法\",0.26,0.52,0.78,1.04,1.3,1.56,1.82,2.08,2.34,3.9,60,16,50,100,166,250,350,466,600,750,0,750,3,0,36,\"主角剑3\",\"攻击\");\nSkills[61] = new Skill(\"玄铁剑法\",0.31,0.62,0.93,1.24,1.55,1.86,2.17,2.48,2.79,4.5,65,18,56,113,188,283,396,528,680,850,0,850,2,4,45,\"主角剑1\",\"攻击\");\nSkills[62] = new Skill(\"玉女剑法\",0.12,0.24,0.36,0.48,0.6,0.72,0.84,0.96,1.08,2.4,55,11,34,69,115,173,242,323,416,520,0,520,2,0,24,\"主角剑2\",\"攻击\");\nSkills[63] = new Skill(\"玉女素心剑\",0.29,0.58,0.87,1.16,1.45,1.74,2.13,2.42,2.71,4.2,65,14,42,84,140,210,294,392,504,630,0,630,2,0,38,\"主角剑1\",\"攻击\");\nSkills[64] = new Skill(\"玉箫剑法\",0.14,0.28,0.42,0.56,0.7,0.84,0.98,1.12,1.36,2.6,45,11,34,69,115,173,242,323,416,520,0,520,2,0,28,\"主角剑2\",\"攻击\");\nSkills[65] = new Skill(\"越女剑法\",0.26,0.42,0.63,0.84,1.05,1.26,1.47,1.68,1.89,3.3,40,11,34,69,115,173,242,323,416,520,0,520,2,0,33,\"主角剑3\",\"攻击\");\nSkills[66] = new Skill(\"黯然销魂掌\",1.54,3.08,4.62,6.16,7.8,9.34,10.88,12.42,13.96,18,55,16,50,100,166,250,350,466,600,750,0,750,2,0,43,\"主角拳掌3\",\"攻击\");\nSkills[67] = new Skill(\"白虹掌\",1.54,3.08,4.62,6.16,7.8,9.34,10.88,12.42,13.96,17,50,11,34,69,115,173,242,323,416,520,0,520,2,0,37,\"主角拳掌2\",\"攻击\");\nSkills[68] = new Skill(\"白驼雪山掌\",1.23,2.46,3.69,4.92,6.15,7.38,8.61,9.84,11.07,13.6,65,14,42,84,140,210,294,392,504,630,0,630,2,0,26,\"主角拳掌4\",\"攻击\");\nSkills[69] = new Skill(\"般若掌\",0.89,1.78,2.67,3.56,4.45,5.34,6.23,7.12,8.01,10.8,30,8,26,52,86,130,182,242,312,390,0,390,2,0,17,\"主角拳掌2\",\"攻击\");\nSkills[70] = new Skill(\"碧波清掌\",1.41,2.82,4.23,5.64,7.05,8.46,9.87,11.28,12.69,15.6,50,14,42,84,140,210,294,392,504,630,0,630,2,0,32,\"主角拳掌3\",\"攻击\");\nSkills[71] = new Skill(\"冰蚕神掌\",1.57,3.14,4.71,6.28,7.85,9.42,10.99,12.56,14.13,17.3,60,14,42,84,140,210,294,392,504,630,0,630,2,5,35,\"主角拳掌4\",\"攻击\");\nSkills[72] = new Skill(\"长拳\",0.8,1.6,2.4,3.2,4,4.8,5.6,6.4,7.2,8.8,35,6,20,41,68,103,144,192,248,310,0,310,2,0,17,\"主角拳掌3\",\"攻击\");\nSkills[73] = new Skill(\"长拳\",0.8,1.6,2.4,3.2,4,4.8,5.6,6.4,7.2,8.8,35,6,20,41,68,103,144,192,248,310,0,310,2,0,17,\"主角拳掌3\",\"攻击\");\nSkills[74] = new Skill(\"长拳\",0.8,1.6,2.4,3.2,4,4.8,5.6,6.4,7.2,8.8,35,6,20,41,68,103,144,192,248,310,0,310,2,0,17,\"主角拳掌3\",\"攻击\");\nSkills[75] = new Skill(\"长拳\",0.8,1.6,2.4,3.2,4,4.8,5.6,6.4,7.2,8.8,35,6,20,41,68,103,144,192,248,310,0,310,2,0,17,\"主角拳掌3\",\"攻击\");\nSkills[76] = new Skill(\"赤炼神掌\",1.25,2.5,3.75,5,6.25,7.5,8.75,10,11.25,13.8,55,14,42,84,140,210,294,392,504,630,0,630,2,0,26,\"主角拳掌4\",\"攻击\");\nSkills[77] = new Skill(\"抽髓掌\",0.95,1.9,2.85,3.8,4.75,5.7,6.65,7.7,8.65,10.5,55,11,34,69,115,173,242,323,416,520,0,520,2,0,20,\"主角拳掌2\",\"攻击\");\nSkills[78] = new Skill(\"春蚕掌法\",1.02,2.04,3.06,4.08,5.1,6.12,7.14,8.16,9.18,11.3,65,11,34,69,115,173,242,323,416,520,0,520,2,0,32,\"主角拳掌2\",\"攻击\");\nSkills[79] = new Skill(\"摧心掌\",1.21,2.42,3.63,4.84,6.05,7.26,8.47,9.68,10.89,13.4,40,14,42,84,140,210,294,392,504,630,0,630,2,0,28,\"主角拳掌3\",\"攻击\");\nSkills[80] = new Skill(\"大力金刚掌\",1.45,2.9,4.35,5.8,7.25,8.7,10.15,11.6,13.05,16,55,14,42,84,140,210,294,392,504,630,0,630,2,4,38,\"主角拳掌1\",\"攻击\");\nSkills[81] = new Skill(\"寒冰绵掌\",1.31,2.62,3.93,5.24,6.55,7.86,9.17,10.48,11.79,14.5,60,11,34,69,115,173,242,323,416,520,0,520,2,5,33,\"主角拳掌3\",\"攻击\");\nSkills[82] = new Skill(\"化骨绵掌\",1.31,2.62,3.93,5.24,6.55,7.86,9.17,10.48,11.79,14.5,65,11,34,69,115,173,242,323,416,520,0,520,2,0,31,\"主角拳掌2\",\"攻击\");\nSkills[83] = new Skill(\"无\",0,0,0,0,0,0,0,0,0,0,2,3,10,20,33,50,70,93,120,150,0,150,2,0,1,\"主角拳掌3\",\"攻击\");\nSkills[84] = new Skill(\"基本拳掌\",0.57,1.14,1.71,2.28,2.85,3.42,3.99,4.56,5.13,6.3,35,6,18,37,62,93,130,174,224,280,0,280,2,0,12,\"主角拳掌3\",\"攻击\");\nSkills[85] = new Skill(\"降龙十八掌\",1.74,3.48,5.22,6.96,8.7,10.44,12.18,13.92,15.66,19.5,65,18,56,113,188,283,396,528,680,850,0,850,5,4,49,\"主角拳掌3\",\"攻击\");\nSkills[86] = new Skill(\"金蛇游身掌\",1.33,2.66,3.99,5.32,6.65,7.98,9.31,10.64,11.97,14.7,60,14,42,84,140,210,294,392,504,630,0,630,2,0,31,\"主角拳掌2\",\"攻击\");\nSkills[87] = new Skill(\"空明拳\",1.52,3.04,4.56,6.08,7.6,9.12,10.63,12.15,13.67,16.8,50,14,42,84,140,210,294,392,504,630,0,630,2,0,35,\"主角拳掌2\",\"攻击\");\nSkills[88] = new Skill(\"灵蛇拳\",1.25,2.5,3.75,5,6.25,7.5,8.75,10,11.25,13.8,55,11,34,69,115,173,242,323,416,520,0,520,2,0,24,\"主角拳掌3\",\"攻击\");\nSkills[89] = new Skill(\"罗汉拳\",0.63,1.79,2.59,3.39,4.19,4.99,5.79,6.59,7.39,9.2,30,8,24,48,80,120,168,224,288,360,0,360,2,0,22,\"主角拳掌2\",\"攻击\");\nSkills[90] = new Skill(\"落英神剑掌\",1.27,2.54,3.81,5.08,6.35,7.62,8.89,10.16,11.43,14,40,11,34,69,115,173,242,323,416,520,0,520,2,0,28,\"主角拳掌2\",\"攻击\");\nSkills[91] = new Skill(\"美女拳法\",1.16,2.32,3.48,4.64,5.8,6.96,8.12,9.28,10.44,12.8,50,11,34,69,115,173,242,323,416,520,0,520,2,0,23,\"主角拳掌2\",\"攻击\");\nSkills[92] = new Skill(\"美女三招\",1.02,2.04,3.06,4.08,5.1,6.12,7.14,8.16,9.18,11.3,50,11,34,69,115,173,242,323,416,520,0,520,2,0,26,\"主角拳掌2\",\"攻击\");\nSkills[93] = new Skill(\"绵掌\",1.2,2.4,3.6,4.8,6,7.2,8.4,9.6,10.8,13.2,50,11,34,69,115,173,242,323,416,520,0,520,2,0,27,\"主角拳掌2\",\"攻击\");\nSkills[94] = new Skill(\"南山掌法\",0.81,1.62,2.43,3.24,4.05,4.86,5.67,6.48,7.29,10,40,8,26,52,86,130,182,242,312,390,0,390,2,0,17,\"主角拳掌3\",\"攻击\");\nSkills[95] = new Skill(\"劈空掌\",1,2,3,4,5,6,7,8,9,11,55,9,29,58,97,146,205,273,352,440,0,440,2,0,23,\"主角拳掌4\",\"攻击\");\nSkills[96] = new Skill(\"七伤拳\",1.57,3.14,4.71,6.28,7.85,9.42,10.99,12.56,14.13,17.3,65,16,50,100,166,250,350,466,600,750,0,750,2,0,38,\"主角拳掌3\",\"攻击\");\nSkills[97] = new Skill(\"如来千叶手\",1.36,2.72,4.08,5.44,6.8,8.16,9.52,10.88,12.24,15,60,14,42,84,140,210,294,392,504,630,0,630,5,0,39,\"主角拳掌1\",\"攻击\");\nSkills[98] = new Skill(\"三花聚顶掌\",1.5,3,4.5,6,7.5,9,10.5,12,13.5,16.5,55,11,34,69,115,173,242,323,416,520,0,520,2,0,33,\"主角拳掌3\",\"攻击\");\nSkills[99] = new Skill(\"太极拳\",1.8,3.6,5.4,7.2,9,10.8,12.6,14.4,16.2,21.9,75,16,50,100,166,250,350,466,600,750,0,750,2,0,22,\"主角拳掌2\",\"攻击\");\nSkills[100] = new Skill(\"天长掌法\",0.87,1.74,2.61,3.48,4.35,5.22,6.09,6.96,7.83,9.6,45,11,34,69,115,173,242,323,416,520,0,520,2,0,26,\"主角拳掌4\",\"攻击\");\nSkills[101] = new Skill(\"天罗地网掌\",0.89,1.78,2.67,3.56,4.45,5.34,6.23,7.12,8.01,9.8,45,9,29,58,97,146,205,273,352,440,0,440,2,0,22,\"主角拳掌2\",\"攻击\");\nSkills[102] = new Skill(\"天山六阳掌\",1.69,3.38,5.07,6.76,8.45,10.14,11.83,13.52,16.21,18.6,50,14,42,84,140,210,294,392,504,630,0,630,2,0,36,\"主角拳掌4\",\"攻击\");\nSkills[103] = new Skill(\"天山折梅手\",1.31,2.62,3.93,5.24,6.55,7.86,9.17,10.48,11.79,14.5,50,11,34,69,115,173,242,323,416,520,0,520,2,0,27,\"主角拳掌4\",\"攻击\");\nSkills[104] = new Skill(\"铁掌\",1.2,2.4,3.6,4.8,6,7.2,8.4,9.6,10.8,13.2,40,9,29,58,97,146,205,273,352,440,0,440,2,0,29,\"主角拳掌3\",\"攻击\");\nSkills[105] = new Skill(\"铜锤手\",1.01,2.02,3.03,4.04,5.05,6.06,7.07,8.08,9.09,11.2,45,8,26,52,86,130,182,242,312,390,0,390,2,0,17,\"主角拳掌4\",\"攻击\");\nSkills[106] = new Skill(\"五罗轻烟掌\",0.83,1.66,2.49,3.32,4.15,4.98,5.81,6.64,7.47,9.2,45,11,34,69,115,173,242,323,416,520,0,520,2,0,23,\"主角拳掌2\",\"攻击\");\nSkills[107] = new Skill(\"五行六合掌\",1.01,2.02,3.03,4.04,5.05,6.06,7.07,8.08,9.09,11.2,55,14,42,84,140,210,294,392,504,630,0,630,2,0,33,\"主角拳掌3\",\"攻击\");\nSkills[108] = new Skill(\"逍遥游\",1.2,2.4,3.6,4.8,6,7.2,8.4,9.6,10.8,13.3,35,6,20,40,66,100,140,186,240,300,0,300,2,0,21,\"主角拳掌3\",\"攻击\");\nSkills[109] = new Skill(\"须弥山掌\",1.32,2.64,3.96,5.28,6.6,7.92,9.24,10.56,11.88,14.6,45,11,34,69,115,173,242,323,416,520,0,520,3,0,25,\"主角拳掌1\",\"攻击\");\nSkills[110] = new Skill(\"野狐拳法\",0.74,1.48,2.22,2.96,3.7,4.44,5.18,5.92,6.66,8.2,40,9,29,58,97,146,205,273,352,440,0,440,2,0,23,\"主角拳掌2\",\"攻击\");\nSkills[111] = new Skill(\"英雄三招\",1.01,2.02,3.03,4.04,5.05,6.06,7.07,8.08,9.09,11.3,50,11,34,69,115,173,242,323,416,520,0,520,2,0,28,\"主角拳掌4\",\"攻击\");\nSkills[112] = new Skill(\"震山铁掌\",0.89,1.78,2.67,3.56,4.45,5.34,6.23,7.12,8.01,9.8,30,9,29,58,97,146,205,273,352,440,0,440,2,0,24,\"主角拳掌3\",\"攻击\");\nSkills[113] = new Skill(\"重阳神掌\",1.68,3.36,5.04,6.72,8.4,10.08,11.76,13.44,15.12,18.5,55,16,50,100,166,250,350,466,600,750,0,750,2,0,37,\"主角拳掌2\",\"攻击\");\nSkills[114] = new Skill(\"参合指\",1.32,2.64,3.96,5.28,6.6,7.92,9.24,10.56,11.88,14.6,65,14,42,84,140,210,294,392,504,630,0,630,2,0,32,\"主角指1\",\"攻击\");\nSkills[115] = new Skill(\"大力金刚指\",1.43,2.86,4.29,5.72,7.15,8.58,10.01,11.44,12.87,15.8,55,14,42,84,140,210,294,392,504,630,0,630,2,0,35,\"主角指1\",\"攻击\");\nSkills[116] = new Skill(\"分筋错骨手\",0.89,1.78,2.67,3.56,4.45,5.34,6.23,7.12,8.01,9.8,45,11,34,69,115,173,242,323,416,520,0,520,2,2,22,\"主角指1\",\"攻击\");\nSkills[117] = new Skill(\"虎爪绝户手\",1.2,2.4,3.6,4.8,6,7.2,8.4,9.6,10.8,13.2,45,11,34,69,115,173,242,323,416,520,0,520,2,0,27,\"主角指1\",\"攻击\");\nSkills[118] = new Skill(\"基本指法\",0.57,1.14,1.71,2.28,2.85,3.42,3.99,4.56,5.13,6.3,35,6,18,37,62,93,130,174,224,280,0,280,2,0,12,\"主角指1\",\"攻击\");\nSkills[119] = new Skill(\"九阴白骨爪\",1.39,2.78,4.17,5.56,6.95,8.34,9.73,11.12,12.51,15.3,50,16,50,100,166,250,350,466,600,750,0,750,2,0,26,\"主角指1\",\"攻击\");\nSkills[120] = new Skill(\"兰花拂穴手\",1.25,2.5,3.75,5,6.25,7.5,8.75,10,11.25,13.8,40,14,42,84,140,210,294,392,504,630,0,630,2,2,22,\"主角指1\",\"攻击\");\nSkills[121] = new Skill(\"六脉神剑\",1.81,3.62,5.43,7.24,9.05,10.86,12.66,14.47,16.28,20,70,18,56,113,188,283,396,528,680,850,0,150,5,0,47,\"主角指1\",\"攻击\");\nSkills[122] = new Skill(\"龙爪手\",1.34,2.68,4.02,5.35,6.89,8.23,9.57,10.91,12.25,14.8,40,14,42,84,140,210,294,392,504,630,0,630,2,0,32,\"主角指1\",\"攻击\");\nSkills[123] = new Skill(\"拈花指\",1.11,2.22,3.33,4.44,5.55,6.66,7.77,8.88,9.99,12.3,65,14,42,84,140,210,294,392,504,630,0,630,2,0,36,\"主角指1\",\"攻击\");\nSkills[124] = new Skill(\"凝血神抓\",0.9,1.8,2.7,3.6,4.5,5.4,6.3,7.2,8.9,12,55,11,34,69,115,173,242,323,416,520,0,520,2,0,28,\"主角指1\",\"攻击\");\nSkills[125] = new Skill(\"千蛛万毒手\",1,2,3,4,5,6,7,8,9,11,50,11,34,69,115,173,242,323,416,520,0,520,2,0,21,\"主角指1\",\"攻击\");\nSkills[126] = new Skill(\"三阴蜈蚣爪\",0.63,1.26,1.89,2.52,3.15,3.78,4.41,5.04,6.67,8.9,65,11,34,69,115,173,242,323,416,520,0,520,2,0,25,\"主角指1\",\"攻击\");\nSkills[127] = new Skill(\"锁喉擒拿手\",0.77,1.54,2.32,3.09,3.86,4.63,5.4,6.17,7.94,9.5,50,11,34,69,115,173,242,323,416,520,0,520,2,0,22,\"主角指1\",\"攻击\");\nSkills[128] = new Skill(\"无相劫指\",1.18,2.36,3.54,4.72,5.9,7.08,8.26,9.44,10.62,13,55,14,42,84,140,210,294,392,504,630,0,630,2,0,33,\"主角指1\",\"攻击\");\nSkills[129] = new Skill(\"一阳指\",1.22,2.44,3.66,4.88,6.1,7.32,8.54,9.76,10.98,13.5,65,14,42,84,140,210,294,392,504,630,0,630,2,2,28,\"主角指1\",\"攻击\");\nSkills[130] = new Skill(\"鹰爪擒拿手\",0.72,1.44,2.16,2.88,3.6,4.32,5.04,5.76,6.48,8,55,14,42,84,140,210,294,392,504,630,0,630,2,0,33,\"主角指1\",\"攻击\");\nSkills[131] = new Skill(\"八荒六合唯我独尊功\",3.5,3.8,4.1,4.4,4.8,5.2,5.6,6.1,6.7,17.5,75,18,56,113,188,283,396,528,680,850,0,850,5,0,86,\"主角内功\",\"攻击\");\nSkills[132] = new Skill(\"北冥神功\",1.77,2.54,3.32,4.09,5.86,6.63,7.4,8.17,9.94,12.8,50,14,42,84,140,210,294,392,504,630,0,630,2,0,0,\"主角内功\",\"攻击\");\nSkills[133] = new Skill(\"蛤蟆功\",1.57,3.14,4.71,6.28,7.85,9.42,10.99,11.56,12.53,16.3,60,16,50,100,166,250,350,466,600,750,0,750,2,0,74,\"主角内功\",\"攻击\");\nSkills[134] = new Skill(\"龟息功\",0,0,0,0,0,0,0,0,0,0,60,14,42,84,140,210,294,392,504,630,0,630,1,0,31,\"主角内功\",\"攻击\");\nSkills[135] = new Skill(\"化功大法\",0.93,2.26,2.89,3.52,4.15,5.78,6.41,7.04,7.67,8.9,65,14,42,84,140,210,294,392,504,630,0,630,2,0,22,\"主角内功\",\"攻击\");\nSkills[136] = new Skill(\"混元功\",1.18,2.36,3.54,4.72,5.9,7.08,8.26,9.44,10.62,13,60,16,50,100,166,250,350,466,600,750,0,750,2,0,72,\"主角内功\",\"攻击\");\nSkills[137] = new Skill(\"金刚不坏神功\",0,0,0,0,0,0,0,0,0,0,50,14,42,84,140,210,294,392,504,630,0,630,2,0,27,\"主角内功\",\"攻击\");\nSkills[138] = new Skill(\"九阳神功\",1.43,2.86,4.29,5.72,7.15,8.58,10.01,11.44,12.87,16.8,70,14,42,84,140,210,294,392,504,630,0,630,3,0,94,\"主角内功\",\"攻击\");\nSkills[139] = new Skill(\"绝世武功\",1.63,3.26,4.89,6.52,8.15,9.78,11.41,13.04,14.67,18,40,18,56,113,188,283,396,528,680,850,0,850,5,0,120,\"主角绝招\",\"攻击\");\nSkills[140] = new Skill(\"葵花神功\",1.4,2.8,4.2,5.6,7,8.4,9.8,11.2,12.6,15,35,18,56,113,188,283,396,528,680,850,0,850,5,0,116,\"主角内功\",\"攻击\");\nSkills[141] = new Skill(\"龙象般若功\",1.81,3.62,5.43,7.24,9.05,10.86,12.66,14.47,16.28,17.2,65,50,150,300,500,750,1050,1400,1800,2750,0,750,2,0,84,\"主角内功\",\"攻击\");\nSkills[142] = new Skill(\"乾坤大挪移\",1.45,2.9,4.35,5.8,7.25,8.7,10.15,11.6,13.05,16,55,16,50,100,166,250,350,466,600,750,0,750,5,0,72,\"主角内功\",\"攻击\");\nSkills[143] = new Skill(\"神龙心法\",1.01,2.02,3.03,4.04,5.05,6.06,7.07,8.08,9.09,11.2,60,14,42,84,140,210,294,392,504,630,0,630,2,3,38,\"主角内功\",\"攻击\");\nSkills[144] = new Skill(\"神照功\",0,0,0,0,0,0,0,0,0,0,75,16,50,100,166,250,350,466,600,750,0,750,1,0,74,\"主角内功\",\"攻击\");\nSkills[145] = new Skill(\"狮吼功\",1.22,2.44,3.66,4.88,6.1,7.32,8.54,9.76,10.98,13.5,60,16,50,100,166,250,350,466,600,750,0,750,5,3,98,\"主角内功\",\"攻击\");\nSkills[146] = new Skill(\"太玄经\",1.74,3.48,5.22,6.96,8.7,10.44,12.18,13.92,15.66,19.5,80,18,56,113,188,283,396,528,680,850,0,850,5,0,56,\"主角内功\",\"攻击\");\nSkills[147] = new Skill(\"吸星大法\",1.63,2.26,3.89,4.52,5.15,6.78,7.41,8.04,9.67,11,60,14,42,84,140,210,294,392,504,630,0,630,2,0,0,\"主角内功\",\"攻击\");\nSkills[148] = new Skill(\"小无相功\",1.63,3.26,4.89,6.52,8.15,9.78,11.41,13.04,14.67,18,60,16,50,100,166,250,350,466,600,750,0,750,2,0,62,\"主角内功\",\"攻击\");\nSkills[149] = new Skill(\"紫霞神功\",1.22,2.44,3.66,4.88,6.1,7.32,8.54,9.76,10.98,13.5,60,14,42,84,140,210,294,392,504,630,0,630,2,0,58,\"主角内功\",\"攻击\");\nSkills[159] = new Skill(\"罗汉伏魔功\",1.36,2.72,4.08,5.44,6.8,8.16,9.52,10.88,12.24,15,70,14,42,84,140,210,294,392,504,630,0,630,2,0,64,\"主角内功\",\"攻击\");\nSkills[166] = new Skill(\"先天功\",2.38,4.73,6.1,8.54,10.85,12.56,14.58,16.88,17.54,19.5,60,14,42,84,140,210,294,392,504,630,0,630,2,0,64,\"主角内功\",\"攻击\");\nSkills[167] = new Skill(\"易筋经\",1.63,3.26,4.89,6.52,8.15,9.78,11.41,13.04,14.67,17,80,18,56,113,188,283,396,528,680,850,0,850,5,0,76,\"主角内功\",\"攻击\");\nSkills[187] = new Skill(\"毒雾\",0.59,1.18,1.77,2.36,2.95,3.54,4.13,4.72,5.3,12.5,65,14,42,84,140,210,294,392,504,630,0,630,3,0,36,\"主角内功\",\"攻击\");\nSkills[188] = new Skill(\"驱蜂术\",0.77,1.54,2.32,3.09,3.86,4.63,5.4,6.17,6.94,8.5,65,14,42,84,140,210,294,392,504,630,0,630,5,2,20,\"主角内功\",\"攻击\");\nSkills[189] = new Skill(\"星宿解毒术\",0,0,0,0,0,0,0,0,0,0,60,14,42,84,140,210,294,392,504,630,0,630,1,0,42,\"主角内功\",\"攻击\");\nSkills[191] = new Skill(\"普通攻击\",0.51,1.02,1.53,2.04,2.55,3.06,3.57,4.08,4.9,10,20,9,29,58,97,146,205,273,352,440,0,100,2,0,5,\"拳掌\",\"攻击\");\nSkills[192] = new Skill(\"火枪术\",1.81,3.62,5.43,7.24,9.05,10.86,12.66,14.47,16.28,20,95,14,42,84,140,210,294,392,504,630,0,630,2,0,1,\"拳掌\",\"攻击\");\nSkills[193] = new Skill(\"混元掌\",1.13,2.26,3.39,4.52,5.65,6.78,7.91,9.04,10.17,15.5,55,14,42,84,140,210,294,392,504,630,0,630,2,0,33,\"拳掌\",\"攻击\");\nSkills[194] = new Skill(\"玄冥神掌\",1.13,2.26,3.39,4.52,5.65,6.78,7.91,9.04,10.17,18.5,60,14,42,84,140,210,294,392,504,630,0,630,2,0,38,\"拳掌\",\"攻击\");\nSkills[195] = new Skill(\"五轮大法\",1.25,2.5,3.75,5,6.25,7.5,8.75,10,11.25,13.8,50,16,50,100,166,250,350,466,600,750,0,750,2,0,41,\"拳掌\",\"攻击\");\nSkills[196] = new Skill(\"阴阳捣乱刃\",1.18,2.36,3.54,4.72,5.9,7.08,8.26,9.44,10.62,13,60,16,50,100,166,250,350,466,600,750,0,750,2,0,29,\"拳掌\",\"攻击\");\nSkills[197] = new Skill(\"三僧鞭法\",1.5,3,4.5,6,7.5,9,10.5,12,13.5,16.5,65,16,50,100,166,250,350,466,600,750,0,750,2,0,32,\"拳掌\",\"攻击\");\nSkills[198] = new Skill(\"芷若鞭法\",1.09,2.18,3.27,4.36,5.45,6.54,7.63,8.72,9.81,15,45,16,50,100,166,250,350,466,600,750,0,750,2,0,23,\"拳掌\",\"攻击\");\nSkills[199] = new Skill(\"易筋神功\",2,4,6,8,10,12,14.01,16,18,23,45,9,29,58,97,146,205,273,352,440,0,440,2,0,44,\"拳掌\",\"攻击\");\n
\n

注意:内功、武器对招式的加成作用不同。

\n

以下是某些武功最佳配套武器:

\n
    if(_root.Skills[_root.body[96]].m_sName == \"辟邪剑法\" && _root.ZB[2] == 29)\n    {\n      hurt = int(2 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"冰雪剑法\" && _root.ZB[2] == 10)\n    {\n      hurt = int(1.3 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"独孤九剑\" && _root.ZB[2] == 29)\n    {\n      hurt = int(1.7 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"金蛇剑法\" && _root.ZB[2] == 22)\n    {\n      hurt = int(1.6 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"灭绝剑法\" && _root.ZB[2] == 29)\n    {\n      hurt = int(1.6 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"绕指柔剑\" && _root.ZB[2] == 14)\n    {\n      hurt = int(1.6 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"太极剑\" && _root.ZB[2] == 25)\n    {\n      hurt = int(2 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"玉箫剑法\" && _root.ZB[2] == 4)\n    {\n      hurt = int(1.4 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"玄铁剑法\" && _root.ZB[2] == 28)\n    {\n      hurt = int(1.7 * hurt);\n    }\n
\n

可以看到,倚天对辟邪、独孤,及真武对太极加成最大。

\n

某些刀法和配套的宝刀:

\n
    if(_root.Skills[_root.body[96]].m_sName == \"柴刀十八路\" && _root.ZB[2] == 31)\n    {\n      hurt = int(1.4 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"胡家刀法\" && _root.ZB[2] == 54)\n    {\n      hurt = int(1.7 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"基本刀法\" && _root.ZB[2] == 32)\n    {\n      hurt = int(1.3 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"狂风刀法\" && _root.ZB[2] == 30)\n    {\n      hurt = int(1.5 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"血刀刀法\" && _root.ZB[2] == 47)\n    {\n      hurt = int(1.6 * hurt);\n    }\n
\n

最佳搭配是胡家刀法配冷月宝刀,然而加成也不过等于玄铁剑对玄铁剑法的加成,在剑里面只能算第二梯队。

\n

棍法的数据

\n
if(_root.Skills[_root.body[96]].m_sName == \"打狗棒法\" && _root.ZB[2] == 59)\n{\n  hurt = int(1.8 * hurt);\n}\nif(_root.Skills[_root.body[96]].m_sName == \"伏魔杖法\" && _root.ZB[2] == 57)\n{\n  hurt = int(1.5 * hurt);\n}\nif(_root.Skills[_root.body[96]].m_sName == \"基本棍法\" && _root.ZB[2] == 56)\n{\n  hurt = int(1.3 * hurt);\n}\nif(_root.Skills[_root.body[96]].m_sName == \"叫花棒法\" && _root.ZB[2] == 59)\n{\n  hurt = int(1.4 * hurt);\n}\nif(_root.Skills[_root.body[96]].m_sName == \"金刚降魔杵\" && _root.ZB[2] == 60)\n{\n  hurt = int(1.6 * hurt);\n}\nif(_root.Skills[_root.body[96]].m_sName == \"灵蛇杖法\" && _root.ZB[2] == 61)\n{\n  hurt = int(1.7 * hurt);\n}\nif(_root.Skills[_root.body[96]].m_sName == \"太祖棍\" && _root.ZB[2] == 58)\n{\n  hurt = int(1.5 * hurt);\n}\nif(_root.Skills[_root.body[96]].m_sName == \"无上大力杵法\" && _root.ZB[2] == 60)\n{\n  hurt = int(1.5 * hurt);\n}\n
\n

最佳搭配是打狗棒法配打狗棒,加成 1.8,稍好于胡家刀法配冷月宝刀,次于最佳剑法宝剑组合。

\n

内功对某些拳掌的加成:

\n
    if(_root.Skills[_root.body[96]].m_sName == \"冰蚕神掌\" && _root.ZB[4] == 167)\n    {\n      hurt = int(1.5 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"黯然销魂掌\" && _root.ZB[4] == 158)\n    {\n      hurt = int(1.6 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"般若掌\" && _root.ZB[4] == 162)\n    {\n      hurt = int(1.7 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"大力金刚掌\" && _root.ZB[4] == 162)\n    {\n      hurt = int(1.6 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"降龙十八掌\" && _root.ZB[4] == 138)\n    {\n      hurt = int(1.9 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"落英神剑掌\" && _root.ZB[4] == 164)\n    {\n      hurt = int(1.6 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"劈空掌\" && _root.ZB[4] == 164)\n    {\n      hurt = int(1.5 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"兰花拂穴手\" && _root.ZB[4] == 164)\n    {\n      hurt = int(1.5 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"七伤拳\" && _root.ZB[4] == 138)\n    {\n      hurt = int(1.6 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"太极拳\" && _root.ZB[4] == 163)\n    {\n      hurt = int(1.7 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"参合指\" && _root.ZB[4] == 169)\n    {\n      hurt = int(1.6 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"九阴白骨爪\" && _root.ZB[4] == 158)\n    {\n      hurt = int(1.6 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"六脉神剑\" && _root.ZB[4] == 167)\n    {\n      hurt = int(1.9 * hurt);\n    }\n    if(_root.Skills[_root.body[96]].m_sName == \"一阳指\" && _root.ZB[4] == 166)\n    {\n      hurt = int(1.6 * hurt);\n    }\n
\n

可以看到降龙配九阳、六脉配易筋经加成最大。

\n

然后小无相功对所有拳掌都有一定加成,如果你的拳掌不属于上面,那么小无相功最佳:

\n
    if(_root.ZB[4] == 148)\n    {\n      hurt = int(1.4 * hurt);\n    }\n
\n

特别地,左右互搏有 1.7-2.2 随机伤害加成:

\n
if(_root.ZB[4] == 190)\n{\n  hurt = int((1.6 + 0.1 * random(6)) * hurt);\n}\n
\n

NPC

\n

所有 NPC 均可修改为队友。\n游戏中不可加为队友的 NPC 修改为队友后战斗时无人物图像。

\n
  1 王语嫣\n  2 令狐冲\n  3 仪琳\n  4 张无忌\n  5 胡斐\n  6 小龙女\n  7 杨过\n  8 公孙绿萼\n  9 段誉\n  10 狄云\n  11 小乞丐\n  12 黄蓉\n  13 韦小宝\n  14 双儿\n  15 赵敏\n  16 任盈盈\n  17 向问天\n  18 周芷若\n  19 阿紫\n  20 阿珂\n  21 长平\n  22 阿九\n  23 九难\n  24 岳灵珊\n  25 香香公主\n  26 苏荃\n  27 袁承志\n  28 蛛儿\n  29 游坦之\n  30 慕容复\n  31 林平之\n  32 田伯光\n  33 欧阳克\n  34 霍都\n  35 虚竹\n  36 乔峰\n  37 郭靖\n  38 神仙醋\n  39 郭襄\n  40 程灵素\n  41 摘星子\n  42 苗若兰\n  43 阿大\n  44 阿二\n  45 白猿\n  46 老虎\n  47 莽牯朱蛤\n  48 巨蟒\n  49 茅十八\n  50 胖头陀\n  51 胖捕头\n  52 鸠摩智\n  53 游驹\n  54 耕夫\n  55 读书人\n  56 梁子翁\n  57 鳌拜\n  58 冯锡范\n  59 陈近南\n  60 段正淳\n  61 灭绝师太\n  62 王夫人\n  63 李捕头\n  64 刑捕头\n  65 多隆\n  66 秀才\n  67 教书先生\n  68 完颜洪烈\n  69 成吉思汗\n  70 吴三桂\n  71 崇祯\n  72 鲜于通\n  73 裘千尺\n  74 裘千丈\n  75 穆人清\n  76 鹤笔翁\n  77 鹿杖客\n  78 白自在\n  79 阿秀\n  80 康熙\n  81 金轮法王\n  82 欧阳锋\n  83 黄药师\n  84 洪七公\n  85 一灯\n  86 周伯通\n  87 裘千仞\n  88 瑛姑\n  89 梅超风\n  90 傻姑\n  91 慧轮\n  92 黄眉僧\n  93 枯荣大师\n  94 无名僧\n  95 圆真\n  96 不戒和尚\n  97 单正\n  98 谭公\n  99 谭婆\n  100 何太冲\n  101 平一指\n  102 何红药\n  103 绿竹翁\n  104 段延庆\n  105 叶二娘\n  106 岳老三\n  107 云中鹤\n  108 斑淑娴\n  109 丁敏君\n  110 澄观\n  111 风清扬\n  112 宁中则\n  113 无涯子\n  114 李秋水\n  115 天山童姥\n  116 丁春秋\n  117 苏星河\n  118 薛慕华\n  119 唐文亮\n  120 阿三\n  121 达尔巴\n  122 陆乘风\n  123 洪安通\n  124 康亲王\n  125 吴应熊\n  126 海大富\n  127 索额图\n  128 太后\n  129 玉玑子\n  130 穆念慈\n  131 成不忧\n  132 梦姑\n  133 郭芙\n  134 阿朱\n  135 李莫愁\n  136 钟灵\n  137 渔夫\n  138 樵夫\n  139 陆天抒\n  140 花铁干\n  141 水岱\n  142 刘乘风\n  143 血刀老祖\n  144 侠客岛主\n  145 张三\n  146 李四\n  147 黄裳\n  148 黄真\n  149 杨逍\n  150 范遥\n  151 韦一笑\n  152 谢逊\n  153 金花婆婆\n  154 殷天正\n  155 胡青牛\n  156 苗人凤\n  157 田归农\n  158 公孙止\n  159 张三丰\n  160 宋远桥\n  161 俞莲舟\n  162 俞岱岩\n  163 殷梨亭\n  164 宋青书\n  165 王重阳\n  166 丘处机\n  167 赵志敬\n  168 尹志平\n  169 掌钵长老\n  170 持棒长老\n  171 传功长老\n  172 执法长老\n  173 全冠清\n  174 马夫人\n  175 玄慈\n  176 空闻\n  177 方证\n  178 阎基\n  179 东方不败(假)\n  180 东方不败\n  181 任我行(无属性)\n  182 任我行\n  183 杨莲亭\n  184 曲阳\n  185 黄钟公\n  186 黑白子\n  187 秃笔翁\n  188 丹青生\n  189 左冷禅\n  190 莫大\n  191 岳不群\n  192 天门\n  193 定逸\n  194 刘正风\n  195 余沧海\n  196 费彬\n  197 冯墨风\n  198 周芷若\n  199 杨过\n  200 南海神尼\n  201 建宁公主\n  202 谢烟客\n  203 神雕\n  204 ???\n  205 蒙面人\n  206 缘根\n  207 老头子\n  208 祖千秋\n  209 达摩\n  210 独孤求败\n  211 渡劫\n  212 渡厄\n  213 渡难\n  214 鹿清笃\n  215 流云使\n  216 妙风使\n  217 辉月使\n  218 木高峰\n  219 史婆婆\n  220 段天德\n  221 冰蚕\n  222 熊\n  223 半瓶神仙醋\n  224 木人\n  225 铜人\n  226 太监\n  227 清兵\n  228 家丁\n  229 强盗\n  230 劫匪\n  231 铁掌帮众\n  232 嵩山弟子\n  233 华山弟子\n  234 恒山弟子\n  235 泰山弟子\n  236 衡山弟子\n  237 丐帮弟子\n  238 日月教众\n  239 少林弟子\n  240 星宿弟子\n  241 明教弟子\n  242 老鸨\n  247 张小肉\n
\n

列表 z[NPC代号] 储存了 NPC 的数值,例如 z[6] 为小龙女。

\n

NPC 数值列表如下:

\n
0 当前生命 ( NPC 的生命、内力可以大于 99999)\n1 生命\n2 当前内力\n3 内力\n4 拆招 ( NPC 的属性可以大于 100,改成 900 以后所有敌人皆是一招灭之)\n5 搏击\n6 闪躲\n7 内功\n8 攻击\n9 速度\n10 武功1\n11 武功1经验\n12 武功2\n13 武功2经验\n14 武功3\n15 武功3经验\n16 馈赠物品1\n17 是否获赠物品1\n18 馈赠物品2\n19 是否获赠物品2\n20 馈赠物品3\n21 是否获赠物品3\n22 馈赠物品4\n23 是否获赠物品4\n24 好感度\n25 bool 效果未知\n26 bool 效果未知\n
\n

公告任务

\n
1.四十二章经的秘密\n2.闯王宝藏的秘密\n3.唐选诗集的秘密\n4.落花流水恶斗血刀僧\n5.华山论剑\n6.救治青翼蝠王\n7.归云庄英雄大会\n8.王语嫣的悲哀\n9.放浪形骸的浪子\n10.绝情谷婚变\n11.悲情杨过\n12.独孤求败的宠物\n13.昔日皇妃\n14.韦小宝性命危矣\n15.庄家的复仇\n16.魔教圣姑\n17.死守襄阳\n18.神雕大侠的三件礼物\n19.四个淫棍\n20.田归农的挑战\n21.回族部落的圣物\n22.群寇争镖银\n23.老尼姑的险境\n24.峨嵋派替天行道\n25.西夏招亲\n26.救治盲女\n27.青城派的仇怨\n28.东郭浪子心\n29.全真派和桃花岛的恩怨\n30.桃花岛主,怡笑江湖\n31.昆仑冰蚕\n32.毒王之争\n33.天王老子傲四方\n34.御厨的无奈\n35.腊八粥\n36.迷途中的小和尚\n37.擂鼓山棋局\n38.镖车被劫\n39.月下白骨\n40.阮姓无辜做冤魂\n41.丐帮和星宿的恶斗\n42-43.少林和武当的恶斗\n44.官逼民反\n45.神秘商人\n
\n

列表 sj 储存事件完成情况,列表 c 储存条件触发情况。

\n

江湖记事的时间储存在列表 k 中,对应的记事储存在列表 l 中。

\n

修改攻略

\n

属性、问题随便,反正要修改。

\n

参见前述回到开始加入多个门派。

\n

古墓

\n

入全真并叛出

\n

第一天午时至酉时(千万别睡觉),回村遇官差调戏女子事件,选1,上前阻挡被秒杀。

\n

丘处机出现,醒来后马上去树林找他,选择加入全真派。

\n

全真教的选择题:前几个题全不选师傅(赵志敬),最后一个最下流无耻的选师傅(赵志敬)。

\n

休息,得到存档。进行修改,金钱改 999999,修为点改 999,闪、轻、内、搏、拆改 99, 其余属性改 100。

\n

内功改玉女,轻功改凌波,剑法改全真、玉女、玉女素心、独孤。掷针、天罗、美女、捕雀可直接修改,或在古墓中学。

\n

经脉可直接修改,或在游戏中点。

\n

如想学全真功夫,可找甄志丙学金雁功。学了全真剑法或三花聚顶掌,比武输了也去不了古墓。

\n

读档,到大殿找丘处机不断养生,直至 3 月比武,逃跑。

\n

最快叛出全真

\n

在游戏开始5天内,牛家村场景下,修改 m[128] 为 150,跳至加入全真事件。\n在全真派中,修改 m[128] 为 108,直接跳到叛出门派事件,触发入古墓事件。

\n

拜入古墓

\n

受辱骂后离开,古墓门口被玉峰蛰,醒来后回答选 1 (死了算了),拜入古墓。

\n

传功

\n

古墓中请小龙女传功,先学天罗地网掌,\n和小龙女切磋到 9 级(武功等级亦可修改存档,下同)再可学捕雀功,用修为点练至 5 级装备,\n让小龙女传功可得玉蜂针,学得掷针术。\n装备玉峰针后和用掷针术和小龙女切磋至 7 级可学美女拳法。

\n

掷针术、捕雀功均为游戏原创。\n掷针术可发射任意暗器。《神雕侠侣》中未提及掷针术,玉蜂针和冰魄银针皆有专门的手法,\n并非通用暗器手法。即便如周伯通这样的高手,因为不明手法,发射的玉蜂针威力全无。

\n

寡欲修到顶之后存档,修改为 1 级,然后再修。修过一定次数后,只需修寡欲 5 天即可从 1 级修到 10 级。\n不过生命内力可直接修改,因此这样没什么意义。

\n

出古墓

\n

修习寡欲至离十二月十五日最近的日期。\n十二月十五日,李莫愁会来,无论输赢小龙女都会说我们打不过师姐,然后放下断龙石,\n选择死要死在一起,二人进入密道。\n先得到九阴真经和玉女真经,然后会有字幕提示出古墓的走法:

\n

第1种提示,西 东 南 北 东 西,最后东或西,\n第2种提示,东 东 西 北 东 西,最后东或北,\n第2种提示,南 北 南 北 东 西,最后南或北。

\n

成功出古墓,小龙女为队友;走入死胡同则死亡。

\n

或者修改 m[128] 为 340,直接出古墓。

\n

小龙女修改

\n

修改小龙女数值,生命内力 999,属性 900,武功分别为驱蜂术(群攻)、玉女素心、美女拳法,武功经验为 999.\n三种物品(玉蜂浆、淑女剑、玉女心经)获赠改为 true. 好感改为 100.、

\n

如此修改后,任何敌人都是一招灭之。

\n

全真

\n

参见古墓。

\n

不同:

\n
    \n
  1. 回答问题时讨好赵志敬可得木剑、全真剑法。
  2. \n
  3. 同古墓回答问题,找赵志敬切磋,连胜 10 次,得木剑、全真剑法,全真练到 9 级,找赵志敬得三花聚顶掌。
  4. \n
  5. 6月比武得重阳神掌。
  6. \n
  7. 9月比武得先天功。
  8. \n
\n

少林

\n

休息 2 次后到 1 年 1 月 2 日,牛家村中看到和尚,拜入少林。

\n

或修改 m[139] 为 初入少林,m[140] 为 少林派.

\n

藏经阁学佛法至 2 级,找慧伦学少林身法。

\n

找慧伦学长拳,长拳 7 级学罗汉拳,罗汉拳 7 级学般若拳。

\n

挑战罗汉堂首座得少林九阳功。

\n

至藏经阁学佛法至 3 月,挑战木人巷,得一苇渡江。

\n

达摩堂

\n

选择达摩堂。

\n

入堂得大力金刚掌。

\n

大力金刚掌 9 级,得大力金刚指。

\n

已学大力金刚指,修佛法到 5 级,得须弥山掌;修佛法 9 级,得拈花指。

\n

挑战达摩堂首座得如来千叶手。

\n

与空闻首次切磋胜利后得龙爪手,连续切磋胜利 10 次后得无相劫指。

\n

般若堂

\n

参见前述回到开始,重入少林。修佛法至 3、6、9 月,挑战木人巷。

\n

入堂得大还丹、纯钢剑、柳叶刀、回风拂柳剑秘籍、飞镖。

\n

从澄观处得漫天花雨、狂风刀法、分筋错骨手、劈空掌。

\n

挑战般若堂首座得金钢不坏神功。

\n

南少林

\n

参见前述回到开始,重入少林。修佛法至 3、6、9 月,挑战木人巷。

\n

入门得龙泉剑、天竺弯刀、蟠龙棍。

\n

从方证处得修罗刀法、达摩剑法、燃木刀法、韦佗杖法。

\n

铜人阵

\n

12 月挑战铜人阵,得易筋经。

\n

武当

\n

时间改到 1 年 1 月 3 日 1 时,进程改为序幕2,地点改为酒 店.

\n

去破庙,遇到强盗分赃,教训强盗。

\n

回酒店休息 2-3 次至 4 日,然后卸去加闪避的轻功,使闪避回落至 99,并与小龙女切磋,败北,血剩 1.\n然后出酒店正赶上强盗来报复,单挑强盗,败北(必须打输,否则俞岱岩不会出现,失去入武当的机会)。\n俞岱岩出面,加入武当。

\n

或者修改 m[128] 为 225,跳至加入武当事件。

\n

入门得武当长拳、梯云纵。

\n

武当长拳 8 级找俞岱岩学震山铁掌。

\n

侠义 6 级找俞岱岩学绵掌。(大殿加侠义,或直接修改。)

\n

基本剑法 7 级找殷梨亭学绕指柔剑。

\n

学绕指柔剑后杀死10个恶霸找殷梨亭学神门十三剑。

\n

绕指柔剑、神门十三剑均 10 级找殷梨亭学玄虚刀法。

\n

丹房帮忙十几次可得虎爪绝户手。丹房试药可刷生命、内力,或直接修改。

\n

侠义值 82 以上可得称号“武当八侠”。侠义值够高,宋远桥送武当九阳功。

\n

侠义值 70 去闭关室找张三丰闭关15天4次后,选“请太师傅传武当绝学”得纯阳无极功。\n再闭关 3-4 次,选“请太师傅传武当绝学”得太极劲。

\n

年底下山后,侠义值 100,回武当,单挑掌门,得太极拳。\n再次单挑掌门,得太极剑、真武剑。\n若已入其他门派,可修改门派为武当后回武当。

\n

华山

\n

拜入华山

\n

将时间修改为 1 年 1 月 4 日 7 时 1 刻, 进程为 序幕2,地点为 酒 店.

\n

去破庙,遇到木高峰,选择救人,然后选择冒充华山弟子。接着令狐冲出现,引荐你加入华山派。

\n

或者修改 m[128] 为 250,跳至加入华山事件。

\n

基础

\n

入门得华山长拳。

\n

至大殿儒风 3 级,华山长拳 8 级,找令狐冲得华山轻功、华山剑法。

\n

华山剑法 8 级,找令狐冲得太岳三青峰。

\n

儒风 5 级后找岳不群得华山心法。

\n

思过崖

\n

厨房,在令狐冲没进思过崖的时候,给师娘足够的食材(常要的有鲤鱼、草鱼、螃蟹、兔肉、鹿肉、野猪肉)及木柴后,\n可以学到宁氏一剑。还可得大概 25 种食物。\n在令狐冲进思过崖(三、六、九月)时,每次给她东西可得 2 瓶烧刀子。\n去思过崖给令狐冲 3 次(6 瓶)烧刀子后,可进思过崖密道。

\n

思过崖密道岔路三选一,出来后密道坍塌:

\n
    \n
  1. 夺命连环三仙剑、万花剑法、五大夫剑、百变千幻云雾剑法、快慢十七路
  2. \n
  3. 金蛇秘笈、金蛇剑、金蛇锥 (可以给袁承志)
  4. \n
  5. 魔教兵器四件:白龙剑、黑血神针、穿云刀、黄金杵(与剧情无关)
  6. \n
\n

尽管武功和物品都可修改,建议用 SL 刷 1,\n因为这 5 种剑法练到 9 级后和在思过崖的令狐冲切磋,切磋完后不论输赢都可习得五岳剑法,算有点剧情。\n修改 m[128] 为 240,直接学会五岳剑法,不用刷 5 种剑法。

\n

或者直接修改 m[128] 为 175,不用等三、六、九月,不用给烧刀子,且可以重复入山洞。

\n

剑宗

\n

后山木屋找穆人清,改拜其为师(前提是儒风未顶级),得狂风快剑。

\n

从穆人清处亦可得夺命连环三仙剑(得诸思过崖)、漫天花雨(得诸少林寺般若堂)。

\n

漫天花雨 9 级找穆人清得神行百变。

\n

神行百变 5 级后第二天在后山木屋遇见风清扬。如未学紫霞,可选自己或令狐冲学习独孤。否则一无所获。

\n

可以修改 m[128] 为 301,直接得独孤九剑,不用拜穆人清,不用未学紫霞。

\n

紫霞秘籍

\n

儒风顶级,未学剑宗武功可得。拜入剑宗之后可以通过征服华山派获得。

\n

下山

\n

然后就是不断儒风 15 日至年末。下山后林平之跟随。\n至林家老宅得辟邪剑谱,灭日月神教得葵花宝典,\n先切磋提升属性后再赠送。

\n

聚贤居

\n

队友:小龙女、林平之。

\n

将门派修改为古墓派,师承改为小龙女。(古墓派无法灭,嘻嘻。)

\n

窍门:装备的武器馈赠给队友,队友得到馈赠,而武器仍在自己手里,研习的武功同理。

\n

切磋林平之,提升其属性。

\n

改等级到 30 级以下,废除小龙女武功(三项武功代码改为 0,否则一招灭敌太快了,逃跑都来不及),\n输给半瓶醋得秘籍:松风剑法、奇门三才刀、太祖棍、五罗轻烟掌、锁喉擒拿手、飞檐走壁、叫花内功;\n改等级到 30 级以上,输给半瓶醋得秘籍:越女剑法、伏魔杖法、化骨绵掌、凝血神爪、北斗仙踪、紫薇心法。

\n

每月事件

\n

【救治青翼蝠王】神秘商人处买棉衣,或直接修改,装备棉衣,战莽牯朱蛤,胜后韦一笑教寒冰绵掌。

\n

趁现在队伍有两个空位,先拿闯王宝藏图:找胡斐打胜他,带他去药王庄,程灵素加入。\n顺便去阎基居,打胜得胡家刀法,自己先学再送给胡斐。\n去苗人凤家选择帮苗人凤,打胜何红药并且侠义够高即可得到闯王宝藏图和苗家剑法。

\n

【救治盲女】医术80以上,先到南方【树林】加入游坦之,给阿紫治眼会牺牲游坦之,打败丁春秋换到【神木王鼎】【腐尸毒】【解毒术】。

\n

【放荡形骸的浪子】由于拜入武当,牛家村已灭,无法买酒,只能直接修改:葡萄酒,梨花酒,百草美酒,高粱酒。跟令狐冲聊天后,队伍有空位,令狐冲加入队伍。

\n

【悲情杨过】给断肠草。事先踢掉最弱的阿紫,杨过加入队伍。

\n

【四个淫棍】目前队伍中有小龙女、林平之、令狐冲、杨过,可以避免淫棍加入,可得武功。\n田伯光的狂风刀法已经从少林学到,欧阳克的蛤蟆功不如霍都的龙象般若功强,因此帮霍都。

\n

【天王老子傲四方】选帮助向问天,队伍满,向问天不得加入。做完此任务后可去梅庄,打败任我行可习狮吼功、吸星大法。

\n

【桃花岛主,贻笑江湖】 选择帮李莫愁胜利后获得五毒秘传,选择帮助黄药师胜利后习得玉箫剑法和弹指神通。

\n

【四十二章经的秘密】去京城杀段天德,饶过完颜洪烈,得刀、棍。\n反复去京城,搜集到 6 本四十二章经。\n踢杨过(目前最弱)去渡口,至神龙教,征服,得 1 本四十二章经,另苏荃加入队伍。\n从神秘商人处得到夜行衣。穿夜行衣至少林寺,乔装混入藏经阁,寻找四十二章经。\n藏经阁需碰运气,不一定找得到,且三楼有可能碰到扫地、张小肉没收。如无耐心可直接修改(镶蓝旗)。\n收集齐全四十二章经后,进入,得银100万。

\n

此时林平之切磋得差不多了,给他辟邪。灭日月神教,得葵花,给林平之。至此林平之长成,全属性过百。

\n

【死守襄阳城】与金轮法王对决,队伍满员,郭靖不加入。

\n

【东郭狼子心】打败何太冲,福缘>80,获得《九阳真经》和蟠桃。

\n

【迷途小和尚】虽然现在是古墓派,到底在少林和虚竹呆过,虚竹马上认出我是师弟。我告知去少林的路,获赠\n某药丸 10 枚。

\n

【韦小宝性命危矣】队伍满员,避免其加入,得银500两。

\n

【回族部落的圣物】得《可兰经》,队伍满员,香香公主不加入。

\n

【魔教圣姑】完成天王老子傲四方和梅庄任务,踢掉最弱的苏荃,任盈盈加入。

\n

【落花流水斗血刀僧】由于只有狄云加入队伍才能得《神照经》,所以踢掉任盈盈。帮落花流水,选不杀狄云,\n狄云加入,并得到《神照经》和《唐诗选辑》。\n狄云是吃货,正好拿华山宁中则做的菜宴请他,不断宴请加好感,最高加到 100.

\n

【西夏招亲】打败鸠摩智,得火焰刀。

\n

【王语嫣的悲哀】踢掉最弱的狄云打慕容复,胜利后王语嫣加入。\n王语嫣极弱,赠女装后好一点。

\n

【闯王宝藏的秘密】如前所述,已拿【闯王宝藏图】,得到倚天剑,屠龙刀,打狗棒,霹雳雷火弹10颗。

\n

【唐诗选辑的秘密】得到唐诗选辑,做完任务就得到5000两。

\n

【庄家的复仇】找四十二章经时曾在京城杀掉鳌拜,故可得庄家回报。队伍满员,避免双儿加入,得十八泥偶,可\n研习罗汉伏魔功。

\n

【良辰吉日】:选择一位女性队员做老婆。该名队员属性会暴涨。

\n

【擂鼓山棋局】段延庆自杀时静观其变,让虚竹阻止并成为掌门,自己则避免所有内功被洗。

\n

【田归农的挑战】踢掉最弱的王语嫣,找胡斐,赢后可得冷月宝刀。

\n

【群寇争镖银】选择帮阿九姑娘,胜出队伍有空位阿九加入,否则得3000两。选择帮田归农,得随机银两。两个一起打,得到一大笔随机银两。

\n

【神雕侠的三件礼物】踢掉胡斐,选择归还打狗棒,因为闯王宝藏里已经拿了 1 根了,没必要贪这根。郭襄加入。\n神秘商人处购买峨眉九阳功,赠郭襄。然后女装赠郭襄。馈赠完毕,属性勉强能看了。

\n

【昔日的皇妃】悟性>50且侠义>70得九阴真经,否则习得空明拳;悟性<50学到左右互搏。\n我喜欢空明拳,故事先修改侠义为 0.

\n

【绝情谷婚宴】周伯通走时,选一,先得到3个生生造化丸,战斗赢后得到公孙绿萼(队伍有空位加入,无空位送君子剑和淑女剑)选二,得断魂草。建议选一,因为小龙女会要淑女剑。断肠草可以在神秘商人处购买,且此任务可反复做。

\n

【全真派与桃花岛的恩怨】黄药师传落英神剑掌和兰花拂穴手再给5个九花玉露丸。

\n

【老尼姑的险境】得天山掌法,小心侠义别超过 80,否则会成为恒山掌门。这个掌门是个空头衔,一样可以征服恒山。

\n

【腊八粥】由于悟性大于 50,太玄功没得学(可以直接修改)。需确保侠义值非正,否则连架也没得打。

\n

然后再把侠义改成大于 30,队伍满员,去无量山洞,得凌波微步。

\n

到塞外找萧峰,确保侠义大于 80,第一次获胜得降龙,第二次得打狗,\n第三次萧峰加入队伍(需事先踢一人,例如最弱的郭襄,不过我没踢,\n让萧峰塞外隐居吧)。

\n

征服各门派可得一大堆武功。

\n

华山之巅

\n

玩家

\n
侠义 <= 0\n生命内力:原始值为 99999。\n属性原始值:内、搏、拆、闪、轻为 99,其他 100.\n五属性加内功、轻功数值: 99x.\n内功:玉女心经\n轻功:凌波微步\n装备:倚天加软猬甲(衣服随意,例如女装,暗器随意)\n招式:辟邪剑法、八荒六合唯我独尊、神照、天罗地网势、美女拳法、玉女剑法、玉女素心剑法、玉女心经\n
\n

未装备快捷的古墓派武功:

\n\n

使用神照不用龟息是因为龟息加别人不如神照一下复活。玩家自身血超过 99999 无需加血,若秒杀而死根本来不及加血。

\n

八荒弱于倚天加独孤,不过内、搏刷到 99x 后没有差别,均为极大溢出,八荒的画面效果要美得多。

\n

队友

\n
    \n
  1. 小龙女:由于属性过高,因此保持武功全废,否则一下就打玩了。
  2. \n
  3. 林平之:血少了点,不过也撑到达摩手下才死,也算够了。
  4. \n
  5. 令狐冲:华山学独孤,酒、紫薇软剑已送。
  6. \n
  7. 东方不败:修改器改出来的,画面中没有形体,孤零零的速度条,更像鬼魅了。
  8. \n
\n

玩家不出手,小龙女无法出手,就靠三个队友出手绰绰有余。

\n

TODO

\n

砍树至午时,回村,与官差争执,醒后至树林找丘处机入全真。

\n

回答问题不要讨好赵志敬,得全真心法。大殿找丘处机养生至 3 月。比武逃跑,判处全真。

\n

以死相逼入古墓。找小龙女学天罗地网势。

\n

修改 m[139] 为 初入武当,m[140] 为 武当派.得武当长拳。

\n

武当长拳 8 级,找俞岱岩学震山铁掌。已学震山铁掌,侠义 6 级找俞岱岩学绵掌。(大殿加侠义)

\n

学绕指柔剑后,至大殿累计打败 10 个恶人,找殷梨亭学神门十三剑。

\n

修改 m[139] 为 初入华山,m[140] 为 华山派。多和林平之切磋,掷针术升到 7 级。

\n

修改 m[128],反复进秘洞,直到得万花剑法、百变千幻云雾剑法等,并得金蛇剑法、金蛇剑。

\n

修改 m[128] 为 301,得独孤九剑。

\n

修改 m[128] 为 230,m[139] 为 初入全真,m[140] 为 古 墓.找小龙女学美女拳法。

\n

修改 m[139] 为 初入少林,m[140] 为 少林派. 门派技能改为 佛法.

\n

至 3、6、9月过木人巷,选达摩堂。修佛法 9 级,大力金刚掌 9 级,得大力金刚指、须弥山掌,得拈花指。

\n

参考

\n","date_published":"Thu, 24 Aug 2017 13:06:40 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/dapi/jyqxz2-cheat/","url":"https://mmap.page/dapi/jyqxz2-cheat/","title":"金庸群侠传 2 加强版作弊教程","content_html":"

金庸群侠传 2 加强版作弊教程

\n

Windows 存档目录为

\n
C:\\Documents and Settings\\用户名\\Application Data\\Macromedia\\Flash Player\\\n#SharedObjects\\随机字母数字\\游戏网址目录\\随机字母数字\\\n
\n

Linux:

\n
~/.config/google-chrome/Default/Pepper Data/Shockwave Flash/\nWritableRoot/#SharedObjects/随机字母数字/游戏网址目录/随机字母数字/\n
\n

存档文件为 gamezly.sol (存档一)、gamelzy (存档二)、gameylz (存档三)。

\n

存档后需要退出游戏,否则存档文件不会更新。

\n

基本属性

\n

变量命名比金庸群侠传 3 有规律多了,基本是拼音首字母。

\n

| 变量 | 含义 | 备注 |\n| name_1 | 姓 ||\n| name_2 | 名 ||\n| LV | 等级 ||\n| JYZ | 经验值 |\n| S_M | 生命 | 最大值 9999 |\n| S_M0 | 当前生命 | 最大值 9999 |\n| N_L | 内力 | 最大值 9999 |\n| N_L0 | 当前内力 | 最大值 9999 |\n| F_Y | 福缘 | 最大值 100 |\n| S_W | 声望 | 最大值 999 |\n| W_X | 悟性 | 最大值 100 |\n| L_D、L_D0 | 力道 | 最大值 300,研习易筋经、九阴真经、九阳真经、葵花宝典等后 L_D 最大 500 |\n| H_T、H_T0 | 护体 | 最大值 300,研习易筋经、九阴真经、九阳真经、葵花宝典等后 H_T 最大 500 |\n| S_F | 身法 | 最大值 100 |\n| Q_Z | 拳掌 | 最大值 100 |\n| Y_J | 御剑 | 最大值 100 |\n| A_Q | 暗器 | 最大值 100 |\n| Y_L | 医疗 | 最大值 100 |\n| Y_D | 用毒 | 最大值 100 |\n| J_D | 解毒 | 最大值 100 |\n| X_Y | 侠义 | 小于 50 为恶,最大值 100 |\n| Y_Z | 银两 | 最大值 9999 |\n| XXD | 学习点 | 最大值 999 |\n| Menpai | 门派 | 初始为「无门派」 |\n| Chenhao | 称号 ||

\n

武功

\n

lv_ 开头的变量记录武功等级,exp_ 开头的变量记录武功经验。\nlv_*XF 则记录心法的等级,最高 5 级。其他武功 lv_ 最高 10 级。

\n

exp_ 只决定升级,如果只改 lv_ 到 10,使用一定次数后可能会出现错误。\n不同的武功经验对应的等级不同。例如降龙 1300 满级,龙象 2200 满级。

\n

| 代码 | 武功 | 备注 |\n| taijiquan | 太极拳 | 遇强则强,特殊之处是对付无名僧一招秒杀 |\n| qishang | 七伤拳 | 升级减血上限 |\n| xingyi | 形意拳 ||\n| anran | 黯然销魂掌 ||\n| tianshan | 天山六阳掌 | 10 级后一定几率生成生死符 |\n| tiezhang | 铁掌 ||\n| liumai | 六脉神剑 ||\n| nianhua | 拈花指 ||\n| taijijian | 太极剑 ||\n| wuyue | 五岳剑法 ||\n| xuantie | 玄铁剑法 ||\n| jiuyang | 九阳神功 ||\n| beiming | 北冥 | 吸内力 |\n| hanbing | 寒冰真气 | 一定几率(10 级最多 7 次)延缓、停止对手行动至打斗结束 |\n| kongming | 空明拳 ||\n| luohan | 罗汉拳 ||\n| xianglong | 降龙十八掌 ||\n| mianzhang | 绵掌 ||\n| hunyuan | 混元掌 ||\n| yiyang | 一阳指 ||\n| tanzhi | 弹指神通 ||\n| canhe | 参合指 ||\n| jinshe | 金蛇剑法 ||\n| dugu | 独孤九剑 ||\n| pixie | 辟邪剑法 | 强力高速 |\n| taixuan | 太玄经神功 ||\n| longxiang | 龙象般若功 ||\n| jinzhong | 吐纳术 | 回血 |\n| jichujian | 基础剑 | 升到 10 级强于最弱剑术 |\n| jichuquan | 基础拳 | 升到 10 级强于最弱拳掌 |

\n

注意:

\n\n

物品

\n

no_ 开头的变量记录物品数量。背包中物品数量只有两位,实际不止,超过 99 战斗时照常使用。

\n

常用物品:

\n\n

有些物品只能通过修改改出:

\n\n

场景

\n

CJ 记录场景:【昆仑仙境】、【华山】、【剑冢】、【百花谷】、【衡阳】、【襄阳】、【侠客岛】、\n【武当派】、【明教过道】、【黑木崖】、【练毒功】、【少林寺】。

\n

攻略

\n

自创

\n

首先,剧情进行至衡阳城,存档。\n修改生命、内力 9999,悟性 49,力道、护体为 300,其他属性为 100,银两 99999,学习点 999.

\n

打败半瓶醋 20 次后可学自创,自创学习后会洗掉所有武功。因此先学自创。\n生命 9999 不够,改九花玉露丸数量。\n普通攻击打败太慢,改飞镖数量。\nrrr 改成 19,到地图刀剑处,有一定概率碰到半瓶醋,获胜得自创。

\n

打败半瓶醋后会减侠义(人品),由于初始侠义 50,减 1 后为恶,阿紫出现。\n帮她捉虫可以增加毒术,但是毒术已经改到 100 了,因此不用理她。

\n

遇到半瓶醋 20 次投降后可以得龙象般若功或学习点或钱或天下第一称号。\n或者直接改 lv_longxiang 和 exp_longxiang.

\n

衡阳城

\n

找小宝货郎买金蛇套装,得金蛇剑法,装备金蛇剑、金丝甲。

\n

客栈上楼遇田伯光和仪琳。选择和田伯光结拜的话以后可以找风清扬学独孤九剑,不结拜的话可以找令狐冲学。\n和田伯光结拜的话,会碰到泰山派道人,阻止田伯光灭口的话会跌侠义值,不过无所谓,因为战胜半瓶醋已经跌侠义了。

\n

武馆可以学形意拳。

\n

医馆的金疮药、小还丹太次,不用买。

\n

百花谷

\n

找周伯通切磋,先输 1 场,得左右互搏。

\n

左右互搏得到,悟性可以改 100 了。再赢 1 场,得九阴真经。

\n

辟邪剑谱

\n

福威镖局找林平之。再去破庙击败木高峰。回福威镖局告诉林平之。

\n

然后再去福威镖局找林平之,得知林已杀木高峰,不过眼睛瞎了无法找余沧海报仇。

\n

至青城派杀余沧海,然后回福威镖局得辟邪剑谱。

\n

无量山洞

\n

至无量山洞,点磕头 100 下,得北冥、凌波微步。

\n

出洞,击败莽牯朱蛤。使用可以解毒变 100,不过解毒已经改到 100 了。

\n

九阳神功

\n

至昆仑派,输给何太冲。注意何太冲每击只伤 1,因此事先要找周伯通打成贫血,否则有的等了。

\n

输掉后被打落山崖,得九阳神功。

\n

少林

\n

至少林寺,选偷入藏经阁,一定概率得拈花指和易筋经。

\n

或者也可以直接修改 no_yijinXF 得到易筋经。

\n

偷到拈花指和易筋经后可拜入少林寺(拜入后就再没机会偷了)。

\n

拜入后从玄苦处学得罗汉拳。罗汉拳 10 级,得混元掌。混元掌 6 级,得参合指。

\n

然后去野外杀生(强盗、老虎) 20 次,回少林寺,会被关,打赢厨僧后成为少林弃徒。

\n

如果超过 30 级即使再杀生也成不了弃徒。这时可直接改门派或者改等级。

\n

弹指神通

\n

此时等级应该已过 20 了,再去破庙,遇李莫愁,选择静观其变,得弹指神通。

\n

剑冢

\n

助大雕,得玄铁剑、玄铁剑法。

\n

黯然销魂掌

\n

至渡口,与杨过切磋,获胜得黯然销魂掌。

\n

万劫谷

\n

至万劫谷,选择对付四大恶人,击败段延庆,得一阳指。

\n

天龙寺

\n

至天龙寺,击败鸠摩智,改姓段,得六脉神剑。(若没在万劫谷得一阳指,则得一阳指而不是六脉神剑。)

\n

聚贤庄

\n

这时声望够高,应该已经得到刘正风金盆洗手请帖和聚贤庄邀请函了。

\n

先去聚贤庄,助萧峰。然后再去长白山,得降龙十八掌。

\n

笑傲江湖

\n

去衡阳参见刘正风金盆洗手大会,事先不要去嵩山派,否则会成为阻止刘正风金盆洗手的人,且得不到笑傲江湖曲谱。

\n

费彬阻止金盆洗手,曲洋救走刘正风,追出,听合奏《笑傲江湖》,击败费彬,得《笑傲江湖》曲谱。

\n

至襄阳城衙门,击败士兵,遭暗算下狱。战胜丁典,不跟随越狱,得乌蚕衣(最强护甲)。

\n

第二天提审时不承认,见绿竹翁,不要赠《笑傲江湖》曲谱,\n否则会得到黑木令,去日月神教会战东方不败,战胜也得不到《葵花宝典》。\n除非先加入日月神教,再带着曲谱到襄阳城衙门,触发绿竹翁事件。

\n

返回衙门,击败,得银两。

\n

寒冰真气

\n

至嵩山派,得五岳令,至华山找封不平,再返回嵩山派,至襄阳妓院找玉玑子,仍返回嵩山派,至铸剑谷教训定逸。

\n

最后至嵩山派得寒冰真气。

\n

华山

\n

侠义改为 50 以上,如果没有成为少林弃徒,则将门派改为「无门派」。

\n

入华山,得《华山心法》。先别练到 5 级,否则一找岳不群说话就会进入思过崖剧情。

\n

找岳不群说话,这样以后思过崖剧情可得五岳剑法。

\n

找岳灵珊说话,有一定几率会切磋,连输 10 次,以后思过崖剧情可得紫霞心法。\n因为岳灵珊每击只能伤 1,因此事先先到渡口找杨过打成贫血,否则有的等了。

\n

找令狐冲说话,给他酒、杯(衡阳小宝货郎处购买)可以得独孤九剑。\n如果不找令狐冲说话的话,因为事先和田伯光结拜过,思过崖剧情可从风清扬处得到独孤九剑。

\n

华山心法 5 级,找岳不群至思过崖闭关,休息几次后,悟出五岳剑法。

\n

遇田伯光,将其击败。(虽说是来抓你走的,但是打输了直接 game over.)

\n

再休息几次后,岳灵珊会来送紫霞秘籍。

\n

然后参加五岳并派大会,获胜,成为五岳掌门。

\n

侠客岛

\n

此时当仍为善,可乘此机会去侠客岛(恶人学不到太玄经)。

\n

至渡口找张三,到侠客岛,得腊八粥,参悟武功得太玄经神功。

\n

入武当

\n

门派改为「无门派」,入武当。

\n

如等级在 30 以上,一入武当马上找俞岱岩学武当心法,再学绵掌,武当心法 5 级后则学梯云纵。\n期间切勿和张三丰讲话,否则会进入围攻光明顶剧情,学不到武功。\n如果不行,把等级改到 30 以下。

\n

光明顶

\n

等级 30 时至光明顶,山脚遇灭绝与魔教教众,助魔教,进山洞,1、2、3、2,选书信,得乾坤大挪移,学习到顶级。

\n

相助明教,靠乾坤大挪移得七伤拳。击败灭绝得倚天剑(最强剑)。

\n

这里若是相助正派,回武当得太极拳、太极剑、真武剑(还不如玄铁剑),但是得不到七伤拳、倚天剑。

\n

至百花谷,与周伯通切磋,靠乾坤大挪移得空明拳。

\n

七伤拳和空明拳是乾坤大挪移能学到的武功,其他的学不到。

\n

葵花宝典

\n

至黑木崖,入日月神教,铁掌 10 级,找向问天。出来后再进黑木崖,击败任我行,得《葵花宝典》。

\n

至此所有秘籍都修炼了,力道、护体可达最大值 500.

\n

此后需要经验值可以找任我行切磋,增加得比较快。

\n

如果碰到任我行说身体不适,如果想拿「东方不败」的称号,那么选择终于等到这一天了,击败向问天、任我行,得称号。

\n

拿了称号也没有其他好处,\n不拿的话反正渡口有杨过可以切磋,任我行除了会吸内力外实力差不多(周伯通弱好多,奇怪),都可以。

\n

长白山

\n

35 级到长白山,助天山童姥得天山六阳掌。

\n

至此除了太极拳、太极剑以外,所有武功都学了。这两样可以通过修改学习。

\n

华山之巅

\n

华山论剑,击败匪兵丙、萧峰、东方不败、无名僧、半瓶醋通关。

","date_published":"Thu, 24 Aug 2017 13:06:40 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/poems/quatrains/","url":"https://mmap.page/poems/quatrains/","title":"絕句","content_html":"

絕句

\n

詞將窮

\n
去留肝膽兩昆侖\n辭達而已未成章\n望斷天涯不回首\n相付惟有淚千行\n
\n

composed at 2011-04-23

\n

無題

\n
柯亭亡臣傳竹笛\n孤山處士妻梅花\n莫羡錦鱗人爭乳\n自有芙蕖憐小蝦\n
\n

composed at 2011-06-01

\n

打油一首嘆喪失光榮傳統不發月餅

\n
月影即是餅\n入眼甘如飴\n畵餅不似月\n遇食亦無虧\n
\n

composed at 2011-09-16

\n

古絕一對

\n

昨日遊清涼山公園,中有南唐古井名還陽者,深幽似通冥府,感其名,因作古絕一對。

\n
五十弦斷盆可鼓\n卅載井枯水猶涼\n還陽徒爾十指戕\n莫若尸居觀天長\n\n君言弦斷盆可鼓\n卻道井枯水猶涼\n卅載尸居觀天恢\n一朝還陽十指戕\n
\n

composed at 2011-10-15

\n

讀莊

\n
生寄死歸奚足悲\n莊生猶嘆吾質失\n寢說豈忘堅白昧\n入土難安皮囊室\n
\n

composed at 2011-12-02

\n

詞窮

\n
天網恢恢筌蹄朽\n窮不窮處詞未工\n欲將殘生抵一聯\n奈何蝶心曉夢終\n
\n

free edition, composed at 2012-03-19

\n
盡忘筌蹄風月好\n齊觀窮達薄詞工\n欲將殘歲抵詩句\n無奈蝶心晨夢終\n
\n

bondage edition, composed at 2012-03-20, and edited at 2012-03-27 (change '餘歲' to '殘歲') and 2012-09-02 (change '曉' to '晨', to avoid 孤平)

","date_published":"Sun, 20 Aug 2017 08:25:35 GMT","date_modified":"Sat, 23 Nov 2019 19:28:41 GMT"},{"id":"https://mmap.page/poems/","url":"https://mmap.page/poems/","title":"詩存","content_html":"

詩存

\n","date_published":"Sun, 20 Aug 2017 08:25:35 GMT","date_modified":"Fri, 21 Apr 2023 11:03:43 GMT"},{"id":"https://mmap.page/dapi/","url":"https://mmap.page/dapi/","content_html":"

故紙

\n\n

舊瓶

\n\n

詩箋

\n\n

文藝

\n\n

游戲

\n\n
\n

詩存 | 碎碎念

","date_published":"Sun, 20 Aug 2017 08:25:35 GMT","date_modified":"Tue, 29 Jul 2025 17:15:05 GMT"},{"id":"https://mmap.page/vim/completion/","url":"https://mmap.page/vim/completion/","title":"Vim Completion Configuration","content_html":"

Vim Completion Configuration

\n

A Bit of History

\n

Vim has built-in support for completions in insert or replace modes,\nmostly based on the content of the current file and included files.\nBy default, it uses separate Emacs-style key bindings (<C-x C-key>)\nfor different kinds of completions.\nSee :help ins-completion for more information.

\n

The modern approach is utilizing language server protocol, a.k.a. LSP, and machine learning.

\n

The concept of LSP is pioneered by vscode,\nso a lot of language servers are written in Node.js and TypeScript.\nWhile mostly used for LSP,\nCoC brings the ecosystem of vscode extensions to vim,\nwhich makes porting them to vim easier.

\n

Then Neovim 0.5+ introduces native LSP support,\nbased on Lua instead of Node.js.\nHowever, as mentioned above, since a lot of language servers are written in Node.js,\nmost likely Node.js is still needed.

\n

Machine Learning based Completion

\n

Popular options of machine learning assisted completion are:

\n\n

I have used Tabnine (free plan) for a while.\nIt does not include whole line and full-function code completion.\nAlthough Tabnine Pro offers offline installation, it requires contacting sales.\nIts free plan is based on the cloud, just like Copilot.

\n

Tabnine Pro is $12 per month, slightly higher than Copilot ($10 per month).\nAnd qualified open source project contributors can use Copilot for free.

\n

Both Codeium and Amazon CodeWhisperer are free for personal use.\nCurrently, CodeWhisperer only supports VSCode and JetBrain IDEs.

\n

I use Copilot and Codeium at the same time under Neovim,\nwhere nvim-cmp can use both as a completion source.\nCodeium tends to offer multi-line completion as a whole,\nand Copilot are more likely to provide completions line by line.\nThe completion quality is roughly the same, as I have experienced.

\n

My LazyVim Configuration for Copilot and Codeium

\n
-- lua/config/lazy.lua\nrequire(\"lazy\").setup({\n  spec = {\n    { \"LazyVim/LazyVim\", import = \"lazyvim.plugins\" },\n    { import = \"lazyvim.plugins.extras.coding.copilot\" },\n    { import = \"plugins\" },\n  },\n})\n\n-- lua/plugins/cmp.lua\nreturn {\n  -- The official plugin does not support nvim-cmp, use a community one instead.\n  {\n    \"jcdickinson/codeium.nvim\",\n    dependencies = {\n      \"nvim-lua/plenary.nvim\",\n      \"hrsh7th/nvim-cmp\",\n    },\n    config = function()\n      require(\"codeium\").setup({})\n    end,\n  },\n}\n
","date_published":"Sun, 23 Jul 2017 13:56:52 GMT","date_modified":"Tue, 25 Apr 2023 07:46:55 GMT"},{"id":"https://mmap.page/coding-style/","url":"https://mmap.page/coding-style/","title":"Style Guide","content_html":"

Style Guide

\n

These are for personal reference only.

\n","date_published":"Sun, 11 Sep 2016 00:46:52 GMT","date_modified":"Mon, 24 Apr 2023 08:23:55 GMT"},{"id":"https://mmap.page/","url":"https://mmap.page/","content_html":"

This is a learning-by-doing project for me to experiment Lume and Deno.

\n

Random Pages

\n

Some random pages for demonstration purposes (content may be outdated or auto generated via AI).

\n

Syntax Highlighting

\n

Syntax highlighting in Lume is supported via Prism or Highlight.js.\nAnd two community plugins for Glow and Shiki are available.

\n

Glow is too naive to me and supports only a limited set of languages.\nCompared to Prism and Highlight.js, Shiki is more powerful and ships zero JavaScript in runtime.\nFor this site, I use starry-night, which is similar to Shiki in essence,\nbut matches GitHub in that it produces classes and works with the CSS it ships.\nThere is no Lume plugin for Starry Night, but it is easy to use with Lume:

\n
site.use(remark({\n  rehypePlugins: [[\n    rehypeStarryNight, {\n      grammars: all \n    }]],\n}));\n
\n

Some random pages with syntax highlighting:

\n\n

More Random Pages

\n\n

Markdown Sandbox

\n

The following table uses GitHub Flavored Markdown (GFM) table syntax,\nwhich may not render correctly in all Markdown viewers:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
ghgistmastodongpgrssjson/log/movies/uses
\n

\"Netlify

","date_published":"Sun, 11 Sep 2016 00:46:52 GMT","date_modified":"Wed, 15 Jul 2026 11:26:55 GMT"},{"id":"https://mmap.page/dive-into/make/","url":"https://mmap.page/dive-into/make/","title":"Write Makefile Compatible with Both GNU make and BSD make","content_html":"

Write Makefile Compatible with Both GNU make and BSD make

\n

BSD make is simple, but GNU make is more popular due to Linux's popularity.\nThus, I prefer to write Makefile compatible with both versions.

\n

Syntax

\n

The following syntax is valid in both GNU make and BSD make.

\n
include config.mk\n\n# variable declaration (this is a comment)\nPREFIX = /usr/local\n\n# First target is the default target which will be invoked when typing `make`.\nall: this-is-a-target another-target\n\nthis-is-a-target:\n        echo command\n        echo `echo command substitution`\n        @echo not echo the command line to screen\n        -echo keep going even if command returns a nonzero status\n\nanother-target: sourcefile\n        echo will only run if sourcefile timestamp is newer\n        echo ${PREFIX}\n
\n

BSD vs. GNU

\n
\n

BSD Make just knows about dependencies, targets, rules and macros.\nGNU Make adds built in rules to that mix to make it easier for the developer.

\n

It turns out that details of systems are conflicting and cannot be known in advance.\nBSD Make deals with system dependencies by having the system define its parameters.\nGNU Make's built in rules turn out to be inadequate.

\n
\n

-- kbw

\n
\n

When using bsd.*.mk, each Makefile can build only one program or library.

\n

...

\n

The file bsd.port.mk is at the center of FreeBSD Ports,\nthe system that builds software packages for FreeBSD.\n(NetBSD pkgsrc calls this file bsd.pkg.mk.)

\n
\n

-- George Koehler

\n
\n

Most of openbsds simple Makefiles are compatible with bmake\nbut if it gets a little bit more complicated\nthere are small differences that break the build.

\n

... the openbsd Makefiles /usr/share/mk ... are not really portable\nand use openbsd specific binaries like lorder and tsort with the openbsd specific -q flag.

\n

And most software is using GNU Make,\nI think it would be way more work to use bsd makefiles on linux targets,\nthey are not really written to be portable.

\n
\n

-- Duncaen

\n

Under debian, BSD make is available as the bmake package.\nAnd FreeBSD makefile templates for bmake are available as the freebsd-mk package.

\n

Bonus: Plan9 mk

\n

mk in Plan9 is similar to BSD make, with fewer rules.

\n

The main difference is templating:

\n\n

Plan9 also supports using different shells within a single mkfile:

\n
MKSHELL=/bin/rc\nuse-rc:V:\n    for(i in a b c) echo $i\n\nMKSHELL=sh\nuse-sh:V:\n    for i in a b c; do echo $i; done\n
","date_published":"Tue, 16 Aug 2016 08:03:18 GMT","date_modified":"Tue, 06 Sep 2022 05:05:55 GMT"},{"id":"https://mmap.page/uses/borg/","url":"https://mmap.page/uses/borg/","title":"A Short Borg Tutorial","content_html":"

A Short Borg Tutorial

\n

Borg is the new generation of attic.

\n
borg init --encryption=keyfile /path/to/repo\nborg create -C lz4 /path/to/repo::NAME-YOUR-BACKUP ~/Documents\n
\n

Free space

\n

Before you start creating backups,\nplease make sure that there is always a good amount of free space\non the filesystem that has your backup repository (and also on ~/.cache).

\n

Encryption

\n

Default enabled with repokey method.

\n
borg init --encryption=none|repokey|keyfile PATH\n
\n

When repository encryption is enabled,\nall data is encrypted using 256-bit AES encryption\nand the integrity and authenticity is verified using HMAC-SHA256.

\n\n

In both modes, the key is stored in encrypted form\nand can be only decrypted by providing the correct passphrase.

\n

Do not forget to backup the key (e.g. via borg key export).

\n

For automated backups the passphrase can be specified\nusing the BORG_PASSPHRASE environment variable.

\n

Be careful how you set the environment;\nusing the env command, a system() call or using inline shell scripts\nmight expose the credentials in the process list directly\nand they will be readable to all users on a system.\nUsing export in a shell script file should be safe, however,\nas the environment of a process is accessible only to that user.\nAlso, using a shell command may leak the passphrase in shell history file.

\n

For server backup, have a look at borgmatic.

\n

Compression

\n
borg create --compression lz4\n
\n

I prefer lz4 since it is very fast.\nIf the repository is on a remote host with slow (dial-up) connection,\nI recommend lzma instead.\nThe default option is no compression.

\n

Upgrade from attic

\n
borg upgrade --inplace REPOSITORY\n
\n

If a backup copy is required, omit the --inplace option.

\n

Hosted Services

\n","date_published":"Sun, 24 Jul 2016 15:49:09 GMT","date_modified":"Tue, 15 Jul 2025 15:16:01 GMT"},{"id":"https://mmap.page/python/persistence/","url":"https://mmap.page/python/persistence/","title":"Python Persistence","content_html":"

Python Persistence

\n

This survey is outdated and unmaintained.\nFor compatibility with other programs,\nI would recommend JSON or SQLite instead.

\n

tl;tr

\n

If we care about compatibility with different Python versions,\nuse cPickle with binary protocol and fast option.

\n

Otherwise, just use marshal.

\n

Performance

\n

A benchmark of marshal, pickle, json, capnp for python 2.7 on my machine.

\n
import timeit\n\nmd = \"marshal.dumps({'people': [{'name': 'Alice'}]})\"\nim = 'import marshal'\n\np d= \"pickle.dumps({'people': [{'name': 'Alice'}]})\"\n\nip = 'import cPickle as pickle'\n\njd = \"json.dumps({'people': [{'name': 'Alice'}]})\"\nij = 'import json'\n\ncd = \"bm_capnp.AddressBook.new_message(people=[{'name': 'Alice'}])\"\nic = 'import capnp; import bm_capnp'\n\ndef benchmark(d, i):\n    return timeit.timeit(d, i, number=10000)\n\n# Benchmarking\nm = benchmark(md, im)\np = benchmark(pd, ip)\nj = benchmark(jd, ij)\nc = benchmark(cd, ic)\n\n# Output result\noutput = \"{name}: {time}\".format\n\noutput(name='marshal', time=m)\noutput(name='(c)pickle', time=p)\noutput(name='json', time=j)\noutput(name=\"Cap'n Proto\", time=c)\n
\n

Cap'n Proto requires an additional schema file:

\n
@0x934efea7f017fff0;\n\nstruct Person {\n  name @0 :Text;\n}\n\nstruct AddressBook {\n  people @0 :List(Person);\n}\n
\n

Result:

\n
marshal: 0.08457612991333008\n(c)pickle: 0.31447696685791016\njson: 0.7639560699462891\nCap'n proto: 0.4193081855773926\n
\n

So marshal seems the fastest on my machine.

\n

However, with binary protocol and fast option,\ncPickle is mostly as fast as marshal.

\n
>>> md = 'marshal.dumps([1, 2, 3])'\n>>> im = 'import marshal'\n>>> pd = 'fp.dump([1, 2, 3])'\n>>> ip = \"import cPickle; fp = cPickle.Pickler(open('/tmp/1', 'wb'), 2); fp.fast = 1\"\n>>> timeit.timeit(md, im, number=1000)\n0.012997150421142578\n>>> timeit.timeit(pd, ip, number=1000)\n0.017292022705078125\n
\n

Compatibility

\n

Compatibility with different Python versions

\n

Marshal is for internal usage (.pyc).\nSo its format may be modified on future versions of Python.\nCurrently (up to Python 3.4.3), there are 4 versions of marshal.\nThe current version can be viewed via marshal.version.

\n

Compatibility with other languages

\n

Implemented in other languages:

\n\n

Export to JSON

\n

To communicate with other programs,\nwe can export to JSON.

\n

On Python 2.7+, the json module from stdlib\nis fast in encoding and decoding JSON.\nNo need to use other modules.

","date_published":"Tue, 12 Apr 2016 13:56:34 GMT","date_modified":"Mon, 05 Sep 2022 10:56:44 GMT"},{"id":"https://mmap.page/dapi/chengshuxianhou/","url":"https://mmap.page/dapi/chengshuxianhou/","title":"如何考察成书先后","content_html":"

如何考察成书先后

\n

一般而言,在不考虑出土文献的前提下,判断整本书的先后:

\n
    \n
  1. 确定了时代的书籍(多为目录类)对两书成书情况的记载。
  2. \n
  3. 从用字、语法、文风等语言学特征判断。
  4. \n
  5. 考证作者年代先后。
  6. \n
  7. 从涉及的史实(包括具体的历史事件,以及某一时代的思潮风尚)来判断。
  8. \n
  9. 其他确定了时代的书对这两种书的征引的情况。
  10. \n
\n

两本书中某段内容的先后,不一定符合两本书的先后,例如:

\n

I. A 书比 B 书时代早,但是 A 中的某段内容其实是后人根据 B 补的(这又包括 A 本来有这段内容或类似这段的内容,但是后来残缺了,于是后人拿 B 中的段落去补,以及 A 本来根本没有类似内容,但是后人为了使 A 更全等原因,拿 B 中的内容去补)。\nII. A 和 B 其实都是抄了更早的 C。\nIII. A 抄了 C,B 抄了 D。

\n

对于 I. 上述判断整本书时代的方法同样适用

\n
    \n
  1. 确定了时代的书籍记载了后人补 A 的情况,或者记载了到某时 A 中的某部分已经亡佚了,目标段落恰巧在亡佚的部分
  2. \n
  3. 同前
  4. \n
  5. 确定作者有助于限定范围,例如某时代的作者不可能写出目标段落
  6. \n
  7. 同前
  8. \n
  9. 考察对目标段落的征引情况
  10. \n
  11. 目标段落和全书的吻合程度
  12. \n
  13. 目标段落在两书中的比较
  14. \n
\n

7 比较复杂一点,比如 A 详细, B 简略,这有两种情况:

\n

7.1 B 早 A 晚,A 在 B 的基础上添油加醋\n7.2 A 早 B 晚,B 概括了 A 的记载

\n

这个判断就比较复杂,要考虑多种因素,写出来太多了。

\n

举一个例子:

\n

A 简略记载了 X 国 Y 地 M 做了某件丑事。\nB 详细记载了 X 国的 M 做丑事的具体经过,对话乃至心理活动,但是没提到 Y 地。

\n

假设 A 概括了 B,那么 B 没有记载 Y,A 从何得知 Y 地呢? 除非 A 从 C 中得知了,这个属于 II,这里不讨论。如果说 A 添油加醋,何以其他细节都省略,唯独加了 Y 地?除非有其他因素(例如 A 的作者讨厌 Y 地的人,所以有意把这件记载安到 Y 地,或者 B 的作者是 Y 地的人,为家乡讳,省略了 Y 地),我们不倾向 A 概括了 B 。

\n

然后我们考虑 B 添油加醋了 A,然后发现 B 具体描述了经过,能更好的说明 B 中的主张,那么省略 Y 地这一细节的记载很可能就是 B 的作者认为 Y 地这一细节没什么用。

\n

由此我们倾向 B 晚于 A。当然有可能是 B 抄 A 的时候漏掉了 Y 地 两个字,或者是后人传抄 B 的时候漏掉了。但是类似的倾向性证据搜集多了就能说明问题了。

\n

II 的话:

\n

如果 C 还在,且其年代确定,那就没什么好讨论的了。

\n

如果 C 在,但年代不确定,那么应用 1-5 于 A、 B、 C

\n

如果 C 已经亡佚,或不确定有 C 存在:

\n
    \n
  1. 确定了时代的书籍记载了A 或 B 抄 C 的情况
  2. \n
  3. 若语言学分析的结果是目标段落和 A 与 B 的成书年代皆不合,反而体现了早于两者的时代特征
  4. \n
  5. 同前
  6. \n
  7. 同前
  8. \n
  9. 同前,引用目标段落而不标 A、B,反而标明了 C 的情况。
  10. \n
\n

III. 将以上方法类推到 C 和 D 的考察中。

\n
\n

以上是一般的方法。对于先秦两汉的古籍,考察其年代,首先要有“别本单行”的意识:最早是单篇,现在看到的都是后人编的。比如《莊子》和《列子》就都是后人编集的。

\n

余嘉锡《古书通例》云:“古人著书,本无专集,往往随作数篇,即以行世。传其学者各以所得,爲题书名”,“虽其平日因人事之肆应,作爲书疏论说,亦所以发明其学理,语百变而不离其宗,承其学者,聚而编之,又以其所见闻,及后师之所讲习,相与发明其义者,附入其中,以成一家之学。故西汉以前无文集,而诸子即其文集。非其文不美也,以其爲微言大义之所托,言之有物,不徒藻绘其字句而已”,“其书不作于一时,其先后亦都无次第。随时所作,即以行世”。

\n

所以先秦两汉的书,不便笼统地讲时代,需分出:

\n

一、 我们现在看到的版本,是什么时候定型的?\n二、 这书最早的胚胎,大约是什么时候出来的?

\n

然后对具体的段落的年代,只能参考一和二,不能直接套用结论,很可能还要再考察。

\n

由于先秦两汉的书成书情况的特征,出土文献还是最简便、最直接的方法。

","date_published":"Mon, 11 May 2015 09:43:00 GMT","date_modified":"Sun, 26 Jul 2026 17:41:03 GMT"},{"id":"https://mmap.page/dapi/bidouxiangzao/","url":"https://mmap.page/dapi/bidouxiangzao/","title":"跋貴妃的紅汗","content_html":"

跋貴妃的紅汗

\n

孟晖. 2010-08-01. 贵妃的红汗[M]. 南京: 南京大学出版社. ISBN 9787305075278

\n
\n

《肘後備急方》...也記有「蓽豆香藻法」...從配料與製作程序來看,這裏所介紹的也是一種比較簡單的澡豆。「藻」乃「澡」字之誤。 (pp. 4-5)

\n
\n

案「藻」不誤。\n「藻」有「藻飾」義。\n此引《肘後備急方》「蓽豆香藻法」,末云「粉飾之也」,「粉飾」即「藻飾」。

\n

【附記】已提交給作者,作者已知悉。

","date_published":"Sun, 04 Jan 2015 14:36:12 GMT","date_modified":"Sat, 23 Nov 2019 19:11:50 GMT"},{"id":"https://mmap.page/dapi/xiaochuang/","url":"https://mmap.page/dapi/xiaochuang/","title":"跋兩晉至唐靈座靈牀漫談","content_html":"

跋兩晉至唐靈座靈牀漫談

\n

靈牀之大小,《兩晉至唐靈座靈牀漫談》1引《宋書·王微傳》「五尺牀」,言五尺之牀難爲臥具,又引《陳書·姚察傳》、《謝貞傳》以「小牀」作靈牀之文。

\n

案《梁書》卷五二云「朔望祥忌,可權安小牀」,亦以小牀爲靈牀。\n唐以前未見稱臥具為小牀者,《北史》卷四八「御牀西北小牀上南坐」,《舊唐書》卷一八六「各危坐於小牀」,《御覽》卷三九三引《晉中興書》云陶淡「設小床獨坐不與人共」,皆稱坐具。\n宋以後小牀則多指臥具。\n又《文選》陸機《弔魏武帝文》云魏武帝《遺令》2以「八尺牀」3爲靈牀。\n則靈床非盡小牀也。\n《宋書》之「五尺牀」,《陳書》、《梁書》之「小牀」,與魏武帝《遺令》之「八尺牀」有別者,\n或《宋》、《陳》、《梁》書傳主皆尚儉,故靈床較常制為簡。\n或孟德自矜創業魏國,高廣靈床,以適歌舞觀聽。

\n

Footnotes

\n
    \n
  1. \n

    王寧玲. 兩晉至唐靈座靈牀漫談[M]. 《文教資料》,2012(34). ↩

    \n
  2. \n
  3. \n

    「吾婕妤妓人,皆著銅爵臺。於臺堂上施八尺床,繐帳,朝晡上脯糒之屬。月朝十五,輒向帳作妓。汝等時時登銅爵臺,望吾西陵墓田。」 ↩

    \n
  4. \n
  5. \n

    《類聚》、《御覽》引作「六尺牀」,未知「六」、「八」孰為形訛。宋趙如燧《野谷詩稿·銅雀臺辭》云「明月空照八尺牀」,亦作「八尺」。倘《遺令》原作「六尺」,則與「五尺牀」近。 ↩

    \n
  6. \n
\n
","date_published":"Fri, 10 May 2013 13:54:56 GMT","date_modified":"Sun, 27 Jul 2025 04:35:12 GMT"},{"id":"https://mmap.page/dapi/lunyu-huijiaojishi/","url":"https://mmap.page/dapi/lunyu-huijiaojishi/","title":"跋論語彙校集釋","content_html":"

跋論語彙校集釋

\n

論語彙校集釋. 黃懷信主撰. 周海生,孔德立參撰. 上海:上海古籍出版社2008年8月. ISBN 978-7-5325-4675-6

\n

論語原文以唐開成石經本爲底本。

\n

彙校先明各舊本異同,次列各家舊校,後加案語。舊本中,敦煌諸唐寫本《論語》殘卷據《敦煌論語集解校證》,而日本正平刊本《論語集解》據《四部叢刊》本。案《四部叢刊》本實據正平刊本影寫本影印,不僅字形走樣,還有異文和誤字。

\n

集釋錄各家舊說大體以時代早晚爲序,一般不取重複,凡訓說相同者取最早一家。

\n

散見於清人著作中的相關論說亦摘要輯取,然其涉獵,區區二十種而已,恐難稱備。

\n

至於「懷信案」部分,余不敏,不能置一詞。

\n

本書彙校,頗為粗疏,余略為翻檢,即為之瞠目,茲臚列如左:

\n

巻三 八侑第三

\n

p262 子曰:「賜也!爾愛其羊,我愛其禮。」

\n

案:開成石經「爾」作「女」。且下「彙校」出「女愛其羊」四字。

\n

巻十 鄉黨第十

\n

p930 疾,君視之,東首,加朝服,拖紳。

\n

案:開成石經「拖」作「扡」。且下「彙校」出「扡紳」二字。似非偶然,疑用別本作工作底本。

\n

巻十一 先進第十一

\n

子張問善人之道。子曰:「不踐迹,亦不入於室。」

\n

案:敦斯3011號寫本句末有「也」字。「彙校」失校。

\n

巻十五 衛靈公第十五

\n

p1416 曰:「吾人於人也,誰毀誰譽?如有所譽者,其有所試矣。

\n

案:當作「吾之於人也」。且下「彙校」出「吾之於人也」五字。

\n

巻十四 憲問第十四

\n

p1284 豈若匹夫匹婦之為諒也,自經於溝瀆而莫之知也?

\n

案:「彙校」部分所引崔灝《四書考異》文字,不屬校勘。

\n

巻五 公冶長第五

\n

p4110-412 子貢曰:「夫子之文章,可得而聞也。夫子之言性與天道,不可得而聞也。」

\n

案:「不可得而聞也」,高麗本「也」下有「矣」字,阮元校勘記中有,「彙校」中沒有吸收。而且「彙校」中引用的錢曾《讀書敏求記》、馮登府《論語異文考證》中都提到了高麗本。

\n

巻十四 憲問第十四

\n

p1256 子路問成人。子曰:「若臧武仲之知,公綽之不欲,卞莊子之勇,冉求之藝,文之以禮樂,亦可以為成人矣!」

\n

案:「若臧武仲之知」,皇本、高麗本「知」作「智」,阮元校勘記中有,「彙校」中沒有吸收。「彙校」云天文本作「智」,然《天文本單經論語校勘記》中無此條。「彙校」云伯2579號作「智」,案2579爲2597之誤。

\n

卷十七 陽貨第十七

\n

p1518 子曰:「唯上知與下愚不移。」

\n

案:皇本「知」作「智」,阮元校勘記失校,「彙校」承其誤。

\n

p1567 子曰:「鄙夫可與事君也與哉?其未得之也,患得之;旣得之,患失之。茍患失之,無所不至矣!」

\n

案:高麗本「未得之」後無「也」字,,阮元校勘記中有,「彙校」中沒有吸收。

\n

卷十八 微子第十八

\n

p1651 周公謂魯公曰:「君子不施其親,不使大臣怨乎不以。故舊無大故,則不棄也。無求備於一人。」

\n

案:「無求備於一人」,「彙校」出「無求備於一人」。且正平本「無」作「毋」,「彙校」失載。

\n

卷二十 堯曰第二十

\n

p1728 謹權量,審法度,修廢官,四方之政行焉。

\n

案:開成石經「修」作「脩」。且下「彙校」出「脩廢官」三字。另「彙校」云高麗本作「修」,案阮校高麗本作「脩」。

\n

p1744 「彙校」出內之咎

\n

案:天文本同,「彙校」失校。

\n

巻十二 顏淵第十二

\n

p1121 季康子問政於孔子曰:「如殺無道,以就有道,何如?」孔子對曰:「子為政,焉用殺?子欲善,而民善矣!君子之德風;小人之德草;草上之風,必偃。」

\n

案:「彙校」部分「君子之德風小人之德草」一條「伯2402號」當爲「伯3402號」。

\n

定州簡本失校的情況我後來也發現了兩處,因書不在手邊,故不列出。

","date_published":"Sun, 10 Mar 2013 13:15:18 GMT","date_modified":"Sat, 23 Nov 2019 19:11:50 GMT"},{"id":"https://mmap.page/poems/resentment-in-boudoir/","url":"https://mmap.page/poems/resentment-in-boudoir/","title":"閨怨","content_html":"

閨怨

\n
幼曾鈔女誡,\n長亦畏豬籠。\n敗柳庭前落,\n出牆杏正紅。\n
\n

composed at 2012-12-23

","date_published":"Sun, 23 Dec 2012 14:16:00 GMT","date_modified":"Sat, 23 Nov 2019 19:28:41 GMT"},{"id":"https://mmap.page/poems/southern-opera/","url":"https://mmap.page/poems/southern-opera/","title":"南曲","content_html":"

南曲

\n

【水底魚】伐芥為舟,鵲閒鴻鴈休。千重山近,瞬目間四秋。涸轍鮒幸,晤莊生立地獲救。縫腸半朽,半朽怎生飴悍鷲?

\n

composed at 2012-05-21

","date_published":"Mon, 21 May 2012 10:24:09 GMT","date_modified":"Sat, 23 Nov 2019 19:28:41 GMT"},{"id":"https://mmap.page/dapi/hezhe/","url":"https://mmap.page/dapi/hezhe/","title":"跋中國語言學論文集","content_html":"

跋中國語言學論文集

\n

我看到其中的《國語中雙聲節並列語兩成分間的聲調關係》一文(pp. 299-314)的時候,有一種熟悉感,難道說我以前在別的地方看到過這篇文章?

\n

最近翻查檢索書籍的時候,無意中找到了。原來余嘉錫的《世說新語箋疏》中有相關的論述,我原來看到過,難怪感覺熟悉呢!

\n

《世說·排調》載:「諸葛令、王丞相共爭姓族先後,王曰:『何不言葛、王,而云王、葛?』令曰:『譬言驢馬,不言馬驢,驢寧勝馬邪?』」余嘉錫《箋疏》謂:「凡以二名同言者,如其字平仄不同,而非有一定之先後,如夏商、孔顏之類。則必以平聲居先,仄聲居後,此乃順乎聲音之自然,在未有四聲之前,固已如此。故言王、葛驢馬,不言葛、王馬驢,本不以先後為勝負也。如公穀、蘇李、嵇阮、潘陸、邢魏、徐庾、燕許、王孟、韓柳、元白、溫李之屬皆然。」(1983)

\n

丁氏此文最早發表在1969年的《史語所集刊》39卷2期(pp. 155-147)上。而《世說新語箋疏》為余嘉錫先生遺著,余先生1955年去世後,由周祖謨等整理成書,因故出版一再拖延,1983年方由中華書局出版。余、丁二人各自注意到此問題,看法亦相近,所謂「閉門造車,出門合轍」,殆此之謂歟。(丁氏關注的範圍較廣,不僅僅限於人名並列,也不僅僅限於平先仄後的情形。但是其文第二部份《本論》首先就討論姓氏並列語的問題,其旨趣和余氏相近。)

\n

引用文獻

\n

余嘉錫. 1983. 世說新語箋疏[M]. 北京:中華書局:791-792

","date_published":"Sat, 12 May 2012 11:38:22 GMT","date_modified":"Sat, 23 Nov 2019 19:11:50 GMT"},{"id":"https://mmap.page/dapi/lunyu-zhengzhu/","url":"https://mmap.page/dapi/lunyu-zhengzhu/","title":"跋唐寫本論語鄭氏注及其研究","content_html":"

跋唐寫本論語鄭氏注及其研究

\n

王素. 唐寫本論語鄭氏注及其研究[M]. 北京:文物出版社,1991年11月. ISBN 7-5010-0503-6

\n

分上下两卷。上卷爲鄭注校錄,據現已發現之唐寫本,恢復半部《鄭注》的原貌。下卷收入王氏所撰相關論文,兼收早期、近期國內外相關論文。

\n

榮新江《鳴沙集》中有《唐寫本論語鄭氏注及其研究拾遺》一文,增校此書未收之唐鈔本殘片三件。後新出吐魯番文書又有《堯曰》殘篇一片,王氏《吐鲁番新出闞氏王国〈論語鄭氏注〉寫本補說》以爲亦是鄭注,文見《文物》2007年第11期。另,據儒藏精華編目錄,第281冊收有《唐寫本論語鄭氏注》一書。

","date_published":"Thu, 03 May 2012 16:56:08 GMT","date_modified":"Sat, 23 Nov 2019 19:11:50 GMT"},{"id":"https://mmap.page/dapi/zuozhuan_guo-jue-ming/","url":"https://mmap.page/dapi/zuozhuan_guo-jue-ming/","title":"左傳春秋經國加爵加名之用例","content_html":"

左傳春秋經國加爵加名之用例

\n

下表羅列了春秋經中「國(或部族)+爵+名」這一類的全部用例。標註年數以及楊伯峻《春秋左傳注》的小節數、頁數。本表據楊伯峻《春秋左傳詞典》編製。

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
人名位置用例及備註
戎蠻子赤哀4/6/1625晉人執戎蠻子赤歸于楚 公羊作曼
吳子乘襄12/4/995吳子乘卒
吳子遏襄25/10/1095吳子遏伐楚 公羊、榖梁作謁。據左傳,吳子卒於是役。
吳子夷末昭15/1/1368吳子夷末卒 公羊作夷昧
吳子光定14/5/1593吳子光卒
吳子餘祭襄29/4/1153閽弑吳子餘祭
宋公佐昭25/7/1455宋公佐卒于曲棘
宋公茲父僖23/2/401宋公茲父卒
宋公成昭10/6/1314宋公成卒
宋公王臣文7/4/554宋公王臣卒
宋公鮑成2/5/785宋公鮑卒
宋公馮莊2/5/159宋公馮卒
宋公御說僖9/1/323宋公御說卒 公羊、榖梁作禦
宋公固成15/5/871宋公固卒
宋公和隱3/5/25宋公和卒
杞伯姑容襄6/1/945杞伯姑容卒
杞伯益姑昭6/1/1273杞伯益姑卒
杞伯郁釐昭24/5/1449杞伯郁釐卒
杞伯匄襄23/2/1071杞伯匄卒
杞伯成定4/5/1533杞伯成卒于會
杞伯過哀8/6/1646杞伯過卒
沈子逞昭23/7/1440沈子逞滅 公羊作楹,榖梁作盈
沈子嘉定4/3/1533以沈子嘉歸,殺之
胡子豹定15/3/1599以胡子豹歸
胡子髡昭23/7/1440胡子髡、沈子逞滅
邾子蘧蒢文13/3/593邾子蘧蒢卒 公羊、榖梁作籧篨
邾子益哀8/4/1646歸邾子益于邾
邾子牼襄17/1/1029邾子牼卒 公羊、榖梁作瞷
邾子穿定3/2/1530邾子穿卒
邾子貜且成17/12/896邾子貜且卒
邾子瑣莊28/2/238邾子瑣卒
邾子華昭1/5/1198邾子華卒
晉侯重耳僖32/4/488晉侯重耳卒
晉侯彪昭10/4/1313晉侯彪卒
晉侯夷吾僖24/5/412晉侯夷吾卒
晉侯獳成10/5/847晉侯獳卒
晉侯去疾昭30/2/1505晉侯去疾卒
晉侯周襄15/7/1021晉侯周卒
晉侯驩文6/4/543晉侯驩卒
晉侯黑臀宣9/9/700晉侯黑臀卒于扈
晉侯夷昭16/4/1375晉侯夷卒
晉侯佹諸僖9/5/324晉侯佹諸卒
秦伯罃文18/2/628秦伯罃卒
秦伯稻宣4/2/676秦伯稻卒
曹伯射姑莊23/9/225曹伯射姑卒
曹伯壽宣14/2/753曹伯壽卒
曹伯須昭18/1/1393曹伯須卒
曹伯襄僖28/20/451曹伯襄復歸于曹 文9/10/571 曹伯襄卒
曹伯滕昭14/2/1363曹伯滕卒
曹伯負芻襄18/5/1035曹伯負芻卒于師
曹伯盧成13/4/859曹伯盧卒于師 公羊、榖梁作廬
曹伯終生桓10/1/127曹伯終生卒
曹伯班僖7/5/315曹伯班 公羊作般
曹伯露定8/5/1562曹伯露卒
曹伯陽哀8/1/1646以曹伯陽歸
曹伯午昭27/6/1481曹伯午卒
莒子朱成14/1/867莒子朱卒
莒子去疾昭14/5/1363莒子去疾卒
莒子庚輿昭23/6/1440莒子庚輿來奔
莒子狅哀14/8/1681莒子狅卒
許男成哀13/2/1674許男成卒 公羊作戌
許男甯襄26/8/1111許男甯卒于楚
許男斯定6/1/1555以許男斯歸
許男新臣僖4/2/287許男新臣卒
許男業文5/7/538許男業卒
許男錫我宣17/1/770許男錫我卒
陳侯朔文13/2/593陳侯朔卒
陳侯柳定8/9/1562陳侯柳卒
陳侯午襄4/1/931陳侯午卒
陳侯溺昭8/2/1299陳侯溺卒
陳侯杵臼僖12/4/340陳侯杵臼卒 公羊作處臼
陳侯林莊1/5/156陳侯林卒
陳侯躍桓12/4/133陳侯躍卒
陳侯款僖28/12/450陳侯款卒
陳侯鮑桓5/1/102陳侯鮑卒
陳侯吳昭13/8/1343陳侯吳歸于陳 定4/1/1533 陳侯吳卒
楚子旅宣18/5/776楚子旅卒 榖梁作呂
楚子審襄13/3/998楚子審卒
楚子昭襄28/9/1139楚子昭卒
楚子麇昭1/10/1199楚子麇卒 公羊、榖梁作卷
楚子虔昭11/3/1321楚子虔誘蔡侯般殺之于申
楚子居昭26/6/1469楚子居卒
楚子軫哀6/6/1632楚子軫卒
頓子牂定14/2/1593以頓子牂歸 公羊作牄
齊侯小白僖17/5/372齊侯小白卒
齊侯無野成9/7/841齊侯無野卒
齊侯杵臼哀5/4/1629齊侯杵臼卒 公羊作處臼
齊侯昭僖27/2/442齊侯昭卒
齊侯祿父桓14/6/139齊侯祿父卒
齊侯潘文14/3/600齊侯潘卒
齊侯元宣10/5/704齊侯元卒
齊侯環襄19/7/1044齊侯環卒 公羊作瑗
齊侯陽生哀10/3/1654齊侯陽生卒
潞子嬰兒宣15/3/758以潞子嬰兒歸
滕子嬰齊僖19/1/379宋人執滕子嬰齊
滕子原昭3/1/1231滕子原卒 公羊作泉
滕子寧昭28/5/1490滕子寧卒
滕子結哀4/9//1625滕子結卒
滕子虞毋哀11/4/1657滕子虞毋卒
榖伯綏桓7/2/118榖伯綏來朝 左傳:名,賤之也。公羊、榖梁以為乃失地之君,故書其名,楊《注》駁之。
蔡侯申宣17/2/770蔡侯申卒 蔡文公
蔡侯廬昭13/8/1343蔡侯廬歸于蔡 昭20/5/1406 蔡侯廬卒
蔡侯申哀4/1/1624盜殺蔡侯申 蔡昭公
蔡侯獻舞莊10/5/182以蔡侯獻舞歸
蔡侯封人桓17/4/148蔡侯封人卒
蔡侯般昭11/3/1321楚子虔誘蔡侯般殺之于申
蔡侯朱昭21/6/1423蔡侯朱出奔楚 榖梁作東
蔡侯考父隱8/3/56蔡侯考父卒
蔡侯肸僖14/5/346蔡侯肸卒
蔡侯東國昭23/5/1440蔡侯東國卒于楚
鄧侯吾離桓7/2/118鄧侯吾離來朝 左傳:名,賤之也。公羊、榖梁以為乃失地之君,故書其名,楊《注》駁之。
鄭伯捷僖32/2/488鄭伯捷卒 公羊作接
鄭伯寤生桓11/2/129鄭伯寤生卒
鄭伯突桓15/4/141鄭伯突出奔蔡 桓15/9/142 鄭伯突入于櫟 莊21/2/216 鄭伯突卒
鄭伯蘭宣3/7/668鄭伯蘭卒
鄭伯堅成4/2/817鄭伯堅卒
鄭伯費成6/7/825鄭伯費卒
鄭伯睔襄2/4/919鄭伯睔卒
鄭伯髡頑襄7/9//949鄭伯髡頑如會,未見諸侯,丙戌,卒于鄵 頑,公羊、榖梁作原,鄵,公羊、榖梁作操
鄭伯嘉昭12/2/1330鄭伯嘉卒
鄭伯寧昭28/3/1490鄭伯寧卒
鄭伯蠆定9/2/1570鄭伯蠆卒 公羊作囆
衛侯鄭僖30/3/478衛侯鄭歸于衛 宣9/10/700 衛侯鄭卒
衛侯燬僖25/1/430衛侯燬滅邢 左傳:同姓也,故名。公羊、榖梁同義。孔廣森《公羊通義》:滅同姓名,唯謂滅周之同姓。若齊之於萊,楚之於夔,彼雖自為同姓,而於王家則為庶姓,罪猶差輕。 僖25/2/430 衛侯燬卒
衛侯輒哀16/1/1697衛侯輒來奔
衛侯惡昭7/5/1282衛侯惡卒
衛侯衎襄26/3/1110衛侯衎復歸于衛 襄29/3/1153 衛侯衎卒
衛侯元哀2/2/1610衛侯元卒
衛侯晉桓12/8/133衛侯晉卒
衛侯朔桓16/5/145衛侯朔出奔齊 莊6/2/167 衛侯朔入于衛 莊25/2/231 衛侯朔卒
衛侯速成2/6/785衛侯速卒 公羊作遬
衛侯臧成14/6/868衛侯臧卒
薛伯定定12/1/1584薛伯定卒
薛伯夷哀10/9/1655薛伯夷卒 公羊作寅
薛伯榖昭31/3/1510薛伯榖卒
","date_published":"Thu, 03 May 2012 16:37:56 GMT","date_modified":"Sat, 23 Nov 2019 19:11:50 GMT"},{"id":"https://mmap.page/dapi/evil-interview/","url":"https://mmap.page/dapi/evil-interview/","title":"魔王訪談錄","content_html":"

魔王訪談錄

\n

最近,由於一個特殊的機緣,我有幸到魔窟走了一遭。利用這個難得的機會,我找魔王做了一個訪談。

\n

我:魔王大人,有時間做個訪談嗎?

\n

魔王:可以。不過作為交換,訪談結束後你要回答我三個問題。如果你的回答不真誠,那你就得留下來給我改善下伙食。

\n

我:成交。您聽說了最近「魔王火燒公主」的事件了嗎?新時代的魔王似乎很有創新精神呢。既然得不到公主的歡心,索性燒死算了。所有權的最重要的部份是處分權吧,從這個意義上說,奪走公主的生命,不正是一種終極的佔有的方式嗎?新時代的魔王,似乎大獲全勝呢。對此,像您這樣終日宅在魔窟之內的傳統魔王有什麽話要說嗎?

\n

魔王:燒個人也燒不死的垃圾,也配稱魔王?

\n

我:雖然沒死,但是這並不影響大局。公主燒成這樣,以後恐怕很少會有王子對她感興趣了吧?何況,不論公主以後還能不能討得王子的歡心,終其一生,恐怕她都走不出魔王的陰影了吧。想想公主的未來吧,求學、工作、戀愛、結婚、養兒,無時無刻不受到這次事件的影響。想想吧,每次洗髮的時候,每次水流從頭頂經臉側毫無阻礙地流向下頜的時候,公主又一次意識到,她的一隻耳朵已經沒有了,無論她多麼恨那個魔王,都無法否認,那個魔王改變了她的一生。恐怕很少有人,能像那個邪惡的魔王一樣,對她的人生施加那麼深刻而長遠的影響吧?某種意義上說,無論魔王的下場如何,他都作為揮之不去的陰影,伴隨公主一生呢。

\n

魔王:別喋喋不休了,我都快以為你是來推銷汽油和打火機的。提出你的問題。

\n

我:我的疑惑是,爲什麽一代又一代的魔王都一根筋地去搶公主,然後讓王子尋上門來殺死自己,讓王子把毫髮無傷的公主帶回去,白白地成就了王子的英名和公主的姻緣?既然能做到魔王,怎麼也不會是笨蛋吧?十幾歲的小孩都想得到的主意,魔王沒有理由想不到吧?就算一個魔王沒想到,這麼多魔王不會一個都沒想到吧?背後到底有什麽隱情呢?

\n

魔王:所以我說那小子不是魔王。燒不死人還在其次,最主要的是,火燒公主,那是只有人類纔會有的想法。當他點火的那一瞬間,他就宣告了自己的失敗,他知道公主的心裏沒有他,他沒機會得到公主的心了,只能以這樣的方式來影響公主的人生了。而魔王,永遠不會真正絕望,魔王永遠堅信,公主是深愛自己的。

\n

我:公主深愛魔王?故事裏可從來沒這麼說過。

\n

魔王:那是你沒有認真去讀!你想想,公主從小生在王宮之中,從小到大,就知道以後要嫁給王子,而魔王是邪惡的。你還能期望她有多少自己的主見呢?所以我們魔王都把公主帶到偏僻的魔窟,這裡沒有世俗的干擾,正適合公主在這樣一個清幽的環境中思考自己的人生,叩問自己的內心,脫離俗知俗見的束縛。假以時日,公主一定能意識到,是世俗的偏見蒙蔽了自己的本心,其實自己喜歡的,是魔王。

\n

我:原來是這樣啊。那怎麼就沒聽說有哪位公主大徹大悟了呢?

\n

魔王:你竟敢質疑我的話?大部份的情況是,那些王子都來得太快了,公主還沒有足夠的時間想清楚。還有,一旦公主最後跟了魔王,王室一定會作為莫大的醜聞秘而不宣,難道還會編成故事四處宣揚不成?

\n

我:唉,原來是家醜不外揚呀。就沒有哪家媒體爆料嗎?

\n

魔王:以人類為銷售對象的媒體敢把自己擺在反人類的立場上嗎?

\n

我:那倒是。說不定有不少王子都被魔王做掉了,只是媒體不報導而已。

\n

魔王:那倒不是。魔王和王子戰鬥,有一個很大的破綻。所以魔王和王子的戰鬥,從來都是輸多贏少。

\n

我:哦?什麽破綻?

\n

魔王:因為怕公主傷心欲絕,除非不得已,魔王并不想真下殺手,往往留有餘地,希望只是擊傷或是擊退,而不要傷了王子的性命。還有,生死之際,是認清內心的絕好的契機。所以很多魔王都在戰鬥中故意讓自己陷入可能毀滅的危機之中,希望在這個瞬間,公主能夠意識到,在魔王和王子生死相搏的時候,開始是想要王子獲勝,但是真到魔王要死的時刻,又暗暗希望魔王不要死。這是極端危險的,因為有勇氣來魔窟的王子實力不會太低。但是生死關頭的契機太難得了,很少有魔王能抵擋住這種致命的誘惑。

\n

我:原來魔王在和王子的戰鬥中吃了這麼多暗虧呢。真是的,魔王原來多逍遙自在啊,就是因為喜歡公主纔變得這麼憋屈吧?

\n

一直漫不經心地回答我的問題的魔王,正色道:愛上公主,這是魔王的宿命。

\n

我:就沒有魔王能逃脫這個宿命嗎?

\n

魔王想了一會,道:曾經有一個例外。有一位魔王,一直不去搶公主。直到王子和公主成婚的前一天,突然出現,把公主搶走了。王子趕到,殺死了魔王。王子和公主發現,魔王的魔窟已經按婚禮的樣子佈置好了,而且比王宮的佈置更好,所以乾脆就召集眾人,在魔窟舉行了婚禮。

\n

我:那他最終還是沒逃過宿命啊。

\n

魔王:不,他愛的不是公主,而是王子。他本來想一輩子呆在魔窟,不去打擾王子和公主的幸福生活。但是在王子成婚前的那一天,他也忍不住前去看了一眼。正好被他聽到公主在向王子抱怨婚禮的佈置不夠好,王子一個勁地賠不是。魔王看到自己的心上人賠不是的樣子,心都碎了。但是他又不能出手相助,因為王子是不會接受魔王的幫助的。於是他就乾脆把公主搶了,又把自己的魔窟按婚禮的樣子佈置。魔王的法力高強,婚禮的陳設自然不是凡間的王宮可比。然後,就是與心上人的一戰。本來魔王是希望就這樣一直戰鬥下去的,但是到後來王子體力漸漸不夠了。魔王擔心王子體力不支,新婚之夜又被公主抱怨,就故意賣個破綻。於是體力不支,本已絕望的王子一劍刺破了魔王的胸膛。絕處逢生的喜悅,成就英名的歡喜,新婚在即的快樂,交織在一起,王子臉上露出了由衷的笑容。望著王子的笑臉,那一刻的魔王是最幸福的:「恐怕你得知可以繼承王位或者公主答應你的求婚的時候,你都沒有這麼開心吧。你這一生最大的歡喜,是我帶給你的。就在此刻。而你的笑容,也溫暖了我的心。我這一生最大的溫暖,是你帶給我的。也是就在此刻。」

\n

我沉浸在這個動人的故事中,久久沒有回過神來。突然魔王說:輪到你了。回答我三個問題!我看你一副陶醉的模樣,倒對你的性取向很是好奇,回答我,你的性取向是什麽?

\n

我想了想,答道:Every man had thought that he loved women, until he met his superman.

\n

這是一個很有技巧的回答。首先它是真誠的,并沒有違反約定。其次它其實什麽也沒說。表面上似乎是說我是gay,但也可以不是,因為我可能還沒遇到我的superman嘛。當然魔王可能不會這麼容易糊弄,可能會問我到底遇到了沒有。但是這樣的話,他就又花費了一次提問的機會,我安然離開的可能性也就會變大不少。

\n

誰知魔王卻沒有過多糾纏,接著問了一個無關的問題:大便之後你用哪種草紙?

\n

我松了一口氣,心想這個魔王不過就是有點猥瑣,有點八卦,應該不難應付。我如實回答了這個問題。

\n

事實證明,魔王不是那麼簡單的人物。他這一問只是讓我自以為過關,產生輕視之心而已。

\n

魔王慢悠悠地說:嗯,我知道這種紙。雖然在超市它被標成衛生紙,其實和某些面紙一樣柔軟。好了,最後一個問題,你有沒有想過,你精心呵護的菊花,那個男人根本就不屑一顧呢?

\n

我後背全是冷汗,但仍然竭力喊道:那你有沒有想過,也許公主根本就不喜歡魔王呢?所謂公主其實是喜歡魔王的,只是她的本心被遮蔽了,她自己沒有意識到,也許根本就是魔王的一廂情願?

\n

魔王:反問不是回答!今晚我可以喝到排骨湯了。

\n

我纔發現我一時情急,竟然忘了回答問題。但是我並不甘心就這樣死掉,所以強辯道:你根本就是被我說破了事實氣急敗壞吧?還魔王呢!一點沒有涵養!

\n

魔王:氣急敗壞的是你自己吧。讓你死得明白吧,雖然我本來沒有必要告訴你。你的反問只是迴避,你沒有勇氣真誠地面對這個問題。我深信公主其實是喜歡我的,雖然她自己沒有意識到,是因為我是魔王。我有作為魔王的自尊和驕傲。你並不是魔王,那你又憑什麽深信你愛的那個男人也愛你呢?

\n

我萬念俱灰地閉上了眼睛。魔王所說的沒錯,我害怕這個問題,我不敢面對,我沒有真誠地回答這個問題,所以我將付出我的代價。

\n

在等待死亡的那一刻,不知不覺地,我又想起那個讓我魂牽夢繞的男人。此時此刻,他又在幹什麼呢?沒來由地,我仿佛看到他就在不遠處看著我。我想,旁人只會以為我死在魔王的手裡,誰又知道我其實是死在那個人的注視之下呢?能在他的注視之下死去,也是一種幸福吧。

\n

這時魔王卻嘆了口氣:我想你知道答案了,說出來吧。

\n

我並沒有睜開眼睛,輕輕地說:當我閉上雙眼的時候,我能感覺到那個男人凝視我的目光是那樣地深情。那一刻,我知道他是愛我的。

\n

說完我纔意識到,我答出來了,我不用死了。但我又有點疑惑,爲什麽魔王要提醒我,如果他不提醒我,那時的我早已把問題和約定忘到九霄雲外,我自己是不會想到要回答問題的。

\n

魔王看到我疑惑的目光,猜到了我的想法:你剛來的時候,靈魂中充斥著悲傷、焦灼、不甘、絕望、懷疑等等情緒,這樣的靈魂勾起了我的食慾,所以我纔陪你做什麽訪談,我只是想借機吃掉你。但是剛剛你的靈魂十分平和,對我來說就是淡而無味了。所以我就提醒你一下,一般而言,在必死的心態下,突然得知已經知道答案,說出來就可以獲救的話,人會有一種絕處逢生的喜悅。我趁這個時候,在你想說未說的時刻,把你一口吞下,雖然是囫圇吞棗,但多少還有些味道。哪知你一點情緒的波動都沒有。

\n

我:這種平和的心態,我想我並不能保持很久。

\n

魔王:但是你已經真誠地回答了我三個問題,依照約定,我只能送你回去。

\n

於是我逃離了魔窟,回到了這個有人說比魔窟還兇險的美好的現實世界。

\n
\n

by Jakukyo Friel weakish@gmail.com under GPL-2

","date_published":"Thu, 03 May 2012 15:53:26 GMT","date_modified":"Sat, 23 Nov 2019 19:16:00 GMT"},{"id":"https://mmap.page/poems/drinking/","url":"https://mmap.page/poems/drinking/","title":"飲酒二首","content_html":"

飲酒二首

\n

無量

\n
不厭嘉蔬惧酌清\n平生見觶便心驚\n綠珠行酒固無飲\n刀下墜樓何預卿\n
\n

作於民國 96 年 (2007),為余所作第一首近體詩。\n(案:「固無飲」原作「固不飲」,「不」不合律,故改作「無」。)

\n

琴無弦

\n
玄風竹葉青\n白首鱔魚黃\n未飲舌先絆\n方醺目半張\n
\n

composed at 2012-03-27

","date_published":"Tue, 27 Mar 2012 03:48:23 GMT","date_modified":"Sat, 23 Nov 2019 19:28:41 GMT"},{"id":"https://mmap.page/dapi/jingxuejueyuan/","url":"https://mmap.page/dapi/jingxuejueyuan/","title":"跋經學抉原","content_html":"

跋經學抉原

\n

蒙文通. 經學抉原[M]. 上海:上海人民出版社,2006年8月. ISBN 7-208-06300-1

\n

重編前言

\n

(蒙默)

\n

丁卯,先生纂《經學抉原》,乃就《導言》改定而成,(虛案:《經學導言》)又增寫數篇,(1)而論說較前精進。(1)

\n

經學導言

\n

經學這門學問,明註是一步,明傳是一步,明經是一步,明道是一步,若只在前三步裏邊纔做得一步,不能做明道的學問,那還算不得一個造詣高深的學問家。(41)

\n
\n

明註已足盡吾年矣!

\n
\n

經學抉原

\n

史公序《十二諸侯年表》,列孔氏《春秋》、《左氏春秋》、《鐸氏微》、《虞氏春秋》、《呂氏春秋》,凡五家,不數《公羊》、《榖梁》,以此二家者即孔氏之學,而《左氏》、《呂氏》之各自爲家也。(74-75)

\n
\n

竊以為不數《公》、《榖》者,未必以其不各自爲家也。或因《公》、《榖》成書晚也。《公羊》徐彥《疏》引戴宏說,即謂「至漢景帝時」「著於竹帛」。

\n
\n

史遷書稱《春秋國語》,兩言左邱失明,厥有《國語》,是史公所見左氏書惟《國語》耳。《十二諸侯年表序》云:「左邱明因孔子史記,具論其語,成《左氏春秋》。」曰「具論其語」,知《左氏春秋》即《國語》也。《論衡·案書篇》:「《左氏》傳經,辭語尚略,故復選錄《國語》之辭以實。」則取《左氏春秋》《國語》為《左氏傳》,漢儒故知其事,史公蓋見《國語》而未見後出之《傳》也。(75)

\n
\n

以兩言「左邱失明,厥有《國語》」,論定史公所見惟《國語》,又以「具論其語」論定史公所言《左氏春秋》即指《國語》,竊以為有失審慎。兩言「左邱失明,厥有《國語》」者,或以舉《國語》以該《左傳》,或因左邱之書以《國語》為著,司馬遷未必但見《國語》也。又,余初見蒙氏引《史記》、《論衡》二書,而於《史記》之「因孔子史記」、《論衡》之「傳經」,不置一詞,未嘗不疑惑叢生也。後於蒙氏下文左、孔相乖之論繹讀再三,始悟蒙氏「《左氏》自據《不修春秋》以立言,此漢師不以《左氏》為經,謂不祖孔子,不傳《春秋》者」之精義。無論史公序《十二諸侯年表》不數《公》、《榖》究出何因,亦無論史公見《左傳》否,要之,《公》、《榖》為孔氏學,師承有自,而《左》無師承,又與孔相乖,故不祖孔子,不傳《春秋》也。今學界多以《左》為經傳,實則其所謂經傳者,已與蒙氏所謂經傳者旨趣相殊也。今學界多用古學,以史視經,以為《左》既為解經而作,三傳之中,舍《左》不能明《春秋》之史事,《左》如何不得稱傳也。既以經為史,宜乎其以傳為史注也。若蒙氏所謂經傳者,則異其趣。蒙氏《儒學五論題辭》即言:「經其表而傳記為之裏。」(212)李源澄《經學通論·論今古學》云:「經學之爲經學,原以儒學納於經文之下而成,有經無說,亦不成其爲經學。故漢人重師說,先師所不傳,道亦不傳也。」(李源澄. 經學通論[M]. 上海:華東師範大學出版社,2010年3月:28. ISBN 978-7-5617-7362-8)殆與蒙氏之意同。《左》既無師承,又與孔相乖,宜乎蒙氏不以《左》為《春秋》之傳也。以《左》為《春秋》之傳,則經傳與史注復有何別乎?故蒙氏此說,實已非同古學

\n
\n
\n
\n

本文之正文皆照錄蒙氏原文,愚見括注虛案或縮進以別之,唯以下至「文字第十」則撮舉《抉原》各節大義。蓋皆本蒙氏之說,摘句而連綴之,顧不盡為蒙氏原文。

\n
\n

序(54-56)

\n

舊史第一(56-59) 三古列國之史,國各不同。孔子固據魯以述文,亦變魯以協道。

\n

焚書第二(59-63)\n秦官舊籍猶存,孔氏之業不殘。樂本無經,其節具於《禮》,其歌具於《詩》。

\n

傳記第三(63-67) 六經傳記,其文多矣,其來遠矣。孔子之定六經,已自有傳。孔子之前,更有傳也。自武帝罷傳記博士,古傳遂缺矣。孔子弟子散於九流,故傳記又往往取諸諸子以為書。諸子書多在傳記中,蓋亦因《詩》、《書》、百家語並在博士。

\n

今學第四(67-71) 今文之學能自相同者,帝王稱制臨決之故也。漢之絀古文,疑以獻王故也。武帝好文辭,浮麗之論滋起,至東京而今文之弊極矣!末流之害既深,古文之學遂乘之而起。

\n

古學第五(71-77) 壁中書,古文家見之,今文家亦見之,皆以傳記視之,不以為經耳。《毛》、《魯》故訓不相遠,《左氏》自為一家,據不修春秋立言,不祖孔子。中興之際,古文家尊《毛詩》,今文家亦尊《毛詩》;今文家排《左氏》,古文家亦排《左氏》也。併《左氏》、《周官》於六藝,劉歆事業也。古文至杜預、王弼始全離今文而自樹一幟也。執《周官》以徧說群經者,鄭氏家法也。

\n

南學、北學第六(77-81) 南學,子雍(王肅)之術;北學,康成(鄭玄)之學。南學蓋源於仲子(宋衷)之《後定》而大於子雍也。鄭玄括囊大典,網羅眾家,冶今古兩學於一鑪。王肅難鄭,一蹈鄭氏,或又甚焉。遂二家分行南北。河洛尚篤信康成,江左則不能確宗王氏。唐一區宇,製作正義,南北二學遂合而為一。

\n

內學第七(81-83) 信毖緯者,今文家有之,古文家亦有之。闢毖緯者,古文家有之,今文家亦有之。緯學雖導源於西京,然西京為律歷陰陽之學,而非成、哀以後圖讖之學。齊人五德之運,此《七略》數術之學也;燕人形解銷化,此《七略》方技之學也。遠則燕齊殊科,近則兩漢異致,皆於經術無涉。自儒者混而同之,各家之真遂莫能辨析也。兩漢經學有經學之師傳,言五德者有五德之師傳,亦可知陰陽五行說之不與經相混淆。《封禪書》所載鼎書、札書,在《漢紀》并謂之讖,尤足見圖書古固有之,入後則并為讖。此桓譚所謂增損圖書,矯稱讖記,張衡所謂圖讖成於哀平之際者也。

\n

魯學、齊學第八(84-87) 就漢世言之,魯學謹篤,齊學恢宏,風尚各殊者,正以魯固儒學之正宗,而齊乃諸子之萃聚也。井研先生以燕學同於齊學,蓋燕之風尚,素與齊同,燕之儒生多自齊往故也,則燕學者齊學之附庸也。善條列諸子者,無過於莊子、荀子、司馬談三家,若劉氏九流之分,本以校書而立部別,《淮南·要略》所陳,專就致用立說,皆不足持之以辨章學術。法家統於道家,名家統於墨家,陰陽家則巫史所傳舊文,無裨學術。則六家之學,惟儒與道、墨而已。

\n

晉學、楚學第九(87-91) 今文之學源於齊、魯,而古文之學源於梁、趙也。三晉之史視齊、魯為備。三晉之學,秦人所深斥者也。秦人之所尊者,齊、魯之學也。在漢亦齊、魯諸儒與方士并進。今古學門戶雖成立於漢,然齊、魯以并進而漸合,晉學以獨排而別行,則始於秦。三晉以史學為正宗,魯人以經學為正宗,若楚人之學,則屈宋以來,自以辭賦為正宗也。東方,儒、墨;北方,法家;南方,道家。

\n

文字第十(92-93)

\n
\n

廖季平先生與清代漢學

\n

汪中之流,固亦嘗推崇東原戴氏也,蓋前乎戴氏者,其治瑣事謏聞,與經事相比,如惠氏箋《漁洋菁華錄》之流;至戴氏而一革舊習,鄙唐宋以下事不屑言,悍然攻程朱之說而不顧,漢學之壁壘至東原而始固,此前世之所以推東原也。今之盛推東原者並此而不知,徒以俞氏著書擬於高郵王氏,由俞推王,由王推戴,顧曰戴長於斷,余固不知言考據而不能斷,兩《經解》中不能斷者將誰氏也?清世每惠、戴並稱,惠言《易》宗虞,言《左氏》宗服,於《書》、《禮》宗鄭,能開家法之端者實惠氏;於虞《易》言消息,故通條例之學者亦始惠氏,雖後之通家法、明條例者或精於惠氏,而以惠、戴相較,則惠實爲優。世之研骨化石者,得其半骼殘骸,於以推測其全體,得他之片骨殘骸,又以推測一全體,此家法條例之比也。苟萃衆多不同世之化石於一室,割短續長,以成一具體備形之骸,雖至愚人亦不出此。不明家法,不究條例,萃古文於一篇,折群言而歸一是,於此而言學在能斷,余不知斷從何起?事之可笑,孰過於斯!(104)

\n

儒家政治思想之發展

\n

秦、漢間學者言三代事,多美備,不爲信據。不信,則擯疑之誠是也,然學人必爲說若是者,何耶?斯殆陳古刺今,以召來世。其頌述三古之隆,正其想望後來之盛。(152)

\n

儒家法夏法殷義

\n

蓋晚周之學,諸派漸融,舍短取長,以易舊貫,家各然也。誠以儒家之義,有取之法家者,儒法固相讎,因曰法殷,不謂取法家也。又有取之墨家者,因曰法夏,不謂取墨家也。(189)

\n

《儒學五論》題辭

\n

宗道者綜諸子以斷其義,純為空言;宗儒者綜諸子而備其制,益切於用。(202)

\n
\n

蒙氏於《論經學遺稿丙篇》亦言:「戰國末期,百家之學術漸趨於匯合,綜百家之長而去其短者為雜家,《呂覽》為之始,而《淮南》繼之。惟雜家以道德為中心,故偏於玄言,不切世用。繼雜家而起者為經術,為儒家,推明仁義之說,固視道家為精,其言政術亦視雜家為備,其取雜家而代之固宜。」(210,211)顧余則以為空言可喜,切用無味。

\n
\n

殆以諸子之義既萃於經術,則經術為根底,而百氏其柯條。支義奇詞,胥就董理,諸子之於經術,倘正辯證法發展之謂歟!此則孟、荀儒者之術,入漢而為經生之業,以恢詭無方之諸子,轉而為湛深純一之經術,道之相承,固宜如此。(202)

\n
\n

此段論漢儒采諸子,誠為切要。蒙氏謂儒「湛深純一」,而斥諸子之「支義奇詞」,其於《論經學遺稿丙篇》又云:「周秦諸子為國史上最為燦爛之思想文化,而經術者此燦爛文化結晶也。」(210)「是則晚周諸子入漢一變而為經學,經學固百家言之結論,六經其根柢,而發展之精深卓絕乃在傳記,經其表而傳記為之裏也。」(212)皆宗儒者之言也。但不知辯證法之於經術,今日之宗儒者當以其為根底歟,抑柯條歟?

\n
\n

論經學遺稿乙篇

\n

前則《呂覽》、《淮南》之書,及《尸》、《管》之儔,胥主於道家以綜百氏,司馬談父子亦其流也。(208)

\n

道家起於南方,偏於玄虛,以仁義為小;法家盛於北方,重視現實,以仁義為迂(大也);皆遠於中華傳統之文化。(211)

\n

孔子和今文學

\n

秦始皇對儒生是深惡痛絕的。然而漢武對儒生卻又推崇備至,這又當如何解釋呢?其實,秦皇、漢武並沒有多大的差別。秦是因「人善其所私學,以非上之所建立」,纔致焚書之禍。從《說苑》的記載看,鮑白令(應是鮑丘之誤,即《鹽鐵論》之包丘子,《史記》之浮丘伯,詳《浮丘伯傳》)提出「禪讓」理論,面責秦始皇為桀紂,而主張五帝「官天下」,反對「家天下」。然而「禪讓」卻是今文學一大義。儒生就是堅持這一主張來與秦的統治者作鬥爭的,所以始皇必至坑儒。但漢武帝又何嘗不如此呢?趙綰、王臧請立「明堂」,這也是今文學一大義(詳後)。趙、王兩人都是武帝的老師,但因此兩人同致殺身之禍。即如武帝以後的眭孟、蓋寬饒,也是請漢帝禪讓而致殺身之禍的。由此可見,凡堅持儒家學說的人,無論是六國之君或秦始皇、漢武都是不能容忍的。而儒之為漢代社會上多數人所推崇,正在於此等人物和他們所堅持的大義。至於漢武帝時所謂以儒顯的,首先是公孫弘這種曲學阿世者。「罷黜百家,立學校之官,皆自仲舒發之。」這是後世稱為大有功於儒學的人。但「湯、武革命」,豈非今文學一大義(詳後)嗎?董仲舒卻變湯、武「革命」為三代「改制」。「易姓受命」是禪讓的學說,但董仲舒何以又要說「繼體守文之君」(即世及之君)「不害聖人之受命」,同時又把今文學主張的井田變為限田呢?實際上,儒家最高的理想與專制君主不相容的精微部份,阿世者流一齊都打了折扣而與君權妥協了,今文學從此也就變質了。董仲舒又何嘗不是曲學阿世之流。儒學本為後來所推重,這時經董仲舒、公孫弘之流的修改與曲解之後,這樣變了質的儒學,卻又是專制帝王漢武帝樂於

\n

治經雜語

\n

《周官》一書貌似規模宏大,職官分明,故後世有「周公致太平」、劉歆偽造之說。然細究其實,亦殊混亂,如選舉不盡屬大宗伯,軍事不盡屬大司馬,冢宰所主則多為王朝內府之事。若再細審之,則各官職分之重複者亦復不少。可見其實非系統完整之理想制度。至其所反映之社會制度亦與戰國以後之實況不合而頗與西周相符(別有專文),皆可證其為就舊日之檔案整理而成者。(269)

\n

惠棟是懂家法的,張惠言之於《易》,莊存與之於《公年》,(虛案:疑當作「公羊」)都可說是明於漢家家法的。(269)

\n

章太炎頗推重孫詒讓《周禮正義》、黃以周《禮書通故》二書,然二書路數則不同。孫為漢學路子,純宗鄭玄,然信之太過。黃以周則不純為漢學,也講宋學,以宋學方法講漢學則時有臆說。然其書又多用林昌彝《三禮通釋》,而其下結論則較林為精,林書則為《五禮通考》路子。(270)

\n

孫明復講《春秋》大一統,蓋針對唐末五代之藩鎮割據而發,故其說得以不脛而走。胡安國《春秋傳》大攘夷,則就南宋形勢言之,故其書終宋之時代三傳行世。(270)

\n
\n

「聯繫實際」,自古有之。

\n
\n

司馬談所言正是說明漢初所謂黃老是什麽,這也說明了《呂覽》的主旨所在。到《淮南》就和《呂覽》精神不同,雖然《呂覽》之精不如《淮南》,但合於一世之用則高於《淮南》。(273)

\n

西漢學術,應當明確由儒家轉變到經生的過程,伏生《尚書大傳》、韓太傅《詩外傳》、董生《春秋繁露》,還是儒家,而劉向、匡衡之輩,則為經生。儒家則猶意氣風發,經生則章句之徒而已。(274)

\n

對《辭海》徵求意見稿經學條目所提意見

\n

《周禮正義》 以東漢鄭玄注為依據。惟對部份清儒如惠士奇、金鍔、鄒漢勳等因不墨守鄭學,雖有很多精辟之論亦棄而不取,但仍是解釋《周禮》比較完備的書。(277)

\n

《儀禮正義》 有系統的《儀禮》注解書。對宋儒、清儒如盛世佐等學說雖不合鄭義,亦並加棌入,與其他墨守漢學的著作不同。書內部分是作者死後他的弟子楊大堉將作者稿本加以整理補成此書,這部分就差一些。(後來曹元弼作《禮經校釋》,是專為此書而作。曹氏墨守鄭學,意義已不同了)(277)

\n

乾嘉學派主要是反對宋明理學,不用唐以後一切學說,自以為是漢學,它是以訓詁為中心。(278)

","date_published":"Sun, 25 Mar 2012 10:11:01 GMT","date_modified":"Sat, 23 Nov 2019 19:11:50 GMT"},{"id":"https://mmap.page/dapi/lunyucidian-patch/","url":"https://mmap.page/dapi/lunyucidian-patch/","title":"跋論語譯注","content_html":"

跋論語譯注

\n

楊伯峻. 論語譯注[M]. 2版. 北京:中華書局,1980年12月. ISBN 7-101-00334-6

\n

此書爲今譯今注之典範。

\n

後附《論語詞典》,亦極有用。唯偶有小誤,如「德」字,《論語》凡40見,《詞典》統計為39見,今依《譯注》所標章節,臚列如左:

\n

1.9 2.1 2.3 4.11 4.25 6.29 7.3 7.6 7.23 8.1 8.20 8.20 9.18 11.3 12.10 12.10 12.19 12.19 12.21 12.21 13.22 14.4 14.4 14.5 14.33 14.34 14.34 14.34 14.34 1534 15.13 15.27 16.1 16.12 17.13 17.14 18.5 19.2 19.11 19.11

","date_published":"Fri, 16 Mar 2012 13:13:05 GMT","date_modified":"Sat, 23 Nov 2019 19:11:50 GMT"},{"id":"https://mmap.page/dapi/moshou/","url":"https://mmap.page/dapi/moshou/","content_html":"

趙伯雄. 春秋學史. 濟南:山東教育出版社,2004年4月. ISBN 7-5328-4203-7

\n

愚以為,經學史之屬,若蒙氏文通《經學抉原》者,可謂精矣。但取此書與蒙書相較,即曉此書難稱精矣。\n雖然,是書條理清楚,稱引詳贍,亦可資讀春秋者參考矣。

\n

第三章第五節述鄭玄《發墨守》、《針膏肓》、《起廢疾》,\n因言及何休《公羊墨守》、《左氏膏肓》、《穀梁廢疾》,云:「何氏三書,今已不傳,1但從書名看,當是墨守《公羊》經義,以攻擊《左傳》、《穀梁》之非。」(234)\n案此本諸唐徐彥《公羊疏》「作《墨守》以拒敵《長義》」。2\n宋末3《六經奧論·春秋經·三傳》亦云:「尊公羊者以公羊為墨守,以左氏、榖梁為膏肓、廢疾。」4\n何休《公羊解詁序》云:「傳春秋者非一,本據亂而作,其中多非常異義可怪之論。\n說者疑惑,至有倍經任意、反傳違戾者。\n其勢雖問,不得不廣,是以講誦師言,至於百萬,猶有不解,時加釀嘲辭,援引他經,失其句讀,以無為有,甚可閔笑者,不可勝記也。\n是以治古學貴文章者謂之俗儒,使賈逵緣隙奮筆,以為公羊可奪,左氏可興。」\n則何著《公羊墨守》,乃補隙守正,以證公羊難奪。5

\n

第九章第四節述陳立、皮錫瑞,(729-739)第五節述廖平、康有爲,(740-767)以鹿門長季平二歲,置皮氏於廖氏之前,亦可,惜通篇無一語道及廖氏於皮氏之影響。

\n

Footnotes

\n
    \n
  1. \n

    《四庫提要》云:「《后漢書》玄本傳稱,任城何休好《公羊》學,遂著《公羊墨守》、《左氏膏肓》、《穀梁廢疾》。玄乃發《墨守》、針《膏肓》、起《廢疾》。」「其卷目之見《隋書·經籍志》者,有《左氏膏肓》十卷,《穀梁廢疾》三卷、《公羊墨守》十四卷,皆注何休撰。而又別出《穀梁廢疾》三卷,注云鄭玄釋,張靖箋。似鄭氏所釋與休原本,隋以前本自別行。至《舊唐書·經籍志》所載《膏肓》、《廢疾》二書,卷數并同,特《墨守》作二卷為稍異。其下并注鄭玄箴、鄭玄發、鄭玄釋云云,則已與休書合而為一。迨於宋世,漸以散佚。」「此本凡《箴膏肓》二十馀條、《起廢疾》四十馀條、《發墨守》四條,并從諸書所引掇拾成編,不知出自誰氏。」則非但何書不傳,鄭書亦散佚矣。 ↩

    \n
  2. \n
  3. \n

    徐《疏》,引何氏《膏肓》、《廢疾》,亦引鄭氏《發墨守》,獨未嘗稱引《墨守》,則其時《墨守》或已不傳。 ↩

    \n
  4. \n
  5. \n

    舊題鄭樵撰,此用《四庫提要》說。 ↩

    \n
  6. \n
  7. \n

    舊題鄭樵. 六經奧論[M]. 臺北:閩南同鄉會,1976-03(民國六十五年三月):153 ↩

    \n
  8. \n
  9. \n

    愚嘗訓墨守為幽閉(墨者,晦也,默也,幽也;守,《戰國策》鮑彪注「猶閉」),以為何著《公羊墨守》,乃正其時公羊家之失。然何書雖已不存,《左氏膏肓》、《穀梁廢疾》當言二傳之弊,依愚說則《公羊墨守》非言公羊傳之失,乃論其時公羊家解公羊傳之誤,殊為迂曲。況訓墨守為幽閉,於他書無徵。足見此說無據。 ↩

    \n
  10. \n
\n
","date_published":"Tue, 13 Dec 2011 10:32:37 GMT","date_modified":"Sun, 27 Jul 2025 04:46:37 GMT"},{"id":"https://mmap.page/dapi/huangkanshoupifuhao/","url":"https://mmap.page/dapi/huangkanshoupifuhao/","title":"跋黃侃手批白文十三經","content_html":"

跋黃侃手批白文十三經

\n

黃侃手批白文十三經. 黃侃批校. 北京:中華書局2006年5月. ISBN 7-101-04909-5

\n

據黃焯《說明》可知,句讀根據舊注,且以一家之說爲主。如《爾雅·釋畜》有一例依郭注斷句,實則應依鄭玄《周禮注》所引斷句,黃侃雖知鄭義爲長,然於句讀則仍從郭。

\n

除斷句外,另有符識四十餘種,涉及分段、空格、乙文、訛字、衍文、脫文、四聲、異文、真書體製與篆文有異之字,等等。各經符識亦有所不同,如:《尚書》僞古文於句旁連加點者,表此類文句確有來歷,非魏晉間人所僞造;《毛詩》於句右旁加綫表興義,於上句左下角與下句左上角用綫連接表上下句於文法需連讀,於句旁加「/」表反問詞,於上下句角加「「」」表此類句爲詩人代所詠之人述之之詞,於字左旁加點表鄭箋與毛傳有異,於上下兩字用弧綫相連表倒裝句或表傳箋補足經意;《周禮》於字或句旁加綫表前人對此提出疑議,於字上加「[]」表衍文;《春秋左傳》於諸字下連續加圈表左氏之詞涉及全書條例,於句旁標直綫表君子曰或仲尼曰,於句末加三角表書法;《春秋公羊傳》、《春秋穀梁傳》於句末字旁加朱綫表疑問語,於句旁加綫表釋《春秋》書法;《論語》句旁連點表重出,字旁加三角表異文。

\n

此書八十年代上海古籍出版社曾影印出版,開本較小,小字批語辨識爲難。今中華書局改以十六開影印,分爲上下冊。

","date_published":"Tue, 13 Dec 2011 10:29:09 GMT","date_modified":"Sat, 23 Nov 2019 19:11:50 GMT"},{"id":"https://mmap.page/poems/exodia/","url":"https://mmap.page/poems/exodia/","content_html":"
\n

Exodia was, at first, a beast of such incalculable and intimidating might,\nthat he was split up into five distinctive parts - each one of them\nbeing chained and then sealed away in a poem (hence \"The Forbidden One\").\nThis would prevent his power from ever being used again.

\n

-- from The Book of Exodia, 5:36

\n
\n

封印されしエクゾディア (Exodia the Forbidden One)

\n
功遜赤練蛇\n容愧綠萼花\n言惑嘉興粽\n德慕峨嵋霞\n
\n

封印されし者の右足 (Right Leg of the Forbidden One)

\n
心吞造化腸猶斷\n念起觀音目已聾\n蝴蝶夢中譏馬白\n寧為赤練不為龍\n
\n

封印されし者の左足 (Left Leg of the Forbidden One)

\n
耳順無聞清梵唄\n目枯未結月明珠\n掘田三尺公孫冢\n但見髑髏顏色愉\n
\n

封印されし者の右腕 (Right Arm of the Forbidden One)

\n
南湖小荷纔聞月\n北閣粗茶已醉人\n穎脫無由何足道\n酣眠袋裏夢游鱗\n
\n

封印されし者の左腕 (Left Arm of the Forbidden One)

\n
皓首一經孱\n聚糧三世瘨\n祗因不知味\n夕死口頭禪\n
\n
\n

Were the five poems remembered by nobody, the five parts of Exodia would\ndie with the poems. After that, Exodia Necross, the deceased Exodia,\ncould be summoned via \"Contract with Exodia\".

\n

-- from The Book of Exodia, 8:28

\n
\n

エクゾディアとの契約 (Contract with Exodia)

\n
五五之年惟待化\n黃粱好夢覺時癡\n起身何急先續幻\n半片明心終善思\n
","date_published":"Mon, 13 Jun 2011 03:31:30 GMT","date_modified":"Sat, 23 Nov 2019 19:32:54 GMT"},{"id":"https://mmap.page/dive-into/centos/","url":"https://mmap.page/dive-into/centos/","title":"CentOS server setup guide for people from debian","content_html":"

CentOS server setup guide for people from debian

\n

A basic server setup guide for people from debian to CentOS.

\n

Software

\n

yum is apt-get/aptitude on CentOS.

\n

Remove not necessary software:

\n
yum grouplist\nyum groupremove <wildcards>\nyum list installed\nyum remove <wildcards>\n
\n

Upgrade system: (equivalent to apt-get update && apt-get upgrade on debian)

\n
yum update\n
\n

Add more packages:

\n

http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

\n

Unlike Debian, Centos's official package repo is very limited.

\n

Services

\n

Check what is running:

\n
chkconfig --list |grep '3:on' |awk '{print $1}' |sort\n
\n

Use chkconfig <service> off to disable unnecessary services.

\n

chkconfig is included as default in Centos.\nIn Debian, you can install it via apt-get install chkconfig,\nthough Debian people are likely to use sysv-rc-conf instead.

\n

Hostname

\n

Make sure your /etc/hosts file have a line like:

\n
127.0.0.1               <your-hostname>.example.com <your-hostname> localhost.localdomain localhost\n
\n

And /etc/sysconfig/network have a line like:

\n
HOSTNAME=your-hostname.example.com\n
\n

Then run hostname <your-hostname>.example.com

\n

Debian doesn't use /etc/sysconfig/network.\nIn Debian, you change hostname in /etc/hostname:

\n
echo 'your-hostname' > /etc/hostname\n
\n

Debian prefers to not include the example.com part.

\n

SSH

\n

Same to Debian.

\n

Firewall

\n

CentOS may enable iptables by default.\nYou may want to disable it via service iptables stop\nor /etc/init.d/iptables stop.\nAnd disable its startup at boot time via chkconfig.

\n

If you want to mess up with it, its configuration file is located at\n/etc/sysconfig/iptables, different to Debian.

","date_published":"Fri, 10 Jun 2011 09:28:08 GMT","date_modified":"Thu, 17 Jul 2025 14:34:57 GMT"},{"id":"https://mmap.page/dive-into/fish/","url":"https://mmap.page/dive-into/fish/","title":"Dive into Fish","content_html":"

Dive into Fish

\n

Introduction

\n

Fish is the Friendly Interactive Shell.\nIt also offers a relative clean syntax for shell scripting.\n(I myself find that rc has a more clean syntax.\nFish's tab completion is powerful.\nThough plan9 fans may say that we should implement tab completion in\nterminal emulator.)

\n

Help

\n

help command or command --help.

\n

Syntax overview

\n
command [argument ...]\n
\n

Commands and arguments are separated by the space character ( ).\nEvery command ends with either a newline or a semicolon (;).

\n

Quotes and escaping

\n

Variable expansions take place in double quoted strings but\nnot in single quoted ones.

\n

Escapes in single quotes: \\' and \\.

\n

Escapes in double quotes: \\\", \\, and \\$.

\n
$ - ? * ~ # ( ) { } [ ] < > ^ & ; ' \"\n
\n

These characters and the space character have special meanings in fish.\nWe need to escape them by prepending them with a backslash.\nWe escape a backslach with another backslash (\\).

\n

IO redirection and piping

\n\n

DESTINATION can be one of the following:

\n\n

For example, redirect both standard output and standard error\nto the file all_output.txt:

\n
echo Hello >all_output.txt ^&1\n
\n

Any FD can be redirected in an arbitrary way by prefixing the redirection with the number of the FD:

\n\n

Prepend the desired FD number and then output\nredirect symbol to the pipe. For example:

\n
make fish 2>| less\n
\n

Jobs

\n\n

Functions and conditional structure

\n

See help page for function, if, switch, and, or, for, while, begin, end, etc.

\n

Notes on wrapper functions:

\n\n

Autosuggestions

\n

fish suggests commands as you type, based on command history, completions, and valid file paths. As you type commands, you will see a completion offered after the cursor, in a muted gray color.

\n

To accept the autosuggestion (replacing the command line contents), hit right arrow or Control-E.

\n

Tab completion

\n

Fish tab completion list features descriptions of the completions and\nit is scrollable\nby arrow keys, page up/page keys,\nthe tab key or the space bar.\nPressing any other key will exit the list and insert\nthe pressed key into the command line.

\n

fish provides completions for:

\n\n

fish provides a large number of program specific completions.

\n

You can write your own builtin.\nSee help complete and /usr/share/fish/completions.

\n

Set variables

\n
set name value1 value2 ...\n
\n

Options:

\n\n

When calling a function, all current local variables temporarily disappear.

\n

Special variables

\n\n

Command line expansions

\n

Wildcards:

\n

?, *, and ** match non-hidden file names.

\n

Use . as the first character to match hidden files.

\n

Command substitution:

\n
(command)\n
\n

Variable expansion:

\n
$variable\n$array  # --> multiple arguments\n\"$array\" # --> one argument\n
\n

Brace expansion:

\n
{a,b,c}\n{$USER}san # Neat, isn't it?\n
\n

Home directory expansion:

\n
~\n~user\n
\n

Process expansion:

\n
%self # shell pid\n%id  # group id\n%string\n%user # pids of processes owned by user\n
\n

Arrays:

\n
$PATH[3] # indices start at 1\n(seq 10)[2..5]\n(seq 10)[2..5 1..3]\n(seq 10)[-1..1]  # Reverse output\n$$foo[1] # the same as ${$foo[1]}\n
\n

History

\n

Press 'up' and 'down' to search commands containing the string entered.\nPress Alt-up and Alt-down, match against the token under the cursor.\nPress escape to abort.

\n

Config files

\n

Variables definitions: ~/.config/fish/config.fish

\n

Function definitions: ~/.config/fish/functions/

\n

Completion definitions: ~/.config/fish/completions/

\n

History file: ~/.config/fish/fish_history.

\n

Feedback

\n

weakish@gmail.com

\n

Copyright

\n

This work is based on the fish user documentation shipped in the fish distributions:

\n

Copyright (C) 2005 Axel Liljencrantz.\nReleased under the GNU General Public License.

","date_published":"Mon, 21 Feb 2011 06:22:23 GMT","date_modified":"Sun, 24 May 2020 13:58:17 GMT"}]}