Skip to content

Instantly share code, notes, and snippets.

@snnsnn
snnsnn / block.ts
Created July 6, 2023 06:40 — forked from Herve07h22/block.ts
Pattern matching instead of Visitor pattern
import { match, P } from "ts-pattern";
const headerBlocType = {
Header: "header",
Paragraph: "paragraph",
Image: "image",
} as const;
interface HeadBlockData {
text: string;
@snnsnn
snnsnn / merb_restful_rangeable_collections.rb
Created June 5, 2023 05:03 — forked from mjwillson/merb_restful_rangeable_collections.rb
RESTful way of exposing a collection resource in merb in a pageable / sub-range-fetchable way. Supports HTTP Content-Range
# Drop me a line if you wanna see this as a proper merb plugin.
class Merb::Controller
ITEM_RANGE = /^items=(\d+)-(\d+)$/
RANGE = /^(\d+)-(\d+)$/
# Displays a collection resource (using Merb's display method) while supporting requests for sub-ranges of items in a RESTful fashion.
# This supports a subset of the HTTP/1.1 spec for content ranges, using a custom range unit 'items'. eg:
# GET /collection HTTP/1.1
# Range: items 10-20
@snnsnn
snnsnn / generate-ssh-key.sh
Created October 21, 2019 09:01 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@snnsnn
snnsnn / tower-grpc-tls.rs
Created August 23, 2019 05:47 — forked from kiratp/tower-grpc-tls.rs
(Mostly working) Sample to use TowerGRPC against a TLS endpoint.
// [dependencies]
// futures = "0.1.27"
// http = "0.1.17"
// tokio = "0.1.21"
// tower-request-modifier = { git = "https://github.com/tower-rs/tower-http" }
// tower-grpc = { version = "0.1.0", features = ["tower-hyper"] }
// tower-service = "0.2"
// tower-util = "0.1"
// tokio-rustls = "0.10.0-alpha.3"
@snnsnn
snnsnn / README.md
Created March 29, 2019 02:09 — forked from jonathantneal/README.md
CSS Modules in PHP

CSS Modules lets you write and use simple class names rather than remembering and maintaining long unique class names for every component. CSS Modules mutates all of your classnames from each partials into new, completely unique classnames that will not conflict when they are bundled together into your main CSS file. Then, a JSON file is generated that maps the happy classnames from each file to the unique classname in the combined file. You load this map in PHP, and begin using the easy-to-remember classnames as you wish.

Docker Quick Reference

Concepts

Dockerfile: blueprint for an image that defines what goes on in the environment inside a container.

Image: an executable package that includes everything needed to run an application --the code, a runtime, libraries, environment variables, and configuration files.

Container: a runtime instance of an image --what the image becomes in memory when executed (that is, an image with state, or a user process).

@snnsnn
snnsnn / println
Last active April 10, 2018 16:30
Write a program to print your name, date of birth. and mobile number.
println!("Hello");
@snnsnn
snnsnn / Direction.rs
Last active April 8, 2018 11:31
Test Snippets
/*
* Write a function called greet
* which takes a name parameter
* and returns a String with a greeting
* "Hello {name}!"
*/