### Quick Setup: Onboard and Install Service
Source: https://github.com/fechin/reference/blob/main/source/_posts/openclaw.md
Command to onboard and install the OpenClaw service.
```bash
openclaw onboard --install-daemon
```
--------------------------------
### Quick Setup: Install OpenClaw
Source: https://github.com/fechin/reference/blob/main/source/_posts/openclaw.md
Instructions for installing OpenClaw using curl or npm.
```bash
# macOS / Linux / WSL2
curl -fsSL https://openclaw.ai/install.sh | bash
# or via npm
npm install -g openclaw@latest
```
--------------------------------
### Worktree Configuration Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/cursor-cli.md
Example JSON configuration for worktree setup scripts.
```json
{
"setup": ["npm install", "cp .env.example .env"]
}
```
--------------------------------
### Getting started
Source: https://github.com/fechin/reference/blob/main/source/_posts/regex.md
Import the regular expressions module in Python.
```python
import re
```
--------------------------------
### CDN Setup
Source: https://github.com/fechin/reference/blob/main/source/_posts/vue.md
Quick start setup using a CDN link for Vue.js.
```html
{{ message }}
```
--------------------------------
### Basic Usage
Source: https://github.com/fechin/reference/blob/main/source/_posts/opencode.md
Examples of starting the TUI, running non-interactively, continuing sessions, and piping input.
```bash
# Start TUI for current directory
$ opencode
# Start TUI for a specific project
$ opencode /path/to/project
# Run non-interactively (headless)
$ opencode run "Explain how closures work in JS"
# Continue last session
$ opencode run -c "Fix the failing tests"
# Pipe input into opencode
$ cat error.log | opencode run "Explain this error"
```
--------------------------------
### Start a new Django Project
Source: https://github.com/fechin/reference/blob/main/source/_posts/django.md
Commands to create a new Django project, including setting up a virtual environment, installing Django, creating the project structure, and starting a new app.
```bash
# Create et access project folder
~$ mkdir project_name
~$ cd project_name
# Create Python virtual env
~$ python3 -m venv venv
# Activate virtual env
~$ source venv/bin/activate
# If you want to deactivate virtual env
~$ deactivate
# Install django (~= same as 4.2.*)
~$ pip install django~=4.2.0
# New django project (from project_name folder)
~$ django-admin startproject config
# Create app (from project_name folder)
~$ python manage.py startapp app_name
```
--------------------------------
### Server & Remote Commands
Source: https://github.com/fechin/reference/blob/main/source/_posts/opencode.md
Examples for starting the OpenCode headless API server, web UI server, enabling mDNS discovery, and setting up basic authentication.
```bash
# Headless API server
$ opencode serve --port 4096
# Web UI server
$ opencode web --port 4096 --hostname 0.0.0.0
# Enable mDNS discovery
$ opencode serve --mdns
# Enable basic auth
$ OPENCODE_SERVER_PASSWORD=secret opencode serve
```
--------------------------------
### Install Script
Source: https://github.com/fechin/reference/blob/main/source/_posts/opencode.md
Recommended installation method using a script.
```bash
$ curl -fsSL https://opencode.ai/install | bash
```
--------------------------------
### Start a Dev Server
Source: https://github.com/fechin/reference/blob/main/source/_posts/quickref.md
Start the development server.
```shell
$ npm run dev
```
--------------------------------
### Quick Start
Source: https://github.com/fechin/reference/blob/main/source/_posts/gemini-cli.md
Install Gemini CLI globally, via Homebrew, or run without installing. Launch interactive or non-interactive sessions, pipe content, resume sessions.
```bash
# Install globally
$ npm install -g @google/gemini-cli
# Or via Homebrew
$ brew install gemini-cli
# Or run without installing
$ npx @google/gemini-cli
# Launch interactive session
$ gemini
# Non-interactive (headless)
$ gemini -p "summarize README.md"
# Pipe content to Gemini
$ cat logs.txt | gemini -p "find errors"
# Run prompt and continue interactively
$ gemini -i "explain this project"
# Resume most recent session
$ gemini -r latest
# Resume with new prompt
$ gemini -r latest "check for type errors"
```
--------------------------------
### Install via Homebrew
Source: https://github.com/fechin/reference/blob/main/source/_posts/opencode.md
Installation for macOS/Linux using Homebrew.
```bash
$ brew install anomalyco/tap/opencode
```
--------------------------------
### Install Homebrew
Source: https://github.com/fechin/reference/blob/main/source/_posts/homebrew.md
Installs Homebrew by downloading and executing the official installation script.
```bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
--------------------------------
### Install via Node.js
Source: https://github.com/fechin/reference/blob/main/source/_posts/opencode.md
Installation using npm.
```bash
$ npm install -g opencode-ai
```
--------------------------------
### Option examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/grep.md
Use regex _(lines starting with 'al')_
```shell
grep -e '^al' filename
```
--------------------------------
### Start and enable PostgreSQL
Source: https://github.com/fechin/reference/blob/main/source/_posts/django.md
Starts the PostgreSQL service and enables it to start automatically at boot.
```bash
sudo systemctl start postgresql
sudo systemctl enable postgresql
```
--------------------------------
### Wildcard Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/find.md
Examples of using wildcards with the -name option to find files.
```shell
$ find . -name "*.txt"
```
```shell
$ find . -name "2020*.csv"
```
```shell
$ find . -name "json_*"
```
--------------------------------
### Testing Setup
Source: https://github.com/fechin/reference/blob/main/source/_posts/vue.md
Commands to install Vitest and Vue Test Utils.
```bash
npm install vitest @vue/test-utils
```
--------------------------------
### Quick Start Commands
Source: https://github.com/fechin/reference/blob/main/source/_posts/grok-cli.md
Commands for running Grok CLI immediately, installing it globally, starting an interactive session, sending initial messages, using headless mode, specifying a model, setting a working directory, and setting the maximum number of tool rounds.
```bash
# Run immediately (no install)
$ GROK_API_KEY=your_key npx -y grok-cli-hurry-mode@latest
# Install globally
$ npm install -g grok-cli-hurry-mode@latest
# Start interactive session
$ grok
# Send initial message
$ grok "Help me understand this project"
# Headless / non-interactive mode
$ grok -p "explain the auth module"
# Use a specific model
$ grok -m grok-4-latest "refactor this file"
# Set working directory
$ grok -d /path/to/project
# Set max tool rounds
$ grok --max-tool-rounds 100 "rewrite the API"
```
--------------------------------
### grid-row-start & grid-row-end Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/css3.md
Example of setting grid-row-start and grid-row-end properties.
```css
grid-row-start: 2;
grid-row-end: span 2;
```
--------------------------------
### Alternative Install from Source
Source: https://github.com/fechin/reference/blob/main/source/_posts/openclaw.md
Instructions for installing OpenClaw from its source code.
```bash
# From source
git clone https://github.com/openclaw/openclaw.git
cd openclaw && pnpm install && pnpm build
pnpm link --global
```
--------------------------------
### Install via Chocolatey/Scoop
Source: https://github.com/fechin/reference/blob/main/source/_posts/opencode.md
Installation for Windows using Chocolatey or Scoop.
```bash
choco install opencode # Chocolatey
scoop install opencode # Scoop
```
--------------------------------
### Router GET Method Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/express.md
An example of handling GET requests for a specific route within a router.
```javascript
//depends on where the router "use()"
router.get('/events', (req, res, next) => {
//..
});
```
--------------------------------
### Initial Project Setup Commands
Source: https://github.com/fechin/reference/blob/main/source/_posts/django.md
Commands to migrate the database, create a superuser, and collect static files.
```bash
(myprojectenv)$ ~/myprojectdir/manage.py makemigrations
(myprojectenv)$ ~/myprojectdir/manage.py migrate
```
```bash
(myprojectenv)$ ~/myprojectdir/manage.py createsuperuser
```
```bash
(myprojectenv)$ ~/myprojectdir/manage.py collectstatic
```
--------------------------------
### Installation
Source: https://github.com/fechin/reference/blob/main/source/_posts/symfony.md
Installs the Symfony CLI.
```bash
curl -sS https://get.symfony.com/cli/installer | bash
```
--------------------------------
### Development Setup
Source: https://github.com/fechin/reference/blob/main/README.md
Steps to set up the development environment for the Reference project.
```bash
git clone https://github.com/Fechin/reference.git
npm install
npm run dev
```
--------------------------------
### Start server
Source: https://github.com/fechin/reference/blob/main/source/_posts/django.md
Command to start the Django development server.
```bash
~$ python manage.py runserver => ex. http://127.0.0.1:8000
```
--------------------------------
### Hello World
Source: https://github.com/fechin/reference/blob/main/source/_posts/cursor-cli.md
Examples of interactive agent sessions and one-shot prompts.
```bash
# Interactive agent session
$ agent
# One-shot prompt (print mode)
$ agent -p "List all TODO comments in this repo"
# Ask a question (read-only)
$ agent --mode=ask "How does auth work here?"
# Plan only (no edits)
$ agent --plan "Refactor the payment module"
```
--------------------------------
### REGEXP_INSTR Function Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/regex.md
Examples showcasing the REGEXP_INSTR function to find the starting position of a substring matching a regular expression.
```sql
mysql> SELECT regexp_instr('aa aaa aaaa', 'a{3}');
2
mysql> SELECT regexp_instr('abba', 'b{2}', 2);
2
mysql> SELECT regexp_instr('abbabba', 'b{2}', 1, 2);
5
mysql> SELECT regexp_instr('abbabba', 'b{2}', 1, 3, 1);
7
```
--------------------------------
### Curl GET/HEAD Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/curl.md
Examples of using Curl for GET and HEAD requests, including verbose output and proxy settings.
```bash
curl -I https://cheatsheets.zip # `curl` sends a request
curl -v -I https://cheatsheets.zip # `curl` request with details
curl -X GET https://cheatsheets.zip # use explicit http method for `curl`
curl --noproxy 127.0.0.1 http://www.stackoverflow.com # `curl` without http proxy
curl --connect-timeout 10 -I -k https://cheatsheets.zip # `curl` has no timeout by default
curl --verbose --header "Host: www.mytest.com:8182" cheatsheets.zip # `curl` get extra header
curl -k -v https://www.google.com # `curl` get response with headers
```
--------------------------------
### Go Client and Server Setup
Source: https://github.com/fechin/reference/blob/main/source/_posts/socket-io.md
Sets up a Socket.IO client connection and a basic Go server.
```go
import "github.com/googollee/go-socket.io-client"
socket, err := gosocketio.Dial(
gosocketio.GetUrl("localhost", 3000, false),
transport.GetDefaultWebsocketTransport(),
)
```
```go
import (
"github.com/googollee/go-socket.io"
"net/http"
)
server, _ := socketio.NewServer(nil)
server.OnConnect("/", func(s socketio.Conn) error {
fmt.Println("Client connected:", s.ID())
return nil
})
http.Handle("/socket.io/", server)
go http.ListenAndServe(":3000", nil)
```
--------------------------------
### HVALS Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get all the values in a hash
```shell script
redis> HSET myhash field1 "Hello"
(integer) 1
redis> HSET myhash field2 "World"
(integer) 1
redis> HVALS myhash
1) "Hello"
2) "World"
```
--------------------------------
### Go Installation
Source: https://github.com/fechin/reference/blob/main/source/_posts/socket-io.md
Installs the Socket.IO client library for Go.
```bash
go get github.com/googollee/go-socket.io
```
--------------------------------
### HKEYS Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get all the fields in a hash
```shell script
redis> HSET myhash field1 "Hello"
(integer) 1
redis> HSET myhash field2 "World"
(integer) 1
redis> HKEYS myhash
1) "field1"
2) "field2"
```
--------------------------------
### LLEN Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get the length of a list.
```shell script
redis> LPUSH mylist "World"
(integer) 1
redis> LPUSH mylist "Hello"
(integer) 2
redis> LLEN mylist
(integer) 2
```
--------------------------------
### opencode.json configuration example
Source: https://github.com/fechin/reference/blob/main/source/_posts/opencode.md
Example of the main opencode.json configuration file.
```json
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-4-5",
"small_model": "anthropic/claude-haiku-4-5",
"default_agent": "build",
"autoupdate": true,
"snapshot": true,
"share": "manual",
"instructions": ["AGENTS.md", "docs/*.md"],
"provider": {
"anthropic": {
"options": { "timeout": 600000 }
}
},
"permission": {
"edit": "ask",
"bash": "ask"
},
"compaction": {
"auto": true,
"prune": true,
"reserved": 10000
},
"server": {
"port": 4096,
"mdns": true
},
"tools": {
"write": false,
"bash": false
},
"disabled_providers": ["openai"],
"enabled_providers": ["anthropic"]
}
```
--------------------------------
### SMEMBERS Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get all the members in a set.
```shell script
redis> SADD myset "Hello"
(integer) 1
redis> SADD myset "World"
(integer) 1
redis> SMEMBERS myset
1)
"Hello"
2)
"World"
```
--------------------------------
### GET Command Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Retrieves the value of a key.
```shell
redis> GET nonexisting
(nil)
redis> SET mykey "Hello"
"OK"
redis> GET mykey
"Hello"
```
--------------------------------
### Dofile and Loadfile Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/lua.md
Shows how to execute Lua files immediately with dofile and load them for later execution with loadfile.
```lua
-- Using dofile
dofile("my_file.lua") -- Executes my_file.lua immediately
-- Using loadfile
local my_func = loadfile("my_file.lua")
if my_func then
-- my_file.lua is valid, now execute it
my_func()
else
print("Error loading file.")
end
```
--------------------------------
### Config sample
Source: https://github.com/fechin/reference/blob/main/source/_posts/ssh.md
Launch by alias
```shell
$ ssh server1
```
--------------------------------
### Programming - Create regex to match all words that start with "ban"
Source: https://github.com/fechin/reference/blob/main/source/_posts/chatgpt.md
Example prompt for creating a regex to match words starting with 'ban'.
```text
Create regex to match all words that start with "ban"
```
--------------------------------
### Starting a Server
Source: https://github.com/fechin/reference/blob/main/source/_posts/express.md
Demonstrates how to start an Express.js server on port 3000.
```javascript
var express = require('express');
var app = express();
app.listen(3000);
```
--------------------------------
### Start an app
Source: https://github.com/fechin/reference/blob/main/source/_posts/pm2.md
Start, daemonize, and monitor an application using PM2.
```shell
$ pm2 start app.js
```
```shell
$ pm2 start bashscript.sh
```
```shell
$ pm2 start python-app.py --watch
```
```shell
$ pm2 start binary-file -- --port 1520
```
--------------------------------
### COMMAND Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get array of Redis command details
```shell
redis> COMMAND
1) 1) "georadius_ro"
2) (integer) -6
3) 1) "readonly"
2) "movablekeys"
4) (integer) 1
5) (integer) 1
6) (integer) 1
7) 1) "@read"
2) "@geo"
3) "@slow"
2) 1) "zpopmin"
2) (integer) -2
3) 1) "write"
2) "fast"
........
```
--------------------------------
### HLEN Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get the number of fields in a hash
```shell script
redis> HSET myhash field1 "Hello"
(integer) 1
redis> HSET myhash field2 "World"
(integer) 1
redis> HLEN myhash
(integer) 2
```
--------------------------------
### Rust Client Setup
Source: https://github.com/fechin/reference/blob/main/source/_posts/socket-io.md
Sets up a Socket.IO client connection for Rust.
```rust
use socketio_client::ClientBuilder;
async fn run() -> Result<(), Box> {
let socket = ClientBuilder::new("http://localhost:3000")
.transport("websocket")
.connect()
.await?;
Ok(())
}
```
--------------------------------
### HGETALL Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get all the fields and values in a hash
```shell script
redis> HSET myhash field1 "Hello"
(integer) 1
redis> HSET myhash field2 "World"
(integer) 1
redis> HGETALL myhash
1) "field1"
2) "Hello"
3) "field2"
4) "World"
```
--------------------------------
### HGET Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get the value of a hash field
```shell script
redis> HSET myhash field1 "foo"
(integer) 1
redis> HGET myhash field1
"foo"
redis> HGET myhash field2
(nil)
```
--------------------------------
### hello.go
Source: https://github.com/fechin/reference/blob/main/source/_posts/go.md
A simple "Hello, world!" program in Go.
```go
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
```
--------------------------------
### Symbol Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/ruby.md
A basic example of creating a Hash with Symbol keys.
```ruby
week_days = {sunday: 11, monday: 222}
```
--------------------------------
### LINDEX Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get an element from a list by its index.
```shell script
redis> LPUSH mylist "World"
(integer) 1
redis> LPUSH mylist "Hello"
(integer) 2
redis> LINDEX mylist 0
"Hello"
redis> LINDEX mylist -1
"World"
redis> LINDEX mylist 3
(nil)
```
--------------------------------
### ZCARD Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get the number of members in a sorted set
```shell script
redis> ZADD myzset 1 "one"
(integer) 1
redis> ZADD myzset 2 "two"
(integer) 1
redis> ZCARD myzset
(integer) 2
```
--------------------------------
### Plan Mode Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/cursor-cli.md
Examples of using the agent in plan mode for read-only analysis.
```bash
$ agent --plan
$ agent --mode=plan "Refactor auth"
```
--------------------------------
### HSTRLEN Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get the length of the value of a hash field
```shell script
redis> HMSET myhash f1 HelloWorld f2 99 f3 -256
"OK"
redis> HSTRLEN myhash f1
(integer) 10
redis> HSTRLEN myhash f2
(integer) 2
redis> HSTRLEN myhash f3
(integer) 4
```
--------------------------------
### init function execution order
Source: https://github.com/fechin/reference/blob/main/source/_posts/go.md
Demonstrates the execution order of var, const, and init functions.
```go
var num = setNumber()
func setNumber() int {
return 42
}
func init() {
num = 0
}
func main() {
fmt.Println(num) // => 0
}
```
--------------------------------
### HMGET Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get the values of all the given hash fields
```shell script
redis> HSET myhash field1 "Hello"
(integer) 1
redis> HSET myhash field2 "World"
(integer) 1
redis> HMGET myhash field1 field2 nofield
1) "Hello"
2) "World"
3) (nil)
```
--------------------------------
### Install via Docker
Source: https://github.com/fechin/reference/blob/main/source/_posts/opencode.md
Running OpenCode using Docker.
```bash
$ docker run -it --rm ghcr.io/anomalyco/opencode
```
--------------------------------
### Overlap and Spacing Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/latex.md
Examples demonstrating overlap and spacing control in KaTeX.
```KaTeX
{=}\mathllap{/\,}
```
```KaTeX
\left(x^{\smash{2}}\right)
```
```KaTeX
\mathrlap{\,/}{=}
```
```KaTeX
\sqrt{\smash[b]{y}}
```
```KaTeX
\sum_{\mathclap{1\le i\le j\le n}} x_{ij}
```
--------------------------------
### SET and GET Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Sets a key-value pair and retrieves its value.
```shell
redis> SET mykey "Hello world"
OK
redis> GET mykey
"Hello world"
```
--------------------------------
### Awk Program Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/awk.md
An example Awk program that prints a start message, then prints records that do not contain 'login' or 'shutdown', and finally prints an end message.
```awk
awk '
BEGIN { print "\n>>>Start" }
!/(login|shutdown)/ { print NR, $0 }
END { print "<< {
console.log('Client connected:', socket.id);
});
```
--------------------------------
### Map Initialization and Operations
Source: https://github.com/fechin/reference/blob/main/source/_posts/go.md
Demonstrates creating, accessing, updating, deleting, and checking for keys in a map.
```go
m := make(map[string]int)
m["k1"] = 7
m["k2"] = 13
fmt.Println(m) // => map[k1:7 k2:13]
v1 := m["k1"]
fmt.Println(v1) // => 7
fmt.Println(len(m)) // => 2
delete(m, "k2")
fmt.Println(m) // => map[k1:7]
_, prs := m["k2"]
fmt.Println(prs) // => false
n := map[string]int{"foo": 1, "bar": 2}
fmt.Println(n) // => map[bar:2 foo:1]
```
--------------------------------
### Single line comments
Source: https://github.com/fechin/reference/blob/main/source/_posts/python.md
Example of a single-line comment in Python, starting with a hash symbol.
```python
# This is a single line comments.
```
--------------------------------
### Docker Support
Source: https://github.com/fechin/reference/blob/main/source/_posts/alpine-linux.md
Commands for installing, starting, and enabling Docker service.
```bash
# Install Docker
apk add docker
# Start Docker service
rc-service docker start
# Enable Docker at boot
rc-update add docker default
```
--------------------------------
### Ask Mode Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/cursor-cli.md
Examples of using the agent in ask mode for question and answer interactions.
```bash
$ agent --mode=ask
$ agent --mode=ask "How does caching work?"
```
--------------------------------
### TTL Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Demonstrates getting the time to live for a key using TTL.
```shell
redis> SET mykey "Hello"
"OK"
redis> EXPIRE mykey 10
(integer) 1
redis> TTL mykey
(integer) 10
```
--------------------------------
### Installing with Homebrew
Source: https://github.com/fechin/reference/blob/main/source/_posts/hook.md
Commands to install the Hook interpreter using Homebrew.
```text
brew tap hook-lang/hook
brew install hook
hook --help
```
--------------------------------
### ZMSCORE Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get the score associated with the given members in a sorted set.
```shell
redis> ZADD myzset 1 "one"
(integer) 1
redis> ZADD myzset 2 "two"
(integer) 1
redis> ZMSCORE myzset "one" "two" "nofield"
1) "1"
2) "2"
3) (nil)
```
--------------------------------
### SRANDMEMBER Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Get one or multiple random members from a set.
```shell script
redis> SADD myset one two three
(integer) 3
redis> SRANDMEMBER myset
"three"
redis> SRANDMEMBER myset 2
1)
"two"
2)
"three"
redis> SRANDMEMBER myset -5
1)
"one"
2)
"two"
3)
"three"
4)
"three"
5)
"one"
```
--------------------------------
### Java Client and Server Setup
Source: https://github.com/fechin/reference/blob/main/source/_posts/socket-io.md
Sets up a Socket.IO client connection and a basic Java server.
```java
IO.Options opts = new IO.Options();
Socket socket = IO.socket("http://localhost:3000", opts);
socket.connect();
```
```java
import io.socket.engineio.server.EngineIoServer;
import io.socket.server.SocketIoServer;
EngineIoServer engineIo = new EngineIoServer();
SocketIoServer io = new SocketIoServer(engineIo);
io.listen(3000);
io.on("connection", args -> {
var client = args[0];
System.out.println("Client connected: " + client.id());
});
```
--------------------------------
### Struct Literals
Source: https://github.com/fechin/reference/blob/main/source/_posts/go.md
Examples of different ways to initialize struct literals.
```go
v := Vertex{X: 1, Y: 2}
// Field names can be omitted
v := Vertex{1, 2}
// Y is implicit
v := Vertex{X: 1}
```
--------------------------------
### Namespaces - Server (All Languages)
Source: https://github.com/fechin/reference/blob/main/source/_posts/socket-io.md
Example of handling connections to a specific namespace on the server.
```javascript
io.of('/admin').on('connection', (socket) => {
console.log('Admin connected:', socket.id);
});
```
```go
server.Of("/admin").OnConnect(func(s socketio.Conn) {
fmt.Println("Admin connected:", s.ID())
})
```
--------------------------------
### PTTL Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Shows how to get the time to live for a key in milliseconds using PTTL.
```shell
redis> SET mykey "Hello"
"OK"
redis> EXPIRE mykey 1
(integer) 1
redis> PTTL mykey
(integer) 1000
```
--------------------------------
### Worktree Creation Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/cursor-cli.md
Examples of creating worktrees, including auto-named, named, and from specific branches.
```bash
# Auto-named worktree
$ agent -w
# Named worktree
$ agent -w feature-auth
# Worktree from specific branch
$ agent -w fix --worktree-base main
# Skip setup scripts
$ agent -w feature --skip-worktree-setup
```
--------------------------------
### RPOP Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Demonstrates removing and getting the last element from a list using RPOP.
```shell
redis> RPUSH mylist "one"
(integer) 1
redis> RPUSH mylist "two"
(integer) 2
redis> RPUSH mylist "three"
(integer) 3
redis> RPOP mylist
"three"
redis> LRANGE mylist 0 -1
1) "one"
2) "two"
```
--------------------------------
### Setup and Loop
Source: https://github.com/fechin/reference/blob/main/source/_posts/arduino-programming.md
The basic structure of an Arduino sketch includes the setup() function, which runs once, and the loop() function, which runs repeatedly.
```cpp
void setup() {
// Code here runs once
}
void loop() {
// Code here runs repeatedly
}
```
--------------------------------
### LPOP Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Remove and get the first element in a list, or block until one is available.
```shell script
LPOP key [count]
```
--------------------------------
### hello.c
Source: https://github.com/fechin/reference/blob/main/source/_posts/c.md
Basic Hello World program in C.
```c
#include
int main(void) {
printf("Hello World!\n");
return 0;
}
```
--------------------------------
### BRPOP Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Remove and get the last element in a list, or block until one is available.
```shell script
redis> DEL list1 list2
(integer) 0
redis> RPUSH list1 a b c
(integer) 3
redis> BRPOP list1 list2 0
1)
"list1"
2)
"c"
```
--------------------------------
### fmt.Printf
Source: https://github.com/fechin/reference/blob/main/source/_posts/go.md
Demonstrates various formatting verbs with fmt.Printf and fmt.Sprintf.
```go
package main
import (
"fmt"
"os"
)
type point struct {
x, y int
}
func main() {
p := point{1, 2}
fmt.Printf("%v\n", p) // => {1 2}
fmt.Printf("%+v\n", p) // => {x:1 y:2}
fmt.Printf("%#v\n", p) // => main.point{x:1, y:2}
fmt.Printf("%T\n", p) // => main.point
fmt.Printf("%t\n", true) // => TRUE
fmt.Printf("%d\n", 123) // => 123
fmt.Printf("%b\n", 14) // => 1110
fmt.Printf("%c\n", 33) // => !
fmt.Printf("%x\n", 456) // => 1c8
fmt.Printf("%f\n", 78.9) // => 78.9
fmt.Printf("%e\n", 123400000.0) // => 1.23E+08
fmt.Printf("%E\n", 123400000.0) // => 1.23E+08
fmt.Printf("%s\n", "\"string\"") // => "string"
fmt.Printf("%q\n", "\"string\"") // => "\"string\""
fmt.Printf("%x\n", "hex this") // => 6.86578E+15
fmt.Printf("%p\n", &p) // => 0xc00002c040
fmt.Printf("|%6d|%6d|\n", 12, 345) // => | 12| 345|
fmt.Printf("|%6.2f|%6.2f|\n", 1.2, 3.45) // => | 1.20| 3.45|
fmt.Printf("|%-6.2f|%-6.2f|\n", 1.2, 3.45) // => |1.20 |3.45 |
fmt.Printf("|%6s|%6s|\n", "foo", "b") // => | foo| b|
fmt.Printf("|%-6s|%-6s|\n", "foo", "b") // => |foo |b |
s := fmt.Sprintf("a %s", "string")
fmt.Println(s)
fmt.Fprintf(os.Stderr, "an %s\n", "error")
}
```
--------------------------------
### BLPOP Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Remove and get the first element in a list, or block until one is available.
```shell script
redis> DEL list1 list2
(integer) 0
redis> RPUSH list1 a b c
(integer) 3
redis> BLPOP list1 list2 0
1)
"list1"
2)
"a"
```
--------------------------------
### Current date and time
Source: https://github.com/fechin/reference/blob/main/source/_posts/php.md
Example of getting the current date and time using the DateTime object in PHP.
```php
// DateTime in PHP handles both date and time
format('Y-m-d H:i:s.u');
// Output ex: 2024-04-27 14:35:22.123456
```
--------------------------------
### Gateway: Startup Options
Source: https://github.com/fechin/reference/blob/main/source/_posts/openclaw.md
Various options for running the OpenClaw gateway.
```bash
openclaw gateway run # foreground
openclaw gateway run --port 19001
openclaw gateway run --force # kill existing listener
openclaw gateway run --verbose # verbose to stdout
openclaw gateway run --bind lan # bind to LAN
openclaw gateway run --auth token --token
```
--------------------------------
### Registry Management
Source: https://github.com/fechin/reference/blob/main/source/_posts/powershell.md
Examples for managing registry keys and values, including getting, setting, creating, and removing them.
```powershell
# Retrieve registry key values
Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" | Select DisplayName, DisplayVersion
# Set registry key values
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" -Name "SettingName" -Value "NewValue"
# Create a new registry key value
New-ItemProperty -Path "HKCU:\Software\MyApp" -Name "NewSetting" -Value "NewValue" -PropertyType String
# Remove a registry key value
Remove-ItemProperty -Path "HKCU:\Software\MyApp" -Name "SettingToRemove"
# Check if a registry key exists
Test-Path "HKLM:\Software\MyApp"
```
--------------------------------
### Option examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/grep.md
Print the name of the file(s) of matches
```shell
grep -l 'robot' /var/log/*
```
--------------------------------
### Running Perl from Command Line
Source: https://github.com/fechin/reference/blob/main/source/_posts/perl.md
Examples of how to run Perl code directly from the command line.
```shell
# Unix/Linux
$perl -e
# Windows/DOS
C:>perl -e
```
--------------------------------
### Find and suffix (added `.bak`)
Source: https://github.com/fechin/reference/blob/main/source/_posts/find.md
Find files starting with 'file*' and append '.bak' to their names.
```shell
$ find . -type f -name 'file*' -exec mv {} {}.bak\;
```
--------------------------------
### Option examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/grep.md
Forgets about case sensitivity
```shell
grep -i ^DA demo.txt
```
--------------------------------
### AJAX Request with Axios
Source: https://github.com/fechin/reference/blob/main/source/_posts/react.md
An example of making an AJAX GET request using the Axios library in a React component.
```javascript
import React from 'react';
import axios from 'axios';
export default function Weather(props) {
function handleResponse(response) {
console.log(response);
}
if (notifications) {
return notifications
;
} else {
let url = `https://notifications.com`;
axios.get(url).then(handleResponse);
return Loading notifications..
;
}
}
```
--------------------------------
### JSON output with full metadata
Source: https://github.com/fechin/reference/blob/main/source/_posts/claude-code.md
Example of getting Claude output with full metadata in JSON format.
```bash
$ claude -p "query" --output-format json
```
--------------------------------
### Setup Startup Script
Source: https://github.com/fechin/reference/blob/main/source/_posts/pm2.md
Generate and save a startup script to ensure PM2 processes restart on server boot/reboot.
```shell
$ pm2 save
```
--------------------------------
### Python Installation
Source: https://github.com/fechin/reference/blob/main/source/_posts/socket-io.md
Installs the Socket.IO client and server libraries for Python, with options for eventlet or aiohttp.
```bash
pip install python-socketio eventlet
# or
pip install python-socketio aiohttp
```
--------------------------------
### Slicing Python Lists
Source: https://github.com/fechin/reference/blob/main/source/_posts/python.md
Provides examples of basic list slicing using start and end indices, including negative indices.
```python
>>> a = ['spam', 'egg', 'bacon', 'tomato', 'ham', 'lobster']
>>> a[2:5]
['bacon', 'tomato', 'ham']
>>> a[-5:-2]
['egg', 'bacon', 'tomato']
>>> a[1:4]
['egg', 'bacon', 'tomato']
```
--------------------------------
### Variables - Variable Commands
Source: https://github.com/fechin/reference/blob/main/source/_posts/powershell.md
Examples of using commands to create, get, and remove variables, including options like ReadOnly and Constant.
```powershell
New-Variable -Name FirstName -Value Trevor
New-Variable FirstName -Value Trevor -Option
Get-Variable
Get-Variable | ? { $PSItem.Options -contains 'constant' }
Get-Variable | ? { $PSItem.Options -contains 'readonly' }
Remove-Variable -Name firstname
# Removes ReadOnly var
Remove-Variable -Name firstname -Force
```
--------------------------------
### Chat Client-Server Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/nc.md
Sets up a simple chat application where a server listens on a port and a client connects to it.
```shell
$ nc -lv 8000
```
```shell
$ nc 192.168.1.9 8000
```
--------------------------------
### Skill Commands
Source: https://github.com/fechin/reference/blob/main/source/_posts/openclaw.md
Commands for managing skills, including listing, checking readiness, getting info, searching, installing, and updating.
```bash
openclaw skills list
openclaw skills check # readiness check
openclaw skills info
openclaw skills search "browser"
openclaw skills install clawhub:browser
openclaw skills update
```
--------------------------------
### Database Connection Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/symfony.md
Examples of DATABASE_URL configurations for different database systems (MySQL, MariaDB, PostgreSQL).
```bash
# MySQL
DATABASE_URL="mysql://username:password@127.0.0.1:3306/db_name?serverVersion=X.Y.Z&charset=utf8mb4"
# MariaDB
DATABASE_URL="mysql://username:password@127.0.0.1:3307/db_name?serverVersion=X.Y.Z-MariaDB&charset=utf8mb4"
# PostgreSQL
DATABASE_URL="postgresql://username:password@127.0.0.1:5432/db_name?serverVersion=X.Y.Z&charset=utf8"
```
--------------------------------
### Hook Configuration Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/gemini-cli.md
Example of how to configure hooks in `settings.json` for different events like `BeforeTool` and `SessionStart`.
```json
{
"hooks": {
"BeforeTool": [
{
"type": "command",
"command": "~/.gemini/hooks/validate-tool.sh",
"matcher": "write_file",
"timeout": 10000
}
],
"SessionStart": [
{
"type": "command",
"command": "echo '{\"systemMessage\": \"Be concise.\"}'"
}
]
}
}
```
--------------------------------
### Custom Filter and Simple Tag
Source: https://github.com/fechin/reference/blob/main/source/_posts/django.md
Example of a custom Django filter for converting a string to lowercase and a simple tag to get the class name of an object.
```python
from django import template
register = template.Library()
@register.filter()
def lower(value):
"""Converts a string into all lowercase"""
return value.lower()
@register.simple_tag
def to_class_name(object):
return str(object.__class__.__name__)
```
--------------------------------
### Config Commands
Source: https://github.com/fechin/reference/blob/main/source/_posts/openclaw.md
Commands for managing OpenCLAW configuration, including showing file paths, getting/setting/unsetting values, validation, schema display, and guided setup.
```bash
# Show config file path
openclaw config file
# Get a value
openclaw config get gateway.port
openclaw config get channels.telegram.botToken
# Set a value
openclaw config set gateway.port 19001
openclaw config set \
agents.defaults.model.primary \
anthropic/claude-sonnet-4-6
# Unset a value
openclaw config unset gateway.port
# Validate config
openclaw config validate
# Print JSON schema
openclaw config schema
# Interactive guided setup
openclaw configure
```
--------------------------------
### Option examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/grep.md
Display 5 lines around matching string
```shell
grep -C 5 'Exception' error.log
```
--------------------------------
### Option examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/grep.md
Display 3 lines after matching string
```shell
grep -A 3 'Exception' error.log
```
--------------------------------
### JavaScript (Node.js) Installation
Source: https://github.com/fechin/reference/blob/main/source/_posts/socket-io.md
Installs the Socket.IO server and client libraries for Node.js.
```bash
npm install socket.io socket.io-client
```
--------------------------------
### Option examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/grep.md
Display 4 lines before matching string
```shell
grep -B 4 'Exception' error.log
```
--------------------------------
### XACK Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Example of using the XACK command. Note: The example shows an error, likely due to the command not being available in the specific Redis version or context used for the example.
```shell
redis> XACK mystream mygroup 1526569495631-0
ERR Unknown or disabled command 'XACK'
```
--------------------------------
### CSS Flexbox Simple example
Source: https://github.com/fechin/reference/blob/main/source/_posts/css3.md
A basic example of setting up a flex container.
```css
.container {
display: flex;
}
```
```css
.container > div {
flex: 1 1 auto;
}
```
--------------------------------
### Python Client and Server Setup
Source: https://github.com/fechin/reference/blob/main/source/_posts/socket-io.md
Sets up a Socket.IO client connection and a basic Python server using Flask and eventlet.
```python
import socketio
sio = socketio.Client()
sio.connect('http://localhost:3000')
```
```python
import socketio, eventlet, flask
app = flask.Flask(__name__)
sio = socketio.Server(cors_allowed_origins='*')
app = socketio.WSGIApp(sio, app)
@sio.event
def connect(sid, environ):
print('Client connected:', sid)
if __name__ == '__main__':
eventlet.wsgi.server(eventlet.listen(('', 3000)), app)
```
--------------------------------
### Install Command Line Tools
Source: https://github.com/fechin/reference/blob/main/source/_posts/homebrew.md
Installs the Command Line Tools (CLT) if not already installed, which is a prerequisite for Homebrew.
```bash
xcode-select --install
```
--------------------------------
### Namespaces - Client (All Languages)
Source: https://github.com/fechin/reference/blob/main/source/_posts/socket-io.md
Example of connecting to a specific namespace on the client.
```javascript
const adminSocket = io('/admin');
```
```python
sio.connect('http://localhost:3000/admin', namespaces=['/admin'])
```
--------------------------------
### Filter Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/mitmproxy.md
Examples of mitmproxy filters.
```mitmproxy-filter
google\.com
```
```mitmproxy-filter
~q ~b test
```
```mitmproxy-filter
!(~q & ~t "text/html")
```
```mitmproxy-filter
":~q ~m GET:.*:/replacement.html"
```
--------------------------------
### Tagging Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/latex.md
Examples of KaTeX tagging for equations.
```KaTeX
\tag{hi} x+y^{2x}
```
```KaTeX
\tag*{hi} x+y^{2x}
```
--------------------------------
### Initializing a New Project
Source: https://github.com/fechin/reference/blob/main/source/_posts/npm.md
Commands to initialize a new Node.js project, creating a package.json file.
```bash
npm init # Interactive setup
# or
npm init -y # Creates a package.json with default values
```
--------------------------------
### Install EJS
Source: https://github.com/fechin/reference/blob/main/source/_posts/ejs.md
Install EJS using npm.
```shell
$ npm install ejs
```
--------------------------------
### Option examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/grep.md
Return all lines which don't match the pattern
```shell
grep -v 'warning' /var/log/syslog
```
--------------------------------
### Start Redis Server
Source: https://github.com/fechin/reference/blob/main/source/_posts/redis.md
Starts the Redis server.
```shell
$ redis-server
```
--------------------------------
### Option examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/grep.md
Search only for the full word
```shell
grep -w "of" demo.txt
```
--------------------------------
### KaTeX Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/latex.md
An example of KaTeX syntax for a mathematical integral.
```KaTeX
% \f is defined as #1f(#2) using the macro
f\relax(x) = \int_{-\infty}^\infty
f\hat\xi\,e^{2 \pi i \xi x}
\,d\xi
```
--------------------------------
### Option examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/grep.md
Only show the matching part of the string
```shell
grep -o search_string filename
```
--------------------------------
### Basic Substitution Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/sed.md
Common examples for substitution with sed.
```shell
$ sed 's/old/new/g' file.txt
$ sed 's/old/new/g' file.txt > new.txt
$ sed 's/old/new/g' -i file.txt
$ sed 's/old/new/g' -i.backup file.txt
```
--------------------------------
### C# (.NET) Client and Server Setup
Source: https://github.com/fechin/reference/blob/main/source/_posts/socket-io.md
Sets up a Socket.IO client connection and a basic C# server using Fleck.
```csharp
var socket = IO.Socket("http://localhost:3000");
socket.Connect();
```
```csharp
using Fleck;
var server = new WebSocketServer("ws://0.0.0.0:3000");
server.Start(socket =>
{
socket.OnOpen = () => Console.WriteLine("Client connected");
});
```
--------------------------------
### Two Columns Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/quickref.md
Example of a two-column section layout.
```text
# Two Columns Example
╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮ ╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
┆ 1 ┆ ┆ 2 ┆
╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╯ ╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╯
╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
┆ 3 ┆
╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╯
```
--------------------------------
### One Column Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/quickref.md
Example of a one-column section layout.
```text
# One Column Example {.cols-1}
╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
┆ 1 ┆
╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╯
╭┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
┆ 2 ┆
╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╯
```
--------------------------------
### Unix and Linux Installation Commands
Source: https://github.com/fechin/reference/blob/main/source/_posts/perl.md
Commands to install Perl from source on Unix/Linux systems.
```shell
$tar -xzf perl-5.x.y.tar.gz
$cd perl-5.x.y
./Configure -de
$make
$make test
$make install
```
--------------------------------
### Examples
Source: https://github.com/fechin/reference/blob/main/source/_posts/jquery.md
Example of using jQuery selectors to manipulate elements.
```javascript
$('button').click(() => {
$(':button').css('color', 'red');
});
```
--------------------------------
### Create a Repository
Source: https://github.com/fechin/reference/blob/main/source/_posts/git.md
Commands to initialize a new local repository or clone an existing one.
```shell
$ git init [project name]
```
```shell
$ git clone git_url
```
```shell
$ git clone git_url my_directory
```
--------------------------------
### Quick Setup: Open Dashboard
Source: https://github.com/fechin/reference/blob/main/source/_posts/openclaw.md
Command to open the OpenClaw dashboard and its default local URL.
```bash
openclaw dashboard
# Local default: http://127.0.0.1:18789/
```
--------------------------------
### Example
Source: https://github.com/fechin/reference/blob/main/source/_posts/jquery.md
Example of jQuery event handling and CSS manipulation.
```javascript
$('#menu').on('click', function () {
$(this).hide();
});
$('body').css('background', 'red');
```