Skip to content

Instantly share code, notes, and snippets.

@swlkr
swlkr / macro_struct.rs
Last active August 1, 2023 16:51
Generate a struct with a proc macro
/// The schema proc macro:
/// Example:
///
/// schema! {
/// Users {
/// id: "integer primary key not null"
/// }
/// }
#[proc_macro]
pub fn schema(s: TokenStream) -> TokenStream {
@swlkr
swlkr / reverse_list.rs
Created January 12, 2023 18:07
Reverse a singly linked list in rust
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode { next: None, val }
@swlkr
swlkr / Dockerfile
Created January 13, 2022 21:27
Rails 7 dockerfile for shippers
FROM docker.io/library/ruby:3.0.3-slim
RUN apt-get update -qq && apt-get install -y --no-install-recommends curl build-essential git-core libjemalloc2 && rm -rf /var/lib/apt/lists/*
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
# install sqlite
RUN curl -O https://www.sqlite.org/2021/sqlite-autoconf-3370000.tar.gz && tar xvzf sqlite-autoconf-3370000.tar.gz
RUN cd sqlite-autoconf-3370000 && ./configure && make && make install
window:
decorations: none
dynamic_title: true
font:
normal:
family: "Fira Code"
style: Retina
bold:
@swlkr
swlkr / nvim.init
Last active October 31, 2021 03:40
my nvim.init
syntax on
set relativenumber
filetype plugin indent on
set autoindent
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set showcmd
set smarttab
@swlkr
swlkr / html-to-hiccup-janet.clj
Last active July 9, 2020 15:52
sort of readable html to hiccup conversion janet script
; based on sogaiu's PEG https://gist.github.com/sogaiu/63efde6daabbdccb2297a9c2a65368ae
(def xmlish-peg
~{:main (sequence (opt (drop :xml-declaration))
(some (sequence :s* :element :s*)))
#
:xml-declaration (sequence
"<?xml"
(any :attribute)
"?>")
(db/delete {:author/name "Cody Coast"})
(db/transact {:post/title "3 things you should know about Coast on Clojure"
:post/body "1. It's great. 2. It's tremendous. 3. It's making web development fun again."
:post/author [:author/name "Cody Coast"]})
(db/transact {:post/title "5 things you should know about Coast on Clojure"
:post/id 1})
(db/transact {:post/title "3 things you should know about Coast on Clojure"
:post/body "1. It's great. 2. It's tremendous. 3. It's making web development fun again."
:post/author-id 2})