Skip to content

Instantly share code, notes, and snippets.

View natecavanaugh's full-sized avatar

Nate Cavanaugh natecavanaugh

View GitHub Profile
@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
@natecavanaugh
natecavanaugh / open-alias.gitconfig
Created July 5, 2011 04:12
Alias to open a set of files in a commit
open = "!f() { editor=`git config --get user.editor`;files=`git show --pretty="format:" --name-only $1`;useopen=`command -v open`; usecygwin=`command -v cygstart`; [[ -n "$useopen" ]] && open -a $editor $files && exit $?; [[ -n "$usecygwin" ]] && editor=$(cygpath -d "$editor"); for i in $files; do echo "opening $i"; $usecygwin $editor $i; done }; f"
@natecavanaugh
natecavanaugh / gist:1186775
Created September 1, 2011 17:52
filter options
{
replaceStr: function(match, fragment, string) {
return fragment + 'm=' + (match.split('<%= javaScriptRootPath %>')[1] || '');
},
searchExp: '(\\?|&)/([^&]+)'
};
@natecavanaugh
natecavanaugh / prefix.js
Created September 26, 2011 19:21
Prefix suffix generation
var BUFFER_PREF_SUFF = [];
A.mix(
LString,
{
prefixFn: A.cached(
function(prefix) {
var instance = this;
return A.rbind('suffix', LString, prefix);
@natecavanaugh
natecavanaugh / liferay_form_bind.js
Created October 4, 2011 00:29
Possible method for handling Liferay's namespaced form elements
Liferay.Form.bind = function(ns, fm) {
var form = document[ns + (fm || 'fm')], formNode = A.one(form);
return function(id) {
return id ? A.one(form[ns + id]) : formNode;
};
};
fm = Liferay.Form.bind('_174_');
fm('toggle_id_users_admin_user_searchkeywords')
RESOLVE = function() {
var seen = {};
var resolved = {};
var aui_mods = YUI.AUI_config.groups.alloy.modules;
var yui_mods = YUI.Env[YUI().version].modules;
var A = AUI();
var all_mods = A.merge(aui_mods, yui_mods);
var mods = all_mods;
// var mods = aui_mods;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
@natecavanaugh
natecavanaugh / .gitconfig
Created November 16, 2011 23:09
Alias for 'git split'
# Paste this line into your .gitconfig
split = "!f() { git checkout -b $2 && msg=$(git stash save) && git checkout - && git reset --hard $1 && git checkout $2 && [[ ! $msg =~ ^'No local changes to save'$ ]] && git stash pop; }; f"
# move all commits after the SHA to a new branch
# use case: I accidentally make a bunch of commits into my master branch for a specific feature.
# I want to split off a feature branch and reset my current branch to some point in time before my changes.
# usage
# git split SHA NEW_BRANCH_NAME
@natecavanaugh
natecavanaugh / liferay.js
Created December 7, 2011 22:59
Liferay Service changes
Liferay = window.Liferay || {};
;(function(A, Liferay) {
var Lang = A.Lang;
Liferay.namespace = A.namespace;
A.mix(
AUI.defaults.io,
{
@natecavanaugh
natecavanaugh / custom_css_class.js
Created January 10, 2012 21:08
Liferay - set custom css class from theme
//replace LINK_ID
//Add this to your theme vm
<div id="LINK_ID">
<a href="javascript:;" data-customCssClass="red">Red</a>
<a href="javascript:;" data-customCssClass="blue">Blue</a>
<a href="javascript:;" data-customCssClass="green">Green</a>
</div>
//Add this to your JS somewhere