Skip to content

Instantly share code, notes, and snippets.

@daniel-nelson
daniel-nelson / gist:8307420
Created January 7, 2014 21:41
If the top or left edge of an Adobe Flash object in a web page is aligned on a fraction of a pixel, the camera and microphone permission buttons are unclickable. They are also (or at least used to be) unclickable when the browser window is zoomed in or out. This CoffeeScript method adjusts the offset to place the upper-left corner on an integer …
fixFlashMargin: =>
$recorder = @modalContainer().find('.asset_editor_modal_container object')
offset = $recorder.offset()
$recorder.offset
top: Math.round(offset.top)
left: Math.round(offset.left)
# https://github.com/tombigel/detect-zoom
# Apparently detect-zoom is no longer reliable
(function (con) {
// the dummy function
function dummy() {};
// console methods that may exist
for(var methods = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(','), func; func = methods.pop();) {
con[func] = con[func] || dummy;
}
}(window.console = window.console || {}));
// we do this crazy little dance so that the `console` object
// inside the function is a name that can be shortened to a single
@daniel-nelson
daniel-nelson / gist:5884463
Created June 28, 2013 12:54
troubleshooting CloudFront
Request URL:http://d2l5dw7ow11yzt.cloudfront.net/339/254/0.5-0.5/assets/images/51b24a2054b709630c000024.jpg
Response Headers:
Age: 162
Cache-Control: public, must-revalidate, max-age=2592000
Connection: keep-alive
Content-Disposition: inline
Content-Length: 0
Content-Type: image/jpeg
Date: Fri, 28 Jun 2013 11:28:58 GMT
Server: nginx/1.2.3 + Phusion Passenger 3.0.11 (mod_rails/mod_rack)
I'm not sure what the problem is, but let me present my observations:
Started with no paperclip version set and no dependencies on paperclip:
$ cat Gemfile | grep paperclip
gem 'paperclip'
$ bundle update paperclip
...
$ cat Gemfile.lock | grep paperclip
paperclip (3.2.1)
paperclip
backend example {
.host = "<%=http_endpoint%>";
.port = "<%=http_port%>";
}
backend s3 {
.host = "assets.example.me";
.port = "80";
}
backend s3staging {
.host = "stagingassets.example.me";
namespace :assets do
desc "move precompiled assets to S3"
task :move_to_s3 => :environment do
puts "finished precompiling. beginning transfer to s3..."
s3 = AWS::S3.new
bucket = s3.buckets[APP_CONFIG[:rails_assets_bucket]]
#!/bin/bash
# usage: precompile_and_deploy production|staging
#
CURRENT_GIT_BRANCH=$(git branch | grep \*)
CURRENT_GIT_BRANCH=${CURRENT_GIT_BRANCH#\** }
if [[ $1 == "-m" || $1 == "--migrate" ]]; then
MIGRATE=true
RAILS_ENV=$2
else
javascript:(function()%7Bvar%20_grid_height=20;if(window.baseliner)%7Bbaseliner.toggle();%7Delse%7Bvar%20_already_loaded=document.getElementById('baseliner-script');if(_already_loaded)%7Breturn;%7D;var%20_baseliner=document.createElement('script');_baseliner.id='baseliner-script';_baseliner.type='text/javascript';_baseliner.src='http://files.keyes.ie/baseliner-latest.min.js';document.getElementsByTagName('body')%5B0%5D.appendChild(_baseliner);var%20loadFunction=function(evt)%7Bif(window.baseliner)%7Breturn;%7D;baseliner=new%20Baseliner(_grid_height);baseliner.toggle();%7D;_baseliner.onreadystatechange=loadFunction;_baseliner.onload=loadFunction;%7D;%7D)();
@daniel-nelson
daniel-nelson / Default (OSX).sublime-keymap
Created March 22, 2012 22:09
my Sublime Text 2 keybindings (requires Vintage package)
[
{ "keys": ["ctrl+space"], "command": "exit_insert_mode",
"context":
[
{ "key": "setting.command_mode", "operand": false },
{ "key": "setting.is_widget", "operand": false }
]
},
{ "keys": ["s"], "command": "save", "context": [{"key": "setting.command_mode"}] },
@daniel-nelson
daniel-nelson / scratch2
Created February 29, 2012 18:58
Cross-domain iframe communication for modern browsers + IE8
if (typeof(window.postMessage) == 'function') {
window.frames['frame_name'].postMessage(message, '*');
} else if (typeof(window.postMessage) == 'object') {
window.setTimeout(function() {
window.frames['frame_name'].postMessage(message, '*')
}, 0);
}
if (typeof window.postMessage == 'function') {
window.removeEventListener('message', receiveMessage, false);