• Breaking News

    Thursday, March 1, 2018

    Drawing a triangle using only bash Ask Programming

    Drawing a triangle using only bash Ask Programming


    Drawing a triangle using only bash

    Posted: 01 Mar 2018 08:12 PM PST

    Arguably the hardest part of most OpenGL tutorials out there is setting up the IDE to get all of the correct static libraries and link in your OpenGL wrappers etc. The problem is all of these only discuss how to do that within a specific IDE.

    I would like to create a c++ executable that uses OpenGL to do image processing within the terminal. The goal is that you could do something like the following:

    combine picture1.png picture2.png "(a/b)+a" output.png

    and have that injected into the final line of a fragment shader so that an output image could be generated based on the two images passed in and a function between them.

    If this could work on any platform that can run Bash that would be great but it is mostly for my usage on MacOS.

    I want to also try to build it without a dedicated IDE just so I can learn how to add parameters to my build and write make files.

    Is there a tutorial out there that covers the process to setup an opengl context in c++ just using the bash terminal?

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

    Does anyone define functions within functions?

    Posted: 01 Mar 2018 12:05 PM PST

    As far as I know most programming languages allow function definitions within other functions.

    I don't know why this thought crossed my mind, but cross my mind it I did.

    I'm curious to know whether anyone knows of someone who uses this fact, and what their reasons are.

    Thanks

    edit:

    Does anyone know someone who sometimes defines functions within other functions? (not for the purposes of building a framework or extending the language, such as in the case of javascript modules)

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

    How can I use Throws with multiple if/else conditions?

    Posted: 01 Mar 2018 04:40 PM PST

    My code is checking whether a person object has the correct first name Test 1, or the correct surname Test 2, if not throw exception A or B, these exceptions will be dealt by ExceptionA.class and ExceptionB.class, code further on then adds the person into a group if they pass both conditions. The problem is of course is that if the first if/else block fails my second never gets executed, is there an alternative way to approach this problem?

    Method throws Exception A, Exception B { if(Test1) { If persons firstname is correct, Test1 is true } else { throw new Exception A } if(Test2) { If persons surname is correct, Test2 is true } else { throw new Exception B } if (Test1 & Test2) { Add Person to a list } } 
    submitted by /u/dietderpsy
    [link] [comments]

    Is there such low level code that cannot have a higher level version?

    Posted: 01 Mar 2018 07:06 PM PST

    For a while operating systems were being written in assembly rather than a higher level language, and I was wondering why there was such resistance, especially because compiled languages would get translated to machine code anyway, so I'm guessing performance was not the cause. For example, the way C++ gives us direct access to memory, multiple inheritance, friend classes, etc, none of which are usually available in managed languages, are there any features of machine code/assembly that are not available in C?

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

    Building my portfolio site

    Posted: 01 Mar 2018 12:23 PM PST

    Hello!
    So I used to be a desktop programmer and I used C++ for my projects but recently I've been switching to web development because that's where the future is. I've learned vanilla JS, CSS and HTML and I'm currently learning Bootstrap, ES6 and Node.js. I'll probably learn Vue.js in the future.
    Anyways I was thinking of rebuilding my shitty weebly site and buying a decent webhost to host my portfolio site on. My question is: Should I use Bootstrap or any other CSS framework or code it from scratch? Also any general tips on building a programmer's portfolio site?

    submitted by /u/1234filip
    [link] [comments]

    Random problems with proper type inference in Kotlin?

    Posted: 01 Mar 2018 02:30 PM PST

    So I am stepping in to try to finish a piece of software on my team, I am not an Android programmer. As far as I can tell though, Kotlin seems to be having and issue where it's type inference doesn't;t recognize that an object is actually a subclass of that object. In this case we are using Parse and I am dealing with a List<Recipe> where Recipe is a ParseObject Subclass. Sometimes it works, but run it again and it decides that it cannot cast ParseObject to Recipe. Has anyone else dealt with anything like this?

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

    A few basic questions (Environment, apt-get, CSS, github).

    Posted: 01 Mar 2018 09:09 AM PST

    Hi. I am not a programmer, but I like to dabble. Some things have been bugging me for some time now. Sorry, if the questions seem dumb.

    1. Is there any way to use Sublime Text or Brackets (or anything else) like a local Codepen? That is, I would like to type in HTML/CSS/JQuery code and see results updated in real time? It would be even cooler if it worked for Python, too, whereas now I need to open up the (Mac) terminal and enter python name of script to run it every time.

    2. If you have a Linux system installed, say on a Pi, you update it using (sudo) apt-get update and then apt-get upgrade. I don't get this part, you are basically trusting some server to download and install anything on your computer (while giving root privileges to do it). What's stopping the bad guys from tweaking some updates and installing a rootkit or a miner?

    3. I like Codepen, because it's friendly to beginners like me. But when I try to experiment with CSS drawing animations, it's very tedious as I have to manually adjust, say, 5%, wait a few seconds to update, nope, too far, 9%, wait, nope, too close etc. There has to be a better way of doing it, right?

    4. I use github pages to publish the results I have from Codepen. How do real programmers work with github? There has to be a better way than manually uploading the index.html, css, scripts etc. and then every time you change something you need to 'commit', which sounds a bit serious.

    Thanks!

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

    C# sending a string from three (Separate) secondary forms into the one main form.

    Posted: 01 Mar 2018 04:27 PM PST

    Hi, I think this diagram will provide more explanation than words.

    I want the user to go through three forms, each will contain one variable inputted by the user which will be sent to the final (blue) form.

    Now how can I pass those variables? get the blue form to accept multiple variables. Or even let it save the variable in the background while the user goes through the rest of the forms. Do the variables get saved in the cache? does that happen automatically?

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

    How to extract stack traces from Bugzilla open repositories?

    Posted: 01 Mar 2018 12:17 PM PST

    I am currently on a project where I have to analyze stack traces to predict the severity of bugs. I need stack traces for that. How to I parse huge stack traces from Bugzilla repository? Or is there any other ways?? Help me.

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

    [Java][Simple] Need help with inheritance

    Posted: 01 Mar 2018 12:01 PM PST

    Basically, I have an abstract class ChildNode

    public abstract class ChildNode { public abstract boolean activate() public abstract void execute(); } 

    and a parent node

    public abstract class ParentNode extends ChildNode { public ArrayList<ChildNode> nodes; public void execute(){ for ( ChildNode node : nodes) { if (node.activate()) { node.execute(); break; } } } } 

    Then I would run this like

    ArrayList<ParentNode> masterNodeArray = null; //adds a bunch of nodes for (ParentNode node : masterNodeArray) { if (node.activate()) { node.execute(); break; } } 

    My issue is, I want parent nodes and child nodes to be able to be part of ParentNode nodes array. So when it loops through the nodes array in the execute function in the ParentNode it will handle both parents and children nodes. So if it reaches a ParentNode, it will handle it as a ParentNode, running the predefined execute function and knowing it has a nodes member to loop through, and if it reaches a ChildNode, it will run the defined execute/activate methods.

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

    [Python] Travel Heatmap

    Posted: 01 Mar 2018 02:56 PM PST

    So, I was trying to do an "travel heatmap " similar to this one, after I saw it on this reddit post, but re-adjusting to me.

    However, when I run the program, I obtain just a blank map

    For this project I used Spyder (pandas & gmplot) e this is the code that I utilized:

    import pandas as pd import json import os from pandas.io.json import json_normalize map_name = 'map' map_center_lat = 41.336924 map_center_long = -8.557212 cord_low_lat = 41.335888 cord_high_lat = 41.337403 cord_low_long = -8.569776 cord_high_long = -8.570515 google_json_path = r'C:\Users\Asus\Desktop\Takeout\Location History\Location History.json' zoom_level = 13 coordinate_resolution = 3 def plot_map(plot_df, map_name): import gmplot gmap = gmplot.GoogleMapPlotter(map_center_lat, map_center_long, zoom_level) gmap.scatter(plot_df.short_lat.tolist(), plot_df.short_long.tolist(), '#FF6666', edge_width=10) gmap.heatmap(plot_df.short_lat.tolist(), plot_df.short_long.tolist()) gmap.draw(map_name +"_map.html") def open_html_map(html_path): import webbrowser chrome_path = 'open -a /Applications/Google\ Chrome.app %s' webbrowser.get(chrome_path).open(html_path) with open(google_json_path, 'r') as f: data = json.load(f) df = json_normalize(data,'locations') df['latitudeE7'] = df['latitudeE7'].fillna(0.0).astype(float) df['longitudeE7'] = df['longitudeE7'].fillna(0.0).astype(float) df['latitude'] = df.apply(lambda x: x['latitudeE7']/10000000.0,axis = 1) df['longitude'] = df.apply(lambda x: x['longitudeE7']/10000000.0, axis = 1) del df['longitudeE7'] del df['latitudeE7'] df2 = pd.DataFrame() df2['latitude'] = df['latitude'] df2['longitude'] = df['longitude'] df2['short_lat'] = df2.apply(lambda x: ((x['latitude']).round(decimals = coordinate_resolution)), axis = 1) df2['short_long'] = df2.apply(lambda x: ((x['longitude']).round(decimals = coordinate_resolution)), axis = 1) df2 = df2.groupby(['short_lat','short_long']).agg({'latitude':'count'}).reset_index() del df2['latitude'] df2.query('short_lat > ' + str(cord_low_lat), inplace = True) df2.query('short_lat < ' + str(cord_high_lat), inplace = True) df2.query('short_long > ' + str(cord_low_long), inplace = True) df2.query('short_long < ' + str(cord_high_long), inplace = True) plot_map(df2, map_name) open_html_map(os.getcwd() + '/' + map_name +"_map.html") 
    submitted by /u/Skelozard1
    [link] [comments]

    Physical Key State - Python

    Posted: 01 Mar 2018 02:14 PM PST

    Hello,

    I am attempting to detect the physical state of a mouse button, but I cannot find a function in windows api (GetKeyState and GetAsyncKeyState do not work) that will allow me to do it. Is there any other module I can download that has this functionality?

    AHK has this functionality in their GetKeyState function, but I cannot find the equivalent for python, thoughts?

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

    When does a program or file become classed as a virus according to anti-virus processes?

    Posted: 01 Mar 2018 04:52 AM PST

    [JavaScript] Making an array that styles div's, and making an array that checks for "bad words" in an input

    Posted: 01 Mar 2018 04:20 PM PST

    Given the arrays:

    var divWidths = [ 100, 200, 300 ];

    var divHeights = [ 300, 200, 100 ];

    var divWords = [ "Going", "To do", "Great" ];

    var divColors = [ "#FF0000", "#00FF00", "#0000FF" ];

    Create an application that makes three divs and places them onto the DOM. They should be sized to those widths and heights, in pixels. The divs should contain the words in the third, words array. Each div should have a background color as specified in the final array.

    Hint(s)

    To change the width:

    dvRef.style.width= 10 + "px";

    To change the height:

    dvRef.style.height = 10 + "px";

    Make sure to add a color to the div:

    dvRef.style.backgroundColor = "#FF00FF";

    The second part of the assignment:

    Create an application that takes input from a user using a simple text input field. Split the string on the spaces, and look for bad words in the string.

    For the purposes of this exercise, bad words are: legos, cloud, and manifold.

    Whenever the user hits submit:

    1. there were any bad words found

    2. How many bad words were found in total (if the string contains "cloud legos are cloud", there has been 3 bad words in the string

    3. Clear out the input element so the users can enter new text.

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

    Programming beginner, need to "write a batch file."

    Posted: 01 Mar 2018 08:37 AM PST

    I'm in an intro college course in programming. The teacher is ... well, not great, but today (Thursday) he told us to go "download" visual basic (NOT Studio) and to look up some youtube videos, learn VB, and write a "batch file" to execute on a computer in class on Tuesday.

    Now, a quick google shows me that Visual Basic support ended 10 years ago. I've been learning basic Python in my other intro computing class, but this professor has given ZERO instruction as to how VB works. I have no idea what he wants, how to do it, or even how to get started.

    Please help???

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

    Converting MATLAB to PsychoPy (python)?

    Posted: 01 Mar 2018 07:51 AM PST

    Hi, I was wondering if there was any program or something that assists with converting a MATLAB task (specifically a stop signal paradigm) to PsychoPy (application for psychology experiments that uses Python)?

    Thanks!

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

    How to compare 3 strings using the comapreTo method without using || and &&

    Posted: 01 Mar 2018 07:50 AM PST

    For one of my projects I need to compare srt1 (abcd) , srt2 (pqrs), and srt3 (wxyz) in alphabetical order. Now the only way I can think of completing this is by using if statements with || and &&, which is not acceptable. Can anyone offer some insight?

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

    Utilizing a random number generator from a object/element class in the driver class

    Posted: 01 Mar 2018 11:36 AM PST

    I'm so confused how this works.

    In my object/element class I have:

    public void randomChannel(int randChanNum)

     int max = 99; int min = 3; Random rand = new Random(); int randomNum = rand.nextInt((max - min) + 1) + min; randomNum = randChanNum; 

    I'm trying to use this method in my driver class to generate a random number between 3 and 99 and print it. Any ideas?

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

    [C] Print out the words for any given integer

    Posted: 01 Mar 2018 05:09 AM PST

    For the range -2 billion to +2 billion. Ex: Enter an integer: 18476 = eighteen thousand four hundred seventy six

    I would not like someone to write the code for me, however, some insight into solving this problem would be greatly appreciated. Im not too sure where to get started. All I can think of is having four billion else if statements, but I know there have to be better ways.

    Thank you guys!

    EDIT: Without the use of arrays

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

    Google Rich Cards or Something Else?

    Posted: 01 Mar 2018 10:52 AM PST

    Hello all,

    I'm trying to create a more impressive link to my page on google, but I'm not sure how to go about it. I'm trying to create a link block that shows all of my pages (links to my pages).

    For example, if you google Amazon, the primary link to their page (not ads) shows a number of pages you can jump to, e.g., Your Account, Books, Amazon Aws, etc.

    I thought Google Rich Cards would do the trick, but I can't find any examples of the this type of layout - I only see layouts for Images (like recipes, movies, etc.). If it's not Rich Cards, I don't know what else it could be.

    Any help would be appreciated!

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

    Copy file from Windows CE (MTP) to Folder on C:\

    Posted: 01 Mar 2018 06:23 AM PST

    Hey guys, i am automating file transfer between a PDA running windows CE to a folder on a windows 10 PC.

    The issue I am having is the PDA not being a mounted drive therefore I cannot specify a path to copy from and to. Is there a way using powershell to get the files out of a MTP, alternatively is there a c++/python script that can get the files out, either by mounting it to a drive or any other way.

    Thanks in advance.

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

    Tic Tac Toe checking for a win (C#)

    Posted: 01 Mar 2018 06:20 AM PST

    https://pastebin.com/CaALiDCS

    I'm trying to make a tic tac toe game and the win check wont work, anyone have a more efficient way of doing this?

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

    What's the best practice for transition from dev environment to test to production, and remembering the changes that need to be made?

    Posted: 01 Mar 2018 01:59 AM PST

    I have a web development project that I'm working on. My current workflow is: develop and do rudimentary testing on my machine, deploy via git and codecommit to my AWS test environment, deploy from there to my production environment.

    The problem I am having is that there are a bunch of things that need to be different with my code when it's running on my machine and the production environment.

    For example, HTTPS has to be disabled as do secure cookies. Debugging has to be enabled as does some verbose error printing.

    Obviously none of this can ever get to production, but I don't see an easy way to make sure of that. How do I remember to reset all those things in the code before deploying to production?

    My project is written in Django, managed with git and deployed on AWS Elastic Beanstalk.

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

    is sonarqube git awreness?

    Posted: 01 Mar 2018 09:21 AM PST

    I am trying to just show bugs/code smells for the commit, instead of the entire code base

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

    How to find the largest group of unconnected members in a tree?

    Posted: 01 Mar 2018 04:53 AM PST

    I'm praticing problem solving with the problems of a competition from last year. For this one I have no idea how to even start, other than iterating through all the possibilities. But it has to work for large inputs and there is a time limit (100 ms) for the program to run, so there has to be a better way. Here is the problem if you want to read the made-up story. There is also an example input and output. I translated it the best I could. https://www.scribd.com/document/372642657/Gang I'm using python 3.6, so help in that would be even better.

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

    No comments:

    Post a Comment