100% found this document useful (1 vote)
59 views49 pages

Go Crazy: A Fun Projects-Based Approach To Golang Programming 1st Edition Nicolas Modrzyk

The document promotes the book 'Go Crazy: A Fun Projects-based Approach to Golang Programming' by Nicolas Modrzyk, which is available for download at ebookmass.com. It also lists several other recommended programming-related books and provides links for downloading them. The content includes various chapters covering topics such as basics of Go programming, HTTP APIs, game development, blockchain trading, and Kubernetes operators.

Uploaded by

paidjonva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
59 views49 pages

Go Crazy: A Fun Projects-Based Approach To Golang Programming 1st Edition Nicolas Modrzyk

The document promotes the book 'Go Crazy: A Fun Projects-based Approach to Golang Programming' by Nicolas Modrzyk, which is available for download at ebookmass.com. It also lists several other recommended programming-related books and provides links for downloading them. The content includes various chapters covering topics such as basics of Go programming, HTTP APIs, game development, blockchain trading, and Kubernetes operators.

Uploaded by

paidjonva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Visit ebookmass.

com to download the full version and


explore more ebook or textbook

Go Crazy: A Fun Projects-based Approach to Golang


Programming 1st Edition Nicolas Modrzyk

_____ Click the link below to download _____


https://ebookmass.com/product/go-crazy-a-fun-projects-based-
approach-to-golang-programming-1st-edition-nicolas-modrzyk/

Explore and download more ebook or textbook at ebookmass.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Software Development with Go: Cloud-Native Programming


using Golang with Linux and Docker 1st Edition Nanik
Tolaram
https://ebookmass.com/product/software-development-with-go-cloud-
native-programming-using-golang-with-linux-and-docker-1st-edition-
nanik-tolaram/

Practical MATLAB Deep Learning: A Projects-Based Approach,


2nd Edition Michael Paluszek

https://ebookmass.com/product/practical-matlab-deep-learning-a-
projects-based-approach-2nd-edition-michael-paluszek/

Kubernetes Programming with Go: Programming Kubernetes


Clients and Operators Using Go and the Kubernetes API 1st
Edition Philippe Martin
https://ebookmass.com/product/kubernetes-programming-with-go-
programming-kubernetes-clients-and-operators-using-go-and-the-
kubernetes-api-1st-edition-philippe-martin/

Kubernetes Programming with Go: Programming Kubernetes


Clients and Operators Using Go and the Kubernetes API 1st
Edition Philippe Martin
https://ebookmass.com/product/kubernetes-programming-with-go-
programming-kubernetes-clients-and-operators-using-go-and-the-
kubernetes-api-1st-edition-philippe-martin-2/
Pragmatist Semantics: A Use-Based Approach to Linguistic
Representation Prof José L. Zalabardo

https://ebookmass.com/product/pragmatist-semantics-a-use-based-
approach-to-linguistic-representation-prof-jose-l-zalabardo/

Go Programming Language For Dummies 1st Edition Wei-Meng


Lee

https://ebookmass.com/product/go-programming-language-for-dummies-1st-
edition-wei-meng-lee/

Chemical Projects Scale Up: How to go from Laboratory to


Commercial Joe M. Bonem

https://ebookmass.com/product/chemical-projects-scale-up-how-to-go-
from-laboratory-to-commercial-joe-m-bonem/

Lua and Golang Coding Made Simple: A Beginner's Guide to


Programming - 2 Books in 1 Mark Stokes

https://ebookmass.com/product/lua-and-golang-coding-made-simple-a-
beginners-guide-to-programming-2-books-in-1-mark-stokes/

Practical Radiology: A Symptom-Based Approach 1st Edition

https://ebookmass.com/product/practical-radiology-a-symptom-based-
approach-1st-edition/
Go Crazy
A Fun Projects-based Approach
to Golang Programming

Nicolas Modrzyk
Contributed by David Li, Jun Akiyama and
Tony Broyez
Go Crazy: A Fun Projects-based Approach to Golang Programming
Nicolas Modrzyk
tokyo-to suginami-ku, Japan

ISBN-13 (pbk): 978-1-4842-9665-3 ISBN-13 (electronic): 978-1-4842-9666-0


https://doi.org/10.1007/978-1-4842-9666-0

Copyright © 2023 by Nicolas Modrzyk


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Melissa Duffy
Development Editor: Jim Markham
Coordinating Editor: Gryffin Winkler
Copy Editor: Kezia Endsley
Cover image designed by Scott Webb on unsplash (https://unsplash.com/)
Distributed to the book trade worldwide by Springer Science+Business Media LLC, 1 New York Plaza, Suite
4600, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.
com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner)
is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware
corporation.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub. For more detailed information, please visit https://www.apress.com/gp/services/
source-code.
Paper in this product is recyclable.
I dedicate this book to planet Earth.
Table of Contents
About the Author����������������������������������������������������������������������������������������������������� xi

About the Technical Reviewer������������������������������������������������������������������������������� xiii


Acknowledgments���������������������������������������������������������������������������������������������������xv

Introduction�����������������������������������������������������������������������������������������������������������xvii

Chapter 1: Go to the Basics�������������������������������������������������������������������������������������� 1


