Skip to content

Instantly share code, notes, and snippets.

def confined_truncation(text, maxCharsPerWord = 20, maxCharsTotal = 80)
text = text.to_s.split(' ')
text = text.collect {|word| truncate(word, :length => maxCharsPerWord - 3, :omission => '...')}.join(" ")
return truncate(text, :separator => " " , :length => maxCharsTotal - 3, :omission => '...')
end
@import "core/core";
.local {
.fifty {
width: 50%;
float: left;
}
.btn {
@etjossem
etjossem / equalsequals.js
Last active December 17, 2015 16:09
What's the difference between =, ==, and ===? In three lines of code:
x = "1"; // Set the value of x to "1" (string).
x == 1; // Is "1" (string) equal to 1 (number) with implicit type conversion? True.
x === 1; // Is "1" (string) strictly equal to 1 (number) with no type conversion? False.
@etjossem
etjossem / .zshrc
Last active December 19, 2015 00:49
Navigation aliases for the many Goodsmiths projects.
# Semi-automatic dev environment. Each of these will open up the relevant goodsmiths app directory in a new window.
alias cdgs="cd ~/projects/goodsmiths"
alias cdre="cd ~/projects/goodsmiths_recommendation_engine"
alias cdas="cd ~/projects/goodsmiths_activity_stream"
alias cdge="cd ~/projects/gaminator"
alias cdgg="cd ~/projects/good_guy_project"
# Fully automatic dev environment. Starts up GS each app in its own tab of a new gnome-terminal (Ubuntu)
alias gsup="gnome-terminal --geometry=170x40 \
--tab --working-directory=$HOME/projects/goodsmiths \

Static-positioned horizontal nav with z-Index

Combination between the absolute positioning and the static approach to horizontal navigation - the best of both worlds.

Use the standard CSS rule for the element itself. Use the :after (absolute) CSS rule to apply z-index, shadow effects, etc.

A Pen by Eric Tjossem on CodePen.

License.

@etjossem
etjossem / A-Pen-by-Eric-Tjossem.markdown
Created November 15, 2013 21:57
A Pen by Eric Tjossem.
<head>
</head>
<body>
<h3>Email Validation Comparison</h3>
<p>If the form clears when submitted, the validator decided its contents were a valid email address.</p>
<form>
<h4>No validation - not RFC-2821 compliant:</h4>
<input type="text" required placeholder="Email" role="email" />
<input type="submit" value="Submit">
@etjossem
etjossem / ImportJSONBasicAuth.js
Created August 20, 2015 20:10
Modification to ImportJSON
function ImportJSONBasicAuthentication(url, query, parseOptions, username, password) {
var fetchOptions = {
"headers" : {
"Authorization" : 'Basic ' + Utilities.base64Encode(username + ':' + password)
},
muteHttpExceptions: true
};
return ImportJSONAdvanced(url, fetchOptions, query, parseOptions, includeXPath_, defaultTransform_);
@etjossem
etjossem / html5_reverse_polyfill.css
Last active September 8, 2015 20:57
You are a horrible person.
blink {
animation-duration: 1s;
animation-name: blink;
animation-iteration-count: infinite;
animation-direction: alternate;
}
@keyframes blink {
0% {
opacity: 1;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
</style>