• Breaking News

    Wednesday, May 1, 2019

    (Java)How would I go about creating a "cancel" method that "cancels" the usage of another method? Ask Programming

    (Java)How would I go about creating a "cancel" method that "cancels" the usage of another method? Ask Programming


    (Java)How would I go about creating a "cancel" method that "cancels" the usage of another method?

    Posted: 01 May 2019 07:50 PM PDT

    Say I have a class that can count to ten. The boolean count method every time it is called it increments the actualCount by 1. However, if I call cancel I should not be able to call count or rather I should not be able to increment the actualCount.

    boolean count() and void cancel() return methods can't be changed.

    public class countToTen{

    private int actualCount;

    boolean count();

    void cancel;

    }

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

    (Angular) Trouble with Observable Async Pipe

    Posted: 01 May 2019 03:47 PM PDT

    Working app: https://stackblitz.com/edit/angular-ry1dev Broken app: https://stackblitz.com/edit/github-lujggc

    The broken app should be getting a list of products from a backend API, saving it to the store, then sending it to the front end. The working app does this. However, the broken app bitches about ngFor only being for iterables.

    Why does the async pipe work for the first app but not the second?

    (Please note: the broken app has been modified so I can present a demo. I've commented out the API code and am instead using a data file found in assets folder to simulate).

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

    Whats a circuit sim which can update topology as a sparse graph of resistances between electrodes of gates as CPU chooses resistances 50 times per second and simulates 100k time steps per second?

    Posted: 01 May 2019 04:37 PM PDT

    Im looking for a flexible openended framework or pieces of code, to build interactive music tools on, where people and AIs would experiment and play music together by varying the resistances in basically a minimalist simulation of a very general FPGA. I may eventually want actual FPGAs as optimizations but simulation of maybe 50 gates at once should be enough for now.

    Its important to update resistances gradually instead of changing topology in a jerky way so the music changes smoothly, unlike stepping on a pedal to switch guitar effects as musicians often do.

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

    Saw someone receive mail from any email address on a domain he owns. How is this done?

    Posted: 01 May 2019 06:47 AM PDT

    Hi all, hope you're doing well. I'm a developer of ~2 years (PHP, JS, some haskell).

    Recently, one of my friends showed me something that he'd built. An email sent to any address on a specific domain (e.g. `[sam.smith@iownthis.com](mailto:sam.smith@iownthis.com)` or `[hiya@iownthis.com](mailto:hiya@iownthis.com)` or even `hnetshuoa342323@iownthis.com`) would be collated into a database.

    This seemed super useful in that you could essentially use the server to get email under any given alias, or to receive 'first-time' discounts multiple times. From what I can gather:

    - It was written in PHP

    - He clearly owns the domain

    - It may have been using a mail transfer agent

    - It _may_ have been running in an EC2 instance

    Any ideas on how he might have achieved it? I was gobsmacked.

    Thanks for your time, any and all help is super appreciated!

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

    Pointer c++

    Posted: 01 May 2019 03:32 PM PDT

    Why is it that when I delete a pointer, sometimes the memory just looks corrupted rather than empty? Sometimes it's a huge ass number and other times it's ???? Followed by some other jibberish...

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

    Java Project - Coding Pig Dice Game

    Posted: 01 May 2019 06:10 PM PDT

    Idk if this is the best place to ask about this. I figured I'd try here before creating a stackoverflow account.

    I have to code the game of Pig in Java for my final computer science class project. For those unfamiliar with Pig, it's a game where players take turns rolling a die. If a 1 is rolled, it's next persons turn. If 2 - 6 is rolled, that is added to their score. But only if they choose to hold. They can also roll again to add to this temporary score. Once a player holds, the total gets added, if a 1 is rolled, points won during the turn are lost and it's next players turn.

    I have no problem coding the project, I am pretty much all done aside from documentation. Problem I have is the project says I have to have an array in the project. We just learned about arrays. I understand them, but I can't figure out how the hell to put one in the project. Idk, maybe I am overlooking something simple. I should also note the game is against a computer opponent. Anyone have any ideas? I'm kind of stuck. Thanks

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

    Converting c++ to MIPS assembly

    Posted: 01 May 2019 06:03 PM PDT

    I have a piece of code in c++ that I need to translate into mips assembly for class. I'm new to writing in assembly and would appreciate any tips there are for an easy conversion!

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

    How is math used in programming?

    Posted: 01 May 2019 05:45 PM PDT

    Throughout every tutorial, every explanation, and every teacher, I'm always being told "It's important to know math for any kind of programming".

    But I've never actually understood where math is used in actual programs. (Aside from game-code and scientific programs)

    In an actual production program, how would math be used?

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

    SIK coding challenge 4 coding challenges

    Posted: 01 May 2019 04:06 PM PDT

    Has anyone done SIk coding challenge 4 coding challenges??

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

    Is Chrome Custom Tabs affected by the new google chromium embedded framework restrictions?

    Posted: 01 May 2019 03:29 PM PDT

    Need to implement some browser operations that do not utilize a web view and we are looking at the option of using chrome custom tabs.

    My concern is google has recently announced new that they will be blocking logins from embedded browser frameworks e.g. Chromium Embed Framework

    Does anyone know if this affects Chrome Custom Tabs?

    Thanks in Advance

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

    Having an issue with andriod studio for a class assignment.

    Posted: 01 May 2019 01:45 PM PDT

    Ok so, in my andriod programming class we are making a basic application that has 3 buttons on the main screen to direct you to 3 other views. My first one is holiday world (its a tourism app).

    In each theme park you have to have a picture, description, name, fees, hours, an EditText to say how many tickets you wish to buy, and a purchase ticket button that displays your total for how many tickets you purchased.

    Well on my initialize for my purchase tickets button I am getting a null pointer exception error on bold and italics line:

    private final double TICKET_PRICE = 39.99;

    private double total;

    private EditText number_of_tickets;

    private double userTickets;

    private Button mPurchaseButtonAnnoying;

    private TextView ticketPrice;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_holiday_world);

    number_of_tickets = findViewById(R.id.get_text);

    ticketPrice = findViewById(R.id.total_textBox);

    mPurchaseButtonAnnoying = findViewById(R.id.purchase_button_annoying);

    mPurchaseButtonAnnoying.setOnClickListener(new View.OnClickListener() { (This line)

    @Override

    public void onClick(View v) {

    userTickets = Integer.parseInt(number_of_tickets.getText().toString());

    total = userTickets * TICKET_PRICE;

    ticketPrice.setText("Your total is $" + total);

    }

    });

    }

    And here is my xml file for the holiday world activity.

    <ImageViewandroid:layout\_width="200dp"android:layout\_height="200dp"android:contentDescription="@string/holiday\_world"app:srcCompat="@drawable/hworld" />

    <TextViewandroid:layout\_width="wrap\_content"android:layout\_height="wrap\_content"android:gravity="center"android:text="@string/holiday\_world" />

    <TextViewandroid:layout\_width="wrap\_content"android:layout\_height="wrap\_content"android:gravity="center"android:text="@string/hworld\_description" />

    <TextViewandroid:layout\_width="wrap\_content"android:layout\_height="wrap\_content"android:gravity="center"android:text="@string/hworld\_info" />

    <EditTextandroid:id="@+id/get\_text"android:layout\_width="wrap\_content"android:layout\_height="wrap\_content"android:hint="@string/ticket\_amount"android:importantForAutofill="no"android:inputType="number"tools:targetApi="o" />

    <Buttonandroid:id="@+id/purchase\_button\_annoying"android:layout\_width="wrap\_content"android:layout\_height="wrap\_content"android:text="@string/purchase\_tickets"android:visibility="visible" />

    <TextViewandroid:id="@+id/total\_textBox"android:layout\_width="wrap\_content"android:layout\_height="wrap\_content" />

    And the exact error is....

    Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference

    at com.example.admin.tourism.HolidayWorld.onCreate(HolidayWorld.java:29) (the line I noted)

    What exactly can I do to fix this? Had the professor look at it as well, and he doesn't know why I am getting the error as well, as other classmates the code works perfectly...

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

    Writing an x86 fat12 bootloader

    Posted: 01 May 2019 01:44 PM PDT

    Hello! I am looking for help/assistance on how to write an x86 bootloader that boots into 32-bit protected mode and searches for a file containing the operating system. I know this is probably the wrong place to ask for learning resources, but can anyone help me?

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

    How do recipe apps Import Recipes from recipe websites?

    Posted: 01 May 2019 09:50 AM PDT

    After scouring the web for an answer, I cannot seem to find any information on how several mobile apps, both Android and iOS, can bring you to a recipe site with a built-in browser and "import" said recipe to your app.

    Is this some library that you need? Certainly not all the websites are somehow collaborating with secret import buttons. These apps are reading the data on the pages and storing the different areas to variables.

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

    Those of you who grew up in the time where computers began to be commercial devices, how did you learn programming?

    Posted: 01 May 2019 09:14 AM PDT

    So It'll probably be books. But from what I know, when you wanted to do anything on your computer, you often had to program it to do so yourself.

    This probably involved learning the chips instruction set and how to write programs, get them to run on the computer and most importantly how to trace errors.

    I really cannot imagine how this is accomplished. I tried learning Microsoft Macro Assembler and got some things to work but without a proper IDE would not know how to compile and run source code.

    Then, of course there's compiled languages, the first commerical one - I think - was the Beginners All-Purpose Symbolic Instruction Language. How where compilers installed? Nowaday's I just tell my machine to grab GCC off the web.

    How did you get started? Any interesting stories or anecdotes? I hope this is the right place to post this.

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

    Writing a C# application to mimic the functionality of a curl script I wrote. No C# experience.

    Posted: 01 May 2019 12:35 PM PDT

    So, I wrote a little script to retrieve some information from an API we have at work. It searches a txt file containing x number of IDs, and then uses curl to call the API and plugs in the IDs from the text file. I'm using jq to extract a specific part of the JSON into a spreadsheet.

    Ultimately, what I'm wanting to do is to write a simple UI that interacts with that same API to extract various fields from the JSON.

    My vision is a box for either a single ID, or multiple, and checkboxes for the available fields, that can be checked based on what all is needed. Then, it would dump the data into a spreadsheet with columns for ID, and then whichever fields were extracted.

    How easy is this to do for someone with little to no C# experience? I know there is a webrequest class - beyond that, I'm clueless.

    Below is the script I wrote which worked beautifully:

    for ID in $(cat IDlist.txt); do echo -n $ID,; curl -s -X GET $(echo "https://url/api/Retrieve/$ID/DisplayInfo") -H "accept: application/json" -H "ApiKey: apikey" | jq .field; done > fields.txt 
    submitted by /u/Gonorrheeeeaaaa
    [link] [comments]

    Find count of nodes in min heap that lie in a range

    Posted: 01 May 2019 12:30 PM PDT

    e.g. Given a min heap, count the number of nodes that lie in a range [x,y]

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

    Someone help why does this keep returning 90 degrees

    Posted: 01 May 2019 06:16 AM PDT

    the lengths i put in are

    a =3 , b =4 , c=5

    public double angleA() {

    double x = ((side\_b\*side\_b)+(side\_c\*side\_c)-(side\_a\*side\_a) )/(2\*side\_b\*side\_c); x = Math.acos(x); return x * (180/ Math.PI); 

    }

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

    Is this script possible and how much would it cost me?

    Posted: 01 May 2019 10:18 AM PDT

    I'm interested in a script that could automatically write down specific data from a site, is it possible to do it and how much would it cost me if I asked someone on fiverr, also who exactly would it be the best to ask?

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

    Does anybody know what's causing this syntax error when trying to make a foreign key using SQLite3 and Python?

    Posted: 01 May 2019 09:35 AM PDT

    import sqlite3 from sqlite3 import Error quiz_results = 'quiz_results.sqlite' # defines quiz_results as the name of the db try: conn = sqlite3.connect(quiz_results) except Error as e: print(e) c = conn.cursor() c.execute('PRAGMA foreign_keys = ON') c.execute(''' CREATE TABLE IF NOT EXISTS Tests ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, Name TEXT, Surname TEXT, Class TEXT) ''') c.execute(''' CREATE TABLE IF NOT EXISTS Questions ( Test INTEGER, FOREIGN KEY(Test) REFERENCES Tests(id), Operand1 INTEGER, Operator TEXT, Operand2 INTEGER, ExpectedAnswer INTEGER, Answer INTEGER, Correct INTEGER) ''') c.execute(''' CREATE TABLE IF NOT EXISTS Results ( Test INTEGER, FOREIGN KEY(Test) REFERENCES Tests(id), nAnswers INTEGER, nCorrect INTEGER) ''') conn.commit() conn.close() 

    I'm trying to create a foreign key which references the id key in the Tests table, however I keep encountering the error:

    Traceback (most recent call last): File "C:/Users/James/PycharmProjects/testingcode/mathsquizDB.py", line 30, in <module> ''') sqlite3.OperationalError: near "Operand1": syntax error Process finished with exit code 1 

    For clarification, I'm making a maths quiz using Python and storing the students, questions and results in an SQLite database. So I am attempting a one to many relationship in which one student can take many tests and have many results.

    I'm also very new to Python and SQLite, so I apologise if it's a silly question.

    If anybody would be able to help that would be great, thank you.

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

    When fixing "bugs", how often do you encounter these various, generalized scenarios?

    Posted: 01 May 2019 05:25 AM PDT

    Regardless of who made the mistake and who provides the fix, these are the layman's bug-fixing scenarios I can guess, but I'm not a software developer:

    1. Oops, I forgot to write certain code for this, and it's broken
    2. Oops, I made a typo/mistake and this is broken
    3. I just wrote bad code, this is broken, and this needs to be rethought and redone
    4. This is a problem, but the code isn't wrong or bad and changing it would break things, so I'll have to add new code to override/supplement the current code for this type of scenario
    5. This edge-case, unusual scenario never came up and is broken, so I'll write new code just for that one situation
    6. That isn't exactly a bug, nothing is broken, and this isn't a radical new feature-request, but in retrospect it's really something I should've included from the beginning

    For #6, I'm thinking along the lines of something obvious in retrospect or an appropriate quality of life function, such as supporting ctrl+v in a one-character text area in the event someone needs to paste a character from a different language. That is just a layman's example, independent of technicalities such as "text areas should be standardized to the blah-blah v3.2 which would've allowed ctrl+v anyway".

    Are there other big examples?

    Would you group 3 & 4 together as the same, or group 4 & 5 together as the same?

    How would you rank those on how often they come up?

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

    Is JavaServerFaces viable, popular, not nearly-completely unknown?

    Posted: 01 May 2019 12:45 AM PDT

    Hi,

    I work part-time for a company that has used an old-school Lynx-based terminal for remote data entry for presumably many years, I'm assuming since at least the 80's. It's not great, but worked okay once you figured out how to use it.

    Recently they decided to update it to a web-based version, and instantly said everyone has to start using this new version ASAP, with the max time limit to do so being by this weekend.

    I finally started using it tonight and I was curious about the .faces extension as I've never heard of it, which is kinda weird as I'm a nerd and look up junk about web dev and related languages & technologies which I have no intention of ever using. JSF doesn't seem to be capable of doing anything better than could be done without it, and in fact seems to make many things more difficult just because of bad design decisions.

    So, is JSF actually maturing and becoming a reasonable, useful tool, and worth using instead of something like HTML/CSS/JS with modern libraries which easily could've served the same purpose and likely worked far better?

    The one good thing I've found so far is the use of MomentJS, but they're even doing that improperly with deprecated methods that throw console messages. They are also using synchronous XMLHTTPRequest for nearly-constant state updates from the server...lol. So, whereas we used to be able to type nearly-constantly and the terminal buffer would allow it to keep up, now we have to wait for it after entering most pieces of data before we can type the next.

    The only reason I can consider that they would want it done this way would be to hide much of the possibly-sensitive parts of the server side information, but then I still don't understand why JSF would be an acceptable technology unless they just didn't bother to pay any attention to what was going to be used because they're too lazy, or incompetent, or don't understand programming/technology -- all things that should cause them to be fired, or at least moved to a different job within the company.

    Also, dev tools are still perfectly accessible because it's just a webpage that we connect to, so it's not like someone can't just look at the network traffic to easily see the server address without even needing WireShark/etc, along with the page source. So, they're not hiding a whole lot or at least not doing so well, if that was actually the intention.


    My impression is that they were scammed by a lowest-quote dev who wanted to do an experiment or uses projects like this to extort companies, but they've spent so much they now feel they have to push it, and because of that everyone who uses their data entry system is getting punished.

    Pretty sure the turnover rate on this job is about to skyrocket; maybe then they'll consider reverting to the old school way again? Lol.

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

    Is LiveCode any use?

    Posted: 01 May 2019 07:42 AM PDT

    It is what I am taught in school and I was wondering if it has any use out side of school/ is related to other languages.

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

    Is there a way to link spreadsheet information into my HTML file?

    Posted: 01 May 2019 07:26 AM PDT

    I have a CSV file with 3 columns and 223 rows. The columns go from items (A column), description (B column), to type (C column). Each row contains information about each item. I want to insert data from all this spreadsheet into my HTML file. Along with this, I want to save time by not copy and pasting 233 sets of information manually.

    Originally the information I needed was on a website, however, I found a suggestion to use a webscraper to get all the information I needed. I did this by using python and now I have all the information in the spreadsheet.

    The template I would like to follow is shown (using spreadsheet terms). If I were manually doing this the next line of code would look this but with a B instead of an A (A1->B1)

    <p class="item-title">(A1 in spreadsheet)</p> <p class="w-itemid">ItemID: N/A</p> <p>&#8226; (A2 in spreadsheet)</p> <ul > <p>Type: (A3 in spreadsheet</p> <p>Item Pool: N/A</p> </ul> 

    Another person suggested that I use this code

    $row = 1; $resultArray = []; if (($handle = fopen("relics.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle)) !== FALSE) { $resultArray[] = $data; $row++; } fclose($handle); } if(count($resultArray)>0){ for($i=0;$i<count($resultArray);$i++){ echo '<p>Item: '.$resultArray[$i][0].'</p>'; echo '<p>Description: '.$resultArray[$i][1].'</p>'; echo '<p>Type: '.$resultArray[$i][2].'</p>'; } } 

    However, I am not too sure how to implement this into my code. I believe this is php, but again I am not too sure how to use this. I have 233 rows in my spreadsheet, so do I put this number in the brackets of $resultArray?

    I want the solution to be able to link the information from my spreadsheet into my HTML without spending an immense amount of time copy and pasting 233 items. I do not mind using Javascript, jQuery, or PHP (but I am still very new to them) as long as it helps me finish this task.

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

    No comments:

    Post a Comment