Skip to content

Instantly share code, notes, and snippets.

View ThomasKruegl's full-sized avatar

Thomas Krügl ThomasKruegl

View GitHub Profile
def double_input_preserved(list,index):
new_list = list[:index] + [list[index]*2] + list[index + 1:]
return new_list
def double_changes_input(list, index):
list[index] *= 2
return list
print("preservered")
function getNestedArr(depth) {
const result = [0, null];
let inner = result;
for (let i = 1; i < depth; i++) {
const next = [i, null];
inner[1] = next;
inner = next;
}
return result;
}
const { interval, of, from } = Rx;
const { take, delay, map, switchMap, groupBy, mergeMap, toArray } = RxOperators;
const foo1 = {
items: []
};
const foo2 = {
items: [1,2,3]
};
const foo3 = {
function getFields(form) {
if (typeof form !== "object") {
return [];
} else {
if (form.formType === "formField") {
// end case, object is a simple field
return [{htmlName: form.htmlName, value: form.value}];
} else if (form.formType === "formGroup") {
// recursion: check every entry of the formGroup
return Object.entries(form)
const { of, throwError } = Rx;
const { finalize, switchMap } = RxOperators;
const observable1 = of(1);
const observable2 = of(2);
const observableError = throwError("error");
function doStuff() {
console.log("stuff");
Explanations for https://eloquentjavascript.net/06_object.html#c_uuBcsDdS7D
Matrix constructor:
this.content[y * width + x] = element(x, y);
-> this.content[3 * 5 + 2] = element(2, 3);
so, what is element(2,3)? element is the argument passed to the constructor, here (in symmetricMatrix):
super(size, size, (x, y) => {
if (x < y) return element(y, x);
else return element(x, y);
// original call
getCredentials(path.resolve(__dirname, "../../config/google_clientid.json")).then( async (content) => {
const buff_content = JSON.parse(content);
const accessData = await authorize(JSON.parse(content), syncdinfo);
const googleGroupData = await createGoogleGroup(accessData)
console.log("googleGroupData = " + JSON.stringify(googleGroupData));
});
// next call
function getAccountStatusInfo(userPrimaryAccountTags, userPrimaryPartyTags, account_status) {
let accountStatus = [];
if (account_status === 'CLOSED') {
accountStatus.push('Closed');
}
const primaryStatus = getPrimaryStatusFromTags(userPrimaryAccountTags);
if (primaryStatus) {
accountStatus.push(primaryStatus);
function hasText(obj, text) {
return Object.values(obj).some( value => {
if (typeof value === "object") {
return hasText(value, text);
} else {
return typeof value === "string" && value.includes(text)
}
});
}
<template>
<div>
<div :class="isSmall ? 'small' : 'large'"
@click="resize()"
class="other-styles"></div>
<div class="other-styles"></div>
<div class="other-styles"></div>
<div class="other-styles"></div>
</div>
</template>