First Steps������������������������������������������������������������������������������������������������������������������������������������� 2
Run and Debug Your First Go Program������������������������������������������������������������������������������������ 2
A Short Note on Debugging with GoLand�������������������������������������������������������������������������������� 8
Before Talking to OpenAI: Reviewing Concepts��������������������������������������������������������������������������� 10
Read from Input��������������������������������������������������������������������������������������������������������������������� 12
Reading from a File��������������������������������������������������������������������������������������������������������������� 13
Custom Data: Go Structs�������������������������������������������������������������������������������������������������������� 14
Writing and Reading Structs from Files��������������������������������������������������������������������������������� 17
Reading a Struct from a File�������������������������������������������������������������������������������������������������� 19
Slicing Program Arguments��������������������������������������������������������������������������������������������������� 20
Using a Custom Library to Load the API Key������������������������������������������������������������������������� 21
Asynchronous Code: Go Routines������������������������������������������������������������������������������������������ 25
Asynchronous Code: Go Routines and Channels������������������������������������������������������������������� 25
Using Go Contexts����������������������������������������������������������������������������������������������������������������� 30
Putting Things Together Into a ChatGPT Client���������������������������������������������������������������������������� 34
Getting an API Key����������������������������������������������������������������������������������������������������������������� 34
First Request������������������������������������������������������������������������������������������������������������������������� 36
Customize the ChatGPT Request������������������������������������������������������������������������������������������� 38

v
Table of Contents

Create a Loop Prompt������������������������������������������������������������������������������������������������������������ 41


Streaming the Response������������������������������������������������������������������������������������������������������� 42
Query and Use a Custom Model�������������������������������������������������������������������������������������������� 43
Summary������������������������������������������������������������������������������������������������������������������������������������ 45

Chapter 2: Write a Tested HTTP Image Generator API�������������������������������������������� 47


Pour Me Some Gin!��������������������������������������������������������������������������������������������������������������������� 48
Working with Queues������������������������������������������������������������������������������������������������������������������ 56
Image Generators������������������������������������������������������������������������������������������������������������������������ 67
Image Generator in a Gin������������������������������������������������������������������������������������������������������������ 71
Quick Gin Tonic and Templates��������������������������������������������������������������������������������������������������� 76
Use a Synchronized Map������������������������������������������������������������������������������������������������������������� 80
Testing the API���������������������������������������������������������������������������������������������������������������������������� 84
Simple Go and Gin Testing����������������������������������������������������������������������������������������������������� 84
Testing the Image Generator������������������������������������������������������������������������������������������������� 90
Summary������������������������������������������������������������������������������������������������������������������������������������ 92

Chapter 3: Writing the Basics for a 2D Game in Go������������������������������������������������ 93


Some Tile Set History������������������������������������������������������������������������������������������������������������������ 93
Library Setup: Raylib������������������������������������������������������������������������������������������������������������� 94
Game Setup��������������������������������������������������������������������������������������������������������������������������� 95
Quick Game Generation with ChatGPT���������������������������������������������������������������������������������� 97
The Moyashi Game�������������������������������������������������������������������������������������������������������������������� 103
The Basic Game Loop���������������������������������������������������������������������������������������������������������� 105
Loading Textures����������������������������������������������������������������������������������������������������������������� 107
Adding a Player Texture������������������������������������������������������������������������������������������������������� 110
Using Key Inputs������������������������������������������������������������������������������������������������������������������ 113
Doing the Game Music�������������������������������������������������������������������������������������������������������� 115
Game Camera���������������������������������������������������������������������������������������������������������������������� 118
Animate Sprites������������������������������������������������������������������������������������������������������������������� 121
Animation for an Idle Moyashi��������������������������������������������������������������������������������������������� 126
Loading the World Map�������������������������������������������������������������������������������������������������������� 127

vi
Table of Contents

Loading the Full World Map������������������������������������������������������������������������������������������������� 131


Full Map and Full Screen����������������������������������������������������������������������������������������������������� 137
Summary���������������������������������������������������������������������������������������������������������������������������������� 138

Chapter 4: Trend Follower for Blockchain Trading����������������������������������������������� 139


Go Crazy or Go Home���������������������������������������������������������������������������������������������������������������� 139
Why Trade in the Financial Markets?����������������������������������������������������������������������������������� 141
Why Automate Trading?������������������������������������������������������������������������������������������������������� 144
The Secret Sauce���������������������������������������������������������������������������������������������������������������� 147
The Recipe��������������������������������������������������������������������������������������������������������������������������� 150
Utensils in the Kitchen��������������������������������������������������������������������������������������������������������� 155
Cooking�������������������������������������������������������������������������������������������������������������������������������� 160
Performance Evaluation������������������������������������������������������������������������������������������������������ 175
A Taste Before Serving the Meal����������������������������������������������������������������������������������������� 187
Dinner Is Served������������������������������������������������������������������������������������������������������������������ 193
Dessert!������������������������������������������������������������������������������������������������������������������������������� 197
Appendix������������������������������������������������������������������������������������������������������������������������������ 204

Chapter 5: Writing a Kubernetes Operator to Run EVM-Compatible


Blockchains����������������������������������������������������������������������������������������� 213
Setting Up Kubernetes on Your Machine����������������������������������������������������������������������������������� 214
Resources Overview����������������������������������������������������������������������������������������������������������������� 216
Let’s Run a Pod������������������������������������������������������������������������������������������������������������������������� 218
Demystifying Kubernetes Operators����������������������������������������������������������������������������������������� 219
Custom Resource Definition������������������������������������������������������������������������������������������������ 220
Controller����������������������������������������������������������������������������������������������������������������������������� 222
Bootstrapping the Project with Operator-SDK��������������������������������������������������������������������������� 222
Creating an API�������������������������������������������������������������������������������������������������������������������������� 223
Generating the Manifests���������������������������������������������������������������������������������������������������������� 225
Configuring the Makefile����������������������������������������������������������������������������������������������������������� 225
Implementing the Operator Reconciliation Logic���������������������������������������������������������������������� 227
Using the Kubernetes Go SDK��������������������������������������������������������������������������������������������������� 237

