Skip to content

Instantly share code, notes, and snippets.

Avatar
🐛

Luis Confraria confraria

🐛
View GitHub Profile
View gist:2cc58338a884eb985bed7728906a8b88
private addStep(step) {
step.id = `scriptStep${this.stepId++}`;
this.ctxQuest.lastStep = step;
this.ctxQuest.steps.push(step);
step.quest = this.ctxQuest;
if (this.state !== 'directC' && step.type === DIRECT_COMMUNICATION_SEND_DIRECT_MESSAGE) {
this.state = 'directC';
}
if (this.state === 'directC' && ![DIRECT_COMMUNICATION_SEND_DIRECT_MESSAGE, ADD_DECISION].includes(step.type)) {
this.state = undefined;
View iframe-replace.js
function iFrameFix(aId, divId) {
const $a = document.getElementById(aId);
const $div = document.getElementById(divId);
const renderIframe = (img = {}) => {
const w = img.naturalWidth || 100;
const h = img.naturalHeight || 100;
$div.innerHTML = `<iframe src="${a.href}" frameborder=0 width="${w}" height="${h}"></iframe>`;
};
if ($a !== null && $div !== null) {
let img = div.querySelector("img");
View script.js
function addLinks() {
Array.from(document.querySelectorAll("[id]")).forEach((e) => {
const a = document.createElement("a");
a.href = `#${e.id}`;
e.parentNode.replaceChild(a, e);
a.appendChild(e);
});
}
if (document.readyState === "complete" || document.readyState === "loaded") {
View topic.js
const streams = {};
function callback(topic, message) {
const [type, cluster] = topic.split("/");
if (type === "log") {
let stream = streams[topic];
if (!stream) {
stream = streams[topic] = fs.createWriteStream(`log_${cluster}.txt`, {
flags: "a",
});
}
View scripts.js
Array.from(document.querySelectorAll('[id]')).forEach(e => {
const a = document.createElement('a');
a.href=`#${e.id}`;
e.parentNode.replaceChild(a, e);
a.appendChild(e);
});
@confraria
confraria / actor.ts
Last active Mar 25, 2020
game scripting
View actor.ts
/*
The ids: system and player are builtin and don't need to be defined
*/
export const actors: Catalogue<Actor> = {
system: {
name: "Talent digital",
email: "no-reply@talent-digital.eu",
type: ActorType.System,
avatarUrl:
"https://talentdigital.eu/wp-content/themes/TalentDigital/images/FM_TDLOGO_small.png",
View samplescene.xml
<performance title="Battle of Wits">
<!--Information about the graphical elements of the play-->
<header>
<!--Cast of characters and props-->
<castList>
<character id="vizzini">
<name>
Vizzini
</name>
<!--Character models defined for this character. The first model is designated the default model-->
@confraria
confraria / package.json
Created Mar 15, 2020
rollup with typescript
View package.json
{
"name": "topz2",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"couch:start": "docker run -p 5984:5984 -it -v $(pwd)/couchdata:/opt/couchdb/data -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=local_development_password topzcouch"
},
"keywords": [],
"author": "",
@confraria
confraria / rightdrawerconfig.js
Created Jun 21, 2019
Add a a new link to rightdrawer
View rightdrawerconfig.js
angular.module('c8y.ui').decorator('c8yDocs', ($delegate) => {
'ngInject';
const listFn = $delegate.list.bind($delegate);
$delegate.list = function() {
return listFn().then(links => {
links.push({
{
icon: 'c8y-book', // choose from http://styleguide.cumulocity.com/icons/fontawesome or http://styleguide.cumulocity.com/icons/cumulocity
label: 'My link'
View assettable.js
function orderBy(property) {
let prop = property;
if (_.isArray(prop)) {
prop = prop.join('.');
}
const [, sign, iterateeString] = prop.match(/^(-?)(.*)$/);
const order = sign === '-' ? 'desc' : 'asc';
let iteratee = iterateeString;