Skip to content

Instantly share code, notes, and snippets.

@ryanburnette
ryanburnette / jquery.shrunkfit.js
Created December 2, 2013 03:19
An old script for squeezing in formatted text that I need to rewrite.
(function( $ ){
$.fn.shrunkFit = function( options ) {
return this.each(function() {
var settings = $.extend({
'increment' : 0.05,
'throttle' : 25
}, options);
@ryanburnette
ryanburnette / slim-html5-boilerplate-ish
Last active January 1, 2016 20:48 — forked from blakehilscher/slim-html5-boilerplate
It's HTML5 Boilerplate(ish) ... in Slim.
doctype html
html.no-js
head
meta charset="utf-8"
meta content="IE=edge" http-equiv="X-UA-Compatible"
title Title
meta content="width=device-width,initial-scale=1" name="viewport"
@ryanburnette
ryanburnette / echo.js
Created January 2, 2014 19:52 — forked from nazgob/hello_node.js
A little node server that just gives your request back to you as JSON.
var http = require('http')
, sys = require('sys')
, server
;
server = http.createServer(function(req, res) {
var echo = {}
;
echo.headers = JSON.stringify(req.headers, true, 2);
@ryanburnette
ryanburnette / _tables.scss
Created January 5, 2014 17:28
A tables template based on Bootstrap tables.
//
// Tables
// --------------------------------------------------
// Bootstrap tables tweaked to work standalone
// Variables
$body-bg: $white;
$table-bg: $white;
$line-height-computed: 1rem;
@ryanburnette
ryanburnette / jquery.be-smart-about-targets.js
Last active January 2, 2016 10:19
Be smart about targets. Use jQuery to add target="_blank" when the destination is not part of the current site.
function () {
$('a[href^="http://"], a[href^="https://"]')
.not('a[href*="' + window.location.hostname + '"]')
.attr('target','_blank')
;
};
@ryanburnette
ryanburnette / header.html
Last active August 29, 2015 13:55
Two versions of jQuery in a restrictive situation.
<!-- At this point our environmental jQuery should have already loaded, we'll
assign it to a separate variable on the window and delete the dollar sign -->
<script>
window.jQuery142 = window.jQuery;
delete window.$;
</script>
<!-- Next, we'll load our next version of jQuery -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
// Jekyll Pygments syntax highlighter styles
// Colors
$default: #FFFFFF
$background: #010101
$comment: #586E75
$error: #586E75
$generic: #93A1A1
$keyword: #859900
$literal: #93A1A1
@ryanburnette
ryanburnette / setnow.jquery.js
Last active May 31, 2017 16:32
A jQuery method that sets datetime fields to the current UTC time.
$.fn.setNow = function (onlyBlank) {
var now = new Date($.now());
var year = now.getFullYear();
var month = (now.getMonth() + 1).toString().length === 1 ? '0' + (now.getMonth() + 1).toString() : now.getMonth() + 1;
var date = now.getDate().toString().length === 1 ? '0' + (now.getDate()).toString() : now.getDate();
var hours = now.getHours().toString().length === 1 ? '0' + now.getHours().toString() : now.getHours();
var minutes = now.getMinutes().toString().length === 1 ? '0' + now.getMinutes().toString() : now.getMinutes();
var seconds = now.getSeconds().toString().length === 1 ? '0' + now.getSeconds().toString() : now.getSeconds();
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json')
, coffeelint: {
app: ['./assets/javascripts/**/*.coffee']
}
module ApplicationHelper
# get the name of the current layout in views
# http://stackoverflow.com/a/9438314/2535178
def current_layout
layout = controller.send(:_layout)
if layout.instance_of? String
layout
else
File.basename(layout.identifier).split('.').first
end