Skip to content

Instantly share code, notes, and snippets.

View natecavanaugh's full-sized avatar

Nate Cavanaugh natecavanaugh

View GitHub Profile
var pieChart = A.Widget.getByNode($0);
var graphic = pieChart.get("graph").get("graphic");
var width = graphic.get('width'), height = graphic.get('width');
var newWidth = width - 100, newHeight = height - 100;
var circle = graphic.addShape({type: 'circle',
width: newWidth,
height: newHeight,
x: 100,
y: 100,
fill: {color: '#ffffff'},
@natecavanaugh
natecavanaugh / carousel_fx.js
Last active August 29, 2015 14:00
Carousel FX definitions
@natecavanaugh
natecavanaugh / up.sh
Last active August 29, 2015 14:01
up function
# Convenience function for moving up levels in the path to the current working directory.
# Synopsis:
# `up [n]` moves n levels up in the directory hierarchy; default is 1.
# `up dirname` changes to the closest ancestral directory by that name, regardless of case.
# `up absolutepath` changes to the specified absolute path; primarily used with command completion (see below).
# Additionally, if command completion via _complete_up() is in effect (<tab> represents pressing the tab key):
# `up [n]<tab>` replaces n with the absolute path of the directory n levels up (default is 1).
# `up dirnameprefix<tab>` replaces dirnameprefix with the absolute path of the closest ancestral directory whose name starts with the specified name prefix, terminated with '/'.
# Whether dirnameprefix is matched case-insensitively or not depends on whether case-insensitive command completion is turned on globally via ~/.inputrc or /etc/inputrc.
# In both cases the completed absolute path ends in '/',
$breakpoint_phone: 768px !default;
$breakpoint_tablet: 980px !default;
@mixin respond-to($types...) {
$maxWidth: -1;
$minWidth: -1;
@each $type in $types {
@if $type == phone {
$maxWidth: if($maxWidth == -1, $breakpoint_phone - 1, $maxWidth);

Possible jQuery plugins

I'm contemplating two new jQuery plugins, but wanted some feedback, both on the implementation, as well as if it's worth doing.

Here are the two pieces of functionality/problems I'm hoping to address (and they're somewhat related):

Problem/Feature 1

YUI has a feature in Nodes and NodeLists with .get. It supports both:

@natecavanaugh
natecavanaugh / Default.sublime-commands
Last active August 29, 2015 14:10
Splitting CSS into structure and skin sections using Sublime Text
[
{
"caption": "Reg Replace: Clean Skin",
"command": "reg_replace",
"args": {"replacements": ["css_comment_skin_properties", "css_comment_skin_properties_borders", "css_comment_skin_mixins", "css_remove_uncommented_properties", "css_remove_comment_from_property", "css_remove_empty_class_rule", "css_reduce_new_lines"]}
},
{
"caption": "Reg Replace: Clean Structure",
"command": "reg_replace",
"args": {"replacements": ["css_comment_skin_properties", "css_comment_skin_properties_borders", "css_comment_skin_mixins", "css_remove_commented_properties", "css_remove_empty_class_rule", "css_reduce_new_lines"]}
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@natecavanaugh
natecavanaugh / Liferay Build System.sublime-build
Last active August 29, 2015 14:19
Build system for sublime, runs ant deploy-fast when modifying something in portal-web, and ant deploy when modifying something in modules/apps
{
"shell_cmd": "ant deploy${file/.*((.*\\/portal-web\\/)|(\\/modules\\/)).*/(?2-fast:)/}",
"working_dir": "${file/(.*(\\/portal-web\\/|((\\/modules\\/([^\\/]+)\\/)([^\\/]+)\\/)))?.*/$1/}"
}
@natecavanaugh
natecavanaugh / MyComponent.js
Last active August 29, 2015 14:20
SoyComponent Error Example
import core from 'metaljs/src/core';
import dom from 'metaljs/src/dom/dom';
import SoyComponent from 'metaljs/src/soy/SoyComponent';
import ComponentRegistry from 'metaljs/src/component/ComponentRegistry';
import './MyComponent.soy.js';
class MyComponent extends SoyComponent {
constructor(opt_config) {
super(opt_config);
}
@natecavanaugh
natecavanaugh / mass_create_6.1.x.js
Last active September 26, 2015 06:07
Quickly add a lot of tags or categories to a Liferay instance (updating for 6.2)
AUI().use(
'liferay-service', 'json', 'async-queue',
function(A) {
var states = [['AL', 'Alabama', 'The Heart of Dixie'], ['AK', 'Alaska', 'The Land of the Midnight Sun'], ['AZ', 'Arizona', 'The Grand Canyon State'], ['AR', 'Arkansas', 'The Natural State'], ['CA', 'California', 'The Golden State'], ['CO', 'Colorado', 'The Mountain State'], ['CT', 'Connecticut', 'The Constitution State'], ['DE', 'Delaware', 'The First State'], ['DC', 'District of Columbia', "The Nation's Capital"], ['FL', 'Florida', 'The Sunshine State'], ['GA', 'Georgia', 'The Peach State'], ['HI', 'Hawaii', 'The Aloha State'], ['ID', 'Idaho', 'Famous Potatoes'], ['IL', 'Illinois', 'The Prairie State'], ['IN', 'Indiana', 'The Hospitality State'], ['IA', 'Iowa', 'The Corn State'], ['KS', 'Kansas', 'The Sunflower State'], ['KY', 'Kentucky', 'The Bluegrass State'], ['LA', 'Louisiana', 'The Bayou State'], ['ME', 'Maine', 'The Pine Tree State'], ['MD', 'Maryland', 'Chesapeake State'], ['MA', 'Massachusetts', 'The Spirit of America'], ['MI', 'M