vii
Table of Contents

Interacting with the JSON-RPC API������������������������������������������������������������������������������������������� 246


Using Port-Forward������������������������������������������������������������������������������������������������������������� 247
Parameterizing Resources and Ports���������������������������������������������������������������������������������������� 248
Implementing the Update Logic������������������������������������������������������������������������������������������������ 250
Implementing Health Checks���������������������������������������������������������������������������������������������������� 258
Creating a Minimal Go HTTP Server������������������������������������������������������������������������������������ 259
Performing a net_peerCount Health Check������������������������������������������������������������������������� 262
Configuring the Readiness Probe���������������������������������������������������������������������������������������� 266
Summary���������������������������������������������������������������������������������������������������������������������������������� 268

Chapter 6: Go Beyond : Connecting to C for a Performance Boost����������������������� 271


C is for Change�������������������������������������������������������������������������������������������������������������������������� 272
Calling C������������������������������������������������������������������������������������������������������������������������������ 272
Calling C Code Located in a C File��������������������������������������������������������������������������������������� 273
C Code Calling Go Code������������������������������������������������������������������������������������������������������� 274
Passing Parameters������������������������������������������������������������������������������������������������������������ 275
Using a Header File������������������������������������������������������������������������������������������������������������� 277
Using a C Struct from Go����������������������������������������������������������������������������������������������������� 278
Matisse, ImageMagick, and Sepia�������������������������������������������������������������������������������������������� 284
ImageMagick on OSX���������������������������������������������������������������������������������������������������������� 285
ImageMagick on Linux�������������������������������������������������������������������������������������������������������� 288
ImageMagick on Raspberry Pi��������������������������������������������������������������������������������������������� 288
GPU Coding on OSX������������������������������������������������������������������������������������������������������������������� 289
Basics: Adding Values from Two Arrays������������������������������������������������������������������������������� 290
Back to the Plot������������������������������������������������������������������������������������������������������������������� 294
Generic GPU Processing Go Code���������������������������������������������������������������������������������������� 297
Opens ETHUSD Hourlies Quotes: Moving Average��������������������������������������������������������������� 299
Slightly Better Moving Average on the GPU������������������������������������������������������������������������� 300
Normalized Set�������������������������������������������������������������������������������������������������������������������� 302
Pearson Coefficient Moving Factor�������������������������������������������������������������������������������������� 304
Sepia Gopher����������������������������������������������������������������������������������������������������������������������� 307

viii
Table of Contents

Extreme Calling OpenCV/C++ from Go������������������������������������������������������������������������������������� 309


Summary���������������������������������������������������������������������������������������������������������������������������������� 315

Chapter 7: Alef from Plan 9���������������������������������������������������������������������������������� 317


Plan 9 from Bell Labs���������������������������������������������������������������������������������������������������������������� 319
The Network Is the Computer��������������������������������������������������������������������������������������������������� 321
The Alef Language�������������������������������������������������������������������������������������������������������������������� 323
Hello Tuple!�������������������������������������������������������������������������������������������������������������������������� 324
Channels and Processes����������������������������������������������������������������������������������������������������� 324
Proc and Task���������������������������������������������������������������������������������������������������������������������� 326
Have Fun with Plan 9���������������������������������������������������������������������������������������������������������������� 330

Index��������������������������������������������������������������������������������������������������������������������� 359

ix
About the Author
Nicolas Modrzyk acts as the CTO of Karabiner Software, a
successful consulting company located in the never-asleep
Tokyo, with its mix of ancestral culture and eco-friendly,
future-oriented dynamic.
He is an active contributor to the open-source
community in various domains, including imaging, ML, AI,
and cloud computing. As an engineer and a leader, Nico
has been involved in designing large-scale applications,
managing mammoth-sized clusters of servers, sometimes
using handwritten software, and enabling world-class
leaders by pushing international boundaries.
Nico ardently focuses on making life simple. (And we all
know how difficult that is!)
He loves pushing people to challenge themselves and go beyond their comfort zones.
To learn other cultures and explore different world views, he has been living around
the planet in various countries, including France, Ireland, Japan, China, Korea, India,
and the United States. You can talk to Nico in French, English, and Japanese, and you can
get along with him in Spanish and Chinese.
Nico is the author of a few programming books, available on Amazon. He recently
picked up the saxophone to honor his grandfather and his uncle, in the hope to match
their skill with a brass instrument.
He will be ready for a jazzy jam session whenever you are.

xi
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
About the Technical Reviewer
David Li is the executive director of Shenzhen Open
Innovation Lab, which facilitates the collaboration between
global smart hardware entrepreneurs and the Shenzhen
Open Innovation ecosystem. Before SZOIL, he co-founded
XinCheJian, the first hackerspace in China to promote
the hacker/maker culture and open-­source hardware. He
co-founded Hacked Matter, a research hub on the maker
movement and open innovation. He also co-founded Maker
Collier, an AI company focusing on motion and sports
recognition and analysis.

xiii
Acknowledgments
All the involved authors—Jun, Tony, David—as well as the technical reviewers, Mathieu
and David, of this book have gone the extra mile to match the deadlines and bring the
writing and code samples to a top-class level.
My two strong daughters, Mei and Manon—you always keep me focused and in line
with my goals.
Psy Mom, French Chef Dad, Little Bro, Artful Sis—I thank you for your love every day,
your support, and all the ideas we share together.
My partner at Karabiner, Chris Mitchell—we’ve been working together for ten years,
and I think we both made tremendous efforts to make the planet a better place. Also,
the whole Karabiner people, at work now or busy making babies, we make a pretty
impressive world team.
Abe-san—who did not participate directly in the making of this book, but we wrote
our first computer book together, and without a first one, and without his trust, I would
not be here to even talk about it.
Kanaru-san—without your Iranian lifestyle and your life changing vision, I would
probably be a monk.
Marshall—without your world encompassing vision, I could have been focusing on
the bigger picture.
Ogier—without your summertime raclette and life-long friendship, I would probably
have been 5 kilos skinnier.
Jumpei—without your strong focus on music, I could not have played in all those
beautiful Tokyo live stages. And welcome Rei-chan!
Gryffin and Melissa—I could not have survived this without your hard work
and trust.
And of course, Marcel le chat—my open-source project on imaging would not be the
same without your feline cuteness.

xv
Introduction
On a sunny drive on the busy roads of Tokyo, over the rainbow bridge and facing the
ocean, my daughter Mei and I are having one of these philosophical talks.
Among the slur of questions she had ready for me, like “what is work for?,” she was
telling me about her need to have someone monitor her and give her deadlines. While
at the time of this writing, she’s barely 20 and hasn’t started a full-blown professional
career yet, she is right in the sense that the need to have deadlines and a purpose is at the
core of many adults’ professional lives.
At the very root of a school system, you are being told what to complete, and by what
date. You do not have input regarding the what or the when. A regular office worker is
told to finish their tasks by the fifth of next month, for example, and some authors are
told to finish three chapters by the end of the month.
That de facto need of what to do and by when happens very early in your career.
I am in favor of looking at things from a different angle. You should set your own
deadlines, and you should be in control of those deadlines. You have a goal, you set
milestones to achieve that goal, and you work on walking that path to that goal.
You want to live your own life and reach your own goals, not someone else’s.
Although I am critical about many of his actions, Elon Musk does not have someone
telling him when to land a rocket on Mars. He has his own schedule. He owns his
schedule. He owns his life.
This is a book on how to own your life again. More precisely, how Go, the
programming language, can help you get your time back, manage it along your dreams,
and own your life again.
I discovered the Go programming language a few years back. At that time, to be
honest, I was more of a Clojure-loving propaganda evangelist. Anything I developed or
touched had to be in Clojure. A deployment script, a web app, a dynamically generated
API around some custom datasets, image and video processing, or applying the latest
Computer Vision algorithm in real time—it did not matter. It greatly helped my career. I
would go even further and say, my life.

xvii
Introduction

How can a programming language help make your life better, you might ask? A
programming language is at first a language, and as such its first goal is to communicate.
We tend to think that a programming language’s only goal is to deal with a computer, but
we deal with computers because we want to communicate something to other people.
Take a simple email, for example. You use a computer to write an email because it
takes less time to reach its recipient, but the goal of an email is still to convey a message
to another person.
Now let’s say you have a lot to communicate, or you want to communicate something
to many people, but with that simple personal touch that makes all the difference
between your email being ignored and it being read and acted upon.
You don’t have much time. In life in general, but also to realize a task. You can use a
computer to help you with that task and save time.
Nowadays one of the best programming languages to put in your toolbox is GoLang.
It includes all the important concepts of Clojure, and that I love in a programming
language, but it’s also in the top ten of the TIOBE index, meaning you can find a few
more programmers to help you do your job.
Don’t get me wrong, there are other great languages, but there are many things that
GoLang gets absolutely right:

–– It is simple

–– It is concise

–– The code is short

–– Concurrency is not an afterthought

–– It can be compiled and run on a large variety of operating systems


and architectures

–– It’s easy to reuse bits of code from one project to the other

–– Errors are simple to handle

–– It is cloud-ready

–– It is very fast (this is probably my favorite)

xviii
Introduction

Go, as a programming language, has a clear and strong purpose: Implement


architecture based on microservices in the most convenient way possible.

This programming book will take you on the path to Ikigai, finding joy in life through
purpose.

xix
CHAPTER 1

Go to the Basics

The goal of this first chapter is to write a ChatGPT client in Go. You’ve probably heard
about ChatGPT. It is an AI-trained chatbot that generates text according to questions
you ask it.
To get to this point, you will run basic Go programs and get used to the language.
Then you will put things together into a ChatGPT client.
But you first need to set up your code editor.

1
© Nicolas Modrzyk 2023
N. Modrzyk, Go Crazy, https://doi.org/10.1007/978-1-4842-9666-0_1
Chapter 1 Go to the Basics

First Steps
As with any new skill, you need a basic setup where you feel comfortable practicing
and trying new things. While Go, the language, makes writing code easier, GoLand, the
editor, makes writing Go easier.
To kick-start this chapter, you learn how to use GoLand as your editor for writing Go.

Run and Debug Your First Go Program


