r/StackoverReddit • • Jul 03 '24

Question Is my login arhitecture right?

5 Upvotes

I am creating a website using nodejs, html css js and I created a login sistem using phonenumber and OTP with firebase.
How it works:
When you create an account, after your phone being validated your name and phone number go to my database.

When you log in with your phonenumber and you get your OTP, i have a javascript code that creates a safe cookie in which your phonenumber is stored so that when you go to your user's page you can see your data.
Is this safe? Is this even a good idea? I tried using session ids but it s way to complicated for me.


r/StackoverReddit • • Jun 29 '24

Confusion regarding f strings

5 Upvotes

I wish to get this result

Hello, Ada Lovelace

The code written for this by a book is
first_name = "ada"
last_name = "lovelace"
full_name = f"{first_name} {last_name}"
print(f"Hello, {full_name.title()}")

But I was wondering, why cant it be this

first_name = "ada"
last_name = "lovelace"
full_name = f"{first_name} {last_name}"
print(f"Hello, {full_name}.title()")

the result of this is
Hello, ada lovelace.title()

I was wondering why this is so?
My reasoning is that the title method can be used on strings right? so then in my case, python would interpret {full_name} as a string, so it should work. Is it the case that methods work only on variables?


r/StackoverReddit • • Jun 23 '24

SQL IIB and esql devs

5 Upvotes

Quick question guys. How rare is it to stumble across an IIB(IBM Integration Bus)/esql developer rn. Also to IIB/esql devs who stumble across this post, how useful/in demand is IIB for right now?


r/StackoverReddit • • Jun 14 '24

Question AttributeError can't set attribute

5 Upvotes

Hello all,

I have an LSTM model in python and I am trying to deploy it on ZCU104 board using Vitis AI(Pytorch). I am stuck on an error while quantizing the model. I am getting the error for the line:

quantizer.export_xmodel(output_dir="quantize_result", deploy_check=True)

and the error is:

[VAIQ_NOTE]: =>Converting to xmodel ...

Traceback (most recent call last):

  File "lstm_quant.py", line 118, in <module>

main(args)

  File "lstm_quant.py", line 107, in main

quantizer.export_xmodel(output_dir="quantize_result", deploy_check=True)

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/pytorch_nndct/apis.py", line 148, in export_xmodel

self.processor.export_xmodel(output_dir, deploy_check, dynamic_batch)

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/pytorch_nndct/qproc/base.py", line 368, in export_xmodel

dump_xmodel(output_dir, deploy_check, self._lstm_app)

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/pytorch_nndct/qproc/base.py", line 505, in dump_xmodel

deploy_graphs, _ = get_deploy_graph_list(quantizer.quant_model, quantizer.Nndctgraph)

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/pytorch_nndct/qproc/utils.py", line 463, in get_deploy_graph_list

return _deploy_optimize(quant_model, nndct_graph, need_partition)

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/pytorch_nndct/qproc/utils.py", line 419, in _deploy_optimize

g_optmizer = DevGraphOptimizer(nndct_graph)

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/nndct_shared/compile/deploy_optimizer.py", line 92, in __init__

self._dev_graph.clone_from(nndct_graph)

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/nndct_shared/nndct_graph/base_graph.py", line 133, in clone_from

self._top_block.clone_from(src_graph.block, local_map, converted_nodes)

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/nndct_shared/nndct_graph/base_block.py", line 47, in clone_from

self.append_node(self.owning_graph.create_node_from(node, local_map, converted_nodes))

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/nndct_shared/nndct_graph/base_graph.py", line 161, in create_node_from

node.clone_from(src_node, local_map)

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/nndct_shared/nndct_graph/base_node.py", line 120, in clone_from

self.op.clone_from(src_node.op, local_map)

  File "/opt/vitis_ai/conda/envs/vitis-ai-pytorch/lib/python3.8/site-packages/nndct_shared/nndct_graph/base_operator.py", line 214, in clone_from

setattr(self, config, new_value)

AttributeError: can't set attribute

Attaching the full error, model code and quantization script in the google links below:

Quantization Script:
https://docs.google.com/document/d/1jRYmPH2z70ovpc_FJIBpUQaTHUPRrTgnPVxlQJ1JLug/edit?usp=sharing

Model Script:
https://docs.google.com/document/d/1OBZw4XhdHpVhA0gKcJn2NzR_WA7ZczQ3hL42f_sMKug/edit?usp=sharing

Full Error:
https://docs.google.com/document/d/1kI1WJqq9pp3aSsGLpNGjf22mzK6swIiZbIXwfUeTGto/edit?usp=sharing


r/StackoverReddit • • Jun 11 '24

Detailed Roadmap of everything about Artificial Intelligence and Machine Learning I need to know before College as I want to be an AI Robotics Engineer (70% AI, 30% Robotics)

5 Upvotes

I’m a sophomore in highschool going into my junior year Fall of 2024. Before I go to college (Fall of 2026) what’s everything I need to know about AI and ML whether it’s programming languages, concepts, etc. A detailed roadmap that includes all the programming languages, AI, ML, and Robotics concepts I would need to know, as well as courses and YouTube videos that would help me learn, and platforms I can practice AI on would be great as I’m a complete beginner that knows just really basic python.

I was thinking before going to college I should have a solid foundation in Python, Java, and C++, (maybe R and Julia). I also want to do develop my own AI (software) based projects (I assume robotics (hardware) based projects is to expensive) that I can monetize and create a startup/business out of it on the right idea but obviously can’t do this with any knowledge in AI, ML, and robotics much less the languages

