• Breaking News

    Thursday, May 23, 2019

    How to create a looping module that creates one window at a time per SQL row result? Ask Programming

    How to create a looping module that creates one window at a time per SQL row result? Ask Programming


    How to create a looping module that creates one window at a time per SQL row result?

    Posted: 23 May 2019 10:24 PM PDT

    I'm creating an IP Configuration program where in one part, I have to modify selected rows from my database to modify information into them.

    In order for me to do this, I have to create a window at every row, then wait for the user to finish the input before the user presses next, and a new window will pop out and the old window would be Destroyed.

    Here is the Code I have for the module:

    class moddtb(wx.Frame): def __init__(self, title, parent=None): global l_a t = len(l_a) self.n = 0 self.b = 0 while self.n<t: while True: wx.Frame.__init__(self, parent=parent, title=title, size=(1100, 500)) panel = wx.Panel(self) self.Centre(direction=wx.BOTH) self.Bind(wx.EVT_CLOSE, self.cls) print(self.n) mycursor.execute("SELECT * FROM ip_config WHERE id=%s;", (l_a[self.n],)) new_ip = mycursor.fetchone() # Really long Variable text list for data in the row... if self.n_hn is None: wx.MessageBox('An error has been made, selected row %s is empty. Skipping to next row.' % (self.n_id), 'Creation Error', wx.OK | wx.ICON_ERROR) continue f1 = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, "Arial") f2 = wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD, False, "Sergoe UI") # Different testboxes here... if self.b==1: b3a = wx.Bitmap("button3 a.png") b3b = wx.Bitmap("button3 b.png") b4a = wx.Bitmap("button4 a.png") b4b = wx.Bitmap("button4 b.png") dtbbtnc = btn.GenBitmapButton(panel, wx.ID_ANY, bitmap=b3a, pos=(700,330), style=wx.NO_BORDER|wx.BU_EXACTFIT,size=(147, 62)) dtbbtnc.SetBitmapSelected(b3b) dtbbtnc.Bind(wx.EVT_BUTTON, self.cc) dtbbtnd = btn.GenBitmapButton(panel, wx.ID_ANY, bitmap=b4a, pos=(880,330), style=wx.NO_BORDER|wx.BU_EXACTFIT,size=(147, 62)) dtbbtnd.SetBitmapSelected(b4b) dtbbtnd.Bind(wx.EVT_BUTTON, self.cls2) self.Show() else: b8a = wx.Bitmap("button8 a.png") b8b = wx.Bitmap("button8 b.png") b4a = wx.Bitmap("button4 a.png") b4b = wx.Bitmap("button4 b.png") dtbbtnc = btn.GenBitmapButton(panel, wx.ID_ANY, bitmap=b8a, pos=(880,330), style=wx.NO_BORDER|wx.BU_EXACTFIT,size=(147, 62)) dtbbtnc.SetBitmapSelected(b8b) dtbbtnc.Bind(wx.EVT_BUTTON, self.cc) dtbbtnd = btn.GenBitmapButton(panel, wx.ID_ANY, bitmap=b4a, pos=(700,330), style=wx.NO_BORDER|wx.BU_EXACTFIT,size=(147, 62)) dtbbtnd.SetBitmapSelected(b4b) dtbbtnd.Bind(wx.EVT_BUTTON, self.cls) self.Show() if t-1==self.n or t==1: self.b=1 if moddtb.IsShown(self)==False: break self.n+=1 def cls2(self, event): frame = dspdtb() self.Destroy() def cls(self, event): nf = MainPage() nf.Show() self.Destroy() def cc(self, event): cr_a = self.hntbx.GetValue() print ("Value: \"",cr_a,"\"") if cr_a != None or cr_a !="" or cr_a !=" " or cr_a !=" " : id = self.n_id ip = self.n_ip cr_b = self.roletbx.GetValue() cr_c = self.athtbx.GetValue() cr_d = self.alstbx.GetValue() cr_e = self.typtbx.GetValue() cr_f = self.envtbx.GetValue() cr_g = self.isiptbx.GetValue() cr_h = self.staiptbx.GetValue() cr_i = self.vliptbx.GetValue() cr_j = self.pubiptbx.GetValue() cr_k = self.grpiptbx.GetValue() cr_l = self.idriptbx.GetValue() cr_m = self.syssztbx.GetValue() cr_n = self.appsztbx.GetValue() cr_o = self.dtsztbx.GetValue() cr_p = self.physztbx.GetValue() cr_q = self.rdcontbx.GetValue() cr_r = self.lgmemsztbx.GetValue() cr_s = self.phymemsztbx.GetValue() cr_t = self.mdltbx.GetValue() cr_u = self.srlnumtbx.GetValue() cr_v = self.prvcputbx.GetValue() cr_w = self.ostbx.GetValue() cr_x = self.wrtytbx.GetValue() cr_y = self.eostbx.GetValue() cr_z = self.eoltbx.GetValue() mycursor.execute("UPDATE ip_config SET host_name=%s, role=%s, authorize=%s, alias=%s, type=%s, enviroment=%s, isci_ip=%s, static_ip=%s, vlan=%s, public_ip=%s, group_ip=%s, idrac_ip=%s, system_size=%s, application_size=%s, data_size=%s, physical_size=%s, raid_config=%s, logical_mem=%s, physical_mem=%s, model=%s, serial_number=%s, `processor/vcpu`=%s, os=%s, warranty=%s, end_of_support=%s, end_of_life=%s WHERE id=%s;", (cr_a, cr_b, cr_c, cr_d, cr_e, cr_f, cr_g, cr_h, cr_i, cr_j, cr_k, cr_l, cr_m, cr_n, cr_o, cr_p, cr_q, cr_r, cr_s, cr_t, cr_u, cr_v, cr_w, cr_x, cr_y, cr_z, id)) if self.b==1: LoadThread() loada = load() loada.ShowModal() wx.MessageBox('A new connection has been created, ', 'Connection Created', wx.OK) frame = MainPage() self.Destroy() else: wx.MessageBox('An error has been made, please fill out the host name before you continue...', 'Creation Error', wx.OK | wx.ICON_ERROR) frame = MainPage() self.Destroy() 

    The problem with this module however are two things:

    1. If I run this program, an infinite loop happens, which results to a never ending cycle of opened windows.
    2. Even without the weird infinite loop problem, if I fixed it with only the first loop in mind, then it'll just display all the windows at once instead of displaying them one by one. Creating confusion within the program.

    Is there a way to display the modification windows one by one per row without having to display them all at once?

    Any help is appreciated. Thanks in advance.

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

    Is there a "Documentation" system/service for general business knowledge?

    Posted: 23 May 2019 05:02 AM PDT

    Context: I'm a software engineer. We all are used to browsing api docs, searching for a keyword and getting it done.

    My fiance was recently promoted to training manager for a quickly growing startup. In the two years they've been up and running they've used Google docs and Dropbox to keep their official "docs".

    I cannot wrap my mind around that, because when they hire a 21yo social media producer you can NOT expect them to browse a folder and open up the correct document, let alone actually read it.

    TLDR is there a styleguidist/storybook/jsdoc/pydoc (etc) solution for small businesses general knowledge? Preferably where you can add a new page and wysiwyg content in?

    PreEdit: WordPress may be a fine solution.

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

    C++ How to create Randomized Attributes of Class Objects?

    Posted: 23 May 2019 04:54 PM PDT

    Hi,

    I'm trying to create a basic dungeon-crawling game in C++. I'm still relatively inexperienced with the language, so I have a question regarding one thing.

    Say I have a class called Enemy that has three attributes: string name, string profession, and int health. In my main game loop, for each turn, I want to spawn a new enemy with a randomly selected name/profession and give the enemy a random health within the range 75 - 150. How would I go about doing this? Could I implement this into a constructor somehow? Also, how can I continue to create new objects like that?

    I'm sorry I don't have any pseudo code. I don't even really know how to approach this one right now. Thank you for any help.

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

    Python prime number code

    Posted: 23 May 2019 02:31 PM PDT

    So I made a function to determine whether an integer entered into the input is prime or not, and it works perfectly except when the number "2" is entered into it, which causes the output to say it isn't prime. Here's the code (https://pastebin.com/DRBJvzAH). I'm not really sure where the problem is, checking for a remainder should work even with 2, shouldn't it?

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

    Why does the while loop does not stop?

    Posted: 23 May 2019 09:42 AM PDT

    I am a beginner programmer and am not very good at it
    i tried this code and it doesnt work

    please help why the while loop doesnt stop

    #include <iostream>

    #include <cmath>

    using namespace std;

    int main(){

    int WaterConsumption; cout << "please type in your water consumption amount u thirsty fuck." << endl; cin >> WaterConsumption; double price; double wcs; double total; if(WaterConsumption>200000){ WaterConsumption /= 1000; int extra; extra = (WaterConsumption-200)\*1.30; price = (0.22\*20)+(0.46\*20)+(0.68\*20)+(1.17\*140)+extra; //price \*= 1000; cout << "Total price : " << price << endl; wcs = (WaterConsumption - 39) \* 0.48; //wcs \*= 1000; cout << "Total Water Consumption Service : " << wcs << endl; total = price+wcs; cout << "The total is " << total << endl; cout << (total-floor(total)); cout << total-floor(total) + 0.01 << endl; 

    do

     { 

    //cout << total << endl;

    //cout << floor(total) << endl;

    //cout << total-floor(total) << endl;

    total = total + 0.01;

     }while((total-floor(total))!=0.00 && (total-floor(total))!=0.05 && (total-floor(total))!=0.10 && (total-floor(total))!=0.15 && (total-floor(total))!=0.20 &&(total-floor(total))!=0.25 && (total-floor(total))!=0.30 && (total-floor(total))!=0.35 && (total-floor(total))!=0.40 && (total-floor(total))!=0.45 &&(total-floor(total))!=0.50 && (total-floor(total))!=0.55 && (total-floor(total))!=0.60 && (total-floor(total))!=0.65 &&(total-floor(total))!=0.70 &&(total-floor(total))!=0.75 && (total-floor(total))!=0.80 && (total-floor(total))!=0.85 && (total-floor(total))!=0.90&& (total-floor(total))!=0.95); cout << "The total rounded out price is : " << total; } 

    }

    please be nice to me

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

    Random question

    Posted: 23 May 2019 04:50 PM PDT

    How do I go about making a sneaker bot? Would making a sneaker bot be under software development or programming?

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

    Should i study recursion mathematically before coding recursive questions ?

    Posted: 23 May 2019 12:58 PM PDT

    How might I begin making a touch/motion based app? More info in the description, but I don't know exactly what I'm searching for.

    Posted: 23 May 2019 12:06 PM PDT

    Essentially, what I'm making this post for is maybe some tutorials/proper terminology/articles for what I'm trying to do. I have a base knowledge of HTML/CSS and JavaScript. I also did a (teeny) tiny bit of app development/coding for iPhone apps a few years ago.

    Basically, I want to make something that is just a full-screen with say, a water pattern on it, and when you swipe across the screen, the water moves.

    In theory, this would eventually be an interactive projection, however, I just want to make something similar that I can display on my iPad for a prototype. This is an element of a college-level project I'm working on.

    Ideally, this app would also be able to have pressure points that when touched would pop up with text or a graphic over the water pattern and then disappear.

    I'm assuming this is a java thing?

    I'm a graphic designer, not a programmer, so this isn't my forte. I only know about it marginally from web design, and web design isn't something I do all the time, so please don't @ me.

    I tried googling but I don't know exactly what I'm searching for this type of thing, I just kept getting sites that help with very general or standard app creation. So, I just need guidance on what to search.

    Edit: I'm also open for this being a website and not an app.

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

    Why automation programs usually uses a host:port server to run on the machine?

    Posted: 23 May 2019 09:31 AM PDT

    When one uses appium or other automation programs often a host cmd server is running in the background to achieve the automation needs, why is it requires a host:port in the background to use it?

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

    Need help figuring out how a website is preventing Reddit from pulling the title and thumbnail

    Posted: 23 May 2019 09:24 AM PDT

    Not sure if this is the right place to post this but I need help identifying what is happening on this website: https://brainly.com/ to prevent Reddit from grabbing the title and thumbnail image. If you you go to a sub and add a link post the "suggest title" says "Attention Required!" and the thumbnail refuses to show (even on pages that have proper OG meta tags)

    Any help you can provide will be extremely appreciated!

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

    Creating a song ranking program

    Posted: 23 May 2019 08:28 AM PDT

    Hey everyone -

    Me and a friend have been a fan of creating music playlists where the songs are ranked based on 'how good they are'. We have been exploring music for a long time now and going through hundreds, maybe even thousands of songs via an excel sheet doesn't feel like the way to go anymore.

    My idea for a much handier song ranking tool would be a little program where the songs are ranked based on the bubble sort algorithm: we get the names of 2 songs on the screen, and we choose the 'best one' of the two. in this way, we go through the list a lot of times, and we eventually get a bubble-sorted ranked playlist of music.

    I'm still not that advanced to creating things like this - (though I have programming knowledge) - what would be the best way to start working on this?

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

    C# trying to create a list of nodes

    Posted: 23 May 2019 08:03 AM PDT

    I'm trying to create a list of nodes (x and y coordinates) from user input and I'm just getting a little frustrated because c# is not my usual language. I'm trying to use for loops and store the info in a node and then store the node in a list. Can anyone help me out?

    I don't need actual code, just an explanation would be appreciated.

    Thanks!

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

    [C][RNGs] ldexp( ... ,-n) vs Division by 2^n

    Posted: 23 May 2019 04:04 AM PDT

    Hey everyone.

    While studying random number generators, I stumbled upon the function ldexp, which is used to divide an integer myInt by a large power of 2:

    int myInt = returnsRandomInt(); double myDouble = ldexp( (double)myInt, -31 ); 

    I was wondering if there is any benefit in doing that. Is it reducing floating point errors compared to the following division?

    int myInt = returnsRandomInt(); double myDouble = (double)myInt / (1UL << 31); 

    The idea is to transform a uniformly distributed integer into a uniformly distributed rational in [0,1).

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

    Design Instagram: how to shard data by PhotoID?

    Posted: 23 May 2019 03:39 AM PDT

    Hi all, I'm going the through a system design article about how to design Instagram. The database design includes User and Photo tables as below:

    User
    UserID: int - PK
    Name: str
    Email: str
    Photo
    PhotoID: int - PK
    UserID: int - FK
    Path: str

    The article explains 2 approaches for sharding: - Sharding by UserID: I understand this first approach. That is we find the ShardID from UserID, then all photos uploaded by that user are also stored in that shard. - Sharding by PhotoID: The ShardID is also derived from the PhotoID, but then how is the user data stored? Let's say user X uploads 2 photos which are stored in two different shards. Will each photo object have to store all data of user X? Doesn't this mean we're having the redundancy of storing the data of user X in 2 shards?

    Hope you guys can help me with this problem, thank in advance!

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

    Could somebody explain to me the best method to solve this problem.

    Posted: 23 May 2019 06:49 AM PDT

    IN C++

    Sam, at Google, is very fond of solving problems. On a day he chooses either problem of type 1 or 2 to solve.

    If he solves a problem at day n then he doesn't solve any problems at day n+1. Every problem has a difficulty level.

    Given the number of days and the toughness of problems on each day, help Maroof to choose problems such that :

    1) sum of the level of problems is maximum

    2) no two chosen problems are on adjacent days

    3) he solves either 0 or 1 problem in a day.

    Input Format:

    First line contains n, the number of days.

    Second line contains n numbers denoting the toughness level of type 1 problems on each day.

    Third line contains n numbers denoting the toughness level of type 2 problems on each day.

    Output Format:

    Single line denoting the maximum sum of toughness level of problems.

    Sample test case

    4

    1 5 3 3

    2 2 4 4

    output - 9

    Explanation of the sample test case:

    The maximum sum of toughness level he can achieve is by solving type 1 problem at day 2 which is of level 5 and a type 2 problem at day 4 which has level 4 . So the answer is 5+4 = 9

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

    How to choose a programing language ?

    Posted: 23 May 2019 01:18 AM PDT

    Hello people, I decided that I would like to learn to program, that would be a kind of hobby in leisure time. I do not have any experience in programming, but through a little research i decided to be interested in front-end development.
    I would focus on web development and perhaps later on games or mobile applications if that is possible.
    Would be super cool if you can recommend me and give me advice on where to start, also which one on your opinion would be best to get job with time invested?

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

    Good books to learn about the basics of programming

    Posted: 22 May 2019 10:55 PM PDT

    I work in marketing but my new job has me focusing on marketing digital products. My programming colleagues talk about agile, scrum, API, Jira, and sprints. These are words that mean very little to me.

    So I want to learn more. While I don't want to do the jobs of my colleagues I want to know enough to understands the basics of what they are talking about and ask them relevant questions.

    Could you recommend books that can help me get there? Thanks.

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

    How to close file reader without calling .close()

    Posted: 23 May 2019 03:37 AM PDT

    I am practicing different tasks to keep myself up to date, and a part of one of the tasks is closing a filewriter without calling ".close()"

    I have searched online but the closest I came to an answer was .dispose(true) but that does not work with filewriter. So I am confused on what I should do. Could someone help me? Thank you to any responses.

    edit: So I actually have to close a filewriter not a filereader. Sorry typo, can't change title.

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

    What is better: Single higher res monitor VS Double lower res?

    Posted: 22 May 2019 11:25 AM PDT

    Through a series of events, I already own all these monitors and am just trying to decide on a setup.

    I'm trying to decide between a single LG 27" monitor at a higher resolution (3840 x 2160 is comfortable for me), or two 25" Dell 1440p monitors, with noticeably lower quality text sharpness and vibrancy.

    I'm a CS student so I do a lot of staring at text and reading, and I use Magnet for snapping windows.

    Should I just get rid of the better LG one and force myself to adjust to the Dells? I don't have the space for 3 monitors, and don't want to mix them, since the quality difference would be too apparent.

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

    Can someone explain this small code for me,i just started programming and i need a little bit of help.I dont understand the decimal parts and the other parts even less

    Posted: 22 May 2019 12:52 PM PDT

    Any way to get notified of changes to real estate website?

    Posted: 22 May 2019 12:34 PM PDT

    My programming skills are pretty well non-existent, I just wanted to know if anyone knew of a tool which could give me an update when data displayed on my specified search on a real estate website (http://centris.ca) changed, as in when a new property was listed.

    Problem I've noticed is the search parameters don't seem to be coded into the URL, making posting the URL into a service like http://www.watchthatpage.com/ impossible.

    Thanks!

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

    What would a normal commission be for a booking / scheduling / payment software for a shop (or a number of shops in the same market)

    Posted: 22 May 2019 12:32 PM PDT

    Not quite sure if this is the right place to ask so if it isn't just redirect me to the right place, but I've got a business idea and me and some friends are looking to develop a universal booking software for shops in a certain market.

    Now the question:

    If there was a linked local, web and mobile app that managed all the bookings for the business, the source of revenue for us would be to charge a commission for every purchase made on that software. What kind of commission would be reasonable for us but also reasonable enough that businesses would still be willing to use it and it will increase their demand more than it would their costs.

    Sorry if it's a bit vague but don't want people to steal the idea and I've never had my own business before so just doing a bit of research. If you got this far thanks for reading :)

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

    Python Pig Latin Translator

    Posted: 22 May 2019 07:02 PM PDT

    So I've created a code in Python to translate words into pig latin, and it works perfectly except when there's only one letter entered into the input, which causes it to put "way" at the end even when there's a consonant. I'm not really sure where the issue is in the code, and sometimes it even works properly, but not all the time, which is very confusing to me. Here's the code: (https://pastebin.com/9BmQdCzJ)

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

    A site like Codecademy, but with faster progression?

    Posted: 22 May 2019 06:22 PM PDT

    Is there a site for learning a new programming language, with the interactive approach like codecademy (short lessons, then interactive tasks in the code editor that checks your code), but with faster progression?

    Codecademy progresses really slow, and focuses so much on beginner basics, so it's not good for people who already know coding, but just want to learn a new language. There is too much typing for too little learning. So i'm hoping for something that assumes you're already a programmer, but just want to switch languages.

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

    Free API for cricket scores

    Posted: 22 May 2019 05:35 AM PDT

    Hi all, i am currently developing an android application regarding cricket score and fixtures, so i need your valuable feedback on Free API if available any, so that i can complete my project.

    Thanks in advance <3

    looking forward to your feedback and solutions.

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

    No comments:

    Post a Comment