Skip to content

Instantly share code, notes, and snippets.

View dcsaszar's full-sized avatar

David Császár dcsaszar

  • JustRelate Group
View GitHub Profile
@dcsaszar
dcsaszar / gist:e902032520286eda3954ab3b140a301d
Created March 10, 2025 09:56
Update Scrivito Links by Search & Replace
search = "https://example.com"
replace = "https://example.com"
contents = await Scrivito.load(() => Scrivito.Obj.onAllSites().all().toArray().flatMap((o) => [o, ...o.widgets()]))
links = await Scrivito.load(() => contents.flatMap((c) => Object.entries(c.attributeDefinitions()).map(([name, [type]]) => (type === "link" && c.get(name) ? [c, name, c.get(name)] : null))).filter((v) => v?.[2].url()?.includes(search)))
links.forEach(([c, name, l]) => c.update({ [name]: l.copy({ url: replace }) }))
@dcsaszar
dcsaszar / index.js (of your test app)
Last active November 12, 2018 14:27
index.js of your test app
console.log("Hello")
ment.style {
padding: 0.5em 1em 0.3em;
font-size: 100%;
font-weight: bold;
color: #444;
opacity: 0.8;
background: #ccc;
display: block;
scrivito.on 'content', (content) ->
if scrivito.in_editable_view()
$(content).find('''
[data-scrivito-field-type=stringlist]:not([data-editor]),
[data-editor~=stringlist]
''').each -> # ...
scrivito.define_editor "stringlist",
can_edit: (dom_element) -> $(dom_element).data("scrivito-field-type") == "stringlist"
edit: (dom_element) -> # ...
DATE_REGEX = /at\s(?<date>20\d\d-\d\d-\d\d\s)\d\d:\d\d:\d\d/
MS_REGEX = /Obj Load \((?<ms>.*?)ms\)\s+(?<q>.*)/
ms_by_query = Hash.new { |hash, key| hash[key] = [] }
ms_by_date = Hash.new { |hash, key| hash[key] = [] }
histogram_ms = Hash.new { |hash, key| hash[key] = 0 }
date = nil
IO.foreach("log/development.log") do |line|
line = line.force_encoding('ISO-8859-1')