• Breaking News

    Tuesday, February 18, 2020

    Losing train of thought Ask Programming

    Losing train of thought Ask Programming


    Losing train of thought

    Posted: 18 Feb 2020 01:01 PM PST

    I'm a game developer with abt 5 years of experience and a considerable coding background. On paper I'm a middle/senior Dev who abides by the patterns and principles of programming and architecture. For abt a year though I've had this persistent issue - I hit a mental brick wall when solving any task even slightly above trivial. Whenever I try to visualize an issue and take a certain amount of variables into consideration, I hit a mental brick wall. My train of thought just falls apart. It's like a thick mist, and I can only see a few feet ahead. I get there eventually through trial and error, piece by piece. Having to piece together small parts of a problem though means a lot of overhead. I'm terribly slow and ineffective, and it shows. I got fired from my last job for that exact reason. Has this happened to anyone else? Did I just go full stupid overnight? How do I get that clarity of thought back?

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

    Need some Vdos Plus assistance

    Posted: 18 Feb 2020 09:20 PM PST

    I posted in my city's sub to help me tackle this and not so much a peep.

    Been trying to figure out the Vdos Plus setup. There's not much documentation on it. Maybe I'm over thinking this.

    I have extracted the data from the hard drive. And placed it in the correct (the root of Vdos plus folder, exactly how the previous owner had it setup. And I can't get it to run correct

    Had to purchase another tower, because i found that I needed windows 7 to make it work. That cleared all the errors I was facing. But it's still not running. Now I know that I'm missing something simple. And I can't think of what.

    Any help will be great.

    Thank You for reading.

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

    Stacking two images together in Python?

    Posted: 18 Feb 2020 07:47 PM PST

    Hi, I was wondering if anyone knew of a way to stack two images together into one in python?

    I don't mean one on top of another in OpenCV windows. I mean literally taking a (256,256) and another (256,256) image and creating a (256,256,2) or (256,256,6) (if color) image.

    Like so

    Basically: I need to stack two images to pass them into a Keras neural network but the original way the user whose picture I'm using did it was through tfrecords that don't seem to work with Keras. So I need to find a new method.

    Unfortunately, it's really hard to search for this since less arcane definitions of "stacking" or "combining" predominate.

    Thank you

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

    [JS] If a lot of function parameters are bad, what should I do then if I need a lot of parameters in my function? And how do I pass top parameters into function functions without redundance and naming them the same way?

    Posted: 18 Feb 2020 07:33 AM PST

    problem:

    function makeTable(id, parentId, class, headerData, rowData, rowsDisplayed, pagination) { makeElement(id, parentId, class); makeHeader(id, headerData); makeRows(id, rowData, rowsDisplayed); function makeElement(id, parentId, class){} function makeHeader(id, headerData){} function makeRows(id, rowData, rowsDisplayed){ var new_row = makeRow(id, rowsDisplayed); fillRow(new_row, rowData); function makeRow(id, rowsDisplayed){} function fillRow(row, rowData) {} } function makePaginationOrOverflow(){ if (pagination) {} else {document.getElementById(id).style.overflow = "auto";} } } 

    As you see, we have a lot of parameters, some of which may appear in two or more sub-functions. And we also have a parameter-less container sub-function which needs to access the top function's parameter but can't.

    So,

    1. What to do when you need to just pass a parameter along into a sub-function? The names will be repetitive, and you will have to depend on scope, unless you want to name them all differently. What if you need the top parameter 3 functions deep? You will pass a useless parameter through 3 levels of functions just to bring it to its final destination?

    2. What if you want an empty function just so you can contain a piece of code, but in it you need a parameter from the top function?

    3. How to use less parameters then? (I heard people suggest putting objects as parameters, and in the objects having all the parameters you need. But isn't that only a hack fix? You are still using a billion parameters, you just don't have to write them. I guess you have 1 reference instead of 10, but I dunno. Not convinced on that one)

    4. Is making GUI and visuals in vanilla htmlcssjs genuinely hard, or do I just get frustrated too easily? Like, how is it compared to using some basic level stuff in other languages? Like, would you rather make a table with data, selectable rows and pagination in html or some other language like python or java. Example fiddle Rule is that you can't use equivalents of fancy libraries like bootstrap or jquery (inb4 everyone tells me these are not fancy, but the bearest minimum and a standard. regardless.)

    Recently, whenever I come to a part that has something to do with GUI, I'm immediately: "oof, ouch, owie, my bones hurt". Making sub-functions is hard because of scope and repetitiveness. I'm with one foot out of the door on this project and html desktop apps in general. I feel like I should switch to python, but I just love javascript because I have been coding in gamemaker (quasi-javascript synthax) for quite some time before even learning the web technologies.

    Tnx!

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

    Redirection of URLs on a VPN

    Posted: 18 Feb 2020 06:51 PM PST

    I want to make some friends connect through a vpn, and I want to make some pages redirect to other pages.

    The vpn is based on wireguard(Ubuntu 16.0.4) and I'm open to using other kinds of software since we're hosting this on Digital Ocean.

    EG

    Peter gets into youtube.com while connected, gets redirected to google.com

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

    [C] What am I doing wrong? String comparison

    Posted: 18 Feb 2020 12:38 PM PST

    An exercise from a book: Write a function that deletes each character in s1 that matches any character in the string s2.

    The code:

    #include <stdio.h> int main () { int b = 0, i = 0, a = 0; int check; #define TRUE 1 #define FALSE 0 char S1[10], S2[10], S3[10]; printf ("S1: \n"); scanf ("%9c", S1); printf ("S2: \n"); scanf ("%9c", S2); for (b = 0; (S1[b] != '\0'); b++) { while (S2[i] != '\0') { if (S1[b] != S2[i]) { check = TRUE; } else { check = FALSE; break; } i++; } i = 0; if (check == TRUE) { S3[a++] = S1[b]; } } printf ("Result: %s \n", S3); return 0; } 

    I input characters of S1 and S2, but there isn't a valid result. Just a random char. Like:

    S1: linux

    S2: unix

    Result: V&z

    submitted by /u/Same-Chemical
    [link] [comments]

    [HTML CSS JS] What is the standard procedure if you want to remove a flex element with lots of children?

    Posted: 18 Feb 2020 12:23 PM PST

    I made a little example for you:

    https://www.w3schools.com/code/tryit.asp?filename=GC280J6AJS99

    EDIT: I just realized none of my elements have actual children. Here is a link which adds an empty child to each element: https://www.w3schools.com/code/tryit.asp?filename=GC28PP7E2BCF

    So, I am creating a random number of elements which are objects themselves. I should be able to add and remove elements as I want.

    But adding is easy, and removing is not. You either get an element floating in space, or orphans. The problem arises when we want to delete an element in the middle of the set of elements.

    • Do we actually delete the element and all its children?
    • Do we hide it and re-purpose it in case we create an element later? How would we then put the element at the end of the line physically?

    Furthermore, I have no connection between the elements and the data. We remove the visual element (actually I only hide it in my example to show how it should look), but we don't delete the data. The logical way would be to connect them via indexes, but that's not enough. That's not secure. We need a proper connection where we know exactly which data belongs to which visual element, and which element belongs to each data.

    • How to connect the data and the visuals so we can easily add new data and easily loop through it?

    The object bracket notation comes to mind. Then we would just push a string with our delete function, and that string would give us the correct property of the object. But how would we loop through it then if we don't have indexes? Really hard thing to consider. For me at least. But I'm sure you already know the optimal solution.

    Please advise!

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

    Issues with C program?

    Posted: 18 Feb 2020 06:14 PM PST

    Not sure if this is the most appreciate place but a professor of mine gave us this code to run but when I attempt to run it I get "./Lab5Q1.c: line 2: syntax error near unexpected token `('./Lab5Q1.c: line 2: `int main()'" Really would appreciate if someone could help me figure out whats going on. I don't get the issue with int main()...

    #include<stdio.h>

    int main()

    {

    int a[10], *p, *q;

    p = &a[2];

    q = p +1;

    q = q + 1;

    *q = 123;

    p = q;

    printf("%d\n", *p);

    printf("%d\n", a[4]);

    }

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

    How to calculate this formula

    Posted: 18 Feb 2020 06:10 PM PST

    The formula is " The formula for the roll from the id is roll = (((id >> 8) & 0xFFFF) % 0x86A1) + (id & 0xFFFF) ". The id in my case is 410000C9.

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

    [HTML, Javascript, PHP] Targeting iframes results in opening a new tab instead

    Posted: 18 Feb 2020 06:02 PM PST

    Hi there, need some help on this.

    So I have page1.php on server1 and page2.php on server2.

    On server1, I have a main.php page that has two iframes, iframe1 and iframe2 where each points to page1.php and page2.php respectively. In page2.php, I have a function that would automatically trigger the function window.open('https://example.com', 'iframe1') whenever an event is going on.

    However, whenever the function is triggered, instead of the iframe1 being targeted, a new tab is opened instead, I have tried looking into the console logs but I cannot find anything that would explain the behaviour.

    Any help on this?

    Edit1: I am guessing this has something to do with different hostnames that results in this behaviour, will look into it more

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

    Can anyone help with workflow for programming on VPS?

    Posted: 18 Feb 2020 05:20 PM PST

    Hey all, Not sure if this post belongs here but I'm not sure where else to ask, let me know if I should go elsewhere.

    I'm using a VPS on digital ocean to do homework for my compilers class and I'm trying to find a better workflow. The crux of the issue is that we're assembling 32 bit binaries wich is no longer supported on macOS Catalina (without some work arounds that our graders/instructor would rather us not do) so working locally isn't an option for me. We're creating our compilers in Haskell using Haskell Stack. I've been using an ubuntu droplet on digital ocean but the workflow is starting to get annoying and I'm wondering if anyone here can help me find something better.

    This is what I'm currently doing:

    • I have stack installed on my Ubuntu droplet.
    • Our assignments are on GitHub Classroom, we clone the repositories and then push the assignments to GitHub for submission. I clone the repo on to my droplet (while ssh'd in)
    • I have OSX Fuse installed on my MacBook and sshfs
    • I mount the filesystem from my droplet using sshfs and then edit my code using atom installed on my MacBook.
    • I ssh in to my droplet in terminal to build and test my code and then push changes to the GitHub repo.

    The main problem I'm having is that my ssh connection drops if I'm not constantly interacting with it. I'm not sure if this is a normal ssh thing or if its because I'm using ssh and sshfs simultaneously because I've never had a problem maintaining ssh sessions before this. Also sometimes sshfs is slow and editor starts to stutter or files don't update right away.

    Is there a better way to do this? I've considered just working in vim through ssh, but I'm much more efficient in Atom. Maybe I just need to put more effort in to learning some more advanced VIM techniques. I'm open to suggestions.

    I'd also be interested in finding a way to make this more automated, like if I could just save my code and have the droplet see that things have changed and then rebuild and run the testing suite. Or if there was a way to work locally (and not deal with sshfs at all) and then push my changes to the VPS (instead of right to GitHub) and have it automatically build and run that would be cool.

    Sorry If this is too open ended, Im just really used to working locally and using a fairly simple toolset, so I don't really know how to make this better. I'm open to any suggestions (that don't cost money)

    Thanks for any input!

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

    Are there any languages that support the idea of strict, type-safe, domain-specific primitives?

    Posted: 18 Feb 2020 10:57 AM PST

    In writing code that interacts with a database, it's almost inevitable that you're going to be holding onto abstract keys (big integers or GUIDs), and a given schema may have dozens or hundreds of different domains (e.g. CustomerId, ProductId, AccountId, etc.).

    Of course, passing a CustomerId into a function that wants an AccountId is just about the worst kind of type mismatch you would ever have the misfortune to debug, yet, as far as I know, no major language supports something like:

    typedef int64_t CustomerId; // to use a C++ example 

    such that you'll get a compiler/build-time error. Sure, you can create a templated class (in C++) that would hold onto this and provide a number of utility functions that would give it the same behavior as a int (or string, or whatever you want as your underlying implementation), but it feels like a feature that is needed often enough that it should be built in.

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

    After my first 40 hour week I am absolutely exhausted and I mess up the most little things. I feel that there is some vitamin Im missing.

    Posted: 18 Feb 2020 12:38 AM PST

    I know that caffeine+theanine doesnt help anymore, it does speed me up but I still can't grasp a lot of things in my head right now like Im not of fuel. I know that after a month or so I will feel on the top of my game again but after a week I'll be exhausted again. Is there some essential vitamin for that much of a brain work? Im not sure if it's sugar or vitamin B or omega-3 or choline that Im lacking or anything else.

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

    Trying to make g-code posting allow # as a legal character.

    Posted: 18 Feb 2020 10:45 AM PST

    Total amateur in coding, but I'll try to make this fairly understandable even without knowledge of the requisite programs.

    I am a CNC programmer trying to make Autodesk Fusion 360 post processor output g-code where the length and diameter offsets are posted as H#3020 and D#3020 respectively.

    Fusion post processing works by following a configuration .txt file using (I believe) Java coding. The machine using the posted file uses the aforementioned H# and D# codes which can be edited after the program is posted, but that's annoying, so I want to make it easier. I have made edits to the configuring files before, and even the H and D posting, but using # caused the post to fail showing the following

    Error: Failed to evaluate post configuration. Code page changed to '1252 (ANSI - Latin I)' Start time: Tuesday, February 18, 2020 6:42:34 PM

    Error: SyntaxError: syntax error Error at line: 852 Failed while processing global script.

    Error: Syntax error: Unmatched } at line 877.

    I can provide further details if asked, but my primary desire is to make the post treat # as though it were a number/letter.

    please and thanks.

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

    JSON polyline points parser

    Posted: 18 Feb 2020 03:41 PM PST

    I want to parse the entire JSON file that contains many JSONObjects "steps". I need to extract all polylines and their points. However, it returns only the very first value and nothing more. Is anything wrong with my loop or I just parse the JSON file wrongly? Thx

    https://gist.github.com/Biseamon/64515eefec707a9c3cb4fcc38dec56a1

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

    [ASP.NET] Why is my session item returning null every time?

    Posted: 18 Feb 2020 09:30 AM PST

    So I'm working on a basic kind of log-in system (I'm a beginner), and I cannot, for the life of me, set a value to one of my session state items. It just doesn't want to take.

    This is what I have in the login event handler:

     SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["dbConnect"].ConnectionString); conn.Open(); string checkuser = "select count(*) from MANAGER where EMP_ID='" + txtID.Text + "' AND MANAGER_PASSWORD='" + txtPassword.Text + "'"; SqlCommand com = new SqlCommand(checkuser, conn); int temp = Convert.ToInt32(com.ExecuteScalar().ToString()); if (temp == 1) { Session["Name"] = txtID.Text; //this works Response.Redirect("Home.aspx"); Session["Admin"] = true; //this does not? } 

    Then, in separate form, I have this in my page load:

     if (!IsPostBack) { MenuItem adminTools = Menu1.FindItem("Admin Tools"); adminTools.Enabled = false; if (Session["Name"] != null) //this works { lblMessage.Text = ", " + Session["Name"].ToString(); //this works if (Session["Admin"] != null) //everything below this should be executed, but it isn't { if ((bool) Session["Admin"]) { adminTools.Enabled = true; } } } } 

    I don't know why the "Admin" session item isn't working... any help would be much appreciated.

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

    Different ids in production

    Posted: 18 Feb 2020 11:06 AM PST

    We have an app at work in which there can be created multiple roles for users to have certain permissions.

    Recently, I implemented a functionality for a new role, and to verify if the current user has that role, I check if the user has associated the id of the newly created role in the MYSQL table with roles and users. For that, I created a constant with the new role; in development environment everything worked fine, but in production, the id of the new role didn't coincide, as they already had created a different role before that took that id. How should this have been done to avoid the problem with different ids?

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

    Can tasks on your mobile device be automated with your own programming?

    Posted: 18 Feb 2020 06:15 AM PST

    Rookie programmer here,

    Wanted to know if it would be possible to create a bot that can scrape various apps or online data right on my phone.

    Thanks for any input!

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

    I'm not sure if this the right place to ask this but here I go

    Posted: 18 Feb 2020 01:26 PM PST

    So hi I'm an aspiring coder who wants to work on like high level things like operating systems and the like or even just like useful and good software but like I don't know why today I'm just feeling like what's the point I'll never be good and like it's not even creative to do this. So my question is like is programming actually creative and like are those things I want to do good fields to go into to be creative?

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

    Sorting Algorithm

    Posted: 18 Feb 2020 01:06 PM PST

    I'm trying to write a comparator function that will sort everything that is above a variable ascending and everything below the variable descending. For example if the number is 5, direction is 1 and my list is [1,2,3,4,5,6,7,8,9,10] the output should be [6,7,8,9,10,5,4,3,2,1], if the direction is -1 and number is 5 again, the list should be [4,3,2,1,5,6,7,8,9,10], does anyone have any ideas how I can achieve this ? I'm writing this in Java.

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

    How do I convert a very large base36 number into base10 using Python?

    Posted: 18 Feb 2020 12:53 AM PST

    By very large I'm talking about something like a 500 character base36 number, how can I do this in Python?

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

    how to write junit tests for payment gateways (Stripe, Paypal)

    Posted: 18 Feb 2020 07:51 AM PST

    language : java/spring

    a payment gateway requires the following things for charge creation

    Source token : generated front-end side is a json with the charge/user details

    any example code will be very handy

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

    Making Something Like Archillect

    Posted: 18 Feb 2020 11:00 AM PST

    So im very new to all of this and ive given myself the goal of eventually making something like the twitter bot archillect and i was wondering what language would be best to learn for something like that

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

    Need help understanding microservices components

    Posted: 18 Feb 2020 10:11 AM PST

    Mongo: Create a complex query with a hasMany relationship

    Posted: 18 Feb 2020 10:09 AM PST

    group: { id: '12345' } member: { id: '98765' groupId: '12345' } 

    I'm creating a query on the group collection to find all groups that contain at least one member. Is this query possible? Or, will I need to query for all groups then filter it by performing another query with find at least one member?

    filter it down with another query into the member collection

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

    No comments:

    Post a Comment