Skip to content

Instantly share code, notes, and snippets.

Avatar
🌱

Andrew Mason andrewmcodes

🌱
View GitHub Profile
@andrewmcodes
andrewmcodes / request.rb
Created January 23, 2023 22:09
Net::HTTP Example
View request.rb
require 'net/http'
require 'net/https'
# Request (GET )
def send_request
uri = URI('https://api.github.com/repos/andrewmcodes/andrewmcodes/events?per_page=99&page=2')
# Create client
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
@andrewmcodes
andrewmcodes / flipper.rb
Created November 29, 2022 18:47
Flipper UI Banner in Production
View flipper.rb
Flipper::UI.configure do |config|
config.banner_text = "Production Environment" if Rails.env.production?
end
@andrewmcodes
andrewmcodes / box_component.rb
Created September 23, 2022 22:08
Example showing how to use `as` option in ViewComponent
View box_component.rb
class BoxComponent < ViewComponent::Base
DEFAULT_TAG = :div
def initialize(**opts)
@opts = opts
@tag_opts = opts.except(:as, :classes)
end
def call
tag.send tag_name, content, class: classes, **tag_opts
View foo.html
<div class="mt-6 flex gap-6"><a
class="group -m-1 p-1"
aria-label="Follow on Twitter"
href="https://twitter.com"
><svg
viewBox="0 0 24 24"
aria-hidden="true"
class="
h-6
w-6
@andrewmcodes
andrewmcodes / esbuild.default.js
Created July 8, 2022 20:28
bridgetown + sass + esbuild
View esbuild.default.js
const path = require("path")
const fsLib = require("fs")
const fs = fsLib.promises
const { pathToFileURL, fileURLToPath } = require("url")
const glob = require("glob")
const postcss = require("postcss")
const postCssImport = require("postcss-import")
const readCache = require("read-cache")
// Detect if an NPM package is available
@andrewmcodes
andrewmcodes / obsidian.css
Created June 17, 2022 18:38
Obsidian CSS Snippets
View obsidian.css
/* Obsidian CSS Snippets */
/* ==============================
Frontmatter
============================== */
.cm-hmd-frontmatter {
font-size: 10px !important;
}
/* ==============================
@andrewmcodes
andrewmcodes / .zshrc
Last active June 8, 2022 18:29
Start Redis and Postgres with asdf
View .zshrc
#!/usr/bin/env zsh
# PG
# Start with `switch_pg 13.6` for example
function pg_switch {
local version_to_run=$1
local currently_running_version=$(psql --no-psqlrc -t -c 'show server_version;' postgres | xargs)
# check if you're erroneously switching to the same version
if [ "$version_to_run" = "$currently_running_version" ]; then
@andrewmcodes
andrewmcodes / App.md
Created May 5, 2022 17:05
Add dashboard in Obsidian with App note example
View App.md

Requires Dataview and MetaEdit

Inbox

const { update } = this.app.plugins.plugins["metaedit"].api;
const { createButton } = app.plugins.plugins["buttons"];

dv.table(
  [
    "Image",
@andrewmcodes
andrewmcodes / foo.md
Created April 3, 2022 02:00
output ruby to file
View foo.md

ruby -v 2>>&1 | tee -a ~/desktop/ruby_output.txt

@andrewmcodes
andrewmcodes / .gitignore
Created March 23, 2022 00:23
Sample GitIgnore
View .gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #