• Breaking News

    Monday, April 15, 2019

    Do "syntax detectors" for languages exist? Ask Programming

    Do "syntax detectors" for languages exist? Ask Programming


    Do "syntax detectors" for languages exist?

    Posted: 15 Apr 2019 03:20 PM PDT

    Hello all,

    I have been learning web development over the past few years and have progressed significantly. Right now I am learning React. However, in my studies I run across a recurring problem: I see something in some code, and it is unexplained. The problem I'm running into right now is very specific, but can be generalized pretty easily. For example, this syntax from the styled components documentation:

    const Button = styled.button` /* Adapt the colors based on primary prop */ background: ${props => props.primary ? "palevioletred" : "white"}; color: ${props => props.primary ? "white" : "palevioletred"}; font-size: 1em; margin: 1em; padding: 0.25em 1em; border: 2px solid palevioletred; border-radius: 3px; `; 

    My Javascript is not great, I am learning it but it will be a while before I know it all. Here I don't understand what the ` is doing. Presumably that's some kind of base Javascript functionality, but I don't understand what it does?

    Is there somewhere where I can input code and have it highlight what the syntax is? For example, in Python if I input something that contained "Foo.attribute" it would link me to using the attributes of an object.

    It seems like it would be pretty straight forward to build seeing as how interpreters already know what all the syntax means.

    Does this exist? If not, maybe I'll build it!

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

    Does SFML support 3D graphics?

    Posted: 15 Apr 2019 10:09 PM PDT

    I apologize for the stupid question, but I've never used SFML before. I'm not looking into photorealistic graphics like in powerful game engines written with DirectX or OpenGL, I'm talking more simpler stuff like cubes and spheres.

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

    Question about looping through bash arguments

    Posted: 15 Apr 2019 09:54 PM PDT

    Here is my script.

    It loops through arguments top to bottom and outputs them in reverse order. If you pass "red green blue" it outputs "blue green red."

    Now I want to build off it and compare each argument assuming they're strings and compare them in lexographic order.

    What I'm struggling to understand is how ${!i} works. I thought it would equal whatever argument which i equals, for example if it's 5 the ${!i} is equal to $5.

    But when I run the script for some reason I'm getting an error with integer comparison. I'm also unsure if I can use ${!i--} to compare the next argument with ${!i}.

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

    Is there a tool that can find technologies that have been used in the site?

    Posted: 15 Apr 2019 04:26 AM PDT

    Instantiation issue when solving this Prolog problem

    Posted: 15 Apr 2019 09:15 PM PDT

    I am trying to solve the following caliban problem using Prolog:

    Brown, Clark, Jones and Smith are 4 substantial citizens who serve their community as achitect, banker, doctor and lawyer, though not necessarily respectively. Brown, who is more conservative than Jones but more liberal than Smith, is a better golfer than the men who are younger than he is and has a larger income than the men who are older than Clark. The banker, who earns more than the architect, is neither the youngest nor the oldest. The doctor, who is a poorer golfer than the lawyer, is less conservative than the architect. As might be expected, the oldest man is the most conservative and has the largest income, and the youngest man is the best golfer. What is each man's profession?

    I found this code online and am trying to run it myself:

    http://www.kernel-panic.org/pipermail/kplug-lpsg/2000-June/001101.html

    but keep getting >/2: Arguments are not sufficiently instantiated when running with ?-solutions(L).

    Anyone have a solution to this issue?

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

    Host profile pictures for user accounts.

    Posted: 15 Apr 2019 07:43 PM PDT

    How would you host images for user profiles on a website? How would you link them to their data on a database?

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

    Looking for a Companion CD for an old Programming Book

    Posted: 15 Apr 2019 06:24 PM PDT

    Hello!

    Years ago I purchased this book: https://www.amazon.com/Real-Time-Terrain-Engines-DirectX9-Development/dp/1584502045

    I am just now getting around to work my way through it. However, I am unable to find my copy of the companion cd that came with the book. Does anyone either have a copy or location where I can get a cd image of the cd that came with the book? I am missing my cd binder which I keep loose cds like these safe.

    Thanks!

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

    How would I push code that has sensitive data without letting others see it?

    Posted: 15 Apr 2019 04:41 PM PDT

    Trying to do a side project using Reddit API and I was wondering how I should go about pushing my code onto Github without letting other's see sensitive info such as API keys, passwords, etc.? Thanks in advance!

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

    Javascript/website help

    Posted: 15 Apr 2019 12:31 PM PDT

    Hi,

    So for my university project I am creating a clock and i have got the code working in javascript. I have created a canvas using windowWidth and windowHeight. I have made everything in javascript as that was the main thing I was focusing on. Now i am trying to center the javascript object i have made but I dont know how to do this. Could anyone please help.

    Thanks!

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

    Seven segment clock in pascal

    Posted: 15 Apr 2019 08:53 AM PDT

    I need it for my school project and i dont know how to make it Please help :(

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

    Python help , simple divisibility checker with a catch

    Posted: 15 Apr 2019 08:47 AM PDT

    in my program , i need to check whether sum of element in list can be divided by 10 or not , it is easy but here is a catch ,3 and 6 are interchangeable , means [ 3 , 3 , 3 ] could be [ 6 , 6 , 6 ] . What is the best way to do it

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

    A simple synopsis reader in python

    Posted: 15 Apr 2019 07:43 AM PDT

    I just created a synopsis reader in python which given the name of the movie returns its synopsis. Please tell me how it is and what i can do to improve my code.. The link is https://github.com/this-is-batman/Synopsis_Reader

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

    Pressing "up" arrow in Python3 returns " ^[[A" instead of the last command

    Posted: 15 Apr 2019 07:37 AM PDT

    How do I fix this? This is in the terminal.

    Here is what it looks like: https://imgur.com/cKHZyTE

    • Version 2.9.4 (421.1.1)
    • Mac OSX Mojave
    • Python 3.6.5 (default, Apr 25 2018, 14:23:58)
    • [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
    submitted by /u/emilepetrone
    [link] [comments]

    Python Programming help

    Posted: 15 Apr 2019 07:33 AM PDT

    So here's my problem: I am not a programmer. I only just started learning Python a few weeks ago, and bam, my professor hits me with an assignment I am nowhere near equipped to handle. I honestly don't know where to start or what to do. I haven't even written any code because we haven't learned how to do anything this complex. There isn't even a useful example in the book. If anyone has any example tutorials, guides, ANYTHING that would help me figure this out, I would be so so very grateful. Below is the assignment. I will upload the data file on request for anyone who wants to poke at that too.

    In this assignment, you will analyze weather data. You can find the data by clicking here. You Need to write a program in Python that will apply the following tasks:

    Filter the attached/linked file and keep the following columns only: STATION, NAME/LOCATION, DATE, AWND, SNOW. Then save the filtered file and name it filteredData.csv. For each NAME/LOCATION, calculate the average snow amount per month. Save the results in two separate .csv files (one for 2016 and the other for 2017) name the files average2016.csv and average2017.csv For each NAME/LOCATION, calculate the total/ sum snow amount per month. Save the results in two separate .csv files (one for 2016 and the other for 2017) name the files total2016.csv and total2017.csv Sort the data in the files average2016.csv and average2017.csv. Store only the top 3 locations from each file. The top 3 locations data will be stored in one file, name it top3.csv. Each column in the top3.csv file will store the results of each year. Thus, the top3.csv file will have the columns 2016 and 2017. From the 2 year data, find the top 10 readings/rows of AWND. Store the result in a file .csv file and name it top10AWND.csv. The new file will have all columns from filteredData.csv, but only the top 10 AWND.

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

    An app that people can wage money and play against each other, winner takes all.

    Posted: 15 Apr 2019 06:36 AM PDT

    Profitable? I am from Africa. What do you think?

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

    What is the simplest way for Javascript to check if a string contains something an array

    Posted: 15 Apr 2019 06:27 AM PDT

    i have a small and weak javascript encryption project but the code needs to find out if the key contains a letter that another string/an array has (i know it is not good but i gotta start somewhere with encryption, so i can work on bigger stuff)

    my current code if this:

    for (i = 0, i < key.length, i++) {

    `if (key.charAt(i).includes("!") || key.charAt(i).includes("?") || key.charAt(i).includes("§") || key.charAt(i).includes("$") || key.charAt(i).includes("%") || key.charAt(i).includes("&") || key.charAt(i).includes("+") ) {` `return null;` `}` 

    }

    but it takes up too much space and i need a simpler version of this checking part, is there a way to make it check if a string contains a part of another string/an array?

    edit: i had an idea of key.charAt(i).includes("item" || "thing" || "stuff") but i don't think it works.

    edit v2.0: resolved, using JShint and w3schools i fixed the "for" loop, used a , but had to insert a ;

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

    Which programming/scripting language would work best for writing something really quick?

    Posted: 15 Apr 2019 01:59 AM PDT

    Once I learned C++ and discovered the wonders of C, I've basically gone from knowing quite a few languages to just using C for everything. I'm one of the few sad people who actually call C a high-level language. Since I know the consensus is that C is low level and only really used for low level things, I figured I'd try learning a higher level language that has certain advantages over C, specifically in being able to write and test out a function very quickly, so I can see that more complicated ideas actually work pretty well before dedicating the time to really write them out optimally. I think it'd be cool to be able to change the variable values of a program and evaluate them as the program is actually running as it'd make debugging and testing pretty fast and easy, but that's completely optional. I honestly know nothing about higher level languages.

    I tend to prefer procedural languages over object oriented the vast majority of the time.

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

    Android App, usage of Firebase/Store and graphs, advice needed

    Posted: 15 Apr 2019 05:08 AM PDT

    I am currently working on an android project, fair to say I am new to this but I want to know the best way I can implement the following problem:

    I am making an app which is based on eye exercises and allows users to exercises their eyes by following a pointer around the screen etc. However, I need to implement a sort of timer (countdown) or any other type and then log the amount of time (seconds or minutes) a user actually exercises with the date that they exercise on and then store this in firebase-Firestore. I will then be displaying this data to the user in the tracker activity class in a form of a graph.

    Any ideas/help is welcome preferably with some links/tutorials on how to implement this. Currently I am saving the date as a string with an auto incremented id in sqlite, but this method is not effective as the data will have to be graphically displayed in a graph, depending on the date and how much time or many times a user exercises for on a particular day.

    Thanks

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

    Looking for help creating a QR based inventory management system

    Posted: 15 Apr 2019 04:30 AM PDT

    I'm partnering with a friend to help create a stock inventory system using QR codes. My friend does the business side whilst I'm ostensibly supposed to do the technical side. However I feel a bit out of depth as I know very little about QR codes and app development in general (I'm a desktop developer).

    My initial idea is to use the QR code to display each item's production information and intended destination by embedding this data into the code itself. Then publish an app to read the QR code, however other regular QR code readers should not be able to read anything.

    I'm somewhat confused as to what a QR code actually is, because from my understanding a QR is simply a link for the device to connect to, but other research suggests that the QR can also embed data and possibly execute code.

    My questions are:

    1) Is it possible for QR to execute code, or be more than just a web link? Is there an API I can read?

    2) How would I print the QR code?

    3) Is it possible to lock QR code data behind certain user profiles on the app? e.g. a client who logs into the app as a 'consumer' will see some data on the QR code but will be obfuscated from what a, say, 'customer' profile sees.

    4) How complicated will the QR look?

    5) Is there a way to track the amount of times a QR code has been scanned and where it is scanned from?

    Alternatively, if you are interested in knowing more about the project, I am looking for a UI/UX designer and an app developer to help me out. We're based in the UK and it will be about a 6 month project. PM me if you want more details!

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

    CS50 String Initialization

    Posted: 15 Apr 2019 03:54 AM PDT

    I am working on Caesar cipher on CS50 Week 2. I have generally wrote most part of the code but the final error message which i have not debugged was the initializing of the string at the end. How do you initialize the string such that the error message goes away and we achieve our objective?

    My function is shown below:

    //Ciphering Function string plainToCipher(string plainText,int key) { int i = strlen(plainText); string cipher; int j = 0; do { if(plainText[j] >= 'a' && plainText[j] <= 'z') { cipher[j] = ((plainText[j] - 'a') + key) % 26 + 'a'; } else if(plainText[j] >= 'A' && plainText[j] <= 'Z') { cipher[j] = ((plainText[j] - 'A') + key) % 26 + 'A'; } }while(j<i); return cipher; } 

    I got this error message:

    caesar.c:71:17: error: variable 'cipher' is uninitialized when used here [-Werror,-Wuninitialized] cipher[j] = ((plainText[j] - 'a') + key) % 26 + 'a'; ^~~~~~ caesar.c:64:18: note: initialize the variable 'cipher' to silence this warning string cipher; ^ = NULL 
    submitted by /u/ethanoler01
    [link] [comments]

    Help needed with SFML library graphics.

    Posted: 15 Apr 2019 03:13 AM PDT

    so i am very new to SFML (less then 24 hrs) and i have encountered with a weird problem. I am trying to load a texture and when i run my code, the cmd shows "failed to load ... " in the very beginning and then prints all sort of weird random gibberish stuff. I am using visual studio 2017 and SFML 2.5 . here is my code :

    #include <SFML/Graphics.hpp> #include "iostream"; using namespace std; using namespace sf; int main() { RenderWindow window(VideoMode(1000, 1000), "Chiggy's Tic Tac Toe!"); CircleShape shape(100.f); shape.setFillColor(Color::Blue); Texture texture; if (!texture.loadFromFile("D:\Developement\Visual Studio\sfml\try\Project0\Project0\mad.png")) { cout<<"Mario failed to load horribly"<<endl; system("pause"); //return EXIT_FAILURE; } while (window.isOpen()) { Event event; while (window.pollEvent(event)) { if (event.type == Event::Closed) window.close(); } window.clear(Color::Black); window.draw(shape); window.display(); } return 0; } 
    submitted by /u/Coolest_Gamer6
    [link] [comments]

    Did any of you hate functional programming? and if so why did you decide to stay with OOP?

    Posted: 15 Apr 2019 01:50 AM PDT

    I am looking into learning Haskell and have heard a lot of good things about functional languages, I wanted to get an opinion from the other side. Has anyone dove into functional programming and then found there were things that bugged them about functional programming? Or that they could not do in functional languages?

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

    No comments:

    Post a Comment