Running your first Go program using JetBrains GoLand should take approximately ten
minutes or less.
In the context of this book, the goal is to go deep into the language as quickly as
possible and become proficient in Go in a matter of hours. Within that context, it’s best
if you use JetBrains’s Go editor called GoLand. Of course, you can use any editor you
choose, but you will find it easier to follow along if you use GoLand.
You can download GoLand for individual use from the following URL:
www.jetbrains.com/go/download/
You will have 30 days of use for free, which should be enough to finish reading and
applying the lessons in this book—and to get you excited for more coding.
GoLand handles all the core Go language installers, paths, and dependencies
for you.
Once you start the editor, click New Project. You’ll see the screen in Figure 1-1.

2
Chapter 1 Go to the Basics

Figure 1-1. Creating a new project in GoLand

Once you have created a new project, a blank project window will be available.
The left side of the window shows your project file, and the right side shows your
code editor (which, at this stage, is empty). See Figure 1-2.

3
Chapter 1 Go to the Basics

Figure 1-2. New Project window

You can right-click in the Project Files tab and create a new Go file, as shown in
Figure 1-3.

4
Chapter 1 Go to the Basics

Figure 1-3. Creating a new Go file

Give your new file a name (see Figure 1-4).

Figure 1-4. The new Go file

5
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Other documents randomly have
different content
OCTOBER.

To be done

In the Orchard, and Olitory Garden.

Trench Grounds for Orcharding, and the Kitchin-garden, to lye for a


Winter mellowing.
Plant dry Trees (i) Fruit of all sorts, Standard, Mural or Shrubs, which
lose their lease; and that so soon as it falls: But be sure you chuse
no Trees for the Wall of above two years Graffing at the most.
Now is the time for Ablaqueation, and laying bare the Roots of old
unthriving, or over hasty blooming trees.
Moon now decreasing, gather Winter-fruit that remains, weather
dry; take heed of bruising; lay them up clean lest they Taint, Cut and
prune Roses yearly.
Plant and Plash Quick-sets.
Sow all stony, and hard kernels and seeds, such as Cherry, Pear-
plum, Peach, Almond-stones, etc. Also Nuts, Haws, Ashen, Sycomor
and Maple keys; Acorns, Beech-mast, Apple, Pear and Crab Kernel,
for Stocks; or you may defer it till the next Moneth towards the later
end. You may yet sow Letuce.
Make Winter Cider, and Perry.

Fruits in Prime, and Yet Lasting.


APPLES.

Belle-et-Bonne, William, Costard, Lordling, Parsley-apples, Pearmain,


Pear-apple, Honey-meal, Apis, etc.

PEARS.

The Caw-pear (baking), Green-butter-pear, Thorn-pear, Clove-pear,


Roussel-pear, Lombart-pear, Russet-pear, Suffron-pear, and some of
the former Moneth.
Bullis, and divers of the September Plums and Grapes, Pines, etc.

OCTOBER.

To be done

In the Parterre, and Flower Garden.

Now your Hyacinthus Tuberose not enduring the wet, must be set
into the house, and preserved very dry till April.
Continue sowing what you did in September, if you please: Also,
You may plant some Anemonies, and Ranunculus’s, in fresh sandish
earth, taken from under the turf; but lay richer mould at the bottom
of the bed, which the fibres may reach, but not to touch the main
roots, which are to be covered with the natural earth two inches
deep: and so soon as they appear, secure them with Mats, or Straw,
from the winds and frosts, giving them air in all benigne intervals; if
possible once a day.
Plant also Ranunculus’s of Tripoly, etc.
Plant now your choice Tulips, etc., which you feared to interre at the
beginning of September; they will be more secure and forward
enough: but plant them in natural earth somewhat impoverish’d with
very fine sand; else they will soon lose their variegations; some
more rich earth may lye at the bottom, within reach of the fibres:
Now have a care your Carnations catch not too much wet; therefore
retire them to covert, where they may be kept from the rain, not the
air, Trimming them with fresh mould.
All sorts of Bulbous roots may now be safely buried; likewise Iris’s,
etc.
You may yet sow Alaternus, and Phillyrea seeds; it will now be good
to Beat, Roll, and Mow Carpet-walks, and Camomile; for now the
ground is supple, and it will even all inequalities: Finish your last
weeding, etc.
Sweep and cleanse your Walks, and all other places, of Autumnal
leaves fallen, lest the worms draw them into their holes, and foul
your Gardens, etc.

Flowers in Prime, or Yet Lasting.

Amaranthus tricolor, etc. Aster Atticus, Amomum, Antirrhinum,


Colchicum, Heliotrope, Stock-gilly-flo., Geranium triste, Ind. Tuberose
Jacynth, Limonium, Lychnis white and double, Pomum Amoris and
Aethiop., Marvel of Peru, Millefol. luteum, Autumnal Narciss.,
Pansies, Aleppo Narciss., Sphaerical Narciss., Nasturt., Persicum,
Gilly-flo., Virgin Phalangium, Pilosella, Violets, Veronica, Arbutus,
Span. Jasmine Oranges.
NOVEMBER.

To be done

In the Orchard, and Olitory Garden.

Carry Comfort out of your Melon-ground, or turn and mingle it with


