Skip to content

Instantly share code, notes, and snippets.

View dev-opus's full-sized avatar
🎯
Focusing

Victor Orlunda dev-opus

🎯
Focusing
View GitHub Profile
@dev-opus
dev-opus / script.py
Created December 9, 2022 07:52
This Gist holds a Python script that was used in computing the Mass Attenuation Coefficient of samples used for my final year project work.
import statistics as stat
import math
def computeIntensity(list):
readings = [x * 1000 for x in list]
intensity = stat.mean(readings) - bg_intensity
return intensity
@dev-opus
dev-opus / caeser.js
Created May 6, 2021 23:11
implementing caeser's cypher
/*
Caeser's Cypher
implemented by your's truly :)
*/
// since we are in a node environment, this is how we get input from the terminal
// note: i'm only get the first two arguments from the input array, excluding 'node app.js'
const [plainText, key] = process.argv.slice(2);
// makes sure plainText is in lowercase and trims
@dev-opus
dev-opus / better.js
Last active May 4, 2021 08:56
better error handling method for asynchronous javascript programming
/*
so uhm, up until about a week ago, my
defacto method for handling errors in an
async/await program-flow was to wrap my
entire code-block in a try/catch; performing
the operations in the `try {}` block and
handling any errors in the `catch(err) {}` block.
it worked well, but it didn't sit well with me
@dev-opus
dev-opus / file-system.js
Last active January 6, 2021 15:22
file system and streams
const fs = require('fs').promises
const path = require('path')
const getData = async (dirName) => {
try {
const buffer = await fs.readFile(dirName)
const data = await JSON.parse(buffer)
return data
} catch (err) {
console.error(err)