Skip to content

Instantly share code, notes, and snippets.

View daehwann's full-sized avatar

daehwan daehwann

  • Seoul, Korea
  • 07:24 (UTC +09:00)
View GitHub Profile
@daehwann
daehwann / page_visitor.js
Created October 23, 2018 07:18
Puppeteer Multipage Visiting Sample
const puppeteer = require('puppeteer');
const qs = require('query-string');
const fs = require('fs');
const util = require('util');
const readline = require('readline-sync');
const viewport = {
width:1500,
height: 1000,
deviceScaleFactor: 1,
// Before start, select galaxy frame in the chrome development tools
async function selectTarget(button, name) {
console.log("Button will be clicked: ", button)
await button.click(); // to open dropdown
var item = await [].slice.call(button.nextElementSibling.querySelectorAll('li')).filter(el => el.textContent == name).pop();
console.log("Item will be clicked: ", item)
await item.click();
}
/*! mmapi v1.4 Copyright 2006-2015 Maxymiser Inc */
/*v1.4.15.64764*/
/*Please do not modify this file except configuration section at the bottom.*/
(function(a,D){function K(b){this.enableUtility=function(a){var d=b.getParam("un",b.baseStorage.storeStrategy.persistent)||"";(new RegExp("(^|,)"+a+"($|,)")).test(d)||(d=d.split(","),d.push(a),b.setParam("un",d.join(",").replace(/(^,)|(,$)/g,""),b.baseStorage.storeStrategy.persistent));return this};this.disableUtility=function(a){var d=b.getParam("un",b.baseStorage.storeStrategy.persistent)||"";(new RegExp("(^|,)"+a+"($|,)")).test(d)&&(d=d.replace(new RegExp("(^|,)"+a+"($|,)","gi"),",").replace(/(^,)|(,$)/g,
""),b.setParam("un",d,b.baseStorage.storeStrategy.persistent));return this};this.enable=function(){b.enable();return this};this.disable=function(){b.disable();return this};this.getConfig=function(){return{storageType:b.storageType,cprefix:b.cprefix,domain:b.domain,baseContentUrl:b.baseContentUrl,cookie_domain:b.cookie_domain,srv:b.srv,async:b.async,beforeInit
@daehwann
daehwann / JcrQueryLibrary.md
Created February 26, 2017 14:45 — forked from floriankraft/JcrQueryLibrary.md
Some useful JCR queries (XPATH, SQL2) for AEM/CQ development.

SQL2

All nodes with a specific name

SELECT * FROM [nt:unstructured] AS node
WHERE ISDESCENDANTNODE(node, "/search/in/path")
AND NAME() = "nodeName"

All pages below content path

@daehwann
daehwann / pageNavigation.java
Created September 27, 2016 00:52
Traverse aem pages
import com.day.cq.wcm.foundation.Navigation;
String rootPage = "/content/mypage";
Navigation nav = new Navigation(rootPage, 0, null, 5);
Iterator<Navigation.Element> itr = nav.iterator();
while (itr.hasNext()) {
Navigation.Element el = itr.next();
Page elpage = el.getPage();
}
@daehwann
daehwann / RemoveDotDir.java
Last active October 14, 2016 03:59
Remove ".dir" folder
package removeDotDir;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class Main {
public static final boolean DELETE = true;
public static final String PATH_NAME = "C:\\Users\\daehwan\\git\\mypackage\\ui.apps\\src\\main\\content\\jcr_root";
@daehwann
daehwann / jcr_acl_setup.java
Last active June 14, 2016 04:06
JCR Access Controll List Setting
final int READ=0, MODIFY=1, CREATE=2, DELETE=3, REPLICATE=4;
String sitePath = "/content/mypage";
boolean siteAcl = false;
if (jcrSession.nodeExists(sitePath)){
BitSet bits = new BitSet(5);
bits.set(READ);
bits.set(MODIFY);
bits.set(CREATE);
bits.set(DELETE);
@daehwann
daehwann / html_resource_response.java
Created June 10, 2016 04:35
Html template response. Copied from Apache Sling project (org.apache.sling.servlets.post.HtmlResponse)
//in servlet
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
// get changelog
changes.insert(0, "<pre>");
changes.append("</pre>");
setProperty(PN_CHANGE_LOG, changes.toString());
@daehwann
daehwann / ajax_progress_interval.js
Last active June 9, 2016 06:10
Ajax progress check by using interval
var intervalObj = {
id: 0,
start: function (){
var inprogress = $(".inprogress").text("Wait");
var intervalId = 0;
intervalId = setInterval(function(){
var text = inprogress.text();
if (text.length < 50) {