This guide walks through setting up a new Python project using mise for Python version management, uv for fast dependency management, and pyproject.toml for project configuration.
As posted on: https://timvisee.com/blog/list-export-your-subreddits/
To obtain a list of your subreddits, do the following:
- First make sure you're logged in on reddit, on a desktop browser.
- Then visit reddit.com/subreddits.
- Then put the following snippet in your browsers address bar, and press
Enter.
Make surejavascript:is included at the beginning, your browser might remove it while copy-pasting for security reasons:
We're going to parse a file, use a conditional to add a new column, then save the new file with an additional column all without using any external dependencies not included in the standard lib
const fs = require('fs');
const inputCsvFile = 'input.csv';
const outputCsvFile = 'output.csv';This is a working example of symmetric encryption in nodejs.
From https://stackoverflow.com/questions/41043878/symmetric-encryption-with-nodejs
var assert = require('assert');
var crypto = require('crypto');
const fs = require('fs')
This file contains hidden or 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 never from 'never' | |
| type ParsedLogs = Array<[string, string]> | |
| type GroupedLogs = { | |
| [K: string]: Array<string> | |
| } | |
| export default function main(logs: string) { | |
| const parsedLogs = parseAndNormaliseLogs(logs) |
This file contains hidden or 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 parseLogs(logs) { | |
| const logsArray = logs.split('\n').map(eachLog => eachLog.split(',')) | |
| const normalisedArray = normaliseArray(logsArray) | |
| const logsWithSeconds = normalisedArray.map(([timestamp, phoneNumber]) => | |
| [calculateTotalSeconds(timestamp), phoneNumber]) | |
| const grouped = groupByPhoneNumber(logsWithSeconds) | |
| const phoneNumberWithLargestTotal = getPhoneNumberWithLargestTotalSeconds(grouped) | |
| grouped[phoneNumberWithLargestTotal] = 0 | |
| return calculateTotalBill(logsWithSeconds, phoneNumberWithLargestTotal) | |
| } |
This file contains hidden or 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 crypto = require('crypto') | |
| const fs = require('fs') | |
| const encryptedData = fs.readFileSync('encrypted_data.txt', { encoding: 'utf-8' }) | |
| const privateKey = fs.readFileSync('private.pem', { encoding: 'utf-8' }) | |
| const decryptedData = crypto.privateDecrypt( | |
| { | |
| key: privateKey, | |
| // In order to decrypt the data, we need to specify the |
This file contains hidden or 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 fs = require('fs') | |
| const crypto = require('crypto') | |
| const dataToEncrypt = fs.readFileSync('data_to_encrypt.txt', { encoding: 'utf-8' }) | |
| const publicKey = Buffer.from(fs.readFileSync('public.pem', { encoding: 'utf-8' })) | |
| const encryptedData = crypto.publicEncrypt( | |
| { | |
| key: publicKey, |
NewerOlder