Skip to content

Instantly share code, notes, and snippets.

View rossta's full-sized avatar
💭
Being curious

Ross Kaffenberger rossta

💭
Being curious
View GitHub Profile
@rossta
rossta / ruby-resources.md
Last active January 26, 2024 19:58
Resources I recommend for learning Ruby and Rails

Resources I recommend to learn Ruby and Rails

New? Start here

I like jumping into tutorials first.

"How to write Ruby" Books

@rossta
rossta / scalable-js-resources.md
Last active November 12, 2023 01:41
Resources for Learning Scalable Javascript Architecture

Scalable JS Resources

Forget what you know about Javascript MVC patterns from your experience with Backbone, Ember, Angular, Knockout, Batman, and yada yada. I encourage you to empty your cup, take a step back and open your mind to the ideas presented in the following resources, primarily from minds of Nicholas Zakas and Addy Osmani, two individuals I consider to be thought leaders in the front-end development world.

@rossta
rossta / urlToPDF.js
Created June 2, 2023 19:33
Generate PDF from webpage with puppeteer
import puppeteer from 'puppeteer';
const [, , url, folder = '.'] = process.argv;
if (!url) throw 'Must supply URL';
(async () => {
const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
@rossta
rossta / index.js
Last active July 19, 2021 12:15
Barebones node js server on express
var express = require('express');
var app = express.createServer();
app.configure(function() {
var pub = __dirname + "./public";
pub = require("path").normalize(pub);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
});
@rossta
rossta / stripe_customer.rb
Created April 8, 2021 10:48
FactoryBot factory for a Hash class (i.e., not an ActiveRecord model)
FactoryBot.define :stripe_customer, class: Hash do
skip_create
initialize_with { new(attributes) }
id { "cus_#{SecureRandom.hex(7)}" }
object { "customer" }
address { nil }
balance { 0 }
created { 1.day.ago.to_i }
currency { "usd" }
@rossta
rossta / initializers:hello.js
Last active November 12, 2020 19:45
Webpack with require.context
console.log('initializer hello.js');
@rossta
rossta / webpacker.config.development.js
Created April 18, 2020 13:36
Webpacker's development webpack config output via console.dir()
ConfigObject {
mode: 'development',
output: {
filename: 'js/[name]-[contenthash].js',
chunkFilename: 'js/[name]-[contenthash].chunk.js',
hotUpdateChunkFilename: 'js/[id]-[hash].hot-update.js',
path: '/path/to/rails/app/public/packs',
publicPath: '/packs/',
pathinfo: true
},
@rossta
rossta / benchmark_open.rb
Created January 2, 2020 16:33
Comparing open from disk to open-uri
require "benchmark"
require "open-uri"
require "pathname"
n = 1_000
Benchmark.bm do |benchmark|
benchmark.report("open(url).read") do
n.times do
open("http://localhost:3035/packs/manifest.json").read
@rossta
rossta / offline.html
Last active June 24, 2019 06:16
offline.html
<!DOCTYPE html>
<html>
<head>
<title>You are not connected to the Internet</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
@rossta
rossta / rossta.zsh-theme
Last active October 31, 2018 00:55
My ZSH theme
PROMPT_PREFIX="%{$fg[blue]%}[%{$reset_color%}"
PROMPT_SUFFIX="$fg[blue]%}]%{$reset_color%}"
HOST_PROMPT="%{$fg_bold[green]%}%n@%m"
DATE_PROMPT="$PROMPT_PREFIX%{$fg[red]%}%D{%I:%M:%S}$PROMPT_SUFFIX"
PWD_PROMPT="$PROMPT_PREFIX%{$fg[white]%}%~$PROMPT_SUFFIX"
LEADER_PROMPT="%{$fg_bold[blue]%}\$%{$reset_color%}"
PROMPT=$'$HOST_PROMPT $DATE_PROMPT$PWD_PROMPT$RUBY_PROMPT$(git_prompt_info)\
$LEADER_PROMPT '