Skip to content

Instantly share code, notes, and snippets.

View sam0x17's full-sized avatar

Sam Johnson sam0x17

View GitHub Profile
@sam0x17
sam0x17 / prettyplease.rs
Created March 21, 2023 19:02
how to use prettyplease for syntax formatting
let formatted = prettyplease::unparse(&syn::parse_file(output.to_string().as_str()).unwrap());
// where output is a TokenStream2
@sam0x17
sam0x17 / bareblock.rs
Created December 19, 2022 06:29
bare block parsing implementation using syn (parse the contents of a block without braces)
struct BareBlock {
stmts: Vec<Stmt>,
}
impl Parse for BareBlock {
fn parse(input: ParseStream) -> syn::Result<Self> {
match Block::parse_within(input) {
Ok(stmts) => Ok(BareBlock { stmts }),
Err(e) => Err(e),
}
@sam0x17
sam0x17 / macos_terminal_colors.sh
Created August 2, 2022 20:45
macos terminal colors / atom one dark colors for macos terminal
# add to .zshrc:
export CLICOLOR=1
alias ls='ls -G'
alias ll='ls -lG'
export LSCOLORS=ExFxBxDxCxegedabagacad
@sam0x17
sam0x17 / http_codes.rs
Last active June 16, 2022 06:39
rust http codes enum
pub enum HttpCode {
Continue = 100,
SwitchingProtocols = 101,
Processing = 102,
EarlyHints = 103,
Ok = 200,
Created = 201,
Accepted = 202,
NonAuthoritativeInformation = 203,
NoContent = 204,
@sam0x17
sam0x17 / rfc3339.rb
Created November 15, 2021 02:49
RFC3339 Time in Ruby without Active Support
Time.now.strftime('%Y-%m-%dT%H:%M:%S%:z')
@sam0x17
sam0x17 / wsl_install_internal.sh
Last active May 28, 2022 21:26
install brew and add to environment
#!/bin/bash
# update apt
sudo apt-get update || exit 1
sudo apt-get upgrade -y || exit 1
sudo apt-get dist-upgrade -y || exit 1
# install required apt packages
sudo apt-get install p7zip-full \
git p7zip-full curl gnupg2 libssl-dev libxml2-dev \
@sam0x17
sam0x17 / pull.sh
Created November 20, 2020 07:03
rsync pull
#!/bin/bash
echo "pulling from sam-desktop via rsync..."
rsync -chavzP --stats sam@sam-desktop:/home/sam/workspace /home/sam/
echo "done."
@sam0x17
sam0x17 / fstab
Created September 12, 2020 22:10
linux mount smb fstab
//plex-server/d /mnt/plex_d cifs uid=sam,credentials=/home/sam/.smbcredentials,iocharset=utf8,vers=3.0 0 0
//plex-server/e /mnt/plex_e cifs uid=sam,credentials=/home/sam/.smbcredentials,iocharset=utf8,vers=3.0 0 0
@sam0x17
sam0x17 / js-guide.md
Last active July 26, 2020 10:00
Become a Reddit Mega Soy JS Dev

Become a Reddit Mega Soy JS Dev

  1. Go through the What is web development? w3schools roadmap (just read)
  2. Go through the entire sidebar of the w3schools HTML guide. You'll already be familiar with a good bit of this but there are a lot of new HTML elements including things like <canvas> etc. that it would be good to be vaguely familiar with. Go through some of the quick little exercises for anything you are unfamiliar with but otherwise don't bother.
  3. Same deal with the w3schools CSS guide. There's some really useful stuff in here since CSS 3 came out, and the more you know about it the better. A bunch of it I probbaly don't even know about.
  4. Go through all of the w3schools Javascript guide. Everything here is relevant so you can get a solid foundation.
@sam0x17
sam0x17 / amber_db_fix.yml
Last active March 19, 2020 06:31
how to get postgresql to work with amber framework in local domain socket mode
database_url: postgres:///my_db_name