Skip to content

Instantly share code, notes, and snippets.

View walterdavis's full-sized avatar

Walter Lee Davis walterdavis

View GitHub Profile
@walterdavis
walterdavis / short_unique_tokens_in_ruby.md
Last active May 5, 2022 22:57 — forked from mbajur/.md
How to create small, unique tokens in Ruby

How to create small, unique tokens in Ruby

That is is basically a "fork" of blog article i'm constantly returning to. It seems that the blog is down:

My choice: Dave Bass’s rand().to_s() trick

Dave Bass proposed this which I picked up for my implementation (here for an 8-chars token):

# == Schema Information
#
# Table name: videos
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# title :text
# youtube_id :string
# leader_id :bigint
@walterdavis
walterdavis / richtext.css
Created January 7, 2020 13:17
Trix Heading
trix-toolbar .trix-dialog--heading {
max-width: 190px;
}
.trix-content h1, .trix-content h2, .trix-content h3, .trix-content h4, .trix-content h5, .trix-content h6 {
line-height: 1.2;
margin: 0;
}
.trix-content h1 {
@walterdavis
walterdavis / gist:3745984
Created September 18, 2012 21:21 — forked from Mr2P/gist:3081898
background size cover polyfill for IE (6, 7, 8)
if ("backgroundSize" in document.body.style) {
return;
}
var body = $$('body').first(),
img = body.getStyle('background-image').sub(/url\((.+?)\)/,'#{1}') || 'default.jpeg',
fill = new Element('img', {src: img,alt: ''}).
setStyle('position:absolute; top:0; left:0; width:100%; height:100%; z-index:-1');
body.setStyle('background:none');
body.insert(fill);
@walterdavis
walterdavis / uri.js
Created April 25, 2012 23:15 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@walterdavis
walterdavis / bootstrap-rvm-and-chef-solo-on-ubuntu.sh
Created March 24, 2012 14:31 — forked from robdimarco/bootstrap-rvm-and-chef-solo-on-ubuntu.sh
Bash script to bootstrap chef solo using RVM on an Ubuntu server
DEFAULT_RUBY_VERSION="1.9.3-p125"
sudo apt-get -y install curl git-core bzip2 build-essential zlib1g-dev libssl-dev autoconf
if [ -x /usr/local/rvm/bin/rvm ]; then
echo "RVM Found..nothing to do";
else
echo "Installing RVM";
curl -o /tmp/rvm-installer -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer
<!-- PHP -->
<?php echo date('Y'); ?>
var Marquee = Class.create({
initialize: function(element) {
this.element = $(element);
this.paused = false;
// If everything fits don't bother with all this mess
if(this.element.scrollWidth == this.element.clientWidth) return;
// Defaults to scrolling through all content in 40 seconds.

A Note

Forking has been fixed, but the old repositories will still be corrupted.

Basics

The method page will create a new page: page "home" do "Hello, world!"