This file contains 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
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") |
This file contains 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
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; | |
} |
This file contains 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
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 = { |
This file contains 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
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) |
This file contains 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
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"); |
This file contains 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
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); |
This file contains 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
// 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 |
This file contains 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
function getAccountStatusInfo(userPrimaryAccountTags, userPrimaryPartyTags, account_status) { | |
let accountStatus = []; | |
if (account_status === 'CLOSED') { | |
accountStatus.push('Closed'); | |
} | |
const primaryStatus = getPrimaryStatusFromTags(userPrimaryAccountTags); | |
if (primaryStatus) { | |
accountStatus.push(primaryStatus); |
This file contains 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
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) | |
} | |
}); | |
} |
This file contains 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
<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> |
NewerOlder