Skip to content

Instantly share code, notes, and snippets.

View jimjeffers's full-sized avatar

Jim Jeffers jimjeffers

View GitHub Profile
@jimjeffers
jimjeffers / html5VideoAspectRatioAdjustment.coffee
Created September 15, 2011 13:24
Breaking the HTML5 Video Aspect Ratio
# Just an example.
# @video is a direct reference to a '<video>' element.
# $() is assuming jQuery is being used in this example.
@video.addEventListener("loadedmetadata", (event) =>
actualRatio = @video.videoWidth/@video.videoHeight
targetRatio = $(@video).width()/$(@video).height()
adjustmentRatio = targetRatio/actualRatio
$(@video).css("-webkit-transform","scaleX(#{adjustmentRatio})")
)
@jimjeffers
jimjeffers / dabblet.css
Created February 17, 2012 23:26
CSS3 Gradient Pixel/Percentage Mix-n-Match Example
/**
* CSS3 Gradient Pixel/Percentage Mix-n-Match Example
*/
background: #f06;
background: linear-gradient(left, #f00 10px, #444 20px, #3465a4 21px, #203388 10rem, #204a87 100%);
min-height:100%;
background: #426fa9;
@jimjeffers
jimjeffers / gist:1043333
Created June 23, 2011 19:05
Apple's Elastic CSS Animations
<!DOCTYPE html>
<html>
<head>
<!-- Apple nicely commented all of these transitions on their source file:
http://images.apple.com/global/styles/productbrowser.css -->
<style type="text/css" media="screen">
/* Just some basic presentational CSS for the example */
a {
background: #000; display: block; color: #fff;
font: 1.5em "Lucida Grande", "Trebuchet MS", Verdana, sans-serif;
@jimjeffers
jimjeffers / noise.coffee
Created May 22, 2011 18:11
Generate noise with Canvas.
# Inspired and largely borrowed from Pixstatic
# http://www.pixastic.com/lib/git/pixastic/actions/noise.js
# https://github.com/jseidelin/pixastic
# And NetTuts tutorial:
# http://blip.tv/nettuts/how-to-generate-image-noise-with-canvas-4439977#EpisodeDescription
# http://net.tutsplus.com/tutorials/javascript-ajax/how-to-generate-noise-with-canvas/
window.Noise = class Noise
constructor: ->
const handleCompletedUploaded: HandleFileUploadFn = useCallback(async preview => {
const normalizedPreviews = mergePreviewsToState([{ ...preview, status: FileUploadStatus.Available }], localPreviews)
setLocalPreviews(normalizedPreviews)
await savePreviews(normalizedPreviews)
}, [mergePreviewsToState, localPreviews, setLocalPreviews])
// Track a completed download and use an effect to update the status
// of the associated upload via the latest component state.
const [finishedDownload, setFinishedDownload] = useState(null as string | null)
useEffect(() => {
if (!finishedDownload) { return }
const updatedPreview = localPreviews[finishedDownload]
if (localPreviews[finishedDownload].status !== FileUploadStatus.Available) {
const normalizedPreviews = mergePreviewsToState([{ ...updatedPreview, status: FileUploadStatus.Available }], localPreviews)
setLocalPreviews(normalizedPreviews)
const save = async () => {
const [localPreviews, setLocalPreviews] = useState({} as INormalizedPreviews)
const handleCompletedUploaded: HandleFileUploadFn = async preview => {
const normalizedPreviews = mergePreviewsToState([{ ...preview, status: FileUploadStatus.Available }], localPreviews)
setLocalPreviews(normalizedPreviews)
}
@jimjeffers
jimjeffers / forecasts.xml
Created February 21, 2018 17:58
Proposed forecast schema.
<?xml version="1.0" encoding="UTF-8"?>
<data>
<time>9:12 AM</time>
<forecaster>M. Graves</forecaster>
<discussion>This week will be winter-like in Yuma as cold air remains settled over the region; High temperatures will stay in the low-mid 60s. Normal for this time of year is 75 degrees F. The main day of interest this week is Friday, on which breezy winds out of the northwest are forecast. Blowing dust may be possible on Friday and therefore the PM-10 (dust) forecast has been bumped up into the Moderate Air Quality (AQI) category to reflect this. PM-10 may increase again on Sunday with breezy northerly winds as well. Ozone is forecast to stay in the Good AQI category through this forecast period. We'll keep an eye out for any changes in the wind forecast later this week.<br/><br/>Check back tomorrow for the next Yuma air quality forecast.</discussion>
<forecasts>
<forecast>
<date>2/21/2018</date>
<day>WED</day>
<aqivalue>46</aqivalue>
<body>
<svg id="map" xmlns:xlink="http://www.w3.org/1999/xlink" width="671" height="367">
<g>
<g id="states">
<a id="s01" class="<?php the_field('al_legal'); ?>" href="http://dispensarypermits.com/united-states-marijuana-dispensary-laws/open-a-dispensary-in-alabama/">
<path d="M446.5848460941517,216.26501324764592L464.81286038377675,214.2603543573807L468.10323765853497,225.08860445900154L472.8937074082319,241.00178951997543L474.61008720683344,244.42048722827803L476.0625626818386,246.29743631830007L475.76722830026273,247.62689856030931L477.10805089685584,248.22910918121545L475.5070201786913,250.09623188502263L475.7873316078113,251.70362228164615L475.13993857965056,254.0096380222493L476.7334995824955,257.72478632149034L476.4216558002466,261.1981977477231L478.0945121552954,264.54108080067283L472.72709714484995,265.33683005517673L449.7452897425235,268.119261782702L449.57058192002177,269.8466738984158L452.3066137029198,272.0345007925466L452.1205917477962,274.1896880002505L453.08275860861545,275.148983180
@jimjeffers
jimjeffers / a_starting_point
Created November 26, 2011 06:34
Server Bootstrap
# To use this script run:
curl -O https://raw.github.com/gist/1395181/d9147fd2aa0ca24ec609c188438d1eec60f8ffb4/bootstrap.sh; chmod +x bootstrap.sh; sudo ./bootstrap.sh
# Also the script assumes a group with admin privileges
# called admin already exists. If it does not you may want
# to check by running visudo:
#
# Create sudo group:
# (may not be necessary LTS now has admin group by default)
visudo