Skip to content

Instantly share code, notes, and snippets.

Avatar

Saulo Venancio saulovenancio

View GitHub Profile
@saulovenancio
saulovenancio / clean_code.md
Created Apr 12, 2020 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin
View clean_code.md

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@saulovenancio
saulovenancio / component.html
Created Dec 30, 2019 — forked from kevinweber/component.html
HTL/Sightly: "Use and call template" pattern. Put template into separate file for reusability, and pass parameters when calling it. Note that in most cases it's not necessary to pass "properties" to the template because they work even if they're not passed explicitly.
View component.html
<sly data-sly-use.component="template.html"
data-sly-call="${component.template @ properties=properties}" />
View Generic List Usage Author dialog Touch and classic
from: https://adobe-consulting-services.github.io/acs-aem-commons/features/generic-lists.html
Touch
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
fieldLabel="Social Service"
name="./social">
<datasource
View aemTouchUIValidation.js
var $input = $('.my-input-field'),
errorMessege = 'This field is required';
if ($input.willValidate()) {
$input.checkValidity(); // true
$input.validationMessage(); // ''
/* Set input field as invalid */
$input.setCustomValidity(errorMessage);
$input.checkValidity(); // false
View demo.less
// USE
.font-face(Ubuntu-Regular, 'https://dl.dropbox.com/u/1220078/ubuntu-new/Ubuntu-Regular-webfont', 400, normal);
.font-face(Ubuntu-Italic, 'https://dl.dropbox.com/u/1220078/ubuntu-new/Ubuntu-Regular-Italic-webfont', 400, italic);
.font-face(Ubuntu-Bold, 'https://dl.dropbox.com/u/1220078/ubuntu-new/Ubuntu-Bold-webfont', 700, normal);
.test {
.font(Ubuntu-Regular, 1em, normal, normal);
h1 {
.font(Ubuntu-Bold, 1.7em, bold, normal);
}
View buttongroup.xml
<alignment jcr:primaryType="nt:unstructured"
name="./alignChildren"
fieldLabel="Alignment of components"
required="{Boolean}true"
selectionMode="single"
sling:resourceType="granite/ui/components/coral/foundation/form/buttongroup">
<items jcr:primaryType="nt:unstructured">
<default jcr:primaryType="nt:unstructured"
name="./default"
@saulovenancio
saulovenancio / User-Group-ACL-Migration.md
Created Mar 7, 2018 — forked from andrewmkhoury/User-Group-ACL-Migration.md
Migrating AEM Users, Groups and ACLs between instances
View User-Group-ACL-Migration.md
  1. Migrate users and groups (If users were not imported automatically via LDAP) Package users and groups (2 separate packages) on the old system (excluding admin and anonymous OOTB users)
    1. Go to CRXDE lite app /crx/de/index.jsp and log in as admin user (on the old system)
    2. Go to "Tools" => "Query"
    3. In the bottom "Query" box enter this query to find the admin user: /jcr:root/home/users//element(*,rep:User)[@rep:principalName="admin"]
    4. Click "Execute" and copy the path of the admin user node in the results to a text file
    5. Repeat step 3 with a query for anonymous user: /jcr:root/home/users//element(*,rep:User)[@rep:principalName="anonymous"]
    6. Click "Execute" and copy the path of the anonymous user node in the results to a text file (so now you should have two paths, one for "admin" and one for "anonymous")
@saulovenancio
saulovenancio / curlPackageFilterRules.sh
Created Mar 5, 2018 — forked from nateyolles/curlPackageFilterRules.sh
AEM/CQ cURL: Adding include/exclude rules to package filters
View curlPackageFilterRules.sh
# Adding include/exclude rules to CQ/AEM package filters through cURL.
# Through a simple search, you will find numerous lists of CQ/AEM cURL commands.
# However, I haven't seen an example of adding rules to package filters. The
# JSON "rules" key takes an array value. You can leave the array empty if you
# don't need to include any rules. The array is of JSON objects with a
# "modifier" key and value of "include" or "exclude", and a "pattern" key with
# your path or regular expression as the value.
# create package
@saulovenancio
saulovenancio / .content.xml
Created Feb 16, 2018 — forked from nateyolles/.content.xml
AEM using Granite Render Conditions
View .content.xml
<items jcr:primaryType="nt:unstructured">
<widgetAlways
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="This always shows"
name="./widgetAlways"/>
<widgetHeaderChrome
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/textfield"
fieldLabel="This only shows when header &quot;User-Agent&quot; contains &quot;chrome&quot;"
@saulovenancio
saulovenancio / .content.xml
Created Feb 16, 2018 — forked from nateyolles/.content.xml
AEM Expression Language
View .content.xml
<cancel
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/hyperlink"
text="Cancel"
href="/content/geo${granite:encodeURIPath(requestPathInfo.suffix)}"/>
You can’t perform that action at this time.