Skip to content

Instantly share code, notes, and snippets.

View charliepark's full-sized avatar
🚀

Charlie Park charliepark

🚀
View GitHub Profile
var BalancedMeasures = {
minimumScreenSizeToRunOn: 992,
classNameToMeasure: "graf--pullquote",
breakCode: "<br class='bmjs'>",
charactersToTriggerOrphanScreen: /[,\.\?\!]/,
run: function(classToRunOn){
if(this.onSmallerScreen()){return;}
var elements = this.getElementsToMeasure(classToRunOn);
Log.toConsole(elements.length);
for(var i = 0; i < elements.length; i++){
var BalancedMeasures = {
minimumScreenSizeToRunOn: 992,
classNameToBalance: "graf--pullquote",
run: function(classToRunOn){
if(this.onSmallerScreen()){return;}
var elements = this.getElementsToBalance(classToRunOn);
for(var i = 0; i < elements.length; i++){
this.balance(elements[i]);
}
@charliepark
charliepark / gutenberg.css
Created July 22, 2015 05:47
CSS to insert into the style block of a Project Gutenberg page to make it more legible
*{font-family: "Avenir Next", "avenir next", avenir next, avenir !important;line-height:1.65}
h3{color: #444;margin: 1rem 0;}
hr{border:0;background: none;border-bottom: 1px solid #eee;}
h3 + hr{margin-bottom: 2rem}
p + hr{margin-top: 4rem;}
p{margin: 0 auto 1.65em;max-width: 36em;text-align: left}
.poem .stanza{background-color: #F6F6F6;border-radius: 10px;box-sizing: border-box;margin: 1em auto;max-width: 36rem;padding: 1rem 1.5rem;}
@charliepark
charliepark / blipnote.html
Created July 28, 2015 14:32
The source code to blipnote.com
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="cache-control" content="public">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=1">
<title>Blipnote</title>
<style type="text/css">html,body,div,span,h1,h2,p,a,form,aside,footer,header,nav{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}aside,footer,header,nav,section{display:block}body{line-height:1}a{color:rgba(255,255,255,.5);cursor:pointer;text-decoration:none}nav a{font-size:12px;letter-spacing:.2em;margin:20px;padding:10px;text-align:center;text-transform:uppercase}a[href*="mailto"]{background:rgba(0,0,0,.2);color:#fff;padding:0 4px}aside{background:#00779d;display:none;overflow:auto;position:absolute;top:0;left:0;bottom:0;right:0;z-index:9}body{box-sizing:border-box;font-family:"gill sans","gill sans mt",sans-serif;letter-spacing:1px;margin:10% auto 0;position:relative;text-align:center;width:350px}body{display:flex;flex-direction:column}header{height:55px
From Rails changeset 5876: http://dev.rubyonrails.org/changeset/5876
A range may be used in the hash to use the SQL BETWEEN operator:
Student.find(:all, :conditions => { :grade => 9..12 })
... so, presumably ...
User.find(:all, :conditions => { :created_at => '2009-01-01'..'2009-02-01' })
... compare with ...
Friendlier Error Messages
(from http://apidock.com/rails/ActionView/Helpers/ActiveRecordHelper/error_messages_for#82-Friendlier-error-message-example)
The default error messages can be a bit stale and off putting. Try somethings like this:
error_messages_for(
:user,
:header_message => "Oops - We couldn't save your user!",
:message => "The following fields were a bit of a problem:",
:header_tag => :h1
This is intended to be a minimalist alternative to Blueprint (www.blueprintcss.org) and other, more fleshed-out CSS grid frameworks. Change 3 variables, and the framework does the rest for you. It's intended for use in Ruby / Rails applications.
========
Put the following in the <head> of your ERB file (either in a layout file or in a partial, if you're calling it from several pages):
<style type="text/css">
.g{BACKGROUND:RGBA(255,0,0,0.2)}
<%
num = number_of_columns = 16
body {font-family:'helvetica neue', helvetica, arial, sans-serif;}
h1 {font-size:24px;line-height:26px;margin:10px 0 18px;}
p{font-size:14px;line-height:18px;margin:0 0 18px;}
place this in public/.htaccess
FileETag none
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
</IfModule>
namespace :deploy do
desc "Restarting mod_rails with restart.txt"
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt"
end
[:start, :stop].each do |t|
desc "#{t} task is a no-op with mod_rails"
task t, :roles => :app do ; end
end