I feel behind since I don’t really know any languages outside of basic Python. I think I’m on good path on my math track as I just took AP Precalc and going into junior year I’m talking BC Calc (equivalent of Calc 2/ sophomore college year math), and then Multivariable & Linear Algebra my senior year. Would appreciate any insight.


r/StackoverReddit • • Oct 15 '24

Question Building a Real-Time Collaborative Text Editor (Google Docs Clone)

4 Upvotes

I'm working on creating a simplified version of Google Docs, focusing on real-time document collaboration. My goal is to allow multiple users to edit a document simultaneously, with changes appearing live for everyone. I've heard that operational transformations are a key technique to achieve this, and I plan to implement them.

Is this feasible for a solo developer? Also, any tips or advice on how to approach this, along with an estimated timeline for completing the project, would be greatly appreciated!


r/StackoverReddit • • Jul 30 '24

Other Code Need help in brainstorming.

Thumbnail self.rprogramming
4 Upvotes

r/StackoverReddit • • Jul 26 '24

Javascript Can you help me debug an issue that only appears on real mobile browsers?

4 Upvotes

Guys, can you help me debug a web dev issue which only appears on mobile browsers?

If you go to this site https://javascript.moe/about, scroll down, back up, then you can't scroll down again and I cannot figure out why. I tried to isolate the cause, but I can't pinpoint the issue.

It's just a sticky 120vh div with some background image and some text, nothing complicated, yet it's hard to debug because browserstack local doesn't work and I need to deploy to test it on a real device :/


r/StackoverReddit • • Jul 25 '24

Python Text analytics and syntactic role

4 Upvotes

Hello everyone. I'm quite new with python and its libraries. I'm interested in text analytics and was wondering if there is any library that allows for the recognition of syntactic roles such as subject and predicate. I know that NLTK has a module for logical formulas, but I couldn't find anything that allows to say if a word is in subject or in predicate position.

Does anybody know how to do that?


r/StackoverReddit • • Jul 20 '24

Javascript Await in next js causing infinite loading with no error

4 Upvotes

I'm trying to query a db with drizzle in next and show the results but when I await the function querying the db my app starts reloading and never stops until i remove the await. When i remove the await I get a promise and I even tried using .then but the promise won't resolve

"use server"

import { db } from "@/server"

export default async function getPosts(){
  const posts = await db.query.PostsTable.findMany()
  if (!posts){
    return {error: "No posts found"}
  } else {
    return {success: posts}
  }
}

get-posts.ts

import Image from "next/image";
import "dotenv/config"
import getPosts from "@/server/actions/get-posts";


export default async function Home() {
  const data = await getPosts()
  console.log(data) 

  return (
    <main className="flex min-h-screen flex-col items-center justify-between p-24">
      <h1>Hello</h1>
    </main>
  );
}

page.tsx

NOTE when i remove the await from infront of the getPosts function call in page.tsx the loop doesn't happen and the following is logged to the console

Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 11554,
  [Symbol(trigger_async_id_symbol)]: 11531,
  [Symbol(kResourceStore)]: {
    headers: [Getter],
    cookies: [Getter],
    mutableCookies: [Getter],
    draftMode: [Getter],
    reactLoadableManifest: {},
    assetPrefix: ''
  },
  [Symbol(kResourceStore)]: {
    isStaticGeneration: false,
    urlPathname: '/',
    pagePath: '/page',
    incrementalCache: IncrementalCache {
      locks: Map(0) {},
      unlocks: Map(0) {},
      hasCustomCacheHandler: false,
      dev: true,
      disableForTestmode: false,
      minimalMode: false,
      requestHeaders: [Object],
      requestProtocol: 'http',
      allowedRevalidateHeaderKeys: undefined,
      prerenderManifest: [Object],
      fetchCacheKeyPrefix: '',
      cacheHandler: [FileSystemCache]
    },
    isRevalidate: false,
    isPrerendering: undefined,
    fetchCache: undefined,
    isOnDemandRevalidate: false,
    isDraftMode: false,
    prerenderState: null,
    requestEndedState: { ended: false },
    fetchMetrics: []
  },
  [Symbol(kResourceStore)]: undefined,
  [Symbol(kResourceStore)]: undefined,
  [Symbol(kResourceStore)]: {
    status: 0,
    flushScheduled: false,
    fatalError: null,
    destination: ReadableByteStreamController {},
    bundlerConfig: {
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/font/google/target.css?{"path":"app/layout.tsx","import":"Inter","arguments":[{"subsets":["latin"]}],"variableName":"inter"}': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/app/globals.css': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/client/components/app-router.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/esm/client/components/app-router.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/client/components/client-page.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/esm/client/components/client-page.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/client/components/error-boundary.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/esm/client/components/error-boundary.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/client/components/layout-router.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/esm/client/components/layout-router.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/client/components/not-found-boundary.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/esm/client/components/not-found-boundary.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/client/components/render-from-template-context.js': [Object],
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/esm/client/components/render-from-template-context.js': [Object]
    },
    cache: Map(0) {},
    nextChunkId: 6,
    pendingChunks: 6,
    hints: Set(2) {
      'L[font]/_next/static/media/c9a5bc6a7c948fb0-s.p.woff2',
      'L[style]/_next/static/css/app/layout.css?v=1721438843815'
    },
    abortableTasks: Set(3) { [Object], [Object], [Object] },
    pingedTasks: [],
    completedImportChunks: [ [Uint8Array] ],
    completedHintChunks: [],
    completedRegularChunks: [ [Uint8Array], [Uint8Array] ],
    completedErrorChunks: [],
    writtenSymbols: Map(0) {},
    writtenClientReferences: Map(1) {
      '/Users/haardikgupta/Desktop/Code/Next Apps/test/node_modules/next/dist/client/components/app-router.js#' => 3
    },
    writtenServerReferences: Map(0) {},
    writtenObjects: WeakMap { <items unknown> },
    identifierPrefix: '',
    identifierCount: 1,
    taintCleanupQueue: [],
    onError: [Function (anonymous)],
    onPostpone: [Function: eg],
    environmentName: 'Server'
  },
  [Symbol(kResourceStore)]: undefined
}

