Skip to content

Instantly share code, notes, and snippets.

@amycheng
amycheng / cleanFormJS.js
Created October 23, 2012 17:29
cleanest jQuery I've ever writtern
$formField.click(function(){
var $_this= $(this);
$_this
.css('opacity','1')
.find('input').removeAttr('disabled');
$_this.siblings()
.css('opacity','.5')
.find('input').attr('disabled','disabled');
});
@amycheng
amycheng / placeholderfallback
Created January 29, 2013 22:03
polyfill for placeholder
$(function() {
function isPlaceholderSupported() {
var input = document.createElement("input");
return ('placeholder' in input);
}
var placeholdersupport = isPlaceholderSupported();
if (placeholdersupport == false) {
// If there is no placeholder support,
@amycheng
amycheng / transitionEnd.js
Created April 30, 2013 22:29
a simple jQuery plugin for creating callbacks for CSS3 transitions
$.fn.transitionEnd = function(callback) {
//plugin for detecting the end of a transition and then doing a callback
$(this).one('webkitTransitionEnd otransitionend msTransitionEnd transitionend',
function(e) {
if (typeof callback == 'function') {
callback.call(this);
}
});
};
@amycheng
amycheng / cookie.js
Created May 10, 2013 15:37
methods for creating/reading/erasing cookies via JS
@amycheng
amycheng / inView
Created August 22, 2013 21:10
a javascript function to check if a html element is in view
function inView(el){
//check if a DOM element is in view
var scrollDistance=document.body.scrollTop;
if (scrollDistance>=el.offsetTop&&scrollDistance<el.offsetHeight+el.offsetTop) {
return true;
}else{
return false;
}
}
@amycheng
amycheng / analysis of BOX.md
Last active December 23, 2015 22:19
a guess at how the BOX performance works

A quick and dirty technology dissection of BOX

The installation/performance in question: http://www.botndolly.com/box .

Bot and Dolly (the firm behind this performance/installation) will will apparently release a post-mortem at some point but here's a quick dissection of the tech.

A big part of this performance is video/projection mapping (mapping animations and graphics to physical objects that aren't necessarily a screen).

MadMapper (http://www.madmapper.com/) seems to be the app of choice to getting started with projection mapping really quickly is (it's expensive tho).

@amycheng
amycheng / form-validation.js
Created October 18, 2013 20:17
A jQuery plugin for form validation. Use for e-mail, message text fields, as well as check boxes and radio buttons.
/*General Purpose Form Validation*/
(function($) {
$.fn.validateForm = function() {
var $form = $(this),
$submit = $form.find('button[type="submit"]'),
$messages = $('.form-messages[data-target="'+$form.attr('id')+'"]'),
successMessage = $form.attr('data-message'),
$requiredFields = $form.find('[data-required="true"]'),
@amycheng
amycheng / shellcommands.sh
Last active January 1, 2016 11:19
Useful Shell commands because I always have to google them!
# copy folders from remote to local
# use '/' for absolute directories
scp -r /path/to/source /path/to/destination
scp -r source login@address:/destination
# delete folder and files within that folder
rm -rf -- <dir-to-remove>
@amycheng
amycheng / phpunit_tips.php
Created January 29, 2015 17:04
PHPunit tips
//to print to the command line during a test
fwrite(STDERR, print_r("comment", TRUE));
//to use CLI colors
phpunit --colors
@amycheng
amycheng / present_relief.txt
Created August 6, 2015 00:23
Present Relief, a cyborg poem
"A glass of wine; shall I get you one? You are very ill."
And so I let down the side-glass next to him
and took faintness
full of something
a glass of it
I talk, and arranged, and wrapped myself up without opening
for whatever