Skip to content

Instantly share code, notes, and snippets.

View sam0x17's full-sized avatar

Sam Johnson sam0x17

View GitHub Profile
@sam0x17
sam0x17 / rust_analyzer_separate_build_dir.md
Last active May 1, 2023 20:25
new solution for getting separate workspace/project-specific build directory for rust-analyzer

The following will allow you to automatically have a workspace-specific separate build directory for rust-analyzer:

in userSettings.json (vscode):

"rust-analyzer.server.extraEnv": {
  "CARGO_TARGET_DIR": "target/analyzer"
},
"rust-analyzer.check.extraArgs": [
  "--target-dir=target/analyzer"
]
[build]
rustc-wrapper = "/home/sam/.cargo/bin/sccache"
[profile.rust-analyzer]
inherits = "dev"
@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 / 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 / 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 / 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 / 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."