Skip to content

Instantly share code, notes, and snippets.


Nate Cavanaugh natecavanaugh

View GitHub Profile
View get_dl_file_entry.ftl
<#assign dlFileEntryService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService")/>
<#if entries?has_content>
<#list entries as entry>
<#assign assetRenderer = entry.getAssetRenderer()>
<#assign title = htmlUtil.escape(assetRenderer.getTitle(locale))>
<#if assetRenderer.getType() == "document">
<#assign fileEntryId = assetRenderer.getClassPK()>
<#assign fileEntry = dlFileEntryService.getFileEntry(fileEntryId)>
natecavanaugh / amirunningliferay_chrome.js
Created Jan 29, 2019
Am I Running Liferay (TamperMonkey)
View amirunningliferay_chrome.js
// ==UserScript==
// @name Am I Running Liferay?
// @namespace
// @include *
// @connect *
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// ==/UserScript==
var createBanner = function () {
natecavanaugh / Lexicon Icon Design
Last active Nov 6, 2019
The Lexicon icon design process and guidelines for designers and developers
View Lexicon Icon Design

Lexicon Icon Design Guidelines

Note: These guidelines do not apply to the Language Flag Icons, which should have their own guidelines


The rules below are mainly there for a few reasons:

  1. To make it easier to communicate to developers what an icon's purpose and naming should be
  2. To make it easier for Liferay's theme developers to be able to customize the look and feel of the icon set from a theme
  3. To make sure that the icons delivered are as fast to load and cruft-free as possible
View JSX.js
'use strict';
import { Component, ComponentRegistry } from 'metal-component';
import IncrementalDomRenderer from 'metal-incremental-dom';
export default EnhanceJSX = ComposedComponent => {
class EnhancedComponent extends Component {
render() {
natecavanaugh /
Last active Nov 12, 2015
Create a cursory changelog from a git log
# Generates a cursory changelog from all tags in a git log
# All params are optional. If the from param is empty,
# it will create a changelog from all tags
# @param from - the tag or git commit to start from
# @param to - the tag or git commit to end at
# @param title - a title to give the log if specifying the previous options
function generate_changelog {
local changes hash log log_title tag tags prev from="$1" to="$2" title nl=$'\n';
natecavanaugh / MyComponent.js
Last active Aug 29, 2015
SoyComponent Error Example
View MyComponent.js
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 './';
class MyComponent extends SoyComponent {
constructor(opt_config) {
natecavanaugh / Liferay Build System.sublime-build
Last active Aug 29, 2015
Build system for sublime, runs ant deploy-fast when modifying something in portal-web, and ant deploy when modifying something in modules/apps
View Liferay Build System.sublime-build
"shell_cmd": "ant deploy${file/.*((.*\\/portal-web\\/)|(\\/modules\\/)).*/(?2-fast:)/}",
"working_dir": "${file/(.*(\\/portal-web\\/|((\\/modules\\/([^\\/]+)\\/)([^\\/]+)\\/)))?.*/$1/}"
# Alot of these configs have been taken from the various places
# on the web, most from here
# Set the colours you can use
natecavanaugh / Default.sublime-commands
Last active Aug 29, 2015
Splitting CSS into structure and skin sections using Sublime Text
View Default.sublime-commands
"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"]}

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:

You can’t perform that action at this time.