the earth, and lay it in ridges ready for the Spring: Also trench and
fit ground for Artichocks, etc.
Continue your Setting and Transplanting of Trees; lose no time, hard
frosts come on apace; yet you may lay bare old Roots.
Plant young Trees, Standards or Mural.
Furnish your Nursery with Stocks to graff on the following year.
Sow and set early Beans and Pease till Shrove-tide; and now lay up
in your Cellars for Seed, to be Transplanted at Spring, Carrots,
Parsneps, Turneps, Cabbages, Cauly-flowers, etc.
Cut off the tops of Asparagus, and cover it with long-dung, or make
Beds to plant in Spring, etc.
Now, in a dry day, gather your last Orchard-fruits.
Take up your Potatoes for Winter spending, there will be enough
remain for stock, though never so exactly gather’d.
A HAMPSTEAD GARDEN IN WINTER.

Fruits in Prime, or Yet Lasting.

APPLES.

The Belle-bonne, the William, Summer Pearmain, Lordling-apple,


Pear-apple, Cardinal, Winter Chessnut, Short-start, etc., and some
others of the former two last Moneths, etc.

PEARS.

Messire Jean, Lord-pear, long Bergamot, Warden (to bake), Burnt


Cat, Sugar-pear, Lady-pear, Ice-pear, Dove-pear, Deadmans-pear,
Winter Bergamot, Belle-pear, etc.
Bullis, Medlars, Services.

NOVEMBER.

To be done

In the Parterre, and Flower Garden.

Sow Auricula seeds thus: prepare very rich earth more than half
dung, upon that seift some very light sandy mould; and then sow;
set your Cases or Pans in the Sun till March. Cover your peeping
Ranunculus’s, etc.
Now is your best season (the weather open) to plant your fairest
Tulips in place of shelter, and under Espaliers; but let not your earth
be too rich, vide Octob. Transplant ordinary Jasmine, etc. About the
middle of this Moneth (or sooner, if weather require) quite enclose
your tender Plants, and perennial Greens, Shrubs, etc., in your
Conservatory, secluding all entrance of cold, and especially sharp
winds; and if the Plants become exceeding dry, and that it do not
actually freeze, refresh them sparingly with qualified water mingled
with a little sheeps or Cow-dung: If the Season prove exceeding
piercing (which you may know by the freezing of a dish of water set
for that purpose in your Green-house) kindle some Charcoal, and
then put them in a hole sunk a little into the floor about the middle
of it: This is the safest stove: at all other times when the air is
warmed by the beams of a fine day, and that the Sun darts full upon
the house shew them the light; but enclose them again before the
sun be gone off: Note that you must never give your Aloes, or
Sedums one drop of water during the whole Winter.
Prepare also Mattresses, Boxes, Cases, Pots, etc., for shelter to your
tender Plants and Seedlings newly sown, if the weather prove very
bitter.
Plant Roses, Althæa Frutex, Lilac, Syringas, Cytisus, Peonies, etc.
Plant also Fibrous roots, specified in the precedent Moneth.
Sow also stony-seeds mentioned in Octob.
Plant all Forest-trees for Walks, Avenues, and Groves.
Sweep and cleanse your Garden-walks, and all other places, of
Autumnal leaves.

Flowers in Prime, or Yet Lasting.

Anemonies, Meadow Saffron, Antirrhinum, Stock-gilly-flo., Bellis,


Pansies, some Carnations, double Violets, Veronica, Spanish
Jasmine, Musk Rose, etc.
DECEMBER.

To be done

In the Orchard, and Olitory Garden.

Prune, and Nail Wall-fruit, and Standard-trees.


You may now plant Vines, etc.
Also Stocks for Graffing, etc.
Sow, as yet, Pomace of Cider-pressings to raise Nurseries; and set
all sorts of Kernels, Stones, etc.
Sow for early Beans, and Pease, but take heed of the Frosts;
therefore surest to defer it till after Christmas, unless the Winter
promise very moderate.
All this Moneth you may continue to Trench Ground and dung it, to
be ready for Bordures, or the planting of Fruit-trees, etc.
Now seed your weak Stocks.
Turn and refresh your Autumnal Fruit, lest it taint and open the
Windows where it lyes, in a clear and Serene day.

Fruits in Prime, or Yet Lasting.

APPLES.

Rousseting, Leather-coat, Winter-reed, Chest-nut Apple, Great-belly,


the Go-no-further, or Cats-head, with some of the precedent
Moneth.

PEARS.

The Squib-pear, Spindle-pear, Virgin, Gascoyne-Bergomot, Scarlet-


pear, Stopple-pear, white, red, and French Wardens (to bake or
roast), etc.

DECEMBER.

To be done

In the Parterre, and Flower Garden.

As in January, continue your hostility against Vermine.


Preserve from too much Rain and Frost your choicest Anemonies,
Ranunculus’s, Carnations, etc.
Be careful now to keep the Doors and Windows of your
Conservatories well matted, and guarded from the piercing Air: for
your Oranges, etc., are now put to the test: Temper the cold with a
few Char-coal govern’d as directed in November, etc.
Set Bay-berries, etc., dropping ripe.
Look to your Fountain-pipes, and cover them with fresh and warm
litter out of the stable, a good thickness lest the frosts crack them;
remember it in time, and the Advice will save far both trouble and
charge.

Flowers in Prime, or Yet Lasting.

Anemonies some, Persian, and Common Winter Cyclamen,


Antirrhinum, Black Hellebor, Laurus tinus, single Prim-roses, Stock-
gilly-flo., Iris Clusii, Snowflowers, or drops, Yucca, etc.
PART IV

GARDEN MOODS
I

TOWN GARDENS

