Skip to content

Instantly share code, notes, and snippets.

@kara-ryli
kara-ryli / yui3-serialize-form.js
Created February 18, 2011 02:26
Serialize a form into a query string with YUI3
YUI().use('node', 'array-extras', 'querystring-stringify', function (Y) {
var form = Y.one('FORM_SELECTOR'), query;
query = Y.QueryString.stringify(Y.Array.reduce(Y.one(form).all('input[name],select[name],textarea[name]')._nodes, {}, function (init, el, index, array) {
init[el.name] = el.value;
return init;
}));
console.log(query);
});
@kara-ryli
kara-ryli / date-ago.js
Created March 30, 2011 20:33
YUI module for calculating the time ago in words in English. Updated from the Prototype version and optimized for compressor.
YUI.add('date-ago', function (Y) {
function round(value) {
return Math.round(value);
}
function distanceOfTimeInWords(from_time, to_time, include_s) {
var include_seconds, distance_in_minutes, distance_in_seconds;
include_seconds = include_s || false;
distance_in_minutes = round(Math.abs(to_time - from_time) / 60000);
@kara-ryli
kara-ryli / loader-config.html
Created April 5, 2012 02:45
FIXME: Configure loader to work correctly with multiple CDNs and a third-party hosted YUI
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Loader Test</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Ryan Cannon">
<script src="http://www.nfl.com/yui/3.4.1/build/yui/yui-min.js"></script>
<script>
var YUI_config = {
YUI.add('handlebars-helpers', function(Y) {
var NS = Y.namespace('TDP'),
Handlebars = Y.Handlebars,
Lang = Y.Lang,
isString = Lang.isString,
isArray = Lang.isArray,
isObject = Lang.isObject,
isFunction = Lang.isFunction,
Aeach = Y.Array.each,
@davglass
davglass / gist:4675460
Created January 30, 2013 18:26
Local Gallery Loading.
YUI.applyConfig({
groups: {
gallery: {
combine: false,
root: '/build/',
patterns: {
'gallery-': { },
'lang/gallery-': {},
'gallerycss-': { type: 'css' }
}
@josephj
josephj / key-event-with-swf.html
Last active December 14, 2015 10:49
SWF swallows any JavaScript key events while it's focused. This demo illustrates how to make key events always work while SWF exists on page.
<!DOCTYPE html>
<html>
<head>
<title>SWF & JavaScript Key Event</title>
<style>
#focusable-link {
position: absolute;
left: -1000em;
top: -1000em;
}
@djangofan
djangofan / endorsedmethod.java
Last active January 6, 2023 22:05
Exercise on safely waiting for unstable web elements with WebDriver.
// This is the official Selenium documention endorsed method of waiting for elements.
// This method is ineffective because it still suffers from
// the stale element exception.
public static void clickByLocator ( final By locator ) {
WebElement myDynamicElement = ( new WebDriverWait(driver, 10))
.until( ExpectedConditions.presenceOfElementLocated( locator ) );
myDynamicElement.click();
}
@anildigital
anildigital / gist:862675ec1b7bccabc311
Created July 26, 2014 18:27
Remove dangling docker images
docker rmi $(docker images -q -f dangling=true)
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active June 17, 2024 15:05
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@wavezhang
wavezhang / java_download.sh
Last active July 19, 2024 13:45
download java from oracle without login
wget -c --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/12.0.2+10/e482c34c86bd4bf8b56c0b35558996b9/jdk-12.0.2_linux-x64_bin.tar.gz