• Breaking News

    Sunday, January 26, 2020

    <= inefficient compared to

    <= inefficient compared to <? Ask Programming


    <= inefficient compared to <?

    Posted: 26 Jan 2020 03:14 AM PST

    Let's say I wanna check if a number is 7 or below, would it be more efficient to do 'num < 8' or 'num <= 7'? Tried to benchmark it, but couldn't find any statistical significant differences. Maybe some low-level programmers know what's fastest in theory? I remember Terry A. Davis (of all people) had some look up table where he could see code length and he actually made the C language more efficient.

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

    How many programming languages do you write in fluently relative to the number of human languages you speak fluently? Is there a correlation?

    Posted: 26 Jan 2020 09:37 PM PST

    Should I continue doing the following in Python, or continue on using something else?

    Posted: 26 Jan 2020 08:59 PM PST

    I am writing a program that uses AI, NLP and thousands of images/audio files to teach a spoken language.
    I am worried that Python will be too slow, or not suited for this job.

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

    Need advise on Calendar APIs

    Posted: 26 Jan 2020 03:46 PM PST

    Fellow programmers, what is your creative outlet/hobby?

    Posted: 26 Jan 2020 07:23 PM PST

    When you're feeling the need to do something creative outside of coding, what do you find yourself doing?

    submitted by /u/incendiary-wit
    [link] [comments]

    Help Writing Temps to a Database

    Posted: 26 Jan 2020 12:43 PM PST

    I am trying to understand how to accumulate data inside a SQL database. I have a PostgreSQL database installed and configured locally on server. The database is a single table with three columns:

    • temp_id primary key
    • temp
    • temp_ts

    Appreciate any assistance in how I can populate temp data from executing my script hourly via Cron and get that data into my database. Below is the bash script and my database schema:

    #!/bin/bash temp=$(vcgencmd measure_temp | egrep -o '[0-9]*\.[0-9]*') echo "$temp" 

    Here is how the script outputs:

    cachedrive@pool-pi1:~ $ sudo sh print_temp.sh [sudo] password for cachedrive: 50.5

    pool_sensor1=# \d pool_temps Table "public.pool_temps" Column | Type | Modifiers ----------+-----------------------------+--------------------------------------------------------------- temps_id | integer | not null default nextval('pool_temps_temps_id_seq'::regclass) temps | numeric | not null temps_ts | timestamp without time zone | not null Indexes: "pool_temps_pkey" PRIMARY KEY, btree (temps_id) 

    Appreciate any assistance on how I can get these values stored in my local db. Thanks!

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

    I don't know what wrong with my code

    Posted: 26 Jan 2020 04:48 PM PST

    When I enter 0 for courses taken I get the output I want,

    When I enter 1 , It prompts to enter the course number which should only 4587, 4599, 8997, and 9696 but I can whatever and it does not show the correct number of credit hours its always 93

    When I enter 2 , It just shoots to the end of the program when a entry is invalid

    Here is my code

    https://ideone.com/pHNif1

    Any help would be appreciated

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

    Whats are the killer features for the next version of HTML (6) going to be ?

    Posted: 26 Jan 2020 04:42 PM PST

    So I'm poking around the web and HTML 5 is about 11 years old now, wondering when the next version of HTML standard will be made available. HTML 5 brought so many useful useful functions like, video tags, geo-location , improved form field types, etc.. What can we expect or hope to get fore the next version?

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

    Gift Ideas for Programming Boyfriend

    Posted: 26 Jan 2020 08:16 AM PST

    Valentine's day is coming up and I'm trying to think of a gift for my boyfriend.
    He's going to school for computer science. I know he wants a Raspberry Pi but I don't have the money for it right now. I'll probably get him one for either his birthday or Christmas.
    Any ideas for a gift for someone that's into programming would be greatly appreciated!!

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

    Array of objects in Javascript?

    Posted: 26 Jan 2020 02:58 PM PST

    Hey! I'm trying to create a javascript array populated with objects that each have four properties. That way, I can iterate through each element of the array and call a function that takes their properties as parameters.

    In c++, I would just make a struct containing the four properties, and than array with that variable type.

    I've done some searching but I can't seem to find an answer. Perhaps it's different in javascript.

    Thanks for reading.

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

    Low data proxy VPN Raspi

    Posted: 26 Jan 2020 01:37 PM PST

    Living in Germany I often experience Edge or even Gprs cellular connections and get frustrated with long loading times when travelling. So I was wondering if I could manually reduce some overhead.

    My idea is to setup a VPN (using PiVPN?) on my Raspi at home and somehow prefetch all incoming web traffic and only return a very stripped down version of it (based on some rules) so I can connect to the VPN from my phone when needed and enjoy low-data versions of the websites I visit.

    The VPN part is quite straightforward, but I couldn't find anything on the website-stripping / low-data-representation part, has this been attempted before? If so can you point me towards any resources?

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

    How long to increment a sum O(N^5) 100,000 times?

    Posted: 26 Jan 2020 01:01 PM PST

    I'm having some issues.

    I've been tasked with grabbing the runtimes of a program when ran through a function that's O(N5). However, my computer hasn't been able to compute past n = 100

    The program is three nested for loops:

    for x = 0, x < n, x++ for j = 0, j < x * x, j++ for k = 0, k < j, k++ sum++

    By my calculations, I think it may be improbable to compute n past 1000. My C script won't compile past 100 and my java program compiled everything immediately but reports 0 times for n past 100.

    Thoughts?

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

    God help me I have to build a Wordpress plugin. Should I build it all within WP or should the backend be built in something better like Laravel?

    Posted: 26 Jan 2020 07:46 AM PST

    The application will be built upon WooCommerce and it will be a web app where customers of a restaurant can place orders.

    Once an order is placed, it should go to a backend system where the chef can notify the waiter that the meal is complete, and the waiter comes to pick it up.

    It will also need to display on a large TV (the current orders) as well as print onto a small printer (receipts and such).

    This will be for multiple restaurants using the same system.

    ---

    The main thing I'm stuck on, is how much of it to build in WooCommerce/WordPress, if the entire app should be contained as a plugin, or if the frontend should be WP but the actual backend should be in a better framework such as Laravel.

    At first, it sounds logical that everything is self-contained, to not have two systems that need to communicate with one another. If it's two systems, I'll need to build an API for the two to communicate, as well as handling authentication between the two apps.

    On the other hand, this app will likely contain some quite complex functions and might end up being a relatively large app, and the WP plugin structure is truly not as friendly (and fun) to program a large app within as opposed to Laravel.

    Note that I'll likely need to make use of node.js for real time displaying of orders, and I want to build the backend interface (for chefs and waiters) in Vue.js. So I think trying to add those two onto Wordpress will drive me insane.

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

    Exception Handling in Java, specifically NullPointer

    Posted: 26 Jan 2020 07:32 AM PST

    So I'm working on a homework project and I think I have it down to one issue that I'm having problems resolving. NullPointerException.

    Essentially my program needs to handle a FileNotFound Exception, which it does. But then it hits the finally() block where I close my Scanner and PrintWriter. They are null at this point since they were initialized at null and no further actions were taken since a file was not found. This is causing a NullPointerException.

    Any ideas? Is there anything I can do with the Scanner and PrintWriter without passing another file to check?

    Edit 2: an if statement was all I needed. I appreciate all the help!

    Edit: some code I should've provided:

    public class ReadingWithExceptions { void process(String inputFilename) { Scanner scannerIn = null; PrintWriter printOut = null; String outputFilename; try { scannerIn = new Scanner(new FileInputStream(inputFilename)); outputFilename = scannerIn.next(); //grabs the output file name // Code blocks here to process the file, if found } catch (FileNotFoundException e) { System.out.println("File Not Found: " + inputFilename + "\n"); } finally { scannerIn.close(); printOut.close(); } public static void main(String[] args) { ReadingWithExceptions reading = new ReadingWithExceptions(); reading.process("file2.txt"); } } 
    submitted by /u/Oderint
    [link] [comments]

    Should I use a default: or else statement as a fallback, even if it is absolutely impossible that it will ever trigger?

    Posted: 26 Jan 2020 07:05 AM PST

    Hello!

    I have some code where I used if and else if because it was 5 lines of code as opposed to like 15 of properly formatted switch statement code.

    And I declare variables in those if-else statements, so that means that if they aren't true (which should literally never happen), then the thing that gets the variables will get an undefined or null or error or whatever.

    Sooo, what should I do? Declare the variables outside of the statement and waste 3 lines for an error, which if it happenned, would frick-up much more than those lines not getting the values they need.

    I dunno. I feel like you will tell me to take all safety precautions, even over the top because you never know. But I dunno. if I can't trust the code to execute line-by line like I have told it, then I dunno what we are doing here. Might as well abort the whole app at that point, even if I ever thought of making a check if everything is allright.

    Example code:

    function myfunction(id, type) { if (type == "button") { var a = "css_class11"; var b = "css_class12"; } else if (type == "link") { var a = "css_class21"; var b = "css_class22"; } if (something) { document.getElementById(id).className = a; } else { document.getElementById(id).className = b; } } 

    tnx!

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

    [C#] High efficiency sorted list, dict, or not?

    Posted: 26 Jan 2020 12:59 AM PST

    Hey!

    I need to think of something really flexible (extendable by add, removeat/remove by key value) that will sort my items by the time they were added to the list (long).

    Atm im using ConcurrentDictionary, because i can remove items while iterating, but it doesnt have that great performance.

    Any tips on how can i approach this?

    Basically i have a queue with time + interval, and when (time+interval>currentTime) remove the item and execute its function (interface implementation).

    If there isnt anything efficient enough, is there a name of thing that i need, so i can look around and find example implementations - to try write it myself?

    Thanks!

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

    A Day in the Life of a Software Engineer Intern at Instagram/Facebook

    Posted: 26 Jan 2020 11:57 AM PST

    My name is Jason and I am studying CS at UCLA. I just created a YouTube channel where I am planning to post content related to what it's like studying computer science at UCLA; getting/acing tech interviews; and what its like interning for tech companies in Silicon Valley (Yelp, LinkedIn, Instagram/Facebook).

    I just uploaded my first video: A Day in the Life of a Software Engineer Intern at Instagram/Facebook, and if interested, it would mean a lot to me if you check out the video. Thanks!

    https://youtu.be/N5dzkFA0XRA

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

    JS or its frameworks ?

    Posted: 26 Jan 2020 12:35 AM PST

    Can anyone tell me that should I go for a plain JS or its frameworks ? I mean no doubt frameworks serve their purpose but JS can do that so should I go for JS rather than its frameworks ?

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

    Kotlin or Java in Android Studio

    Posted: 26 Jan 2020 04:09 AM PST

    I want to learn android studio and want to make some apps for project, so which language will be good Kotlin or Java?

    submitted by /u/Asif-Ahmed
    [link] [comments]

    Are there some more granular official common reference levels of knowledge for programming languages other than some vague junior/senior badge? Something like in natural languages A1, A2, B1, B2, C1, C2, N, etc.?

    Posted: 26 Jan 2020 01:52 AM PST

    For example, if you go here:

    https://en.wikipedia.org/wiki/Common_European_Framework_of_Reference_for_Languages#Common_reference_levels

    You can see what expectations each level has.

    Is there something similar in programming languages, if not universally than at least for some of them?

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

    C Sparse Matrix

    Posted: 25 Jan 2020 11:15 PM PST

    3 strings have their important words stored in another character array.

    ex:

    A: "The sky is blue"

    B: "The grass is green"

    C: "Sky" , "Blue, "Grass", 'Green"

    How do I create a matrix such that when scanning A from left to right, it will show a 1 when an important word is encountered and 0 when an unimportant word is encountered, and the same goes for B?

    The final array should look something like this:

    Sky Blue Grass Green //Not to be included in the output

    A 1 1 0 0

    B 0 0 1 1

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

    No comments:

    Post a Comment