r/StackoverReddit • • Jul 17 '24

Other Code Error While Converting py to apk

4 Upvotes

Hello there,

I was trying to convert my .py file to an .apk file and was getting into some errors. The code below is the code I ran before converting the file. I was doing this from Google Colab

!pip install buildozer

!pip install cython==0.29.19

!sudo apt-get install -y \
    python3-pip \
    build-essential \
    git \
    python3 \
    python3-dev \
    ffmpeg \
    libsdl2-dev \
    libsdl2-image-dev \
    libsdl2-mixer-dev \
    libsdl2-ttf-dev \
    libportmidi-dev \
    libswscale-dev \
    libavformat-dev \
    libavcodec-dev \
    zlib1g-dev

!sudo apt-get install -y \
    libgstreamer1.0 \
    gstreamer1.0-plugins-base \
    gstreamer1.0-plugins-good

!sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev libffi6

!sudo apt-get install libffi-dev

!buildozer init

After I was done running these commands, I edited the buildozer.spec file.

So, now when I ran !buildozer -v android debug, this was the log below with the error at the bottom.

  STDOUT:
autoreconf: export WARNINGS=
autoreconf: Entering directory '.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal -I m4
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: configure.ac: not using Intltool
autoreconf: configure.ac: not using Gtkdoc
autoreconf: running: /usr/bin/autoconf
configure.ac:8: warning: The macro `AC_CANONICAL_SYSTEM' is obsolete.
configure.ac:8: You should run autoupdate.
./lib/autoconf/general.m4:2081: AC_CANONICAL_SYSTEM is expanded from...
configure.ac:8: the top level
configure.ac:74: warning: The macro `AC_TRY_COMPILE' is obsolete.
configure.ac:74: You should run autoupdate.
./lib/autoconf/general.m4:2847: AC_TRY_COMPILE is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
acinclude.m4:3: AC_FUNC_MMAP_BLACKLIST is expanded from...
configure.ac:74: the top level
configure.ac:91: warning: The macro `AC_HEADER_STDC' is obsolete.
configure.ac:91: You should run autoupdate.
./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from...
configure.ac:91: the top level
configure.ac:118: warning: The macro `AC_TRY_COMPILE' is obsolete.
configure.ac:118: You should run autoupdate.
./lib/autoconf/general.m4:2847: AC_TRY_COMPILE is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
m4/asmcfi.m4:1: GCC_AS_CFI_PSEUDO_OP is expanded from...
configure.ac:118: the top level
configure.ac:122: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:122: You should run autoupdate.
./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
configure.ac:122: the top level
configure.ac:138: warning: The macro `AC_TRY_COMPILE' is obsolete.
configure.ac:138: You should run autoupdate.
./lib/autoconf/general.m4:2847: AC_TRY_COMPILE is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
configure.ac:138: the top level
configure.ac:185: warning: The macro `AC_TRY_COMPILE' is obsolete.
configure.ac:185: You should run autoupdate.
./lib/autoconf/general.m4:2847: AC_TRY_COMPILE is expanded from...
lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
./lib/autoconf/general.m4:2249: AC_CACHE_VAL is expanded from...
./lib/autoconf/general.m4:2270: AC_CACHE_CHECK is expanded from...
configure.ac:185: the top level
configure.ac:215: warning: _LT_CMD_GLOBAL_SYMBOLS is m4_require'd but not m4_defun'd
aclocal.m4:778: LT_SYS_SYMBOL_USCORE is expanded from...
configure.ac:215: the top level
configure.ac:310: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:310: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.ac:310: the top level
configure.ac:418: warning: The macro `AC_HELP_STRING' is obsolete.
configure.ac:418: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
acinclude.m4:353: LIBFFI_ENABLE_SYMVERS is expanded from...
configure.ac:418: the top level
configure.ac:418: warning: AC_PROG_LD is m4_require'd but not m4_defun'd
acinclude.m4:251: LIBFFI_CHECK_LINKER_FEATURES is expanded from...
acinclude.m4:353: LIBFFI_ENABLE_SYMVERS is expanded from...
configure.ac:418: the top level
configure.ac:418: warning: The macro `AC_TRY_RUN' is obsolete.
configure.ac:418: You should run autoupdate.
./lib/autoconf/general.m4:2997: AC_TRY_RUN is expanded from...
acinclude.m4:251: LIBFFI_CHECK_LINKER_FEATURES is expanded from...
acinclude.m4:353: LIBFFI_ENABLE_SYMVERS is expanded from...
configure.ac:418: the top level
configure.ac:418: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:418: You should run autoupdate.
./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
acinclude.m4:353: LIBFFI_ENABLE_SYMVERS is expanded from...
configure.ac:418: the top level
configure.ac:41: error: possibly undefined macro: AC_PROG_LIBTOOL
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure:8578: error: possibly undefined macro: AC_PROG_LD
autoreconf: error: /usr/bin/autoconf failed with exit status: 1




  STDERR:

