Skip to content

Instantly share code, notes, and snippets.

View jaredcwhite's full-sized avatar
🌲

Jared White jaredcwhite

🌲
View GitHub Profile
@aarongustafson
aarongustafson / responsive-iframes.css
Created October 25, 2011 17:07
Responsive iFrames with jQuery
iframe {
max-width: 100%;
}
<!doctype html>
<!-- http://taylor.fausak.me/2015/01/27/ios-8-web-apps/ -->
<html>
<head>
<title>iOS 8 web app</title>
<!-- CONFIGURATION -->
@albertogg
albertogg / redcarpet.rb
Last active September 24, 2021 12:17
Rails markdown parser using Redcarpet. It also parses erb within the markdown template.
# gem install redcarpet
# config/initializers/redcarpet.rb
# {viewname}.html.md
module ActionView
class Template
module Handlers
class Markdown
class_attribute :default_format
self.default_format = Mime::HTML
@schickling
schickling / Rakefile
Last active May 12, 2025 13:28
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
@adambeynon
adambeynon / bindings.rb
Created May 7, 2014 15:58
Opal Bound attributes + DOM Compiler
module Vienna
class BaseBinding
def initialize(view, context, node, attr)
@view = view
@context = context
@node = node
@attr = attr
setup_binding
end
anonymous
anonymous / contentblocks.rb
Created March 21, 2015 23:29
Gives you a mechanism in Jekyll to pass content up from pages into their parent layouts. It's kind of like having Rails' content_for available for Jekyll.
# Plugin: jekyll-contentblocks
# Author: Rusty Geldmacher
# Git: https://github.com/rustygeldmacher/jekyll-contentblocks
# Instructions: https://github.com/rustygeldmacher/jekyll-contentblocks#usage
module Jekyll
module ContentBlocks
VERSION = "0.0.3"
module Common
def get_content_block_name(tag_name, block_name)
block_name = (block_name || '').strip
@narainsagar
narainsagar / nodejs - get filesize in readable format.md
Last active January 14, 2022 05:33
node.js - function to get file and convert the file size in humanly readable format.

node.js - get the filesize in human readable format.

This will take filePath as a function parameter and reads the file via fs module and get the file and converts it's size into more humanly readable format.

const fs = require('fs');
function getFileSize(filename) {
  const stats = fs.statSync(filename);
  //console.log('stats', stats);
 const {size} = stats;
@iscott
iscott / simple_authentication_rails_5_bcrypt_and_has_secure_password.md
Last active November 14, 2024 10:54
Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

Cheat Sheet: Simple Authentication in Rails 6 with has_secure_password

The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.

First the simplest/core layers, then optional layers depending on which features/functionality you want.

Specs
AUTHOR Ira Herman
LANGUAGE/STACK Ruby on Rails Version 4, 5, or 6
@KonnorRogers
KonnorRogers / imageable.rb
Last active February 19, 2021 23:27
Inline SVGs and Webp picture tags
# frozen_string_literal: true
# Useful methods for dealing with images
module Imageable
def inline_svg(filename, **options)
filepath = File.join(Rails.root, 'public', asset_pack_path("media/images/#{filename}.svg"))
Rails.cache.fetch(filepath) do
file = File.read(filepath)
doc = Nokogiri::HTML::DocumentFragment.parse file
@asgerb
asgerb / index.js
Created June 11, 2021 11:50
netlify-cache-bridgetown-media-transformation
module.exports = {
// Restore file/directory cached in previous builds.
// Does not do anything if:
// - the file/directory already exists locally
// - the file/directory has not been cached yet
async onPreBuild({ utils }) {
await utils.cache.restore("./.bmt-cache")
},
// Cache file/directory for future builds.
// Does not do anything if: