This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://trycf.com/gist/5276cc942cc493a1e6f42b74b9f93eb0/lucee5?theme=monokai | |
data = [ | |
{"id": 1, "message": "one", "parent": 0}, | |
{"id": 2, "message": "two", "parent": 1}, | |
{"id": 3, "message": "three", "parent": 2}, | |
{"id": 4, "message": "four", "parent": 3}, | |
{"id": 5, "message": "five", "parent": 4}, | |
{"id": 6, "message": "six", "parent": 5}, | |
{"id": 7, "message": "seven", "parent": 0}, | |
{"id": 8, "message": "eight", "parent": 7}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component { | |
property name="jSoup" inject="javaLoader:org.jsoup.Jsoup"; | |
function spider( required string link ){ | |
var meta = { "url" : arguments.link, "alt_images" : [] }; | |
try { | |
var jsDoc = jSoup | |
.connect( link ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component{ | |
function log (required struct criteria) { | |
cfhttp(url = "https://api.kisdigital.com/chron/log", method = "POST", charset = "utf-8"){ | |
cfhttpparam(type = "header", name = "Content-Type", value = "application/json"); | |
cfhttpparam(type = "body", value = serializeJSON({ | |
"appid": "e92c801d-659a-4548-8a16-b79f6b37cf2d", | |
"type": criteria.keyExists("type") ? criteria.type : "information", | |
"log": criteria.keyExists("log") ? criteria.log : "default", | |
"message": criteria.keyExists("message") ? criteria.message : "No message." | |
})); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var sass = require('gulp-ruby-sass'); | |
var concat = require('gulp-concat'); | |
var stripDebug = require('gulp-strip-debug'); | |
var uglify = require('gulp-uglify'); | |
var rimraf = require('gulp-rimraf'); | |
var del = require('del'); | |
var paths = { | |
jsdir: './_src/js/**/*.js', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component { | |
// given an array, return an array of arrays with {{chunkSize}} elements | |
function chunk (required array input, required numeric chunkSize) { | |
var output[1] = []; | |
var idx = 1; | |
input.each((item, index) => { | |
output[idx].append(item); | |
if(index % chunkSize == 0 && index < input.len()) output[++idx] = []; | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component extends="coldbox.system.EventHandler" { | |
property name = "SpiderService" inject; | |
function xmlToJson (event, rc, prc) { | |
var u = event.getValue("u", ""); | |
prc['data'] = {}; | |
if(u.len()){ | |
var obj = createObject("java", "org.json.XML"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="xmlToStruct" access="public" returntype="struct" output="false"> | |
<cfargument name="xmlNode" type="string" required="true" /> | |
<cfscript> | |
var res = {}; | |
var xmlDoc = xmlSearch(xmlParse(xmlNode), "/node()")[1]; | |
for(var i = 1; i <= xmlDoc.xmlChildren.len(); i++){ | |
var n = replace(xmlDoc.XmlChildren[i].XmlName, xmlDoc.XmlChildren[i].XmlNsPrefix & ":", ""); | |
if(res.keyExists(n)){ | |
if(!isArray(res[n])){ | |
tmp = res[n]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"userId": 1, | |
"id": 1, | |
"title": "I rewrote the title", | |
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto" | |
}, | |
{ | |
"userId": 1, | |
"id": 2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
baseUrl = "https://jsonplaceholder.typicode.com"; | |
api = new API(); | |
api | |
.setUrl( baseUrl & '/posts') | |
.execute(); | |
writeDump(api.getResult()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component output = "false" { | |
public function init() { | |
variables['instance'] = {}; | |
instance['hasExecuted'] = false; | |
instance['isJson'] = ""; | |
instance['created'] = now(); | |
instance['url'] = ""; | |
instance['resolvedUrl'] = ""; | |
instance['verb'] = "GET"; |
NewerOlder