# Command failed: ['/usr/bin/python3', '-m', 'pythonforandroid.toolchain', 'create', '--dist_name=myapp', '--bootstrap=sdl2', '--requirements=python3,kivy,kivymd,pillow', '--arch=arm64-v8a', '--arch=armeabi-v7a', '--copy-libs', '--color=always', '--storage-dir=/content/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a', '--ndk-api=21', '--ignore-setup-py', '--debug']
# ENVIRONMENT:
#     SHELL = '/bin/bash'
#     NV_LIBCUBLAS_VERSION = '12.2.5.6-1'
#     NVIDIA_VISIBLE_DEVICES = 'all'
#     COLAB_JUPYTER_TRANSPORT = 'ipc'
#     NV_NVML_DEV_VERSION = '12.2.140-1'
#     NV_CUDNN_PACKAGE_NAME = 'libcudnn8'
#     CGROUP_MEMORY_EVENTS = '/sys/fs/cgroup/memory.events /var/colab/cgroup/jupyter-children/memory.events'
#     NV_LIBNCCL_DEV_PACKAGE = 'libnccl-dev=2.19.3-1+cuda12.2'
#     NV_LIBNCCL_DEV_PACKAGE_VERSION = '2.19.3-1'
#     VM_GCE_METADATA_HOST = '169.254.169.253'
#     HOSTNAME = '749c454ee124'
#     LANGUAGE = 'en_US'
#     TBE_RUNTIME_ADDR = '172.28.0.1:8011'
#     COLAB_TPU_1VM = ''
#     GCE_METADATA_TIMEOUT = '3'
#     NVIDIA_REQUIRE_CUDA = ('cuda>=12.2 brand=tesla,driver>=470,driver<471 '
 'brand=unknown,driver>=470,driver<471 brand=nvidia,driver>=470,driver<471 '
 'brand=nvidiartx,driver>=470,driver<471 brand=geforce,driver>=470,driver<471 '
 'brand=geforcertx,driver>=470,driver<471 brand=quadro,driver>=470,driver<471 '
 'brand=quadrortx,driver>=470,driver<471 brand=titan,driver>=470,driver<471 '
 'brand=titanrtx,driver>=470,driver<471 brand=tesla,driver>=525,driver<526 '
 'brand=unknown,driver>=525,driver<526 brand=nvidia,driver>=525,driver<526 '
 'brand=nvidiartx,driver>=525,driver<526 brand=geforce,driver>=525,driver<526 '
 'brand=geforcertx,driver>=525,driver<526 brand=quadro,driver>=525,driver<526 '
 'brand=quadrortx,driver>=525,driver<526 brand=titan,driver>=525,driver<526 '
 'brand=titanrtx,driver>=525,driver<526')
#     NV_LIBCUBLAS_DEV_PACKAGE = 'libcublas-dev-12-2=12.2.5.6-1'
#     NV_NVTX_VERSION = '12.2.140-1'
#     COLAB_JUPYTER_IP = '172.28.0.12'
#     NV_CUDA_CUDART_DEV_VERSION = '12.2.140-1'
#     NV_LIBCUSPARSE_VERSION = '12.1.2.141-1'
#     COLAB_LANGUAGE_SERVER_PROXY_ROOT_URL = 'http://172.28.0.1:8013/'
#     NV_LIBNPP_VERSION = '12.2.1.4-1'
#     NCCL_VERSION = '2.19.3-1'
#     KMP_LISTEN_PORT = '6000'
#     TF_FORCE_GPU_ALLOW_GROWTH = 'true'
#     ENV = '/root/.bashrc'
#     PWD = '/content'
#     TBE_EPHEM_CREDS_ADDR = '172.28.0.1:8009'
#     COLAB_LANGUAGE_SERVER_PROXY_REQUEST_TIMEOUT = '30s'
#     TBE_CREDS_ADDR = '172.28.0.1:8008'
#     NV_CUDNN_PACKAGE = 'libcudnn8=8.9.6.50-1+cuda12.2'
#     NVIDIA_DRIVER_CAPABILITIES = 'compute,utility'
#     COLAB_JUPYTER_TOKEN = ''
#     LAST_FORCED_REBUILD = '20240627'
#     NV_NVPROF_DEV_PACKAGE = 'cuda-nvprof-12-2=12.2.142-1'
#     NV_LIBNPP_PACKAGE = 'libnpp-12-2=12.2.1.4-1'
#     NV_LIBNCCL_DEV_PACKAGE_NAME = 'libnccl-dev'
#     TCLLIBPATH = '/usr/share/tcltk/tcllib1.20'
#     NV_LIBCUBLAS_DEV_VERSION = '12.2.5.6-1'
#     COLAB_KERNEL_MANAGER_PROXY_HOST = '172.28.0.12'
#     NVIDIA_PRODUCT_NAME = 'CUDA'
#     NV_LIBCUBLAS_DEV_PACKAGE_NAME = 'libcublas-dev-12-2'
#     USE_AUTH_EPHEM = '1'
#     NV_CUDA_CUDART_VERSION = '12.2.140-1'
#     COLAB_WARMUP_DEFAULTS = '1'
#     HOME = '/root'
#     LANG = 'en_US.UTF-8'
#     COLUMNS = '100'
#     CUDA_VERSION = '12.2.2'
#     CLOUDSDK_CONFIG = '/content/.config'
#     NV_LIBCUBLAS_PACKAGE = 'libcublas-12-2=12.2.5.6-1'
#     NV_CUDA_NSIGHT_COMPUTE_DEV_PACKAGE = 'cuda-nsight-compute-12-2=12.2.2-1'
#     COLAB_RELEASE_TAG = 'release-colab_20240711-060152_RC00'
#     PYDEVD_USE_FRAME_EVAL = 'NO'
#     KMP_TARGET_PORT = '9000'
#     CLICOLOR = '1'
#     KMP_EXTRA_ARGS = ('--logtostderr --listen_host=172.28.0.12 --target_host=172.28.0.12 '
 '--tunnel_background_save_url=https://colab.research.google.com/tun/m/cc48301118ce562b961b3c22d803539adc1e0c19/m-s-2v31ve1examkw '
 '--tunnel_background_save_delay=10s '
 '--tunnel_periodic_background_save_frequency=30m0s '
 '--enable_output_coalescing=true --output_coalescing_required=true')
