Skip to content

Instantly share code, notes, and snippets.

@ryanoglesby08
ryanoglesby08 / git_rubocop.rake
Created February 26, 2015 01:13
A rake task to run rubocop on changed ruby files in a git repository. Meant to be run as part of a pre-commit task.
desc 'Run Rubocop on uncommitted changed files'
task :git_rubocop do
RUBY_FILENAME_PATTERNS = %w(Gemfile Rakefile .rb .rake)
def ruby_file?(filename)
RUBY_FILENAME_PATTERNS.each do |pattern|
return true if filename.include? pattern
end
false
end
@ryanoglesby08
ryanoglesby08 / server.js
Last active April 4, 2024 13:25
A node.js SPA server that serves static files and an index.html file for all other routes.
/*
Incredibly simple Node.js and Express application server for serving static assets.
DON'T USE THIS IN PRODUCTION!
It is meant for learning purposes only. This server is not optimized for performance,
and is missing key features such as error pages, compression, and caching.
For production, I recommend using an application framework that supports server-side rendering,
such as Next.js. https://nextjs.org
@ryanoglesby08
ryanoglesby08 / create-icons.ts
Last active February 16, 2022 20:42
Generate React icon components from SVG files using SVGR
import { transform } from '@svgr/core'
import fs from 'fs'
import template from "./template"
const ICON_DEFAULT_COLOR = 'black'
const fileName = "svgs/myIcon.svg"
const svgData = fs.readFileSync(fileName)
const componentData = transform.sync(