• Breaking News

    Wednesday, June 23, 2021

    Issue with Kotlin variable inheritance Ask Programming

    Issue with Kotlin variable inheritance Ask Programming


    Issue with Kotlin variable inheritance

    Posted: 22 Jun 2021 05:00 PM PDT

    I have been writing some generic classes / interfaces in Kotlin to try to reduce the amount of code needed to interact with a number of entities in Spring. I have extended the Persistable class and defined an abstract variable, ID, that is common to all of the entities:

    abstract class PersistableWithUpdates<ENTITY: Any, KEY: Serializable> : Persistable<KEY>, IdEntity<KEY>() { abstract override var ID: KEY var updated: Boolean = false override fun getId(): KEY = ID override fun isNew(): Boolean{ println("id: $ID, isNew: ${!updated}") return !updated } fun markUpdated(){ updated = true } // ... } 

    This class implements another abstract class containing the abstract ID variable:

    abstract class IdEntity<T: Serializable>{ abstract var ID: T } 

    The following entity has been my test bed for the PersistableWithUpdates class:

    @Entity @Table(name = "links") data class CacheLink( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) override var ID: Int = 0, @Column(nullable = false) var url: String = "", @Column(nullable = false) var title: String = "", ) : PersistableWithUpdates<CacheLink, Int>(){ // ... } 

    In my test service, I have been trying to check the functionality of the markUpdated function by creating links that share the same ID and marking them as updated. Upon saving, however, all of the links are inserted as new links. To debug, I tried stepping through the debugger and didn't see anything wrong. I resorted to added a print statement immediately before the save and another in the isNew function. The result for a test with one insert and one update was the proper update values (false for the insert, true for the update), but the values were incorrect in the isNew function print:

    id: 0, isNew: true id: 0, isNew: true 

    From the values given, it seems like the default values for id and updated are being used in the isNew function, regardless of what values are set in the class. I've tried tweaking the code several times, including using an open var and an abstract var for updated, but I get the same result regardless. I assume that I misunderstand something about how the Kotlin inheritance system works, but I have yet to find a solution reading through the docs. A nudge in the right direction would be appreciated.

    submitted by /u/omegaweasel
    [link] [comments]

    is there anthing you can do on visual basic that you can't in c# or vice versa?

    Posted: 23 Jun 2021 04:17 AM PDT

    I am student in electronic engineering school(I will get my degree once I am done with my intership).

    in the first semester we studied visual basic and in the second semester c#.

    I don't really see much difference between these 2 languages.

    I just write the same commands with 2 different ways.

    is c# just a worse version of visual basic?or simply the educational system has left out a lots of things that should be taught to me?

    according to this site https://www.javatpoint.com/vb-net-vs-c-sharp events are automatically bound in visual basic and in c# they don't even exist,what are the "events"?

    and what are the"structured"and "unstructured" error handlings it is talking about?

    (I haven't touched either of these languages in years by the way)

    submitted by /u/soiramio3000
    [link] [comments]

    Display/embed interactive wireframes (figma) on a website

    Posted: 23 Jun 2021 02:41 AM PDT

    Is there a way to display a wireframe (like one made in figma or Adobe XD) that can be scrolled and clicked and be interactive in general but still only be embedded on the website itself?

    Let me explain what I have in mind, I want a website to display different apps that can be experienced all at once basically. An app should be displayed like a "card" on the site and when the mouse is hovering over it, you can scroll the inside of the card and potentially click on items inside the card which could change the view inside of said card.

    Hope I made it clear and what I hope even more is that there is already some kind of framework for this^

    I'm thankful for any advice :)

    submitted by /u/nightsky_
    [link] [comments]

    How to track changes in a database/API I don’t control?

    Posted: 22 Jun 2021 10:07 PM PDT

    Hi there, I use an app, which has pretty terrible change logging, so I want to build something that connects to their API and can identify what's changes have been made since a certain date.

    Unfortunately the API doesn't have webhooks, so I need to periodically connect to the API, download all the data, and then try to identify anything that might have changed since the previous time I connected.

    1 way of doing this is to just loop through all the transactions each time and compare line by line, but I was hoping there would be a smarter way?

    I've tried googling but I can't find and good rabbit holes to go down to figure out a solution.

    submitted by /u/TheOneMerkin
    [link] [comments]

    CORS ISSUE WITH FLASK

    Posted: 22 Jun 2021 09:41 PM PDT

    I am trying to make a chatbot front end with flask and Ajax

    when I run the flask app from my command line everything works fine

    but when I open the index.html file and try to enter data into the text-field it throws the following error on clicking the post button

    Access to XMLHttpRequest at 'file:///C:/chatbot' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https

    and

    Failed to load resource: net::ERR_FAILED

    also the frontend looks as I want it when I run the flask app through the command line

    but when I open the index.html file everything automatically changes dimensions

    such as the width, height and all

    I have tried passing all the headers correctly and almost every thing available on the web

    submitted by /u/yuv0918
    [link] [comments]

    Simple unix awk question

    Posted: 22 Jun 2021 09:32 PM PDT

    can someone help with unix awk command? i can't get this variable logstart to print, it just prints the string

    awk '/---/ { print "---\n\n\ ${logstart} \n" ; next } 1' "$tmpfile" thanks for any help

    submitted by /u/AccurateSun
    [link] [comments]

    Software developers, did you build your own app templates?

    Posted: 22 Jun 2021 01:35 PM PDT

    I'm thinking something like having an ui with a webserver and a db with some dummy business logic.

    I only have some years of experience but it seems to me that most new projects face a common set of issues like an inefficient infrastructure for tests, setting up linters/prettiers, non centralized error handling or setting up the build deploy pipeline. This things are not strictly business relevant so they are not prioritized at the beginning. But they also seem to be the things that make development harder as time passes. It's also harder to add them later on in the development process.

    Have you automated this? Was it worth it?

    submitted by /u/Gifaro
    [link] [comments]

    Transitioning from Aerospace Engineering to Software as a student - should I get a certificate?

    Posted: 22 Jun 2021 11:16 AM PDT

    I'm currently studying a BEng in Aerospace Engineering at a UK university. I have been thinking of slowly improving my programming and potentially transitioning to a software role either within the Aerospace industry itself or outside of it. I am currently enrolled in the MIT 6.00.1x: Introduction to Computer Science and Programming Using Python course, and I was wondering whether it would be worth obtaining the certification as proof that I am competent in Python; this is particularly important to me if I wish to move out of the industry.

    The general consensus I've read is that certification is not really worth it but as I have no Computer Science bachelor's I was wondering whether just having a bunch of projects on GitHub would be sufficient to get a good entry-level job.

    submitted by /u/Skelzor01
    [link] [comments]

    How to recieve input from computer in .ReadLine() methods like those used in websites that people used to practice programming

    Posted: 22 Jun 2021 04:40 PM PDT

    So my team wants to replicate the test case feature from those websites but I can't wrap my head around how this works nor how to do it. Can somebody please guide me on how it works or give a hint on what to search? My google searches are not giving me any helpful links

    submitted by /u/DarkTech1399
    [link] [comments]

    JavaScript Video.js

    Posted: 22 Jun 2021 07:39 PM PDT

    Hi! I'm using Video.js as my primary media player (https://github.com/videojs/video.js) and I was curious on how exactly I can work to implement the incorporation of .srt files (captioning).

    I want to allow users to upload a .srt file and then include that src in the video.js options setup. To do this, would I need to connect to something like Amazon S3 to get a URL of the srt file to be able to include it in my video.js setup? Or how could I go about this.

    submitted by /u/InvictusJoker
    [link] [comments]

    Wait to click a button after appearing on the page with Tampermonkey

    Posted: 22 Jun 2021 07:38 PM PDT

    There's a button on a web page that I would like to automatically click. The problem is that it only appears on the page once another button has been clicked. I've successfully automated the first click, but I have not been able to automate the second click once that button has appeared.

    The following code works when I run it in the console after the button has appeared:

    // ==UserScript== // @name Soundplate SUBMIT MUSIC Button // @include https://play.soundplate.com/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js // @grant GM_addStyle // ==/UserScript== var TargetLink = $("a:contains('SUBMIT MUSIC')") if (TargetLink.length) window.location.href = TargetLink[0].href 

    But I'm not quite sure how to run it after the first click has occurred / after the button has appeared on the page.

    I've heard of waitForKeyElements, but I'm not exactly sure how I'd implement it here. That might be the solution. Any and all advice would be deeply appreciated.

    submitted by /u/the_crabnebula
    [link] [comments]

    What is the sqlite equivalent of postgres array_to_json and row_to_json?

    Posted: 22 Jun 2021 01:23 PM PDT

    How do I fix "leaked semaphores" on StyleGAN CoLab?

    Posted: 22 Jun 2021 03:35 PM PDT

    Pls help,,,I keep getting a semaphore error and then my training stops. I'm not sure what that means

    Evaluating metrics... /usr/local/lib/python3.7/dist-packages/torch/utils/data/dataloader.py:481: UserWarning: This DataLoader will create 3 worker processes in total. Our suggested max number of worker in current system is 2, which is smaller than what this DataLoader is going to create. Please be aware that excessive worker creation might get DataLoader running slow or even freeze, lower the worker number to avoid potential slowness/freeze if necessary. cpuset_checked)) /usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py:1051: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at /pytorch/c10/core/TensorImpl.h:1156.) return forward_call(*input, **kwargs) /usr/lib/python3.7/multiprocessing/semaphore_tracker.py:144: UserWarning: semaphore_tracker: There appear to be 34 leaked semaphores to clean up at shutdown len(cache))

    submitted by /u/orb1111
    [link] [comments]

    Can't connect to localhost:8000

    Posted: 22 Jun 2021 03:55 AM PDT

    Hello, programming student here! I'm really new to this and have no background whatsoever. Actually, I'm not sure if I can even word my question properly but here I go,

    I have a problem using phpMyAdmin for my project. I'm using JavaScript and my professor made us a server(?) that I'm not really sure how to use.

    So I have to make a simple enrollment system that saves the user's input from a registration form, and then allows that user to login to the site. The user's input should end up in the database in phpMyAdmin. But when I try to GET or POST the user's input nothing changes in the database?

    The errors say "CORS Failed" and "NS_ERROR_DOM_BAD_URI" and " Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8000/enrollment/update. (Reason: CORS request did not succeed). "

    I'm so lost I don't even know what I'm doing. Help!!

    submitted by /u/somnusson
    [link] [comments]

    Webhook Listener MERN stack

    Posted: 22 Jun 2021 06:52 PM PDT

    I created a MERN stack app with a webhook endpoint on my Node server. This is called by a different client. What is the best way to notify my React front end when the external client calls my webhook endpoint? I looked at using a websocket, though this doesn't seem to give me exactly what I want, as I believe they're intended to be connected to the React front end and send/rec messages that way. Any insight is appreciated.

    edit: Polling is an option, but I wanted to limit the number of API requests made.

    submitted by /u/shiner_bock_
    [link] [comments]

    Help compiling degrib from NOAA on ubuntu

    Posted: 22 Jun 2021 06:28 PM PDT

    Hello all,

    I am attempting to compile the degrib application from NOAA. It's a fairly small program, the source is available here:

    https://vlab.noaa.gov/web/mdl/degrib-download

    Should be easy if all the dependencies are met, but I'm not that adept at configure. I don't suppose any of you have compiled it before, but considering I think my issues are more (gnu) configure related I figured I'd try here...

    As the instructions say, I download the tarball, go to the src dir, run configure, and run make.

    I get these errors though:

    xmlIO.c:(.text+0x425): undefined reference to `gzopen64' xmlIO.c:(.text+0x50d): undefined reference to `gzopen64' ../libxml/.libs//libxml2.a(xmlIO.o): In function `__xmlOutputBufferCreateFilename': xmlIO.c:(.text+0x47fd): undefined reference to `gzopen64' xmlIO.c:(.text+0x48af): undefined reference to `gzopen64' ../libxml/.libs//libxml2.a(xzlib.o): In function `xz_head': xzlib.c:(.text+0x4ba): undefined reference to `lzma_auto_decoder' xzlib.c:(.text+0x59a): undefined reference to `lzma_properties_decode' ../libxml/.libs//libxml2.a(xzlib.o): In function `xz_decomp': xzlib.c:(.text+0x105d): undefined reference to `lzma_code' ../libxml/.libs//libxml2.a(xzlib.o): In function `__libxml2_xzclose': xzlib.c:(.text+0x1c85): undefined reference to `lzma_end' 

    I can get the gzopen64 errors to go away by copying /usr/lib/x86_64-linux-gnu/libz.a to the src/zlib directory. However I shouldn't have to since zlib1g-dev is installed.

    I can't find an equivalent trick to the lzma ones, but copying some static library into the source isn't really a great idea anyway. I believe I also have the appropriate libxml2 packages installed which should provide - at least, /usr/lib/x86_64-linux-gnu/liblzma.a and .so exist...

    I'm not good at configure outside of running it...how can I check where configure is looking for these libraries and modify it so it's using the right ones?

    Some googling suggested:

    export LDFLAGS='-L/usr/lib/x86_64-linux-gnu'

    but that didn't work. configure --help provides a switch (--with-zlib) for zlib but there's nothing for lzma/libxml2.

    submitted by /u/TurbulentViscosity
    [link] [comments]

    Can't Find Fairy Floss Terminal Link..

    Posted: 22 Jun 2021 06:09 PM PDT

    I really like the Fairy Floss theme and would like to put it as the theme for my terminal. The thing is I can't find any..

    submitted by /u/Cyxuz
    [link] [comments]

    My kali is just stuck at the time screen, how to fix this?

    Posted: 22 Jun 2021 08:47 PM PDT

    Should I purchase a new laptop/tablet?

    Posted: 22 Jun 2021 12:57 PM PDT

    So, a little information about my current laptop. It's an Acer Aspire V Nitro 17" laptop, running Intel Core i7-4720HQ CPU @ 2.60GHz, 8GB of RAM, Nvidia GeForce GTX 860M.

    I'm not sure about any other specs, or if any other specs matter for programming.

    I'm contemplating purchasing Microsoft's Surface Pro 7 2-in-1 tablet. I've heard good things about it. I would like the portability of the Surface Pro 7, along with the long battery life. The battery on my laptop is currently dead (I have to keep it connected to an outlet) And if I'm connected to a portable battery, I would like to have the least power consumption available. My laptop consumes a lot out of my portable battery, so having the long battery life + low power consumption makes me consider Surface Pro.

    But I've heard some bad things about using a tablet. You can't do any major programming with it, and wondering why. If I can run Visual Studios, then shouldn't' I be able to code anything?

    I'm brand new to coding. Learning HTML, and want to become a front end developer. And I want to be able to code whilst I'm out camping, in nature, etc. Might as well work and enjoy nature, outdoors, etc. if I can.

    Thoughts on the Surface Pro 7? Any other laptop suggestions? Or should I just stick to my current laptop?

    Problem with my current laptop is it's pretty slow. It takes a while to load anything (including File Explorer, or right clicking anywhere) but once it's loaded, it's pretty quick. Like I'm having no problems typing this out.

    Edit: Thanks for all the tips and help everybody! I purchased an SSD 1Tb and 16GB of RAM. Now to figure out how to install it! <3

    submitted by /u/LoLTAJ
    [link] [comments]

    Where do i start if i want to build a service that's equal to Yodeck?

    Posted: 22 Jun 2021 12:40 PM PDT

    i'd also like to know wich framework they're using. Similar sites are: https://www.novisign.com/ https://dwall.online/ https://broadsign.com/ Im assuming is some kind of cms on top of AWS, but i'd like guidance on where to start

    submitted by /u/brusslipy
    [link] [comments]

    *EASY FIX* stupid c coding assignment our teacher gave us.

    Posted: 22 Jun 2021 09:37 PM PDT

    Hey guys!

    New to coding here. Our teacher gave an assignment and told us to compile the program with this make file, but i keep getting this error somehow. Probably a typo or some crap. :)

    gcc -Wall -std=c99 -Werror -pedantic -o a.out e2.c2Makefile:2: recipe for target 'all' failed3

    Error output:
    1e2.c: In function 'main':2e2.c:14:3: error: statement with no effect [-Werror=unused-value]3 for(i = a; i < b; i + c) 4 ^5cc1: all warnings being treated as errors6make: *** [all] Error 17

    HERE'S THE CODE:

    #include <stdio.h>

    #include <stdlib.h>

    int main(int argc, char **argv)

    {

    /* The variable 'a', 'b' and 'c' are the first, second and third

    * arguments respectively */

    int a = atoi(argv[1]);

    int b = atoi(argv[2]);

    int c = atoi(argv[3]);

    int i;

    /* Your code here */

    for(i = a; i < b; i + c)

    {

    printf("%d",i);

    }

    }

    if you guys could give me a fix, that would be amazing! Thanks!

    submitted by /u/Nurobyte1
    [link] [comments]

    C#/Assembly/Doesn't matter - How do compilers identify the calling convention of external functions?

    Posted: 22 Jun 2021 10:37 AM PDT

    Hi, this is a bit of an "odd" question but regardless I am posting here out of desperation because my stackoverflow question is getting 0 comments, 0 answers & low views:

    I'm writing a compiler (hobby) and am trying to perform something similar to this equivalent (C#):

    [DllImport("User32.dll")] private static extern Int32 wsprintfA (IntPtr i,String s0,Int32 i0); // c calling convention [DllImport("Kernel32.dll")] private static extern Int32 GetTickCount (); // standard [DllImport("User32.dll")] private static extern Int32 MessageBoxA (IntPtr i,IntPtr i0,String s0,Int32 i1); // standard public static void Main (String[] args) { // this serves no purpose other than to use two unique calling conventions String str="Number: -00000000000."; IntPtr ptr=Marshal.StringToHGlobalUni(str); wsprintfA(ptr,"Number: %d.",GetTickCount()); MessageBoxA(IntPtr.Zero,ptr,"...",0); Marshal.FreeHGlobal(ptr); } 

    which works for stdcalls, except when the c calling convention for instance is called the stack isn't returned to its original position. I need to detect the calling convention in order for the compiler to know to set the stack to its original position, this is the compilation error in assembly (FASM syntax):

     format PE start: call [GetTickCount] mov ebp,esp ; <-- This line is never compiled push eax push someStrFormat push someStr call [wsprintfA] ; C calling convention ; Important: This line is never compiled either mov esp,ebp ; <-- ; The compiler ignores the necessary instructions that ; are required for c calling convention functions to ; return the stack to normal, because it cannot ; detect the calling convention of the function push 0 push someStr push someStr push 0 call [MessageBoxA] xor eax,eax ret someStr: rb 32 someStrFormat: db 'No. %d',0 section '.idata' import data readable writeable dd 0,0,0,RVA kernel_name,RVA kernel_table dd 0,0,0,RVA user_name, RVA user_table dd 0,0,0,0,0 kernel_table: GetTickCount dd RVA _GetTickCount dd 0 user_table: MessageBoxA dd RVA _MessageBoxA wsprintfA dd RVA _wsprintfA dd 0 kernel_name db 'KERNEL32.DLL',0 user_name db 'USER32.DLL',0 _GetTickCount dw 0 db 'GetTickCount',0 _MessageBoxA dw 0 db 'MessageBoxA',0 _wsprintfA dw 0 db 'wsprintfA',0 

    literally ANY help or information is appreciated

    submitted by /u/coomphs
    [link] [comments]

    Robotics algorithm for grid navigation

    Posted: 22 Jun 2021 12:44 PM PDT

    So i have this boe bot and a 5*5 grid and i want it to navigate through the grid. Like the input would be the coordinates it should go to and i will only know the starting co-ordinate when I put it on the grid, after that it has to come up by itself on where to go for the next co-ordinate, and i am a bit clue less on how to do this, i am thinking it will probably use some kind of SLAM, algorithm but i don't know what kind. So if anyone can help me with the algorithm for this it would be much appreciated.

    Example- input like -'A1N B2 C3' So basically robot will start at 0,0(meaning i will put robot at 0,0) then go to 2,2 and then to 3,3.

    submitted by /u/sericsheon
    [link] [comments]

    Introducing new processes in my team.

    Posted: 22 Jun 2021 04:24 AM PDT

    In my team I got the task to introduce and supervise new processes. This was not really specified. We are a little R&D team with embedded projects. One or so year ago I introduced the team to the concept of unit test. It is hard to do in embedded projects except for modules and drivers. e.g.: specific temperature sensor is mockable and it is worth to unit test since the driver is reusable in other projects.
    Not so long ago I started to introduce the idea of CI/CD to the team, and they like it. I got three months to implement this new processes. Since I myself is selftaught in this I have a vague understanding, I would like to ask for your help to not make obvious mistakes. We use Bitbucket and JIRA and rarely Confluence. In the last year or so I learned about CI/CD, docker, ceedling for C test.
    My ideas so far:

    1. Delegate unit tests for the team. ( we have a few driver which would worth to unit test).
    2. Implement a coding guideline or even a linter. (Of course team decision which one)
    3. Introduce new processes, like:
      1. How a pull request is accepted(who review which kind of code, how many reviewers)
      2. How you should name your commits. (JIRA ticket number, descriptive msg)
      3. Documentation. ( I am not big on documentation, so I would accept any advice here.)
      4. Better documentation for tools.
      5. Introduce some kind of retrospective. ( I have a really vague idea about Agile, and I don't dare to throw it in, since when I my team used Agile in my previous company, according to a senior dev it was many thing but not the real Agile. )
    4. Also we use git submodules and I heard it is obsolate solution. The idea of how we want to use it is:
      1. We develop a driver (e.g.: to a specific Accelerometer).
      2. We write unit tests. ( I know TDD would be better, but first I am happy If they learn the ceedling part).
      3. We push it to its specific repo where other projects can reach it download it and modify it if necessary (e.g. you not implement the full driver for your project, but other projact can use the left out feature).
      4. ... profit. I am not sure how to introduce it to my or others project the specific driver to not ruin the version control part or use the slighltly obscure submodules.

    If you have other ideas, or correction please feel free to write about it. If you want to talk about your team horrific processes you are still welcome.

    submitted by /u/Naahun
    [link] [comments]

    Memory addresses and bytes in RAM (C/C++)

    Posted: 22 Jun 2021 11:45 AM PDT

    If one memory address holds 1 byte of memory, how can an integer (4 bytes) be located at one single memory address? As opposed to arrays, in which each element consists of one memory address, all consecutive to each other.

    submitted by /u/ZED_118
    [link] [comments]

    No comments:

    Post a Comment