#     NV_LIBNPP_DEV_PACKAGE = 'libnpp-dev-12-2=12.2.1.4-1'
#     COLAB_LANGUAGE_SERVER_PROXY_LSP_DIRS = '/datalab/web/pyright/typeshed-fallback/stdlib,/usr/local/lib/python3.10/dist-packages'
#     NV_LIBCUBLAS_PACKAGE_NAME = 'libcublas-12-2'
#     COLAB_KERNEL_MANAGER_PROXY_PORT = '6000'
#     CLOUDSDK_PYTHON = 'python3'
#     NV_LIBNPP_DEV_VERSION = '12.2.1.4-1'
#     ENABLE_DIRECTORYPREFETCHER = '1'
#     NO_GCE_CHECK = 'False'
#     JPY_PARENT_PID = '82'
#     PYTHONPATH = '/env/python'
#     TERM = 'xterm-color'
#     NV_LIBCUSPARSE_DEV_VERSION = '12.1.2.141-1'
#     GIT_PAGER = 'cat'
#     LIBRARY_PATH = '/usr/local/cuda/lib64/stubs'
#     NV_CUDNN_VERSION = '8.9.6.50'
#     SHLVL = '0'
#     PAGER = 'cat'
#     COLAB_LANGUAGE_SERVER_PROXY = '/usr/colab/bin/language_service'
#     NV_CUDA_LIB_VERSION = '12.2.2-1'
#     NVARCH = 'x86_64'
#     NV_CUDNN_PACKAGE_DEV = 'libcudnn8-dev=8.9.6.50-1+cuda12.2'
#     NV_CUDA_COMPAT_PACKAGE = 'cuda-compat-12-2'
#     MPLBACKEND = 'module://ipykernel.pylab.backend_inline'
#     NV_LIBNCCL_PACKAGE = 'libnccl2=2.19.3-1+cuda12.2'
#     LD_LIBRARY_PATH = '/usr/local/nvidia/lib:/usr/local/nvidia/lib64'
#     COLAB_GPU = ''
#     GCS_READ_CACHE_BLOCK_SIZE_MB = '16'
#     NV_CUDA_NSIGHT_COMPUTE_VERSION = '12.2.2-1'
#     NV_NVPROF_VERSION = '12.2.142-1'
#     LC_ALL = 'en_US.UTF-8'
#     COLAB_FILE_HANDLER_ADDR = 'localhost:3453'
#     PATH = '/root/.buildozer/android/platform/apache-ant-1.9.4/bin:/opt/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/google-cloud-sdk/bin'
#     NV_LIBNCCL_PACKAGE_NAME = 'libnccl2'
#     COLAB_DEBUG_ADAPTER_MUX_PATH = '/usr/local/bin/dap_multiplexer'
#     NV_LIBNCCL_PACKAGE_VERSION = '2.19.3-1'
#     PYTHONWARNINGS = 'ignore:::pip._internal.cli.base_command'
#     DEBIAN_FRONTEND = 'noninteractive'
#     COLAB_BACKEND_VERSION = 'next'
#     COLAB_CUSTOMIZE_FOR_VM_TYPE = '1'
#     OLDPWD = '/'
#     _ = '/usr/local/bin/buildozer'
#     PACKAGES_PATH = '/root/.buildozer/android/packages'
#     ANDROIDSDK = '/root/.buildozer/android/platform/android-sdk'
#     ANDROIDNDK = '/root/.buildozer/android/platform/android-ndk-r25b'
#     ANDROIDAPI = '31'
#     ANDROIDMINAPI = '21'
# 
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2**

If anybody has a solution please let me know.

Thanks in advance,

No_Trick705


r/StackoverReddit • • Jul 10 '24

Question Advice for GitHub

4 Upvotes

I have a web application to make this week as the first step in the recruitment process for a company. One of the requirements is to use GitHub so that they will be able to see my project and also my commits.

Should I just commit to the main branch, then, or should I create a different one? I was also thinking about making a branch for each individual functionality and making PRs and then merging into the branch with the final product, but I thought maybe this would be too much since it's just me working on the project.

What do you advice me to do?


r/StackoverReddit • • Jul 08 '24

C++ 📌 Asynchronous Programming With C++ 📌

4 Upvotes

Hi there, I've been working on a project in C++, and I am very proud of the results, I hope you like it.

The project is called NodePP, it is a framework for C++, which changes the syntax of C++, for one that is more friendly and similar to NodeJS. In order to create scalable and efficient applications in C++.

The project adds support for:

  • 📌: Coroutines & Generators

  • 📌: Regex & Json Processing

  • 📌: HTTP/s, TCP, TLS & WebSocket servers

  • 📌: HTTP/s, TCP, TLS & WebSocket clients

  • 📌: Events, Promises, Observers & Timers

The great thing about this project is that I do not use threads at all, but internally create an Event-Loop, which is responsible for executing the tasks in the background, and with the help of the native non-blocking api (windows | posix) , and with the help of Poll ( Poll | Epoll | WsaPoll ), create a 100% asynchronous framework.

