Skip to content

Instantly share code, notes, and snippets.

View rumblestrut's full-sized avatar

Eric J. Gruber rumblestrut

View GitHub Profile
@rumblestrut
rumblestrut / random.js
Created December 29, 2014 17:15
Random number generator (1 to 10)
var bigDecimal = Math.random();
var improvedNum = (bigDecimal * 10) + 1;
var randomNumber = Math.floor(improvedNum);
alert(randomNumber);
@rumblestrut
rumblestrut / Current Date JS
Created September 12, 2014 21:01
Current date JavaScript
<html>
<head>
<title>Current Date</title>
<script type="text/javascript">
var d = new Date();
var current_date = d.getDate();
var current_month = d.getMonth() +1;
var current_year = d.getFullYear();
document.write("Today is " + current_month + "-" + current_date + "-" + current_year);
</script>
<html>
<head>
<title>Output</title>
</head>
<body>
<?php echo $output; ?>
</body>
@rumblestrut
rumblestrut / checker.rb
Last active December 21, 2015 04:38
Ruby script that tests if domains are up and resolving correctly.
require 'net/http'
pages = %w( www.ericjgruber.com
www.lawrencecoders.com
www.americanacollectors.com
www.witchesbecryin.com
)
threads = []
@rumblestrut
rumblestrut / decode-base64.rb
Created March 27, 2013 13:45
Base 64 decoding with Ruby.
require "base64"
enc = Base64.decode64("UHV0IHlvdXIgc2hvZXMgb24u")
puts enc
@rumblestrut
rumblestrut / encode-base64.rb
Created March 27, 2013 13:44
Base 64 encoding with Ruby.
require "base64"
enc = Base64.encode64("Put your shoes on.")
puts enc
@rumblestrut
rumblestrut / form-option.arrays.rb
Created July 10, 2011 02:51
Option buttons for forms
<div class="field">
<%= f.label :state %><br />
<% states = { 'Kansas' => 'KS', 'Missouri' => 'MO', 'Nebraska' => 'NE' } %>
<% list = states.sort
list.each {|x| %>
<%= f.radio_button :state, x[1] %> <%= h(x[0]) %> <br />
<% } %>
</div>
@rumblestrut
rumblestrut / gapfix.txt
Created May 5, 2011 00:26
Drupal gap fix for browsers
It looks like Firefox (and presumably, other browsers) are not liking the display: block; CSS in your modules/system/defaults.css on line 51.
Let's not modify core CSS files, but instead add this to your theme's CSS:
.node.clear-block {
display: inline-block !important;
}
@rumblestrut
rumblestrut / rotate.js
Created May 4, 2011 21:11
Rotating images with javascript
Oh sure, you could do this with jQuery, but in my early days, this is what I used ...
<script>
<!--
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 8000
// Duration of crossfade (seconds)
var crossFadeDuration = 3