Skip to content

Instantly share code, notes, and snippets.

View walterdavis's full-sized avatar

Walter Lee Davis walterdavis

View GitHub Profile
[paperclip] copying assets/blobs/000/011/848/original/Sting_CB_Bounce_Blue.mov to local file /tmp/Sting_CB_Bounce_Blue20140730-24289-1vunrv7.mov
Sting_CB_Bounce_Blue.mov
[paperclip] [ffmpeg] ffmpeg -i "/tmp/Sting_CB_Bounce_Blue20140730-24289-1vunrv7.mov" 2>&1
[paperclip] [ffmpeg] Command Success
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jQuery Without Duplication</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript" charset="utf-8"></script>
</head>
// get a reference to all of the thumbnails
var thumbnails = $$('#thumbnails img');
// listen for a click on one of them
document.on('click', '#thumbnails img', function(evt, elm){
// remove the highlight from the current element
thumbnails.invoke('removeClassName', 'active');
// insert a copy of the selected image in the main area
$('main').update(elm.clone(true));
// highlight the new current thumbnail
elm.addClassName('active');
document.on('click', 'input[name="commit"]', function(evt, elm){
var f = elm.up('form');
fake_progress = new Element('div', {className: 'progress progress-striped active', style: 'width: 100%; clear:both'});
f.insert({before: fake_progress});
var bar = new Element('div', {className: 'bar'});
fake_progress.insert(bar);
bar.setStyle('width: 2%');
var rnd = 0.2
function add_random(){
rnd = Math.random();
<?php
$rows = 106;
function seek_row_count($rows, $target = 35){
$result = $rows % $target;
if($result == 0 || $result > 1) return $target;
return seek_row_count($rows, --$target);
}
print seek_row_count($rows, 35);
?>
private function decode_fluency($record){
$values = array('' => 0, 'none' => 0, 'basic' => 1, 'functional' => 2, 'fluent' = 3);
$read = $values[$record['can_read']];
$write = $values[$record['can_write']];
$speak = $values[$record['can_speak']];
$this->can_read = ($read > 0);
$this->can_write = ($write > 0);
$this->can_speak = ($speak > 0);
$this->can_understand_spoken = ($speak > 2); //speak is fluent
$this->can_peer_review = ($read == 3 && $write >= 2); //read is fluent & write is fluent/functional
@walterdavis
walterdavis / application.rb
Created May 3, 2015 18:06
When you have an Asset model...
Rails.application.config.assets.prefix = '/the-other-assets'