Here is the link of the project:

If you are interested in knowing the usefulness of this framework, here is a list of projects that I have done 100% with this framework:


r/StackoverReddit • • Jul 08 '24

Java First Mini Java "Project".

4 Upvotes
package Currencies;

import java.util.NoSuchElementException;
import java.util.Scanner;

public class converterInterface {
  private String input;
  Scanner scanner = new Scanner(System.in);

  public static void main(String[] args) {
    converterInterface c = new converterInterface();
    c.myInterface();
  }

  protected String ThrowInvalidValueException() {
    String error = "Invalid value!!!";
    System.out.println(error);
    return error;
  }

  public void RequestUserInput() {

    System.out.print("There are 5 currencies that can be converted: Naira, Euros, Cedis, Pounds, Dollars.");

    System.out.print(
        "\nType in the individual name of the currency you want to convert, then type in the individual name of the currency you want to convert it to.");

    System.out
        .print("\nNOTE: You can not convert a currency to itself!! You can type in \"exit\" to stop the application");
     
    while(___){
    System.out.println("\nWhat currency would you like to convert: ");

    input = scanner.nextLine().toLowerCase();
    myInterface();
}

  }

  public void myInterface() {

    String sInput = null;
    switch (input) {
      case "naira":
        Naira naira = new Naira();
        System.out.print("To what currency would you like convert Naira: ");
        sInput = scanner.nextLine().toLowerCase();

        switch (sInput) {
          case "euros":
            naira.NairaToEuros();
            break;

          case "dollars":
            naira.NairaToDollars();
            break;

          case "pounds":
            naira.NairaToPounds();
            break;

          case "cedis":
            naira.NairaToCedis();
            break;
          default:
            ThrowInvalidValueException();
        }
        break;

      case "cedis":
        Cedis cedis = new Cedis();
        System.out.print("To what currency would you like convert Cedis: ");
        sInput = scanner.nextLine().toLowerCase();

        switch (sInput) {
          case "euros":
            cedis.CedisToEuros();
            break;

          case "dollars":
            cedis.CedisToDollars();
            break;

          case "pounds":
            cedis.CedisToPounds();
            break;

          case "naira":
            cedis.CedisToNaira();
            break;
          default:
            ThrowInvalidValueException();

        }
        break;

      case "pounds":
        Pounds pounds = new Pounds();
        System.out.print("To what currency would you like convert Pounds: ");
        sInput = scanner.nextLine().toLowerCase();

        switch (sInput) {
          case "euros":
            pounds.PoundsToEuros();
            break;

          case "dollars":
            pounds.PoundsToDollars();
            break;

          case "naira":
            pounds.PoundsToNaira();
            break;

          case "cedis":
            pounds.PoundsToCedis();
            break;
          default:
            ThrowInvalidValueException();

        }
        break;

      case "euros":
        Euros euros = new Euros();
        System.out.print("To what currency would you like convert Euros: ");
        sInput = scanner.nextLine().toLowerCase();

        switch (sInput) {
          case "pounds":
            euros.EurosToPounds();
            break;

          case "dollars":
            euros.EurosToDollars();
            break;

          case "naira":
            euros.EurosToNaira();
            break;

          case "cedis":
            euros.EurosToCedis();
            break;
          default:
            ThrowInvalidValueException();

        }
        break;

      case "dollars":
        Dollars dollars = new Dollars();
        System.out.print("To what currency would you like convert Dollars: ");
        sInput = scanner.nextLine().toLowerCase();

        switch (sInput) {
          case "pounds":
            dollars.DollarsToPounds();
            break;

          case "euro":
            dollars.DollarsToEuros();
            break;

          case "naira":
            dollars.DollarsToNaira();
            break;

          case "cedis":
            dollars.DollarsToCedis();
            break;
          default:
            ThrowInvalidValueException();

        }
        break;

      default:
        ThrowInvalidValueException();

    }
  }

}

This is a mini currency converter app I made. All the values for conversion were already predetermined by me. I'm having some trouble trying to loop through the code in the RequestUserInput method cause it keeps throwing this error {"What currency would you like to convert: Exception in thread "main" java.util.NoSuchElementException: No line found at java.base/java.util.Scanner.nextLine(Scanner.java:1651) at Currencies.converterInterface.myInterface(converterInterface.java:31) at Currencies.converterInterface.main(converterInterface.java:8)"} at me and idk what to do. This code is also pretty crude as I am new to java.


r/StackoverReddit • • Jul 03 '24

Python Help Creating Code That Goes Through Excel File and Selectively Copies Data Into Different Excel File

4 Upvotes

Hi all!

This is a repeat post, but I think posting it in this subreddit is more appropriate than that which I originally posted in as it is a pretty specific request. I am trying to create a code that will iterate through rows in an Excel file. Starting with column E and up through column Z, I would like the program to see if the cell is empty or not. If not, I would like the code to distribute the values of columns A-D in that row into columns A-D of the destination workbook. I would like the current cell (somewhere in columns E-Z) to be placed into Column E of the destination workbook. For context, columns E-Z will contain values that have been separated by Text to Column, but I still want each to be individually associated with the data in columns A-D.

I have included my code below. I am not receiving any error messages but nothing is being distributed into the destination workbook. I would really love any insight into what fixes I can implement or whether this is close to anything (should I approach it differently, such as using pandas?). Thank you very much in advance!!

