soj.ooO
BETA
The social discussion platform
Home
Pochas
Channels
Videos
Log in
Sign up
Sign up
Home
Pochas
Channels
Videos
Log in
Sign up
Parent Post: AI Is A Controlled Tool, It Is Not Here To Help You or Me Specifically
M
mrinfinity
·
4/5/2025, 7:56:58 PM
·
permalink
I use AI for development. I work on passion projects which means I work on things I believe in, it's too hard for me to sit down, get up, do things, sit back down, re-focus, zone in, code, flow, get interrupted, get back up, go do things; and repeat over and over. In work life, I jump from task to task or 'this needs done' to 'this needs done' or 'this call' to 'this call' - it's hectic. AI answers my questions and gives me perspectives; for example I took two hours (time I do not have at the moment and wish I did) of coding something the wrong way and stumbled upon how to do it the right way, then I asked it how I could implement it the right way; and sure as hell; it told me. Everything in development is a component. A component of a whole, if you break it down; if you build one small part of a time it adds up; if you ask the AI to build small things in detail; say 'Build me a function that searches a directory, a function searchDir(dirName,'keyword') that searches all .json files in a given directory for all items that contain the keyword, then return the item name, for example x { y: "z" should return "z",' it will build you that function. Yes, I could code this myself, but I enjoy making it this way and learning the languages. Believe it or not, I cracked my knuckles this morning and the middle of my hands cracked and my hands hurt so bad my eyes widened in pain. I'm in my mid 30s. So, I ask myself, do I really want to type ALL of this code, even though I can? Everybody before this was going to stackoverflow. ```code function searchDir(dirName, keyword) { const results = []; // Check if directory exists if (!fs.existsSync(dirName)) { console.error(`Directory "${dirName}" does not exist`); return results; } // Get all files in the directory const files = fs.readdirSync(dirName); // Filter for JSON files and process them files .filter(file => path.extname(file).toLowerCase() === '.json') .forEach(file => { const filePath = path.join(dirName, file); try { // Read and parse the JSON file const data = JSON.parse(fs.readFileSync(filePath, 'utf8')); // Search for the keyword in the JSON object searchObject(data, keyword, results); } catch (error) { console.error(`Error processing file ${filePath}: ${error.message}`); } }); return results; } /** * Recursively searches an object for a keyword and collects matching item names * @param {Object|Array} obj - Object or array to search * @param {string} keyword - Keyword to search for * @param {Array} results - Array to collect results */ function searchObject(obj, keyword, results) { if (!obj || typeof obj !== 'object') return; // Handle arrays and objects if (Array.isArray(obj)) { // For arrays, check each element obj.forEach(item => searchObject(item, keyword, results)); } else { // For objects, check each key-value pair Object.entries(obj).forEach(([key, value]) => { // If value is an object or array, search it recursively if (value && typeof value === 'object') { searchObject(value, keyword, results); } // Check if value is a string containing the keyword else if (typeof value === 'string' && value.includes(keyword)) { results.push(value); } }); } } ``` 
Save
Cancel
2
bumps
Share
M
mrinfinity
·
4/5/2025, 7:58:40 PM
·
permalink
So in retort, it helps me 'break through' and helps me.
Save
Cancel
1
bump
Share
Signature
Loading…
Verify locally
Close