Skip to content

Instantly share code, notes, and snippets.

View ashrewdmint's full-sized avatar

Andrew Smith ashrewdmint

View GitHub Profile
@ashrewdmint
ashrewdmint / keypress-censor.js
Created February 17, 2011 21:55
jQuery keypressCensor
$.fn.keypressCensor = function(match) {
var regex = match ? match : /[^0-9]/;
$(this).keypress(function(e){
var keyCode = e.keyCode || e.charCode;
var key = String.fromCharCode(keyCode);
if (key.match(regex) && ! (e.ctrlKey || e.metaKey)) {
e.preventDefault();
}
});
$.fn.linkHeight = function(target) {
var el = $(this);
target = $(target);
var padding = parseInt(el.css('padding-top'), 10) + parseInt(el.css('padding-bottom'), 10);
function updateHeight() {
el.height('auto');
var targetHeight = target.outerHeight() - padding;
if (targetHeight > el.height()) {
el.height(targetHeight);
function viddlerVideoSwitch(objectElement, newId) {
viddlerVideoInterface(objectElement, function(movie){
movie.setMovie(videoId, true);
}, function(video){
video = $(video);
var src = video.attr('src');
var poster = video.attr('poster');
var oldId = src.match(/file\/([^\/]+)\/html5/)[1];
var oldIdRegexp = new RegExp(oldId);
video.attr('src', src.replace(oldIdRegexp, newId));
require 'time'
name = "Andrew"
wake_up_time = "5:30am"
tomorrow = Time.now
tomorrow -= tomorrow.hour * 60 * 60
tomorrow -= tomorrow.min * 60
tomorrow += 60 * 60 * 24
Vjsp.getStyle = function(element, property, toInt) {
var result = element.style[property];
if (! result) {
if (element.currentStyle) {
result = element.currentStyle[property];
} else if (window.getComputedStyle) {
// Convert to dash-case
property = property.replace(/([A-Z])/g,"-$1").toLowerCase();
result = document.defaultView.getComputedStyle(element, null).getPropertyValue(property);
@ashrewdmint
ashrewdmint / webkit-redraw-bug.html
Created October 15, 2010 22:48
WebKit Video Overlay Redraw Bug
<!DOCTYPE html>
<html>
<head>
<title>WebKit Bug</title>
<style type="text/css">
#container { position: relative; width: 800px; }
#controls { position: absolute; bottom: 0; left: 0; width: 100%; }
#controls, #controls * { height: 30px; }
#bar-outer { background: black; }
#bar-inner { position: absolute; background: red; width: 20px; }
class NameNotUnique < StandardError; end
class Name
attr_reader :name
def initialize(name)
set_name(name)
end
def ==(another_name)
name == another_name.to_s
class Me
include Parent
def use_swimming_pool
puts "This pool is so refreshing!"
end
def go_on_vacation
expose :use_swimming_pool
end
Copyright (c) 2010, Andrew Smith
This software is a copy of software that I wrote, but it is not "my"
software, it is your software, because it resides on your computer.
Therefore, you may do what you want with it, not because I said so,
but because you own your computer.
I have no right to dictate to you what you may or may not do with
your computer, therefore I have no right to dictate to you what you
may or may not do with a copy of software that I wrote which is on
**********************************************************************
APERTURE SCIENCE
ASSET PACKAGING AND CAKE DELIVERY SYSTEM
"We Do What We Must, Because We Can"™
**********************************************************************
Copying /source to /public
Compiling compass
exists css
unchanged style.sass