import openpyxl
from openpyxl import Workbook, load_workbook
def copy_data(source_sheet, destination_sheet):
    for row in source_sheet.iter_rows(min_row=2, min_col=1, max_col=26, values_only=True):
        for cell in row:
            if cell is not None:
                # Determine the column index of the current cell
                column_index = row.index(cell) + 1  # Index starts from 0, column from 1
                # Copy data from source to destination sheet
                dest_row = destination_sheet.max_row + 1
                destination_sheet.cell(row=dest_row, column=1).value = source_sheet.cell(row=column_index, column=1).value  # Column A
                destination_sheet.cell(row=dest_row, column=2).value = source_sheet.cell(row=column_index, column=2).value  # Column B
                destination_sheet.cell(row=dest_row, column=3).value = source_sheet.cell(row=column_index, column=3).value  # Column C
                destination_sheet.cell(row=dest_row, column=4).value = source_sheet.cell(row=column_index, column=4).value  # Column D
                destination_sheet.cell(row=dest_row, column=5).value = str(column_index)  # Current cell in columns E-Z


# Load the source and destination workbooks
source_wb = load_workbook('/Users/KALII/Downloads/Data For Delimiter Experiment.xlsx')
destination_wb = load_workbook('/Users/KALII/Downloads/SeniorManagementTrackerAppendRows.xlsx')
# Assigning sheets
source_sheet = source_wb.worksheets[0]
destination_sheet = destination_wb.active

copy_data(source_sheet, destination_sheet)

# Save the destination workbook
destination_wb.save('SeniorManagementTrackerAppendRows.xlsx')

r/StackoverReddit • • Jul 01 '24

how can I find high paying freelancing clients as a web developer

4 Upvotes

r/StackoverReddit • • Jun 30 '24

Question PDF File cannot be opened when uploaded to Supabase, I am using Puppeteer to convert HTML to a PDF

4 Upvotes

r/StackoverReddit • • Jun 28 '24

Python Need help at this event-discrete-simulation problem

Thumbnail
self.learnpython
4 Upvotes

r/StackoverReddit • • Jun 27 '24

Python Optimizing KDTree in a loop

4 Upvotes

I'm using Python and scipy KDTree to help find the nearest points in an FEA analysis. It boils down to a rotating shaft inside a cylinder and I want to find the minimum gap between the shaft and cylinder at every tine point.

Given that I have 100s of points to check for >10,000 time points it leads a decently long run time. Any tips on improving run time or perhaps a better method for this?

Pseudo code:

shaft_points = get_shaft_history() # XYZ point time history

cyl_points = get_cyl_history()  #XYZ point time history

time = range(10000)
gap = [1e6] * len(time)

for cp in cyl_points: # loop over each point
    for t in time:  # loop over time
        sp = shaft_points[i, :] # all shaft points at time t
        kdtree = KDTree(sp)
        dist, point = kdtree.query(cp, k=1) # find closest point between shaft and cylinder at time t
        if dist < gap[t]:
            gap[t] = dist  # set new min value

r/StackoverReddit • • Jun 24 '24

Dijkstra and Prim Algorithms, Variants and their Differences

4 Upvotes

So I'm getting slightly confused. In our lectures, we learned about these two implementations of Prim and Dijkstra that use PQs. But on GeeksForGeeks, you don't use the PQ but instead you kind of 'mark' something as a solution by including them into a boolean array...

For Prim (GeeksForGeeks)

  • Set all node weights to infinity.

  • Pick one node and set it's weight to 0.

  • Update all the node weights based on the edge weight from your node to adjacent node

  • Pick the node with the smallest node weight

  • Repeat (For-loop V-1 times)

For Prim (Our Version)

  • Set all node weights to infinity

  • Pick one node and set it's weight to 0.

  • Initialize a PQ, because you set your node's weight to 0, the first one that will be popped off will be your node.

  • Get the node with smallest node weight from your PQ

  • If your node is inside the PQ and the edge weight is smaller than it's node weight, update your node (PQ gets updated as well)

  • Repeat until PQ empty

