• Breaking News

    Thursday, December 28, 2017

    Creating an interpreter : the VM Ask Programming

    Creating an interpreter : the VM Ask Programming


    Creating an interpreter : the VM

    Posted: 28 Dec 2017 03:48 PM PST

    Hello

    I'm attempting to make a programming language. But, currently, I'm using visitors to evaluate my AST.

    Expressions and variables are nearly 100% implemented, but the code starts to get kind of messy and complicated, with a lot of workarounds. (See for yourself in the expr folder). I can't imagine the mess this will be once the whole thing is done, it will be a nightmare to debug ! :(

    I think that having a VM (->converting the tree to a flow of instructions) will make the code cleaner, and as a bonus it'll allow for more optimizations.

    But, I don't want to start messing with binary files just now1. So, to work around that, my idea is this :

    • After the parsing process : Run a "CodeGen" visitor
    • The "CodeGen" visitor will output a std::list (or vector) of Instruction objects and a constants table. The instruction objects (a struct) would hold a variable (probably an enumeration) and up to 3 arguments, under the form of a char/int variable.
    • This would be passed to a "pseudo VM", to which the instruction objects would be fed, and executed.

    So, It's like a "normal" vm, except that I skip the whole "generate a binary file and make the vm read instructions from it" part.

    But, I have a few questions :

    • Consider that I'm not trying to make a ultra fast language, will this method be a bottleneck in the interpretation process, and cause a major slowdown2 ?
    • Similarly to my first question : If i decide to compile the file to a binary file (using a function that converts instruction objects to a binary representation) and then re-read it later to execute it, I'll need to read the whole file and create a Constants table and a std::list<instruction> to pass to the VM. Will this be a major performance problem2 ? (Re-reading the file and creating the structures)

    I'm really sorry if this isn't well explained, I'm here if you have any questions.

    Thanks !

    1 Why ? Because I'd need to create a completly new file format to store my compiled programs, and learn about serializing C++ types to binary and a lot of other stuff. It'll take a lot of time and I prefer focusing on making a working, complete implementation of my language first.

    2 By performance problem, I mean something that's slow enough to cause a major bottleneck. Which means that this part would be so slow it would take longer to execute than every other part of my interpreter combined.

    PS: English is not my first language, if I wrote some sentences that are badly worded or some incorrect words, tell me. I take critics on my writing happily ! :)

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

    Can my github account get credit for commits to a VS Team Services repo?

    Posted: 28 Dec 2017 08:28 PM PST

    I just started a new job, and all of our repos are in VS Team Services. Before this job, though, I was doing really well on github projects and I don't want to lose traction on my github account. I was wondering if it was possible for my github account to recognize commits to a VS Team Services private repo, without actually showing the commits (for privacy).

    It sounds like it's not possible, being that the repo isn't in github, but perhaps someone knows a way.

    Thanks in advance!

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

    Looking for an SMS communication platform (imessage, google voice) where I can programmatically read the contents and generate my own analytics. Here's what I've tried...

    Posted: 28 Dec 2017 04:36 PM PST

    So far, I've considered google voice. This would be perfect, but all the APIs are from half a decade ago and defunct.

    I've considered twilio / nexmo / similar services but they are unideal because I need to be able to text them back like normal in a non-programatic fashion as well (like a texting app).

    I've considered using gvoice email sms notifications and hooking it to a callback so I can keep track of incoming messages (and create a model of the entire conversation as it progresses by storing it in my personal server's db) and also possibly automate sending texts back using the reply email address, but it would not be able to read my responses that I sent manually.

    Any ideas (or working gvoice api somehow)?

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

    Max codepoint in Unicode?

    Posted: 28 Dec 2017 08:16 PM PST

    In Wikipedia and basically every other site there is on unicode codepoints, the supposed max value is U+10FFFF, because that's all that UTF-16 can support through Surrogate pairs, yet there are apparently assigned codepoints between U+11000 - U+1106F. (source)

    So what is the actual maximum codepoint in Unicode?

    (by codepoint I mean in the unencoded form, aka UTF-32, I already know about UTF-16's Surrogate pairs between U+D800 and U+DFFF, that's NOT what I'm asking about)

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

    Python 3/anaconda install help

    Posted: 28 Dec 2017 07:56 PM PST

    I'm a cs student, and I'd previously installed python anaconda 3 on my computer. When I'd done it previously, I was able to type jupyter notebook from any command line, and it would a notebook from any directory. Additionally, if i had a .py file saved and navigated to the working directory, I could type in the commnand line python <file name>.py, and the program would execute. Additionally, although I don't remember this as well, I was able to install any module or library via pip by typing in pip install <whatever>. Later I switched computers, and had to reinstall python. When I did the reinstall, I lost all three of these functionalities. It would always say jupyter or pip or python not recognized. Now that the semester has ended, I've uninstalled python and redownloaded it, but want to make sure I can do those three things. What should I do to make sure I can do these? Thank you so much

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

    Please recommend a language to build a simple web-based dashboard.

    Posted: 28 Dec 2017 03:54 PM PST

    I'm looking to build a simple web-based dashboard. The idea is that this dashboard will display weather, time, upcoming reminders, maybe some other things, on a seperate display (driven by a raspberry pi). This display would simply pull up the webpage full screen to create the dashboard. I have experience programming in python for personal raspberry pi projects, but that's about it. Seems like the right tools might be something like HTML, CSS, PHP, or js, but I'm really not sure which would be best here. Please let me know if I can clarify anything or if you've got any suggestions. Thanks.

    Edit: I should add that this isn't going to be in a professional setting - strictly for fun, so maintenance, security, dependability, things that big corporations would care about, aren't really driving factors here. Basically just looking for the easiest way to make the dashboard look pretty. Thanks!

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

    How do I edit exposure time using the Arducam USB shield software?

    Posted: 28 Dec 2017 06:57 PM PST

    Hello Everyone!

    I have tried asking this elsewhere but I have had no success so hopefully someone here can point me in the right direction.

    I have a MT9F002 module by Arducam with the requisite USB Shield interface. The driver package comes with a "USB Test" program which I am using to take pictures. I need to be able to change the exposure time and I am having a tough time parsing the source code to see what I need to change.

    Can anyone suggest a solution to my problem? Please and Thank You!

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

    Please recommend image processing tools to determine the sharpest image form a collection

    Posted: 28 Dec 2017 06:20 PM PST

    Given a set of still images taken from a video, I need to find out the sharpest image. Most of these images will have some degree of motion blur. I need some pointers on what algorithms / libraries / services should be used to determine the sharpest image in the collection. It might help to look at the problem as "find the image with least amount of blur". In that case I'll be looking for a tool/algorithm to measure motion blur.

    I have some basic knowledge image processing but have years of experience using scientific computing libraries like SciPy, NumPy etc. What algorithms or software tools should I use for this problem?

    I am open to using either Python or NodeJS as long as I can find reasonable options. I heard before that there are some cloud services that can do this kind of image processing. I'm open to using such a service, depending on cost etc.

    Thanks.

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

    I cannot understand the fundamental difference between caching and buffering

    Posted: 28 Dec 2017 01:59 PM PST

    I have looked at this online so many times but I still don't understand how a buffer is different from a cache. You store data in a buffer for faster access and you store data in a cache for faster access. So, what is the difference then if both are the same in the sense that they act as a bridge of fast movement between two devices or a device and a program? Please, someone, explain this to me.

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

    Is it possible to send questionnaires/surveys with action buttons via text instead of redirecting to an external website?

    Posted: 28 Dec 2017 03:37 PM PST

    Similar to how Twitter has questionnaires/surveys with 4 clickable buttons. Is it possible to do the same thing, but via text message instead of sending a link that redirects the person to an external site to submit their answer? Cheers.

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

    Implementing a helpdesk. Share what works, what doesn't work.

    Posted: 28 Dec 2017 03:37 PM PST

    Howdy Devs,

    I figure that most of us have to deal with a helpdesk system of some sort. If you are anything like me you recognize some things that work, and some things that do not work. If you had the opportunity what would you do to re-implement the helpdesk at your company. Share with me what works and what doesn't work. Looking for insight from the minds of developers.

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

    How can you turn investor data from Yahoo Finance into a investor spreadsheet (Google Spreadsheets or Excel) with all the ratios (e.g. p/e), past data (3 years of EPS), and the current price of the stock?

    Posted: 28 Dec 2017 03:02 PM PST

    Basically, instead of manually inputting this data, I can easily use a program that will input this data for me. This will make it efficient, accurate, and fast. I am not a programmer myself but I know that their is a relationship with Python and spreadsheet softwares. Has anyone ever done this?

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

    Making a wordcloud out of skype conversation history in a specific style/shape.

    Posted: 28 Dec 2017 02:36 PM PST

    I am sorry if this does not fit here but I just do not know where to go. What i wish to accomplish is to create a wordcloud in a style I saw here on Reddit a few years ago. I want the wordcloud to be made from the text of skype conversation history (over quite some years so a lot of data I would imagine) and have it turn out in the style similar to this: http://i.imgur.com/f4WpAkh.png

    With some digging i found the GitHub (https://github.com/winneon/makeswordclouds) with the source of the bot from way back then, but I simply do not have the knowledge to know where to even begin in understanding how to adapt/learn from this and put it into my own usecase.

    To summarize: I wish to take raw skype conversation data, somehow clean it up so its usable, then make a wordcloud out of it in the style of the picture above (exact font not vital). I do not wish to make a bot out of this or even mass produce it, I only have to do it once so having it be somewhat manual and not as automated and straight forward as it could be is okay.

    Any help/tips/pointing in the right direction on how I could accomplish this would be so greatly appreciated. Is it feasible at all or just a wild dream? It would make a great gift and I have wished to do this ever since I first saw the example of it being done to Reddit comments.

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

    What specifically do you need to do to deploy a full stack application onto a server?

    Posted: 28 Dec 2017 09:48 AM PST

    My lack of understanding of networking is frustrating me, there's just something I am not grasping following tutorials. Maybe someone here can help. My client app is a website. My basic stack:

    express.js (client web-app) <-> node.js <-> MongoDB

    I have a completed application using this stack working on my local machine.

    What do I need to do to actually get this onto a server with a domain name?

    Can I deploy my client app, data access app, and database all on one single server?

    How does that work if MongoDB always needs to be running?

    What I think I know:

    • Deploying on a single server has security/scalability issues

    • I'll likely need to buy a domain name from another site and then hook up the namespace of where I'm hosting it through that site.

    • That it's possible to deploy a a client-side website and node.js on a single server, just not sure about the database aspect.

    I'm not sure how far off this is from programming, but I feel like this is the right place to post this. Thank you to whoever answers this question, if anyone.

    submitted by /u/alex-C137
    [link] [comments]

    Help with preventing overflow on centered <ul>s and centering icons vertically.

    Posted: 28 Dec 2017 01:00 PM PST

    I have been working on a todo list and i was wondering whether there is a way to prevent overflow of text in my <ul> using CSS. Link to image. Also how do i center icons vertically, i tried some tricks from the internet but those don't work for me. Link to image.

    This is my associated HTML for the list

    <div id="container"> <h1> To-do <span> <i class="fa fa-pencil" aria-hidden="true"></i></span> </h1> <input type="text" placeholder="New task"> <ul> <li> <span class="delete"> <i class="fa fa-eraser" aria-hidden="true"></i> </span> <span class="task"> Internships </span> </li> <li> <span class="delete"> <i class="fa fa-eraser" aria-hidden="true"></i> </span> <span class="task"> Machine Learning </span> </li> <li> <span class="delete"> <i class="fa fa-eraser" aria-hidden="true"></i> </span> <span class="task"> Project Euler </span> </li> </ul> </div> 

    CSS

    #container { width: 33%; margin: 10% auto; } ul { margin: 0; padding: 0; list-style: none; } li:nth-of-type(even) { background-color: #f2f2f2; } li:nth-of-type(odd) { background-color: #f9f9f9; } li { font-size: 1.2em; line-height: 39px; box-sizing: border-box; height: 39px; margin: 0; color: #24213a; } 

    HTML for uncentered vertical icon

    <header class="w3-container w3-teal"> <span onclick="document.getElementById('id01').style.display='none'" class=" "> <!-- &times; --><i class="fa fa-times" aria-hidden="true"></i> </span> <h2>Settings</h2> </header> 

    CSS

    .fa-times { font-size: 35px; float: right; } 
    submitted by /u/SIR_TREX
    [link] [comments]

    Tracking subreddit comments over time - how to start?

    Posted: 28 Dec 2017 04:12 AM PST

    Hey guys, I want to learn how to monitor certain subreddits and see how the words in the comments in them change over time. Ideally I want to have a list of ~500 words to track and save this data into google sheets.

    I have no idea where to start since I don't know any programming languages but I'm very willing to learn for this project, could someone point me in the right direction? I've had a brief look at the reddit API documentation but I'm still confused

    Thank you!

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

    Advice on coding a choice-based role playing game?

    Posted: 28 Dec 2017 12:44 PM PST

    Please read my description before directing me to some do-it-all program that can facilitate the process.

    So, I am a novice programmer at best. I don't have much knowledge outside of basic coding, and often do not know how bits of code interact with each other.

    This is my goal... I would like to create a choice-based roleplaying game with these features: a text box for displaying the story at its current position, a list of choices for story branching, a side panel that shows the current stats of the user, and a small box in the corner for displaying pictures relevant to the current situation.

    I would like this to be an applet that can be accessed online, but does not require more than one webpage to display it. I do not mind using external programs to help me map out the story branches, but I ultimately would like it to export code that I can integrate with my user-interface. There is this online program I like called Squiffy, that will turn your modelled story into Javascript and HTML. I am open to other suggestions.

    Here's where I run into questions: I do not have much experience with GUI's, or combining different coding languages. What program should I use / learn to make the GUI for this game? I would like it to be compatible with the code generated from the story progression module. As stated before, I should be able to compress and run it on my computer, but post it as an applet online. Moreover, can Javascript / HTML be accessed by my GUI, and be used within the applet?

    Additional details: I currently use Eclipse for almost everything, and only know coding in Java and Python.

    Thank you so much, prompt responses will be available for follow ups.

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

    How do I load and output a GLES texture in RenderScript on Android?

    Posted: 28 Dec 2017 12:35 PM PST

    What skills do I need to know in order to create a lobby/matchmaking area for a simple game.

    Posted: 28 Dec 2017 12:32 PM PST

    It just needs to be a lobby where players can find a game that is filling up and choose to join/leave.

    edit- im mostly trying to keep track of the moving parts that I would need to be aware of

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

    REST API in Go?

    Posted: 28 Dec 2017 07:59 AM PST

    Hello, I want to make a REST API to consume with mobile apps (firstly Android).

    Would you think Go with a proper framework is a good choice? Or would you stay with PHP?

    Any other programming language that you would recomend is welcome.

    I want it to be rather simple to maintain and grow. I don't really have a preference with databases technology.

    I am most familiar with ASP.NET MVC (C#) and MSSQL for now.

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

    How to know wich event closed a window in diferent window C# wpf

    Posted: 28 Dec 2017 11:10 AM PST

    I have this window that calls another window, and there's two differnt buttons that can close the second window. Is there any way for me to know wich button event closed the second window in the first window ?

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

    School related question.. Wondering which of the following courses would be best to take.

    Posted: 28 Dec 2017 06:17 AM PST

    Hello /r/AskProgramming, hoping this is a suitable place to post.

    My career goal in life it to be a Software Developer. Start to finish life cycle, full stack. Right now, to complete my transfer degree, only one of the two courses are required to fulfill my transfer requirements:

    'Elementary Statistics'
    Introduction to the use of probability and statistical inference for business decision making. Various distributions and techniques are presented to prepare the student for parametric estimation and testing.

    or 'Foundations of Discrete Mathematics'
    This course is designed to introduce students to the concepts involved in mathematical proofs. Topics covered include the use of logic, quantifiers, set theory, relations and functions, and proof techniques and applications.

    I am sure that the school I ultimately transfer to will cover these topics in further detail, espcially if I decide to pursue a post grad degree. Was just wondering if this sub had any input as to which one would be best to start with first.

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

    What are some causes of visibly rendered entities like '&lt;' (double-encoding) that could apply inconsistently in the same page?

    Posted: 28 Dec 2017 09:26 AM PST

    I've seen HTML entities rendered before, and I assumed the author must have copied HTML source containing encoded characters into a WYSIWYG editor before publishing the results as a web page of their own. I found some pages that described general character encoding issues, and I got the sense that copying between different or unspecified content types could cause something along those lines.

    This example defies my understanding: https://www.codeproject.com/Articles/7150/Member-Function-Pointers-and-the-Fastest-Possible

    If you look at the source of the page, there are 32 instances of &lt;CODE lang=c++&gt;, scattered throughout lines 800-1300 of 2400, some right next to correct uses! For example, #12 is on line 825, while 826 is formatted impeccably by comparison, e.g. <code>&lt;=</code> in the source to render <=. As it turns out, all of the code tags specifying C++ are mangled. Considering all that, it's getting very hard for me to believe this was user error. However, I'm starting to doubt my assumption that the encode/decode process is guaranteed to be symmetric, for lack of a better explanation.

    What else could be causing this, in either the example I gave or in general?

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

    Can't exit program using while (c++)

    Posted: 28 Dec 2017 08:34 AM PST

    need help

    include <iostream>

    include <cstdlib>

    include <ctime>

    using namespace std;

    void StartScreen(int five, int ten, int twenty, int fifty, double total){

    cout << "\n \n \n ..: JAQK POT :.. " << endl; cout << " ****************************" << endl; cout << " Jack Ace Queen King" << endl; cout << " 5c 10c 20c 50c " << endl; cout << " " << five << " " << ten << " "<< twenty << " " << fifty << endl; cout << "\n Total = RM" << total << endl; 

    }

    void clScreen(){ for(int i = 0; i < 100; ++i){ cout << "\n"; } }

    int main() { char start;

    cout << "+----------------------+" << endl; cout << "| ------------------ |" << endl; cout << "| |" << endl; cout << "| ---------- |" << endl; cout << "+----------------------+" << endl; cout << "\n Press any key to continue . . ."; cin >> start; clScreen(); string x, exit = "o"; srand (time(NULL)); int max = 10; int five = rand() % max; max -= five; int ten = rand() % max; max -= ten; int twenty = rand() % max; max -= twenty; int fifty = max; int j, a, k, q; double total = five*0.05 + ten*0.1 + twenty*0.2 + fifty*0.5, amount; double c05 = 0, c10 = 0, c20 = 0, c50 = 0; while (exit != "N" || exit != "n"){ clScreen(); StartScreen(five, ten, twenty, fifty, total); cout << "\n Press D or d if you want to deposit." << endl; cout << " Press W or w if you want to withdraw." << endl; cout << " Press R or r if you want to reset." << endl; cout << "==>"; cin >> x; if(x == "D" || x == "d"){ cout << "How many 5c coins? ==> "; cin >> j; five += j; cout << "How many 10c coins? ==> "; cin >> a; ten += a; cout << "How many 20c coins? ==> "; cin >> q; twenty += q; cout << "How many 50c coins? ==> "; cin >> k; fifty += k; } else if (x == "W" || x == "w"){ cout << "Please enter the amount (in RM) => "; cin >> amount; int tmp = amount*100; if(tmp%5 != 0 || amount > total){ cout << "INVALID"; } else { while(amount > 0){ if(fifty > 0 && amount >= 0.5){ fifty -= 1; c50 += 1; amount -= 0.5; } else if (twenty > 0 && amount >= 0.2){ twenty -= 1; c20 += 1; amount -= 0.2; } else if (ten > 0 && amount >= 0.1){ ten -= 1; c10 += 1; amount -= 0.1; } else if (five > 0 && amount >= 0.05){ five -= 1; c05 += 1; amount -= 0.05; } } cout << "Yes, Please collect your coins: "; if (c50 > 0){ cout << "\n 50c x " << c50 << endl; cout << "20c x " << c20 << endl; cout << "10c x " << c10 << endl; cout << "5c x " << c05 << endl; } } } else if (x == "R" || x == "r"){ cout << "How many 5c coins? ==> "; cin >> five; cout << "How many 10c coins? ==> "; cin >> ten; cout << "How many 20c coins? ==> "; cin >> twenty; cout << "How many 50c coins? ==> "; cin >> fifty; } else { cout << "Invalid input"; } StartScreen(five, ten, twenty, fifty, total); total = five*0.05 + ten*0.1 + twenty*0.2 + fifty*0.5; cout << "\n Total = RM" << total << endl; cout << "\n Please press any key to continue," << endl; cout << " press N or n to exit the program => "; cin >> exit; } return 0; 

    }

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

    Logging API calls

    Posted: 28 Dec 2017 05:00 AM PST

    Does anyone have experience with logging API calls server side, to keep track of all of the user's interactions with our server? I want to know if this is practical.

    I am asking this because I'm looking at a strange exception reported from one of our user's phones, and we have an inkling that it happened after one of the users' calls to our API. I thought having an API log would be nice in retrospect to immediately see where it happened.

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

    No comments:

    Post a Comment