Skip to content

Instantly share code, notes, and snippets.

View Alamin02's full-sized avatar
🎵
...all we need is just a little patience

Al Amin Alamin02

🎵
...all we need is just a little patience
View GitHub Profile
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:
const input = {
page1: {
group1: [{ url: 'test1' }, { url: 'test2' }],
group2: [{ url: 'test3' }, { url: 'test4' }],
},
page2: {
group1: [{ url: 'test5' }, { url: 'test6' }],
group2: [{ url: 'test7' }, { url: 'test8' }],
},
};
{
"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",
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));
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;
}
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;
}
}
const urlIterator = makeUrlIterator(content);
for(const url of urlIterator) {
yourSecretThing(url);
}
function* indexMaker() {
var index = 0;
while (true)
yield index++;
}
const indexGenerator = indexMaker();
console.log(indexGenerator.next().value); // 0
console.log(indexGenerator.next().value); // 1
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])