Skip to content

Instantly share code, notes, and snippets.

View gscottolson's full-sized avatar

G. Scott Olson gscottolson

  • Microsoft
  • California
View GitHub Profile
/**
* Add ipad IOS7 Classes
* Allows us to temporariliy try to fix the slight scroll 100% hack.
* http://stackoverflow.com/questions/19012135/ios-7-ipad-safari-landscape-innerheight-outerheight-layout-issue
*/
if (navigator.userAgent.match(/iPad;.*CPU.*OS 7_\d/i)) {
$('html').addClass('ipad ios7');
}
/**
@gscottolson
gscottolson / css.coffee
Created July 1, 2014 20:53
React CSSMixin: vendor prefixed properties
module.exports = CSSMixin =
#
# Return the object containing the inline styles for `property` with
# vendor prefixes. Can be used with React inline styles:
# http://facebook.github.io/react/tips/inline-styles.html
#
getVendorPrefixedProperties: (property, value) ->
capitalizedProperty = "#{property.charAt(0).toUpperCase()}\
#{property.slice(1)}"
@gscottolson
gscottolson / gist:4b859ccdbd57b77de5d7
Created August 7, 2015 17:13
Convert MOV to Animated GIF
mkdir ./pngs
ffmpeg -i src.mov -r 10 ./pngs/out%04d.png
mkdir ./gifs
sips -s format gif .pngs/*.png --out ./gifs
gifsicle ./gifs/* --optimize=3 --loopcount --colors 256 --resize 375x667 > ./animation.gif
@gscottolson
gscottolson / string.shorten.js
Created January 17, 2012 21:53
Shorten a long string of HTML to a predetermined length and append with '...'
String.prototype.shorten = function( length ) {
//shorten a string while minding the possible HTML markup within
var original = this.toString()
, length = length || 500
, tagRE = /<\/?\w+(\s+\w+="?[^>]*"?)*\s*>/g
, openTagRE = /<[^>\/]*([^\/]*>)/g
, closeTagRE = /<[\/]([^\/]*>)/g
, pipeRE = /\|/
, tag = ''
, tags = original.match( tagRE )
# If browser doesn't support placeholders, take the placeholder text and set it as the field's value
unless Modernizr.input.placeholder
$("input[placeholder]").each (index, element)->
unless $(element).val()
$(element).val($(element).attr("placeholder"))
@gscottolson
gscottolson / index.html
Last active December 10, 2015 21:48
A CodePen by Hjörtur Hilmarsson. CoverFlow - CoverFlow built with CSS3 and a small doze of JavaScript
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>CSS3 CoverFlow</title>
<link rel="stylesheet" href="css/coverflow.css">
@gscottolson
gscottolson / Preferences.sublime-settings
Created December 19, 2013 14:18
My latest settings file Sublime Text 2
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"auto_complete_with_fields": true,
"bold_folder_labels": true,
"caret_style": "phase",
"detect_indentation": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
import * as Ensure from '../../../../utils/lib/Ensure'
import markdownBlockDelimiter from './markdownBlockDelimiter'
import {BlockTypes, BlockTypeRegExps} from './Types'
import {
CharacterMetadata,
ContentState,
ContentBlock,
EditorState,
genKey,
} from 'draft-js'
# this functionality relies on Moment.js 2.0.0
# http://momentjs.com/docs/
$scheduleSelects = $('.schedule__select')
$scheduleYear = $('.schedule__year')
$scheduleMonth = $('.schedule__month')
$scheduleDay = $('.schedule__day')
$scheduleHour = $('.schedule__hour')
$scheduleMinute = $('.schedule__minute')
$scheduleReset = $('.schedule__reset')