For Dijkstra (GeeksForGeeks)

  • Set all node weights to infinity

  • Pick one node and set it's weight to 0

  • Update all node weights based on the edge weight from your node to adjacent node. The update is cumulative, so you don't just assign the edge weight like in Prim but sum it with the one of your node.

  • Pick the node with the smallest node weight

  • Repeat (For loop V-1 time

For Dijkstra (Our Version)

  • Set all node weights to infinity

  • Pick one node and set it's weight to 0

  • Initialize a PQ

  • Get the node with the smallest node weight from your PQ

  • For all adjacent nodes, relax them, that is, update them cumulatively.

  • Repeat until PQ is empty

Main Differences

The GeeksForGeeks version of Prim and Dijkstra are practically identical. Their only difference is how the node weights are updated. Prim will just assign the edge weight to the node, whereas Dijkstra does it cumulatively.

Our version is also almost the same. Dijkstra also updates stuff cumulatively which is called 'relaxation' but for some reason in Dijkstra, we do not check if the node is in the PQ like in Prim. Do you guys know why?

Also, is the GeeksForGeeks version actually ineffcient? Because the bottleneck is this extractMin function which can become constant if you implement a PQ. The for loop that runs V-1 iterations should be the same as the while loop that runs until PQ is empty, since the PQ is only empty after V nodes are extracted.

References:
https://www.geeksforgeeks.org/dijkstras-shortest-path-algorithm-greedy-algo-7/

https://www.geeksforgeeks.org/prims-minimum-spanning-tree-mst-greedy-algo-5/

For our version, I have the pseudocode. If requested, I'll uploud images but for the time being I leave it like this.


r/StackoverReddit • • Jun 20 '24

C Do people hash on pointers in practice?

4 Upvotes

So I was solving LeetCode problems and I use C and I realized that whenever I have to implement my own hashMap, I just kind of wing the function by looking up good hashFunctions or just using the modulo on the upper bound provided by the task description. But sometimes the task doesn't specify if the values are distinct or not and then I had a realization.

If we hash on pointers, wouldn't we have a guarantee that at least all values we hash are unique? So the only thing that causes the collision is the hashFunction itself and nothing else. We still have to resolve them either with chaining or open adressing but at least we can now just never worry about duplicates.

EDIT:
I think what I posted here a but stupid. So I'll explain why I had this realization in the first place.

There was a problem that was about detecting cycles in a linked list and yes, the 'smart solution' is using the runner/walker resp. hare/tortoise or whatever you want to call it technique. But there is also as solution that involves hashing and the idea was, instead of hashing on the node value, you should hash on the pointer of that node. So even if you had a linked list with duplicate values, you have a guarantee that all nodes are considered to be distinct and the only time you hash something at the same spot twice is when you have a cycle. Perhaps the whole 'hashing on pointer' only makes sense for this specific task.


r/StackoverReddit • • Jun 15 '24

Merging Two Sorted Linked List in O(n) or O(n^2) time?

4 Upvotes

So I was solving a LeetCode problem and got confused by my own solution. I provide the code.

Here the helper functions I used:

struct ListNode * createNode(int value){
    struct ListNode * newNode = malloc(sizeof(struct ListNode));
    newNode->val = value;
    newNode->next = NULL;
    return newNode;
}

struct ListNode * insertEnd(struct ListNode * root, int val){
    struct ListNode * newNode = createNode(val);
    if(root==NULL){
        return newNode;
    }
    struct ListNode * p = root;
    while(p->next !=NULL){
        p = p->next;
    }
    p->next = newNode;
    return root;
}

struct ListNode * insertNormal(struct ListNode * root, int val){
    struct ListNode * newNode = createNode(val);
    if(root==NULL){
        return newNode;
    }
    newNode->next = root;
    root = newNode;
    return root;
}

struct ListNode * reverseLinked(struct ListNode * root){
    struct ListNode * output = NULL;
    struct ListNode * p = root;
    while(p!=NULL){
        output = insertNormal(output, p->val);
        p = p->next;
    }
    return output;
}

So the issue I'm struggling with:

If I merge two sorted linked list using insertEnd, I get the exact result but I think it takes quadratic time because my function insertEnd is upper bounded on O(n), isn't it? So we have something linear that is nested in something else that is linear, resulting in O(n^2)?

Alternatively, if I merge sorted linked list using insertNormal, it should take linear time. And reversing the result also takes linear time. So the end result is still O(n) overall.

Here the two merge algos:

Merging using insertEnd

struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2) {
    struct ListNode * p1 = list1;
    struct ListNode * p2 = list2;
    struct ListNode * output = NULL;
    while(p1!=NULL && p2!=NULL){
        if(p1->val > p2->val){
            output = insertEnd(output, p2->val);
            p2 = p2->next;
        }
        else{
            output = insertEnd(output, p1->val);
            p1 = p1->next;
        }
    }
    while(p1!=NULL){
        output = insertEnd(output, p1->val);
        p1 = p1->next;
    }
    while(p2!=NULL){
        output = insertEnd(output, p2->val);
        p2 = p2->next;
    }
    return output;
}

Merging using insertNormal + Reverse

struct ListNode* mergeTwoLists(struct ListNode* list1, struct ListNode* list2) {
    struct ListNode * p1 = list1;
    struct ListNode * p2 = list2;
    struct ListNode * output = NULL;
    while(p1!=NULL && p2!=NULL){
        if(p1->val > p2->val){
            output = insertNormal(output, p2->val);
            p2 = p2->next;
        }
        else{
            output = insertNormal(output, p1->val);
            p1 = p1->next;
        }
    }
    while(p1!=NULL){
        output = insertNormal(output, p1->val);
        p1 = p1->next;
    }
    while(p2!=NULL){
        output = insertNormal(output, p2->val);
        p2 = p2->next;
    }

    output = reverseLinked(output);

    return output;
}

r/StackoverReddit • • Jun 10 '24

Should I start with Python or C/C++ for Robotics and AI Development?

4 Upvotes

Hello everyone,

I'm planning to dive into robotics and AI development with ambitious goals like building robots, mechs, power armor, AI systems, and bionics. I’m also looking to gain the skills needed to create something fun, like a game, and ultimately aim to make a career out of these interests.

Current Situation:

  • I already have an Arduino, which my brother gave me, and I’m excited to start building with it.

  • Since I'm still in high school, I also want to learn something that I can monetize easily to fund my projects and research.

My Dilemma:

  • I’m unsure whether I should begin with Python or C/C++. I understand both languages have their strengths, but I want to make sure I choose the one that aligns best with my long-term goals and provides a solid foundation for both software and hardware integration.

Additional Context:

  • Python is praised for its simplicity and is widely used in AI, machine learning, and high-level robotics programming.

  • C/C++ is known for its performance and control, especially useful for low-level hardware programming and real-time systems.

Questions:

  1. Which language would be more beneficial to start with given my goals?

  2. How should I leverage my Arduino to enhance my learning experience?

  3. Are there specific projects or resources you would recommend for a beginner in robotics and AI?

  4. What skills should I focus on to monetize my knowledge and fund my projects?

Any advice or insights from your experiences would be greatly appreciated!

Thanks in advance for your help!


r/StackoverReddit • • Jun 10 '24

Important

4 Upvotes