Few people will deny the peace of mind a sheet of green grass can
give, but few people, one imagines, trouble to think how they are
preserved in large Towns and Cities. If it were not for Societies many
little open spaces would years ago have been covered with streets of
houses, many fair trees have fallen, none have been planted, and
those growing have been neglected and allowed to die. Of the many
Societies whose work has been to preserve for the Public pleasure
grounds, good trees, parks, and flower gardens, not one deserves
such praise as the Metropolitan Public Gardens Association, whose
great work has been carried on since 1882.
When one considers that in Hampstead over six hundred acres have
been preserved by energetic Committees from the hands of builders
it is easy to see how great is the debt of London to those who
voluntarily work for this and other Open Space Societies.
It is not, however, by these large tracts of open country that the
towns and cities alone benefit. Seats, fountains, flower beds, and
pavements have been placed in old church-yards and disused burial-
grounds opened for the benefit of the public. One has only to look at
the map of the Metropolitan Public Gardens Association to see how
wonderful their work has been and still is.
To dwellers in Towns the sight of flowers in the streets is like a
breath of the country. The long line of flower-sellers in the High
Street, Kensington, one group of women in Piccadilly Circus, in
Oxford Circus, in other spots where the place of their flower baskets
brightens all the neighbourhood, are doctors, though they do not
know it, of high degree. They bring the message of the changing
year. They are a perpetual flower calendar, people to whom a
reverence is due. One looks in Piccadilly Circus for the first
Snowdrops, the little knots of their delicate white faces peering over
the edge of the flower baskets. From the tops of omnibuses the first
Violets are seen. Anemones have their turn, and Mimosa, and
Cowslips, and Roses soon glow in the midst of the traffic, and
elegant Carnations in their silver grass, and great piles of Asters. So
we may read the year. All through the grey and desolate Winter
these flower women hold their own, through cold and rain, and pale
Winter sun they keep the day alive with the glowing colours of
flowers. I often wonder, as I see them sit there so patiently, if they
know the joy they give the passer-by, or if they are more like the
rocks on whom flowers grow by nature. They are a curious race,
these flower-women, untidy, with a screw of hair twisted up under a
battered hat of black straw, with faded shawls wrapped round them,
and the weapons of their craft arranged about them—jam jars of
water, wire, bass, rows of little sticks on the end of which
buttonholes are stuck. And they have wonderful contrivances for
keeping their money, ancient purses rusty like many of themselves,
in which greasy pennies and wet sixpences wallow in litters of dirty
paper. I would not vouch for the truth of all they say, for it would
appear from their words that every flower in their baskets is but just
picked, or only that second from the market. And they regard such
evidence as withered and wet flower stalks with half-humorous
scorn. For all they may not be well favoured, and a pretty flower-
woman is as rare as a dead donkey, still, for me, they have a certain
dingy dignity, or rather a natural picturesque quality as of lichen on
the pavements.
AZALEAS IN BLOOM, ROTTEN ROW.

