• Breaking News

    Saturday, October 13, 2018

    If EEPROM can only be written 100,000 times, where should I be writing my history before my microprocessor turns off? Ask Programming

    If EEPROM can only be written 100,000 times, where should I be writing my history before my microprocessor turns off? Ask Programming


    If EEPROM can only be written 100,000 times, where should I be writing my history before my microprocessor turns off?

    Posted: 13 Oct 2018 04:27 PM PDT

    My system is 260,000 steps(stepper motor) and since infrared didnt work at the distance I needed, I'm looking to program based on step location.

    I was wondering if I could write the last known step location as I turn off the power to the microcontroller.

    Wishful thinking, as this seems like a non-trivial issue. Any ideas?

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

    Why is Turing completeness the criterion for determining whether a given computer language is a "programming language?"

    Posted: 13 Oct 2018 09:11 AM PDT

    What Language to Use/Learn For Simple Data Storage and Retrieval System With GUI

    Posted: 13 Oct 2018 08:58 PM PDT

    I'm entering an event through my school and know the very basics of a couple languages, but I've wanted to learn how to us them for an actually practical scenario.

    So here are the requirements: Topic: Develop a computer program to manage the issuance of e-books to a class of students. Give the class and e-book a name. The program must complete a minimum of the following tasks:

    -Track student name and grade in school with ability to enter/view/edit.

    -Track the redemption codes for each individual copy of the e-book with ability to enter/view/edit codes.

    -Track the issuance of e-books for a student--a redemption code may be used only once and paired with the student.

    -Generate or print weekly report to show to whom books are assigned.

    -Data must be stored persistently. Storage may be in a relational database, a document-oriented NoSQL database, flat text files, flat JSON or XML files.

    -The user interface must be a GUI with a minimum of five different control types including such things as drop-down lists, text fields, check boxes, emails, or other relevant control types.

    -All data entry must be validated with appropriate user notifications and error messages including the use of required fields.

    submitted by /u/1BilboBaggins
    [link] [comments]

    I Turing how can I end a loop after certain amount of time also how do I set a variable once and make it so it does not keep setting the variable, Thnx

    Posted: 13 Oct 2018 06:57 PM PDT

    Calculating 3D/4D Space-filling curve indexes

    Posted: 13 Oct 2018 04:52 PM PDT

    Hey, I was wondering if anyone had any experience or anywhere to point me to to calculating the Hilbert curve for a 4D object?

    I've seen work with Morton Codes/Z-orders but I'd like to use a Hilbert Curve to store spatial+temporal data and was wondering if anyone had any help on the algorithm.

    Just need help getting started.

    Thanks.

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

    What are general strategies for determining a given language's strengths and weakness, or attractive features?

    Posted: 13 Oct 2018 12:45 PM PDT

    It's often hard to figure out what a given language is best for, worst for, or why one might prefer it over others. Especially given how so many are designed to be of generic use. Often even careful googling doesn't offer especially clear or succinct answers.

    What are some general strategies to go about finding these things out, or making them for myself without having to learn the language first?

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

    Anyone know of a free API that gives you the precipitation totals for the last seven days?

    Posted: 13 Oct 2018 04:00 PM PDT

    I've tried using the Dark Sky API, but that only has snowfall amounts. I've also tried the OpenWeatherMap API, but the precipitation history part of it seems to be paid. Anyone know of an API that will give me the precipitation for the last 7 days? It would be very much appreciated. Thanks.

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

    Help finding a platform/os writer. Universal(?)

    Posted: 13 Oct 2018 02:35 PM PDT

    I remember stumbling across a certain website that was a platform website. From what I remember the big plus was that you could program in the compiler and have it function on whatever flavor of sbc/embedded device you wanted. It was a bit universal from what I remember.

    I think it was promoted by a few of the big players. Only name I think I recall was Intel. I found it a year plus ago and remembered it, but cannot find it in my bookmarks and was hoping maybe someone here used it and could point me in the right direction.

    Basically, I think, it would take your code and make it cross platform. I am assuming here, since the details are hazy, but if you had an ARM, x86, RISC, etc. It would compile and you could update your devices.

    It has my interest piqued and I want to see more of it. If you can help it is greatly appreciated.

    Sorry for the lack of concrete details. I cannot remember if it was spitting out a customized linux OS every time for your device or doing its own thing down a completely different road. I think the former.

    This has been nagging me in the back of my head and I cannot locate it. My google-fu skills are weak.

    Have a wonderful day and sorry for piling on to your tasks. I wish I could locate it myself.

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

    What is technically considered a single CPU instruction?

    Posted: 13 Oct 2018 05:14 PM PDT

    This is in the context of an ISA, not "single CPU instruction" as a CPU is executing a program.

    Here are some example CPU Instructions, according to the way I'm talking about them:

    • mov
    • push
    • addi

    In the programmer's manual for a given ISA, a single "instruction" typically is an opcode, with a bunch of arguments, where the opcode is what governs what instruction it is. Naively, two instructions are the same iff they have the same opcode. Thus, adding an immediate 5 is the same instruction as adding an immediate 1, because those instructions would have the same opcode. In short, if each opcode is 8 bits, then there are potentially as many as 256 different instructions.

    However, I have an ontological problem with this. To me, "add 5 to register r0" is a different instruction than "add 1 to register r0", just like if I instruct someone to add 4 and 5, it is a different instruction than instructing them to add 1 and 5. So, really, the arguments determine the instruction as well. Thus, if each instruction, total, is a fixed 32 bits, we can potentially have 232 different instructions.

    However, this latter view, while one cannot argue that it's wrong, isn't satisfactory either. The fact is, (under this view) there are certainly groups of instructions that are extremely similar to one another. The "add an immediate 5" and "add an immediate 1" are a pair of such instructions. But, more importantly, no programmer's manual will list "add an immediate 5" and "add an immediate 1" as separate instructions, because that would be utterly ridiculous.

    So, can someone help me out?

    tl;dr I'm looking for a really nice definition of the term 'CPU Instruction'. What is a 'CPU Instruction'? If you are familiar with ontology, what I'm really asking is: what, ontologically, is a 'CPU Instruction'? Under what conditions are two CPU Instructions the same?

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

    Why am I getting garbage characters when outputting these arrays?

    Posted: 13 Oct 2018 12:28 PM PDT

    I am getting random characters at the end of these arrays when I execute the program. Am I initializing them wrong somehow?

    #include <stdio.h> //function prototypes char createReverseArray(char a[], char b[], int n); void printArray (char a[]); void main(void){ char array1[3] = {'p', 'a', 'n'}; char array2[4] = {'g', 'o', 'l', 'd'}; char array1_t[3]; char array2_t[4]; createReverseArray(array1,array1_t,3); createReverseArray(array2,array2_t,4); puts("Before Change"); printArray(array1); puts("After Change"); printArray(array1_t); puts("Before Change"); printArray(array2); puts("After Change"); printArray(array2_t); } // end main //function which reverses array a into array b char createReverseArray(char a[], char b[], int n){ int i=0; int j=n-1; for (i=0; i<n; i++){ b[i]=a[j--]; } }// end createReserveArray // function which displays an array void printArray (char a[]){ int i = 0; while (a[i] != '\0'){ printf("%c ", a[i]); i++; } printf("\n"); }//end printArray 

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

    How would you design the auth process for a decentralized game?

    Posted: 13 Oct 2018 02:34 AM PDT

    I have recently started designing a simple virtual world type of game in which players will run a server on their own computer and connect to it locally via their web browser, with the ability to create and follow links to other servers run by their friends or perhaps other third parties. Similar to OpenSimulator's "hypergrid" concept, but I want to start small and nail down the fundamentals.

    I'm trying to keep authentication/authorization as seamless as possible without losing sight of security. What I imagine is that each player server could run its own OAuth 2 provider. When the player connects to a remote instance, it will automatically generate and send a key allowing the remote server to call back and ask for permissions via the OAuth 2 mechanism. The user grants the permissions, and then the remote server can request the necessary data to present their avatar in the remote world.

    The player could optionally also create usernames/passwords for themselves and/or friends, and sign into their home server from any browser.

    My only experience with OAuth 2 is superficially using the ASP.NET libraries for Facebook and Google authentication, and I've read that implementing a provider can be touchy. Is it even the right direction to be looking to enable this type of scenario? Or how would you approach it?

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

    C# DataGridView selected cell border color change

    Posted: 13 Oct 2018 11:16 AM PDT

    Hello, I am trying to format a data grid in C# so that once a cell is clicked (event dataGridView1_CellClick) the cell that was clicked becomes highlighted (via border changing color). Changing the background color will not work as all cells are filled with an image and no background is available to be seen.

    I am able to identify the clicked cell with the following code but am then unable to change the border color for that cell, any code I try changes all borders in the grid.

    //Identify and return the cell value that was clicked
    string msg = String.Format("Row: {0}, Column: {1}",
    dataGridView1.CurrentCell.RowIndex,
    dataGridView1.CurrentCell.ColumnIndex);
    MessageBox.Show(msg, "Current Cell");

    Edit: My best guess was
    dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].DataGridView.GridColor = Color.Red;

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

    Help understanding sample programming challenge

    Posted: 13 Oct 2018 06:18 AM PDT

    THIS IS A SAMPLE CHALLENGE NOT THE REAL ONE.

    I was trying to solve this problem but the wording was too vague and not descriptive. Also, it didn't have any explanation for the sample test cases.

    The screenshot is here

    Could you please help me understand how this sample output was computed for the sample input?

    From what I could understand this looks like a dynamic programming problem but I am unable to understand their description of the problem.

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

    Request for interview!

    Posted: 13 Oct 2018 05:47 AM PDT

    Is there anybody here who is deployed in the field of IT and willing to answer a couple questions for an interview? It's for a college assignment. It would be greatly appreciated!

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

    Does anyone want to mentor me on building my business crud app?

    Posted: 13 Oct 2018 09:06 AM PDT

    A little background info on me, I started programming about 3 years ago now with the intention of building a business system for my business. Version 1 was done within a few months of sheer brute force spaghetti. Version 2 is full blown api back end javascript front end and it is taking so much longer. I have some questions pertaining to how to structure my app, that I would call simple fixes at this point, but the longer I wait on them the worse it will get. The main problem is that I have never worked with other programmers, I've been trying to figure it all out on my own this whole time. I would love if someone with experience in these matters wanted to chat on the phone or on slack or something like that to answer some questions I have. For some reason google fu is failing me here, so many of the answers I find, even on SO, deal with specific tech stacks that aren't relevant.

    My current questions (there are always new ones) -

    1 - Should an api get call really return ALL results? what if there are millions of results? Because of this, I have set up pagination server side- each end point is programmed to paginate and send the pagination, but that means that the front end cannot control how many per page. The front end takes the pagination from the response and creates the controls based on that. Should I make the back end pagination be able to be overwritten by the front end? Should I put an absolute limit (5000 records or something) in that case? I'm not even going to get into cursor pagination at this point, but still struggling with how complex to make this.

    2 - list items for forms. separate end points? single end point per view? caching? what if there is a new record but the cache has not reset? server side caching? I dont want 5 requests for every form get....or do I ? I am trying to bring in as many REST principles as possible but this is where it all breaks down for me. For instance a table might have "id" and "name", but another table might have "id" and "customer name", so, the "normal" endpoints don't work for me for lists. I am populating list items from a separate query that returns "id" and "display" (and some other information) so that things are streamlined on the javascript side. Am I doing it wrong?

    3 - lets just make a general question about caching. front end, back end, even the database. One thing I don't understand is the common knowledge of, select as few fields as possible to cut down on query time. But if you always select *, wont the query cache and be even faster? same thing for pagination, it some cases wont it just be faster to send all the results as long as they are cached?

    4 - viewmodel information. such as say, user information that goes in a userbar. or user preferences. Separate endpoint? load it all on the initial load? how is this generally done?

    5 - foreign keys in results. Right now I am doing find and replace in the client side using a "lists" object. I have also built out the same functionality on the server side. But, I am considering doing all of the joins in sql "views" to speed things up, provide better searching, and just make things more simple. But it feels so 1970 I just dont even know. I could put the resource link in the results like in rest, but it would make the rest of my app SO much more complicated and would essentially be the same find and replace method just more complicated.

    I would be grateful for any help on these issues as I have been thinking about them for a couple weeks now and its freezing my progress. This happens once a month or so and things would be so much easier if I had a coworker who was better at it that I could just ask "hey how would you do this?". Unfortunately I don't have that so I turn to you...

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

    TSLint costum rules not doing anything?

    Posted: 13 Oct 2018 09:01 AM PDT

    Craps Game

    Posted: 13 Oct 2018 07:44 AM PDT

    Need help with this assignment -- still new to java and especially javafx.

    Teacher provided code for a craps game

    public void play()

    {

    myPoint = 0; // point if no win or loss on first roll

    Status gameStatus; // can contain CONTINUE, WON or LOST

    int sumOfDice = rollDice(); // first roll of the dice

    numberOfRolls ++;

    if (gamesPlayed==0)

    {

    avgRolls = 0;

    }else

    avgRolls = numberOfRolls/gamesPlayed;

    // determine game status and point based on first roll

    switch ( sumOfDice )

    {

    case SEVEN: // win with 7 on first roll

    case YO_LEVEN: // win with 11 on first roll

    gameStatus = Status.WON;

    break;

    case SNAKE_EYES: // lose with 2 on first roll

    case TREY: // lose with 3 on first roll

    case BOX_CARS: // lose with 12 on first roll

    gameStatus = Status.LOST;

    break;

    default: // did not win or lose, so remember point

    gameStatus = Status.CONTINUE; // game is not over

    myPoint = sumOfDice; // remember the point

    System.out.printf( "Point is %d\n", myPoint );

    break; // optional at end of switch

    } // end switch

    // while game is not complete

    while ( gameStatus == Status.CONTINUE) // not WON or LOST

    {

    sumOfDice = rollDice(); // roll dice again

     numberOfRolls++; 

    if (gamesPlayed==0)

    {

    avgRolls = 0;

    }else

     avgRolls = numberOfRolls/gamesPlayed; 

    // determine game status

    if ( sumOfDice == myPoint ) // win by making point

    gameStatus = Status.WON;

    else

    if ( sumOfDice == SEVEN ) // lose by rolling 7 before point

    gameStatus = Status.LOST;

    } // end while

    // display won or lost message

    if ( gameStatus == Status.WON )

    {

    System.out.println( "Player wins" );

    winning = " is a Winner!";

    gamesPlayed++;

    totalWins++;

    }

    else

    {

    System.out.println( "Player loses" );

    winning = " is a loser!";

    gamesPlayed++;

    }

    } // end method play

    // roll dice, calculate sum and display results

    public int rollDice()

    {

    // roll each die

    die1.roll();

     die2.roll(); 

     // sum of die values 

    sum = die1.getValue() + die2.getValue();

    // display results of this roll

    System.out.printf( "Player rolled %d + %d = %d\n",

    die1.getValue(), die2.getValue(), sum );

    return sum; // return sum of dice

    } // end method rollDice

    We are required to make a GUI using scene builder to play the game. I have it all built but I cannot figure out how to use this code to play the game. Button should be presses to execute the first roll which will either set the point and continue, lose, or win. Then you press the button to roll once until a win or lose condition is met.

    @FXML

    public void rollDie(ActionEvent event) { Craps game = new Craps(); [game.play](https://game.play)(); 

    (other code to set labels and such)

    }

    If I add game.play() to my actionevent for the button it will just run through the game which I guess is expected. HOW do I use this code to play the game then>? I cannot figure out how to wait for the button to be pressed before continuing while loop iterations. Should I be approaching this differently?

    TL:DR Trying to figure out how to stop the while loop until button is pressed again. Am I approaching this the wrong way?

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

    What's a good way to display an HTML file (or, at least, simply a formatted table) to other users via the Internet without having to make your own website?

    Posted: 13 Oct 2018 01:28 AM PDT

    Basically, are there any suitable services for this?

    Context: I'm working on a Twitch chat bot in Python. It's a program that the streamer runs on their computer, and it does things like let users play minigames, enter raffles, and request songs to be played on stream. I would like to be able to display the current list of songs in the song request queue upon a command call by a Twitch user. Other bots, such as Nightbot or Deepbot, do this by providing a link to a page on their own domain, where the current queue is uploaded to be displayed publicly.

    I don't have the money or resources to get my own domain (besides, it's only for the sake of song requests), so is there a good way to do it other than using the streamer's PC as a host and giving viewers a link to a generated HTML page? I wouldn't want to expose their IP to everyone, and it just seems like such a terrible way to do it.

    One example I thought about was generating an image and uploading it to imgur, but that wouldn't work well with large queues, nor does it provide a way to link the songs or to easily copy their names as text.

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

    AVR assembler

    Posted: 13 Oct 2018 04:39 AM PDT

    Hello everyone!

    I'm studying CS and right now I'm having a subject in which we learn assembly (on ATMega16). I find it quite confusing so I'm wondering which books or tutorials would be good for me to research (to make assembly clearer)

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

    php beginner ide setup for remote debugging

    Posted: 12 Oct 2018 11:59 PM PDT

    Hi,

    I have been a php developer for about 5 years now but all this time I used Notepad++ because I find it so easy like that but debugging is very time consuming with print_r and error_log.
    I need help setting up IDE to use remote debugging. I used eclipse pdt but could not succeed. The problem was it asked for remote path local path and things like that so I tried a bit and quickly gave up because of fear of messing things up on server.
    If someone here can help me somehow that would be very nice.

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

    Recursive Binary Search

    Posted: 12 Oct 2018 11:33 PM PDT

    Hi,

    i need to write a program that recursively searches array using binary search. I wrote the program, and it works correctly i believe. The only problem is, when a number is not in the array i need to return the value -1. My program does not return -1, i just get "exit status -1"

    int binary_search_rec(int* A, int n, int item)

    {

    int mid = n / 2;

    if (A[mid] > item)
    binary_search_rec(A, mid, item);

    else if (A[mid] < item)
    return mid + binary_search_rec(&A[mid], (n + 1)/2, item );

    else if (A[mid]==item)
    return mid;

    else
    return -1;
    }

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

    Best way to create APIs when i dont have the source code ?

    Posted: 12 Oct 2018 11:16 PM PDT

    Text gets cut on PDF

    Posted: 12 Oct 2018 11:12 PM PDT

    I am using this library to convert my HTML to PDF. I have got the process going but when I download the PDF which is 11 pages, in some pages the paragraphs and input fields gets cut in half at the end of the page. The size of the PDF can increase or decrease based on the input of the user before the print function is executed.

    Is there a way to make sure that the page does not get cut off. The library I am using allows me to setup page breaks manually but the size of the page for me is dynamic. I cannot use this feature.Based on another StackOverflow post I did this

    div{ page-break-inside: avoid; } 

    However, this did not work at all.

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

    No comments:

    Post a Comment