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
import re | |
word_list = [] | |
with open("text.txt", 'rt') as myfile: | |
for line in myfile: | |
matches = re.findall('\/\/(.+?)\#\#', line) | |
word_list = word_list + matches | |
with open("output.txt", 'w+') as outputfile: | |
for word in word_list: |
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 input = { | |
page1: { | |
group1: [{ url: 'test1' }, { url: 'test2' }], | |
group2: [{ url: 'test3' }, { url: 'test4' }], | |
}, | |
page2: { | |
group1: [{ url: 'test5' }, { url: 'test6' }], | |
group2: [{ url: 'test7' }, { url: 'test8' }], | |
}, | |
}; |
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
{ | |
"groups": [ | |
{ | |
"data": [ | |
{ | |
"site": "Justice Department Charges Julian Assange in Superseding Indictment", | |
"url": "justice.gov" | |
}, | |
{ | |
"site": "iOS14 reveals that TikTok may snoop clipboard contents every few keystrokes", |
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 generateEvenNumberSequence(start, end) { | |
const sequence = []; | |
const firstValue = start % 2 === 0 ? start: start + 1; | |
for (i = firstValue; i <= end; i = i + 2) { | |
sequence.push(i); | |
} | |
return sequence; | |
} | |
console.log(generateEvenNumberSequence(1, 10)); |
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* makeEvenNumberIterator(start, end) { | |
const sequence = []; | |
const firstValue = start % 2 === 0 ? start: start + 1; | |
for (i = firstValue; i <= end; i = i + 2) { | |
yield i; | |
} | |
return sequence; | |
} |
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 content = require('./dummy.json'); | |
function* makeUrlIterator(content) { | |
const { groups } = content; | |
for (const group of groups) { | |
const { data } = group; | |
for (const entry of data) { | |
yield entry; | |
} | |
} |
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 urlIterator = makeUrlIterator(content); | |
for(const url of urlIterator) { | |
yourSecretThing(url); | |
} |
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* indexMaker() { | |
var index = 0; | |
while (true) | |
yield index++; | |
} | |
const indexGenerator = indexMaker(); | |
console.log(indexGenerator.next().value); // 0 | |
console.log(indexGenerator.next().value); // 1 |
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
a = [[2, 3, 4], [3, 4, 5]] | |
b = [[4, -3, 12], [1, 1, 5], [1, 3, 2]] | |
def get_dimension(a): | |
if not type(a) == list: | |
raise ValueError('Input is not a matrix') | |
dim_x = len(a) | |
dim_y = len(a[0]) |