Skip to content

Instantly share code, notes, and snippets.

View badvision's full-sized avatar

Brendan Robert badvision

View GitHub Profile
@badvision
badvision / previewOrAnnotateOnly.js
Last active August 29, 2015 14:24
AEM 6.1: Require a user to be in a specific group in order to edit content. Other users will only see preview and annotate layers
// This must be in a client library with the category cq.authoring.editor.hook
/* global Granite, CQ, window */
(function($, author, user, http) {
'use strict';
var UUID = 'UUID',
MEMBERS = 'EDITOR_MEMBERS',
EDITOR_GROUP = '/home/groups/express/express-content-editors',
PREVIEW = 'Preview',
ANNOTATE = 'Annotate',
hideEditLayer = function() {
@badvision
badvision / kaboom.a
Created July 15, 2015 07:20
Apple II: Kaboom animation
*= $300;
!cpu 65c02;
;Kaboom: Simple Lo-res color cycle just for fun
php
pha
phx
phy
REM Original posted by mmphosis to comp.sys.apple2.programmer
REM Shortened down to two lines by b. robert
0 HGR : HCOLOR= 6: HPLOT 0,0 : CALL 62454: B = 70 : FOR Y = 0 TO 99 : READ A$:L = LEN (A$): IF L THEN B = B + 2: P = 130: Q=131: FOR X = 1 TO L:P=P+2: Q=Q+2: HCOLOR=VAL(MID$ (A$,X,1)) : FOR Z = B TO B+1 : HPLOT P,Z TO Q,Z: NEXT Z,X,Y
1 DATA 66666555555,66665555555555,666644477477,66647477747777,666474477747777,66644777744444,6666677777777,66664445444,66644445444,6744445544,7774455755,6445555555,6664455555,6664444,66444,
import com.webcodepro.applecommander.storage.os.dos33.DosFormatDisk
import com.webcodepro.applecommander.storage.Disk
import com.webcodepro.applecommander.storage.physical.DosOrder
import com.webcodepro.applecommander.storage.physical.ByteArrayImageLayout
import java.io.File
def baseDir="/Users/blurry/Downloads/ac33"
def outDir="/Users/blurry/Downloads/ac33_extracted"
def sourceFolder = baseDir as File
@badvision
badvision / buildGroupMatrix.groovy
Created March 8, 2016 17:17
Part 2 of building user information (See getGroupInfo.groovy for instructions)
import groovy.json.*
def slurper = new JsonSlurper()
slurper.setType(JsonParserType.INDEX_OVERLAY);
def groupDir = '.' as File
def output = 'matrix.txt' as File
def users = new TreeMap();
def userGroups = new HashMap();
@badvision
badvision / getAllGroupInfo.groovy
Last active March 8, 2016 17:18
AEM Group membership extractor, use with buildGroupMatrix to produce a spreadsheet of all users and what groups they're in
// Step 1: retrieve group list via http://AEMINSTANCE:4502/home/groups.xml and save as group.xml
// Step 2: modify this script (find/replace AEMINSTANCE:4502 with your AEM host/port, also USERNAME and PASSWORD)
// Stpe 3: run this script in the same directory as group.xml
// Step 4: make the output groups_retrieve.sh executable and run it
// Step 5: use the buildGroupMatrix.groovy script to render the spreadsheet
def groupXml = 'groups.xml' as File
def outScript = 'groups_retrieve.sh' as File
def allGroups = new XmlSlurper().parseText(groupXml.getText())
pathBuilder = {node, path="" ->
@badvision
badvision / publish renditions.jsp
Last active May 19, 2016 20:04
Publish non-original renditions to another instance, using multiple publish queues in round-robin fashion
<%@include file="/libs/foundation/global.jsp"%>
<%@page session="false" contentType="text/html; charset=utf-8" pageEncoding="UTF-8"
import="java.util.*,
com.adobe.acs.commons.fam.*,
com.adobe.acs.commons.functions.*,
com.adobe.granite.asset.api.*,
com.day.cq.replication.*,
org.apache.sling.api.resource.*,
javax.jcr.*"%><%
ActionManagerFactory amf = sling.getService(ActionManagerFactory.class);
@badvision
badvision / regenerate thumbnails.jsp
Created May 19, 2016 20:12
Regenerate thumbnails using synthetic workflow
<%@include file="/libs/foundation/global.jsp"%>
<%@page session="false" contentType="text/html; charset=utf-8" pageEncoding="UTF-8"
import="com.adobe.acs.commons.workflow.synthetic.*,
com.adobe.acs.commons.fam.*,
com.adobe.acs.commons.functions.*,
org.apache.sling.api.resource.*,
java.util.*,
javax.jcr.*,
com.day.cq.search.*,
com.day.cq.dam.commons.util.DamUtil,
@badvision
badvision / all ips.jsp
Created May 19, 2016 20:17
List all IP Addresses that the server is listening on.
<%@page session="false" contentType="text/html; charset=utf-8"
import="java.util.*,java.net.*"%><%
List<NetworkInterface> ifaces = Collections.list(NetworkInterface.getNetworkInterfaces());
for(NetworkInterface ifc : ifaces) {
if(ifc.isUp()) {
List<InetAddress> addrs = Collections.list(ifc.getInetAddresses());
for(InetAddress addr : addrs) {
%>
<%=addr.getHostAddress()%><br>
@badvision
badvision / disk usage.jsp
Last active May 19, 2016 20:29
Call the *nix command line "df -h" to obtain the disk usage of the server
<%@page session="false" contentType="text/html; charset=utf-8"
pageEncoding="UTF-8" import="java.lang.*,java.io.*"%><%
Process p = Runtime.getRuntime().exec("df",new String[]{"-h"});
p.waitFor();
%><h2>STDERR:</h2><pre><%
String line;
BufferedReader error = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while((line = error.readLine()) != null){
%><%=line%>
<%