These people are the town’s gardens of odd corners, while another
tribe of them are perambulating gardens bringing sudden colour into
the soberest of streets. There are those who carry enormous baskets
on their heads, and cry in some incomprehensible tongue words
intended to convey a message such as “All fresh.” To see a gorgeous
glowing mass of Daffodils sway down the street borne triumphantly
aloft like the litter of some Princess is one of those sights to repay
many grey days. Then the brothers to this tribe are those who carry
from street to street Ferns and Lilies on carts, drawn often by a
patient ass. I own feeling a distrust for these men, they do not
dispense their goods with much love. They are not eloquent, as are
many flower women in praise of the beauties of the India plant, or
the Shuttle-cock Ferns. I feel that they are interlopers in the
business, and have failed at the hardware trade, or have no capacity
for the selling of rush baskets, or the grinding of scissors. At the
heels of all those who sell flowers in the streets are the out-cast
members of the tribe, men with brutal faces who follow lonely
women in unfrequented streets trying to thrust dead plants upon
them, and cursing if they are not bought. And there are the aged
crones who sit by the railings of little squares and hold out a tray of
boot laces, matches, a few very suspicious-looking Apples, and, in
the corner, a bunch of dead flowers—a kind of æsthetic appeal.
Your true flower-lover will search as carefully among their baskets
for the object of his desire as will the collector the musty curiosity
shops for prizes for his collection. There comes the time when the
first Snowdrops, their stalks tied with wool, appear here and there
and may be brought home as rare prizes. A word here of flower
vases. Clear glass is the only form of vessel for any kind of flower. I
feel certain of that. No crock, no form of pottery gives out greater
the real value to your cut flowers. The stalks are part of the beauty
of the flower, the submerged leaf as lovely as the leaf above. And,
above and beyond all things, glass shows at once if your water is
pure, and if your vase is full. Nowadays beautiful striped glass vases
are made and sold so cheaply that there is no excuse for the old,
and often ugly, pot vases so many people use. I own to a certain
liking to seeing roses in old China bowls, but have a lurking
suspicion that I am Philistine in this.
There is, of course, a distinction between Town Gardens and
gardens in Towns. The one being the open free spaces dedicated to
the pleasure of Duke and tramp alike: the other the hidden and
hallowed spots where the town dweller fights soot, grime, smoke,
and lack of sun, and fights them in many cases wonderfully well.
One finds, though, that many people fancy that only Ivy, cats, and
dustbins will flourish in the heart of a smoky City. This is not the
case. Broom, Lilac, Trumpet Flower, Traveller’s Joy, many kinds of
Honeysuckle, Passion Flower, Tulip Tree, many kinds of Cherry and
Plum Trees bearing beautiful blossoms, Barberry, and Almond Trees
—all these will grow well and strongly even in the worst parts of
London. Five kinds of Honeysuckle will flourish; they are:
Lonicera Lepebouri
„ Flexuosam
„ Brachypoda
aurea
„ Serotinum
„ Belgicum
Besides these, pink and white Brambles, Meadowsweet, Weigela,
and Rhododendrons all grow fairly easily.
One of the first sights the traveller notices on approaching any large
town is the numerous and gay back gardens of the little houses. The
contents of these gardens are a true index to the inhabitants of the
houses. Where one garden boasts little but old packing-cases, drying
linen, a few stalks of hollyhocks, and one or two giant sunflowers,
the very next will show borders full of all varieties of flowers in
season, an eloquent picture of what may be done with a little
trouble. The consolation and pleasure these little town gardens give
is out of all proportion to their size. The man who can come home to
a villa, however badly built and hideous, and it often appears that
some competition in ugliness has won suburban prizes, can find a
delight all good gardeners know in working his plot of land.
One thing we can see at a glance, that the good influence of one
well-kept garden in a row will very soon have its effect. There is one
street I know within the bounds of London, a street of new houses
with little gardens in front of them running down to the pavement. I
watched this street with interest from its very beginning. At first it
was a thing of beauty, the men at work on the buildings, the
scaffolding against the sky, the horses and carts waiting with loads
of brick, the gradual growth of the houses from foundation to roof.
Even the ugliest building is beautiful in the course of construction,
the poles and ladders hiding the coarse design. Then there came a
day when the street was finished. It is not an entire street, but
about half, being a row of twenty or so houses built in flats, three
flats in each house. When the men left and the houses stood naked,
after the plan of the builder, looking pitiful and commonplace, the
new red brick was raw, the little balconies very white and staring,
the windows like blind eyes. Every ground-floor flat had the
disadvantage of less light and air than the others, but it was the
possessor of about nine feet of land between the door and the
pavement. For a long time I waited to see what would become of
this tenant-less row of houses. I gained a kind of affection for them,
and walked past the white signboards once or twice a week reading
always “To Let” written on the windows, painted on the notice
board, pasted on papers across the doors. The melancholy aspect of
these houses appealed to me; they had a look of dumb anxiety as if
they longed to hear the sound of voices in their empty rooms. At last
I saw one day three huge furniture vans drawn up in front of the
houses, and during the next two weeks more vans arrived and there
was a sound of hammering in the street, and a smell of unpacking.
Men came there with boxes and parcels, and tradesmen began to
drive up in carts and motor-cars. I felt that those houses still
standing empty had a jealous look in their windows, like little girls
who had been left to sit out at a dance. The notice boards were all
shifted to their front gardens, their bell wires still hung unconnected
from holes by the front door.
The thing I was really waiting to see happened at Number Two. The
builder, after finishing the houses had, I suppose, come to the
conclusion that a little help from Nature would do no harm. Some
good fairy prompted him to plant Almond and May Trees alternately
in the front gardens. To each house an Almond and a May. I had
waited eagerly, determining by some fantastic twist that the spirit of
the new houses would first make her appearance in one of these
trees. So far the street had possessed no character except that
vague rawness that all new places wear. The great event occurred at
Number Two. Very delicately an Almond tree put out the first
blossom. The life of the street began. I did not wonder about the
favoured owners of the ground floor of Number Two. I knew.
Not long after the Almond tree had bloomed a cart drew up before
Number Two, and three men began to wheel barrow loads of earth
into the front garden. They were directed by a gentleman of some
age, but of cheerful countenance. He smiled as each load of earth
was neatly placed. He looked at the earth as if he already saw it
covered with flowers. In his mind’s eye he was arranging a surprise
for the street.
The next event of notice in the street was the appearance of
Number Two garden, a blaze of flowers set in a desert of red brick. A
balcony of Number Sixteen, far down the road, entered into friendly
competition. Numbers Five and Nine worked like slaves. Three
followed suit with carpet-bedding on a tiny scale. A Laburnam and a
Lilac sprang like magic from the soil of Number Ten. Then, one day,
the whole of Number One burst into flower from top to toe. The
tenant of each floor having apparently been secretly at work to
surprise the rest. Two, who had started, and was indeed the father
of the street, put forth more strenuous efforts.
To-day I am certain of a pleasant walk, and can come out of a
wilderness of bricks and mortar to my charming oasis flowering in
the land. I wonder if the people who live in those flats and who
compete with each other in a friendly rivalry of blossom realise what
they are doing for the hundreds who pass by in the day and are
cheered.
The Association I have named before, the Metropolitan Public
Gardens Association, give in their statement for 1907 a list of their
window garden competitions for that year. One sees that many of
the poorer parts of London have taken the idea, and this note I
quote from South Hackney shows the result: “Twelve entries. Eight
prizes of the total amount of One Pound, Ten Shillings. Remarks:
Clean, fresh-looking, more creepers than last year; example set is
improving character of roads, as others, not competitors, have
started gardens.”
Any one who knows the dreary and desolate appearance of town
streets, especially in those parts where life is lived at the hardest,
and surroundings are of the most sordid, will encourage a work
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookmass.com

You might also like