• Breaking News

    Sunday, October 4, 2020

    On linux, is it considered good practice to use filesystem APIs to access device info, or would it be better to look for more specific APIs? Ask Programming

    On linux, is it considered good practice to use filesystem APIs to access device info, or would it be better to look for more specific APIs? Ask Programming


    On linux, is it considered good practice to use filesystem APIs to access device info, or would it be better to look for more specific APIs?

    Posted: 04 Oct 2020 07:51 AM PDT

    I'm working on a program on Linux that needs to work with usb devices. I could get all the information I want about device trees, serial ports, etc.. by porgrammatically opening files in /dev/* and /sys/bus/usb/*, but for someone coming from Windows, it seems a bit odd to me to open files to get information about usb devices.

    Having worked a lot with similar windows APIs, it would feel more natural to look for a built in system library and use its functions to query usb device information.

    I want to make sure that my software works properly on as many different linux distros as possible. I don't know if these 'virtual file paths' are standard across all of linux, or if it's even recommended to use them in programming.

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

    Just started trying to learn C++, can’t even get a simple program to run

    Posted: 04 Oct 2020 06:31 PM PDT

    So, I Just began learning C++ and am watching a tutorial series by Caleb Curry, it's a 10 hour long tutorial on the basics, so I just started, we wrote a small program and we were going to test it in the terminal by saying "g+ Starter.cpp" (Starter.cpp is the name of my folder) and it just keeps saying "the term 'g++' is not recognized as the name of a cmdlet, function l, scriptfile, or operable program" I created the exact same code as Caleb but his works and mine doesn't, help?

    submitted by /u/I-already-redd-it-
    [link] [comments]

    I'm thinking about learning server-side subjects.

    Posted: 04 Oct 2020 08:28 PM PDT

    Recently, I'm interested in SQL and server-side subjects.

    So, I'm thinking of turning my old HP laptop which has N3060(very weak CPU) in it, into a toy server laptop with Ubuntu-server or any other Linux. It has only 4GB ram, but surprisingly it works with no problem. Just extremely slow for web browsing.

    The question is 'is that weak laptop also good for a newbie for studying server-side?'

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

    Ternary operator

    Posted: 04 Oct 2020 03:37 PM PDT

    i'm learning Lua and i leaned that using logic operators you can mimic the ternary operator, but i don't understand why if you compare a bool to a int it returns a int

    Why True and 1 is equal to 1?

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

    What advantage does a constant have over a variable you just don't change?

    Posted: 04 Oct 2020 11:13 AM PDT

    My understanding is that constants are values that are fixed, and variables change, which is simple enough. I want to know what advantage a constant has over a variable that won't ever be changed, with the following pseudo code as an example.

    constant on_floor = 0 constant in_air = 1 some_function_regularly_called_in_a_game_loop(): if "jump" pressed: if player_state == on_floor: jump() 

    And let's say player_state has been set somewhere else at some other point.

    My question is, why can't I just have them as variables? They won't ever be changed, so what does setting something like that as a constant actually do?

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

    How does moodle work?

    Posted: 04 Oct 2020 09:21 PM PDT

    Is it hard to use/modify? Would it be too expensive to get someone to help me set it up as I want it to be?

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

    Run fail issues (C++)

    Posted: 04 Oct 2020 07:10 PM PDT

    Hello,

    Getting a run fail issue when choosing "transaction type" program auto says "not transaction type".

    Here is assignment description. "Write a C++ program that prompts the user for an Account Number(a whole number). It will then prompt the user for the initial account balance (a double). The user will then enter either w, d, or z to indicate the desire to withdraw an amount from the bank, deposit an amount or end the transactions for that account((accept either uppercase or lowercase). You must use a switch construct to determine the account transaction and a do…while loop to continue processing."

    Planning to add loop once I get program to run once without loop.

    Thanks for any help

    #include <iostream> using namespace std; int main() { int accountNumber, transaction; double accountBalance, amount, newAccountBalance; // declare variables cout << "Enter the account number:" << endl; // prompt the user for an Account Number and account balance cin >> accountNumber; cout << "Enter the initial balance:" << endl; cin >> accountBalance; cout << "SAVINGS ACCOUNT TRANSACTION\n" // output SAVINGS ACCOUNT TRANSACTION options << "(W)ithdrawal\n" << "(D)eposit\n" << "(Z) to end account transaction\n" << "Enter first letter of transaction type(W, D or Z) :" << endl; cin >> transaction; // The user will then enter either w, d, or z switch (transaction) { case 'w': // if w amount to withdraw case 'W': cout << "Amount: " << endl; cin >> amount; newAccountBalance = accountBalance - amount; break; case 'd': // if d prompt user to imput amount to deposit case 'D': cout << "Amount: " << endl; cin >> amount; newAccountBalance = accountBalance + amount; break; case 'z': // if z is chosen output will be No more changes. case 'Z': cout << "No More Changes.\n"; newAccountBalance = accountBalance; default: cout << "Not a transaction type.\n"; } cout << "Balance for this account is now : " << newAccountBalance << endl; // always display the new Balance for this account before restarting loop. return 0; } 
    submitted by /u/IceQweenItMe
    [link] [comments]

    What's your opinion on the Haxe programming language?

    Posted: 04 Oct 2020 04:08 AM PDT

    It's a language that came out 15 years ago and it basically transpiles to other languages or compiles to source for several platforms, as I've understood. But nobody is talking about it and there's not so many stuff out there about it. Why? Did it just happen that it's not popular or there are actual reasons to hate it/not prefer it among other alternatives? It also looks a lot like TypeScript, and it can also transpile to JS, but still Typescript is the one that's popular despite not being "original"

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

    I couldn't fix the infinite loop despite 40 hours paid. How to discuss?

    Posted: 04 Oct 2020 05:57 PM PDT

    Last week the lead programmer was out on vacation and I couldn't complete any of the tasks given. My primary issue to solve involved a program that had an infinite loop. I believe this due to how it iterated through data to check for conditions, the parameter in recursion grew faster than it could reduce itself.

    I'm closer, but tomorrow I'll provide my best solution is a dumb "break" after 2000 recursions. It works technically, but I obviously don't like it.

    Anyway, I'm not sure how to explain this to the lead programmer. I didn't change my open issue I was working on all week despite not making visible progress.

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

    My code turns spaghetti when I optimize it. Am I the only one? How can I prevent this (aside from using comments)?

    Posted: 03 Oct 2020 11:37 PM PDT

    Detect s-pen input on samsung tablet in order to make straight lines?

    Posted: 04 Oct 2020 05:54 PM PDT

    So I hate the fact that Onenote on android is really limited. I have this Samsung tablet on which I take notes in class with the s-pen.

    I would like to programm an app that at the end will be a circle over the interface like others apps already do. Simply you press the circle and till is pressed you can draw straight line.
    I already looked for a solution but I didn't find any.

    So I was thinking that I need to detect the input of the pen and write some code where I define x and y that is the position of the start, etc.(I didn't think about this yet but it's okay It will be the funny part anyway, right?lol). I have experience in coding and I would like to put this project on the cv..
    What do you suggest? It is possible or I am understimate everything?
    I saw Ionic as a framework that can be a good option but still I don't know how to somehow detect the s-pen input.

    Thank you

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

    (c++) What does the i mean?

    Posted: 04 Oct 2020 10:04 AM PDT

    I'm learning c ++ and although this has been explained to me, I can't understand what i is in an operation, here is an example for(int i = 1; i <= n; i ++).

    I know it is supposed to be the loop of the operation that is performed but still I'm having a hard time trying to understand it.

    Thank you so much if someone can explain it to me!!

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

    Flutter/Reactnative/Native for map app.

    Posted: 04 Oct 2020 12:02 PM PDT

    Hi! To develop a map app about trails, POI and other map related stuff, what would you choose?

    • Flutter (1 app)
    • React Native (1 app)
    • Native (2 apps)

    It's tempting to use Flutter or React Native, but I'm worried about flexibility of the frameworks.

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

    We have no video player to watch any lectures or anything. Replacement for Google's youtube that does this ? ?

    Posted: 04 Oct 2020 11:40 AM PDT

    Looking for something like https://iina.io/ but it's only for mac

    Need something like this ^ but doesnt seem like it exist, and progress in desktop video player is super lacking and seems pretty much dead since everyone just uses youtube video player

    Seems like there's nothing like youtube video player for desktop

    Very few needs:

    1. Is able to change all or almost any hotkeys via UI? Not via config file. Via UI
    2. Can press 3 to skip 30% into video like you can on youtube?
    3. Sleek modern look by default?
    4. Actively updated to improve it and make it better

    Need desktop video player

    Things that don't do the above

    vlc confirmed by a user that knows about vlc

    Media Player Classic and r/MPCHC is dead with no users

    freetube has no desktop version ??

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

    Copy links of youtube videos and paste them into a text file

    Posted: 04 Oct 2020 11:26 AM PDT

    I want to make a program that copies links of all of the youtube videos from a channel and pastes it into a text file. Are there any tutorials or something that could help me? Thanks

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

    Help with NAS/Cloud/Git combo

    Posted: 04 Oct 2020 07:14 AM PDT

    Hello,

    I have a question. I want to follow the following guide: https://opensource.com/article/18/9/host-cloud-nas-raspberry-pi with the addition of adding a Gitlab server. Do i need make any precautions to make this works?

    Some brainfarts:

    - I want to make two folders: Cloud & Gitlab.
    - Both need be accessable via the NAS interface.
    - Is it possible (such as with OneDrive) to only download files with I need them?

    Any help is welcome!

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

    Understanding system calls in x86_64 Linux

    Posted: 04 Oct 2020 10:07 AM PDT

    Hey all, quick question about system calls in x86_64 Linux.

    So, if I have a simple C program named program.c, and I disassemble it into an .asm file by running "gcc -S -o program.asm program.c", which lines of my assembly code correspond to a system call?

    I've read a little bit of documentation and it looks like the return value of a system call is stored in the %rax register. So if I have the following instruction in my .asm file:

    movq %rax, -32(%rbp)

    Does this mean a system call is occuring? If so, how do I know which system call it is? I looked at this table (https://filippo.io/linux-syscall-table/) and I don't see any system calls for negative numbers (-32).

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

    How should I go about protecting an entire express+react app with a password

    Posted: 04 Oct 2020 04:00 AM PDT

    I am creating a express + react app. I want to have the option to protect the entire app with a single global password. I want this to prevent access to any static resources on the server until the user has entered the global password. Theoretically I could accomplish something like this by creating a middleware that blocks all static files unless a user has set a cookie to the password. However that just doesn't seem like the right way to do this and maybe there is a different server side technology I can use to protect the app?

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

    Intercepting service worker push messages

    Posted: 04 Oct 2020 05:17 AM PDT

    I was trying to make an extension that would catch push messages on the chrome browser and run a code on the payload. However, despite searching everywhere online, I was unable to find anyone who shows how to this is done. This had me wondering if it is actually possible.

    So far, I know that each website has its own service worker which are registered on the browser, then once you subscribe to the push notification of the website the service worker listens to push events sent by the push service.

    I have tried overriding the service worker js file using chrome devtools override section, nevertheless it didn't work. I also noticed that the devtools are able to record push messages at the application -> background services -> push messaging compartment, I am curious how is it capable of recording these push messages, is there some sort of chrome library that it is utilizing?

    I am currently new to javascript and programming in general so I'd appreciate if you would advice me on how I should approach this problem. Thanks for reading.

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

    Pseudocode works great until I hit double loops

    Posted: 04 Oct 2020 08:23 AM PDT

    i'm getting ready to do algo practice ahead of interviews and double loops (or more) have always been my bane. Sometimes I can do them no problem, other times I lose the plot and the task goes sideways. Under the watch of an interviewer that's not okay.

    Do you guys have any tips on reducing complexity and / or clarifying intent and understanding in conditions that call for double or triple loops?

    One thing I have thought about is taking the nested loop behavior out of the main flow, like so:

    // find all palindronmes in a string // english pseudo // Main Flow capture every single string reverse the string, compare it to the first if there is an exact match, return the string to a list of matches // logic pseudo for each character in input string function createStingsFromAllFollowing flatten array to contain every single possibility. Output: everyPossibleSubString for each substring compareAgainstFollowingSubstrings // function createStingsFromAllFollowing input: receive substring spliced from index 0 to end ...continues 

    As a side question I'm also curious if this level of pseudo takes too long during an interview? It takes a while to write and think through.

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

    Pandas and dataframes, lambda help?

    Posted: 04 Oct 2020 07:43 AM PDT

    See: https://imgur.com/rerRe1c

    The top represents what my dataframe looks like now, the bottom represents what I'd like it to look like.

    The logic is that for an ID/Date, a person either wins or doesn't win the value. 2DayWinPct is the given UserID's winning percentage over the 2 days prior to the date listed (e.g. ID 1 date 2019-09-04 the value is 0.5, because they won on 2019-09-02 but did not win on 2019-09-03). 2DayAvgWin is similarly calculated -- the sum of their wins divided by the number of times they won for the prior two days.

    I am able to produce the bottom table using SQL but the DB size makes it better to get simple data and do the processing with Python so I'd like to try doing it that way. I'm still picking this stuff up as I go, and I'm fairly sure lambdas are involved, but I could definitely use some assistance. Thanks!

    EDIT: It's also important to note that if a certain ID doesn't show up for a day, that doesn't affect percentage. For example, if ID X shows up on 2020-01-01 (winning) and 2020-01-03, but not on 2020-01-02, then their 2DayWinAvg for the 2020-01-03 date will be 1, not 0.5.

    EDIT 2: This is a simplified version of what I'm doing, in reality the period is not two days but set as a constant earlier in the code -- I figure if I can just get a loop/lambda for the two day period I can use the same/similar logic if it were an X day period.

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

    Hey, could someone help me out with creating a flowchart if I pmd them?!

    Posted: 04 Oct 2020 12:58 PM PDT

    My flowchart requires there to be like four different outputs and I'm just so confused to like how to make it all work out ?! Thank u🙂

    submitted by /u/2sad2broken
    [link] [comments]

    How do I use D3DKMTGetDeviceState or D3DKMTGetScanLine?

    Posted: 04 Oct 2020 06:44 AM PDT

    C++ (Visual Studio), Windows.

    For timing reasons, I would really like to find out some information about when the last Vsync was. After a lot of fruitless searching, I finally found two DirectX functions, either of which may give me the information I need. But I'm completely clueless as to how to use them.

    I can't seem to work backwards from the functions to find a good explanation, nor have I made much progress starting from the beginning with DirectX. So, really, and I know this is a bit lazy, but I'm hoping will be able to give me some hints or a brief guide on how to get the info I need.

    My program doesn't have anything to do with DirectX otherwise.


    Option 1: D3DKMTGetDeviceState

    This function needs a D3DKMT_GETDEVICESTATE struct as input, and it looks like I need to fill at a minimum:

    • D3DKMT_HANDLE hDevice; [in] A handle to the device that status is requested for.
    • D3DKMT_DEVICESTATE_TYPE StateType; I think I need to set this to D3DKMT_DEVICESTATE_PRESENT_DWM to get the status of the Desktop Windows Manager

    I have no idea how to get hDevice, and I'm only guessing it refers to a graphis card.


    Option 2: D3DKMTGetScanLine

    As input this requires:

    typedef struct _D3DKMT_GETSCANLINE { D3DKMT_HANDLE hAdapter; D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId; BOOLEAN InVerticalBlank; UINT ScanLine; } D3DKMT_GETSCANLINE; 

    with the first two variables completed. I'm assuming hAdapter refers to a graphics card (despite not being called hDevice as above), but I've got nowhere trying to work out what a VidPnSourceId is.


    Does anyone have any hints on how to properly use either of these? Thanks!

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

    what was the most important recourses that you used through your programming journey

    Posted: 04 Oct 2020 06:26 AM PDT

    i mean by that (a book , website ,a way of thinking :D ,advice from prof etc.....) that helped u to learn coding faster and understand programming more ( i hope i made my point clear :D)

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

    Super secured pc

    Posted: 04 Oct 2020 03:46 AM PDT

    I'm trying to use multi factor authentication to encrypt one of my boot drives. I've found a software that allows for an encryption solved by a USB key on top of a passcode, I want to take it further though and require some form of wireless approval, I'm thinking either via another device on the network or a Bluetooth device. Anybody know how I can do this?

    It's Ubuntu btw.

    P.S. I don't have any practical reasons for this, It's way overkill and would fail instantly if someone threatened to hit me.

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

    No comments:

    Post a Comment