• Breaking News

    Wednesday, April 25, 2018

    Standard ML Help Ask Programming

    Standard ML Help Ask Programming


    Standard ML Help

    Posted: 25 Apr 2018 06:34 PM PDT

    I am currently taking a discrete mathematics class at college as I am a Computer Science major. But recently, we were all given the task of coding multiple functions/methods in SML as part of our last homework. Nobody in the class is even remotely familiar with the program besides for the basics he went over in class. The assignment is due in a week but I have no idea where to start. I know it's pitiful to ask for homework help but I could use all the help I could get. Here are the tasks: https://imgur.com/a/WcwTYwt

    If anyone knows how to do these problems please pm me or comment. Thank you so much.

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

    How would I use a lamba in this situation rather than using an override. (Java)

    Posted: 25 Apr 2018 08:11 PM PDT

    MyInterface myInterface = new MyInterface()

    {

    @Override

    public void printMe(String message) {

    System.out.println(message);

    }

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

    Is Python a suitable language for parsing data and outputting to a preset template?

    Posted: 25 Apr 2018 02:47 PM PDT

    Hello /r/AskProgramming,

    The Question/Goal

    I'm looking to parse ASTM strings in an excel/CSV file to choose a Word Document template to fill, then to pull values from the same ASTM string to fill into the chosen template.

    Does this seem like a project a relative Python novice can accomplish? Is Python a good language for this idea?

    After hearing about the wonders of Python from friends, I thought I should look at it.

    The Problem

    Here's a website with an example and explanation on ASTM strings.

    ASTM strings can be complicated. For example:

    ASTM D2000M5BG710A14B14E014E034F19

    Breaking that up for the sections to parse and decipher:

    ASTM D2000 M 5 B G 710 (A14 B14 E014 E034 F19)*

    .* - Denotes special requirements which may or may not appear, may appear in various quantities, and may be completely different each time they do appear.

    The Work So Far

    I've been exploring python and associated packages, and believe I've found one that does almost everything I'm looking for: docx-mailmerge

    Testing it with the simple examples shown on the above-linked website works nicely, and I can see potential here.

    I figure I need an incremental function to break down the string to component pieces, check the standard requirements individually against specific "tables" to choose a template.

    Next I think it would check the special requirements section against another "table" for information to add to the template afterward--ideally it would create additional merge fields to simplify this process, but I don't know if this is possible yet.

    Once all of this is done, I imagine the script would pull the information from the string and write it into a dictionary to fill the template.

    Finally, the script would then merge all of the collected information into the word file.

    End Question

    Suggestions, comments, ideas, and (constructive) criticism are welcome!

    I didn't realize this would be as long as it is. If you've made it this far, thank you for reading!

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

    I'm developing a user-interface that models scientific processes based off user input. What language should I use?

    Posted: 25 Apr 2018 07:43 PM PDT

    I'm developing a user interface that gathers specific input parameters from the user, runs scientific calculations, and then displays the output to the user. I've written a version using html, javascript, and css - however, I'm unsure if this is the best way to write it (what about java/c++?). I'm looking for a robust language that offers flexibility in design/layout and mathmatical operations. In the long run, the interface will be used as a teaching tool for the processes its modeling.

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

    How can I prevent submitting a payment twice?

    Posted: 25 Apr 2018 05:18 PM PDT

    I'm working on a project where the user sees the amount to pay and the payment method. They confirm, which submits a form. It makes a request to a payment server, then once it gets a response back, saves a record in the database.

    How can I avoid problems like the user clicking confirm and submitting a payment, then pressing the back button before the response can be saved?

    Thanks.

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

    [NOVICE] At work I create databases using Microsoft Access and SharePoint at work and I want to come up with an alternative solution. Kindly requesting advice!

    Posted: 25 Apr 2018 01:58 PM PDT

    Hi there!

    I am a novice programmer working with VBA and SQL to create databases with user interfaces in Microsoft Access using SharePoint Tables as a back-end. I work in a government building with no programmers besides myself and have very limited resources at my disposal (pretty much just Microsoft Office suite, I don't have the ability to get MySQL, etc.)

    Obviously Access has its shortcomings and I really dislike how they have to use an Access file. My users definitely favor websites.

    I have a few ideas for solutions but whichever one I pick I know I will need to do a lot of learning so I want to make sure I pick the right one and not waste time.

    Publishing a web access file seems PERFECT but Microsoft is discontinuing Web Access support.... (very frustrating as this seems perfect)

    Another option is to master Microsoft PowerApps. This video gave me some hope https://www.youtube.com/watch?v=CO6xfbjnYwc

    The final option (and likely the most work) would be to learn Javascript and embed the functionality within SharePoint webparts. I have a feeling this is the best option.

    Anyone have any input by chance on what the best strategy for me to improve my business tools is? Any support is highly appreciated!!

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

    [bash] How do I pass an array of strings to a Bash script and join that array?

    Posted: 25 Apr 2018 06:44 PM PDT

    I want to join an array of strings on the string "%2C+". My shell script launch looks like this.

    #!/bin/bash function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; } selectQuery=$(join_by "%2C+" $1) echo selectQuery 

    But when I run ./download-data $("state_code" "county_code"), I get this error in the terminal: bash: state_code: command not found.

    I need to pass the argument as an array since I plan to pass more arrays later on. Something like ./download-data $("state_code" "county_code") $("more" "string").

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

    Trying to create a list of isolated Chinese words from a text file.

    Posted: 25 Apr 2018 06:43 PM PDT

    Language: Java. I also have no experience

    The gist of things:I'm a hobbyist language learner, not a programmer by any means. I'm trying to isolate individual Chinese words from a large jumble of text. Then I want to make a list of those words, separated by a tab or space.

    Additional background: I use a flashcard program called anki. I exported all my cards as a text file, generating something that looks like....

    欠 to owe Qiàn 债 debt "<span class=""tone4"">Zhài</span><!--Zhai-->" "<span class=""tone4"">债</span>" (侵占)公有土地 to invade and occupy " 

    ...this huge mess. Some words are by themselves, like "欠". Others I want are in sentences marked by "()", like (侵占)公有土地.

    What I've tried to think of: Again, no programming experience, so I'm mostly guessing. I was looking at Java. My thought is to create a Scanner to read the original file. I also create a second new file.

    Then in a while loop, as long as the scanner can find new words, add the found Chinese words to a text variable. Add "text variable + tab" to the file.

    Main Questions/Problems (I think): How can I create a scanner that both (a) only returns Chinese words from a multilingual document and (b) will be able to isolate individual words in a Chinese sentence when separated by parentheses- i.e. the 侵占 from (侵占)公有土地 ?

    For "B" I was thinking maybe I have to create a second scanner that goes through the entire string of characters looking specifically for a "(".

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

    Help using UART with GPS module - Embedded C

    Posted: 25 Apr 2018 05:15 PM PDT

    Hi all, so I got a hold of this GPS module called a Hornet ORG1510-MK05, and I'm trying to connect it via UART4 and UART5 on the STM32F303RE (ARM architecture). I'm having issues getting it to respond to anything at all. I have already confirmed that I have it wired properly.

    Here's what I've got to try testing this thing in main():

    char Test[128]; //buffer char Test2[128]; //buffer char CLEAR[128]; //clear buffer char buff[128]; char get[2]; char GPSTEST[8]; char GPSTEST2[8] = "ABCDEF"; uint16_t uret=5; uint16_t uret2 = 5; MX_UART4_Init(); MX_UART5_Init(); memset(CLEAR, '\0',128); //sizes buffer sprintf(CLEAR, "\n\r\n\r\n\r\n\r\n\r\n hey yall \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r"); HAL_UART_Transmit(&huart5, (unsigned char*)CLEAR, sizeof(CLEAR), HAL_MAX_DELAY); //send status HAL_Delay(1000); /*GPS SETUP*/ HAL_Delay(60000); memset(buff, '\0', 128); sprintf(buff, "Buffer:"); while (1) { arr[0] = 5; arr[1] = 5; arr[2] = 5; memset(get, '\0', 2); memset(Test, '\0',128); //sizes buffer memset(Test2, '\0',128); //sizes buffer memset(GPSTEST, '\0',8); memset(GPSTEST2, '\0',8); sprintf(GPSTEST, "PMTK000"); HAL_MAX_DELAY); HAL_Delay(500); HAL_UART_Transmit(&huart4, (unsigned char*)GPSTEST, 8, HAL_MAX_DELAY); uret2 = huart4.Instance->TDR; sprintf(Test2, "TELEM: UART4 TDR: %d EOT!\n\r", uret2); HAL_UART_Transmit(&huart5, (unsigned char*)Test2, sizeof(Test2), HAL_MAX_DELAY); HAL_Delay(500); GPIOC->ODR = 0x0000FFFF; uret = huart4.Instance->RDR; sprintf(Test, "TELEM: UART4 RDR: %d EOT!\n\r", uret); //format in returned data HAL_Delay(500); GPIOC->ODR = 0x00000000; HAL_UART_Transmit(&huart5, (unsigned char*)Test, sizeof(Test), HAL_MAX_DELAY); HAL_Delay(500); GPIOC->ODR = 0x0000FFFF; HAL_UART_Transmit(&huart5, (unsigned char*)CLEAR, sizeof(CLEAR), HAL_MAX_DELAY); HAL_Delay(500); 

    If anyone has idea for what I might do differently, that'd be very helpful. Or if you have ideas from scratch for how to interface with this thing, that'd be awesome too!

    submitted by /u/SL-Gremory-
    [link] [comments]

    REST API best practices

    Posted: 25 Apr 2018 08:46 PM PDT

    Hey all,

    I'm in the process of developing a REST API and I've been in discussions with my senior about context, and neither of us are sure what the "best" or "most RESTful" way to do this is.

    I have an endpoint that is baed on the structure /device/{123}/action/, but under certain circumstances, actions may not need a device context after we've discussed it further.

    This leads me to either: A) providing the device ID in a querystring (/device/action?id=123) B) having two separate endpoints (/device/action and /device/{123}/action) and having the second subclass from the view of the first, adding an extra filter in to limit resultsets etc

    It seems to me that with A) we would have to account for having an ID and not having an ID, and in B) everything would be much more reusable.

    Are either of these "more" RESTful than the other, or are both equally as RESTful and valid as each other, depending on the sitaution? I feel like being explicit with the URI is the right way to go.

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

    How do I effectively ask a question about debugging my code?

    Posted: 25 Apr 2018 01:55 PM PDT

    I have seen other people type text and then their code comes up in a white box but I dont know how to do that. Also, should I zip my code (in VB) and upload it for people to see? Finally, should I post screenshots of the whole piece of code for better context?

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

    How do I check for last iteration in for loop java?

    Posted: 25 Apr 2018 01:52 PM PDT

    I'm trying to add numbers that are divisible by 3 and 5 for 1 through n. On the last iteration I want to get rid of the plus sign so it shows, if n = 10 3 + 5 + 6 + 9 = 23 but right now it's showing 3 + 5 + 6 + 9 + = 23 How do I get rid of the plus sign after 9? Here's my code

    package com.example; import java.util.*;

     `public class Add1toN { public static void main(String[] args) { Scanner in = new Scanner(System.in); int sum = 0; System.out.println("Enter a number:"); int n = in.nextInt(); ArrayList<Integer> list = new ArrayList<Integer>(); for(int i = 1; i <= n; i++) { if(i % 3 == 0 || i % 5 == 0) { sum += i; list.add(i); System.out.print(i); if(i != list.size() - 1) { System.out.print(" + "); } } } System.out.println(" = " + sum); } } 

    `

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

    Someone can explain very well what is a Constructor and for what is useful? Java

    Posted: 25 Apr 2018 02:54 PM PDT

    Really have problems understanding that, also I don't see the difference between a constructor and the getter and setter function (that also don't understand very well).

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

    Search function in a PHP script

    Posted: 25 Apr 2018 02:39 PM PDT

    Curious how i would go about searching multiple items in a PHP Script? i have a string that is set to search a sheet for a phone number but i can only get it to search one item. I want it to search multiple items. Like Search my forwarded phone number against a google sheet. Then also search the number it came from on the sheet also.

    I tried setting the search string to $search=substr($_POST[ForwardedFrom|From],1); But that didnt seem to help.

    Here is a screenshot of the code. https://imgur.com/a/N6u0xv0

    Thanks!! Much appreciated.

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

    [VB] Basic log in screen synced to Access having error while running

    Posted: 25 Apr 2018 02:34 PM PDT

    I'm fairly new to coding and I have a project to do for school. I basically have to create a system for a fake business to store and edit data. I am using VB to do this and I want to sync it to Microsoft Access. I have tried to copy this tutorial for a login screen that checks with my database to see if the data entered is correct (http://www.visual-basic-tutorials.com/form/Login-tutorial-database.htm) My database is a bit more complicated than the one in that tutorial. Heres a screenshot of the database in relationship form https://prnt.sc/ja5goo

    Heres the code that I'm using with the error marked https://pastebin.com/vFYHLpJn

    This is what the error says: Exception Unhandled System.Data.OleDb.OleDbException: 'No value given for one or more required parameters.'

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

    [C] When I call "sleep(1)" in my loop, the loop just stops working for some reason

    Posted: 25 Apr 2018 02:07 PM PDT

    Here's the code in question:

     void* printHello(void *arg) { int id = *((int*)arg); while(1) { printf("Thread %d: Hello World!\n", id); sleep(1); } return NULL; } 

    I am doing an exercise regarding Multithreading right now. So when I compile and run this in the console, it prints:

    $ ./a.out 2 Thread 1: Hello World! Thread 2: Hello World! $ 

    And that's it. But I am trying to do an endless loop where it continuously prints this. When I remove the sleep(1) it works and does an endless loop.
    Anyone has an idea why the sleep(1) is breaking my loop?
    Help would be appreciated

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

    How can I learn programming in a fun way?

    Posted: 25 Apr 2018 09:40 AM PDT

    What is a project I can work on that would be enjoyable to do in learning more code? Which language is the most fun and useful?

    I have experience in RStudio, and a little JavaScript.

    But I want to learn something useful (python, C++ or something maybe?) and do something enjoyable while learning (making a game perhaps?)

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

    Programming language that is native and cross platform.

    Posted: 25 Apr 2018 04:37 PM PDT

    Hello, I am curious to see if anyone knows of a programming language that is native and cross platform.

    It must have the ability to be compiled for multiple platforms, without having to change code to support that platform. (assuming I don't use any platform specific libraries)

    It must require no dependencies to run on each individual platform.

    Suggestions appreciated, Thanks so much!

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

    Are there any good articles on the merit of tracking the average age of all open bugs/issues?

    Posted: 25 Apr 2018 12:48 PM PDT

    My team has a sizable backlog, and some bugs are pretty old. We keep our eye on a number of metrics as a team, and I was thinking that maybe average active bug age would be useful. Does anyone know any good articles or discussions on whether this is a useful thing to do?

    Your own thoughts on the matter are welcome and appreciated as well, but if I pitch it to my team I'd like to be able to reference some articles, so that's what I really need.

    Thanks!

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

    How to document request for change in application, so you liked it.

    Posted: 25 Apr 2018 12:33 PM PDT

    Hi, this is a question for working developers, especially corporate.

    I've been given a task of optimizing certain areas of a very large CRM. This has been developed almost every week for years. There is constantly something being done on it.

    Basically a worker has to click here, verify that, come back there and do something, because some data is missing. He/she is losing this much time doing that and this is the way how it supposed to work.

    Now, how do I document such request so you wanted to work with me. What information I need to provide you with so it was easily understood and you actually wanted to do it. I'd appreciate any information you can give me, or if you have an example of such document, that would also be tremendous.

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

    [C] How to get two strings on the same line in a printf statement.

    Posted: 25 Apr 2018 11:22 AM PDT

     for(int i = 0; i < current_number_of_contacts; i++){ printf("%s%s%s%s", s[i].first_name, " ", s[i].last_name,"\n"); } 

    I tried to concatenate the two strings like so, but it didnt work.

     char *result = malloc(strlen(s[i].first_name)+strlen(s[i].last_name)+1); strcpy(result, s[i].first_name); strcat(result, s[i].last_name); printf("%s%s", result, "\n"); 

    The ouput was still on different lines for first and last name.

    Thank you in advance.

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

    Need help with a programming assignment:(

    Posted: 25 Apr 2018 02:29 PM PDT

    I'm beginner in this of programming, and I need to do a Proyect, would you guys help me?:(

    The thing is I need to make a program that a user needs to give a number, for example, "negative thirty-one" and what I need to do is that the program gives back a "-31". Thanks for your help:) (In Java, Im using NetBeans IDE 8.2)

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

    Batch script - How to escape double quotes and redirection signs in this example? How to properly escape double quotes and redirection signs?

    Posted: 25 Apr 2018 03:04 AM PDT

    foo foo < key= "12345" > foo foo 

    The user inputs the key, and we try to match it:

    SET /P input= Please enter the key: FIND "<key = %input% >" test.txt 

    This doesn't work.

    I've tried these examples with FIND:

    FIND "^<key = ""%input%"" ^>" test.txt FIND "^^<key = ""%input%"" ^^>" test.txt 

    I think I managed to get the variable that's under double quoted to work somehow.

    But the redirection signs are just not working.

    How should I do this?

    Is FIND the best tool for the job?

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

    Character-limited api call for a json object

    Posted: 25 Apr 2018 01:42 AM PDT

    For context, I'm trying to write some javascript code that will be evaluated by a Twitch.tv chat bot (NightBot) that will take user input (A pokemon's name), then as output give a certain piece of information about that pokemon (Its type).

    NightBot has a function called urlfetch that I can use to load a JSON object from an api like this one: https://pokeapi.co/api/v2/pokemon/lucario/ . urlfetch will return the raw json data given, as a string. I'm trying to do this, then parse the json object to get the desired information. The parsing works fine - it's the loading I'm having trouble with.

    My issue is that urlfetch will return an error if the information given by the URL fed to it is more than 400 characters long. The API I linked above returns fairly large JSON objects. I haven't been able to find any other APIs for this period, let alone ones that return shorter objects.

    The vast majority of the information returned by the API is irrelevant - all I need is the very last item, an array containing its type information. Is there a way I can extract just this information from the API without loading all the rest of the JSON object, and reaching my character limit? Alternatively, are there any APIs that can execute javascript code I send to it, so I can avoid the character limit problem entirely?

    The command I'm creating (In NightBot's syntax) is:

    $(eval var obj = JSON.parse('$(urlfetch https://pokeapi.co/api/v2/pokemon/lucario)');obj.types[0].type.name;) 

    The javascript code being executed would be:

    var obj = JSON.parse('{the JSON object returned by the url}'); obj.types[0].type.name; 

    I don't expect this to be relevant, but the entire command has a character limit of just under 500 characters. I intend to add more once (if?) the api issue is solved to deal with secondary types and such, but I don't expect to need help with that part.

    Thank you for any help.

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

    Need help with a programming assignment.

    Posted: 25 Apr 2018 10:26 AM PDT

    We're supposed to make a password generator in javascript that would make a random string of numbers with the inputted length from a prompt. This is the shell that he provides.

    // Step 1. var passwordLength=prompt("Enter number in range 8 through 16"); passwordLength=Number(passwordLength) ; // convert var password="" ; // empty string initialized // Step 2. the loops passwordLength number of times

     var randomCharacter=String.fromCharCode(33+parseInt(93*Math.random())); 

    // Step 3. the password document.write(password);

    What do I do? I am stuck.

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

    No comments:

    Post a Comment