• Breaking News

    Tuesday, March 27, 2018

    Way to change user agent with Selenium in Microsoft Edge? Ask Programming

    Way to change user agent with Selenium in Microsoft Edge? Ask Programming


    Way to change user agent with Selenium in Microsoft Edge?

    Posted: 27 Mar 2018 09:08 PM PDT

    I'm trying to get the user agent to change to Microsoft Edge mobile within Edge when I open it with Selenium. The current language I'm using is Python.

    The user agent string looks like this: Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 640 XL LTE) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.10166

    However, I'm not exactly sure how to configure the syntax for handling the user agent of Microsoft Edge. I'm somewhat new to Selenium. With that said, I do have an example of what it might look like in Chrome:

    from selenium import webdriver

    from selenium.webdriver.chrome.options import Options

    opts = Options() opts.add_argument("user-agent=Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; Microsoft; Lumia 640 XL LTE) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.10166")

    driver = webdriver.Chrome(chrome_options=opts)

    This page has helped me tremendously: https://stackoverflow.com/questions/29916054/change-user-agent-for-selenium-driver

    Any and all help would be deeply appreciated. Thanks, and have a great one.

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

    Reading values from a text file in C programming

    Posted: 27 Mar 2018 03:26 PM PDT

    I have to write a program that asks the user to enter the amount he or she has budgeted for a month.

    I then have to make a loop through a file that has a list of expenses for the month. I am supposed to take the expenses from the file and keep a running total.

    When the end of file is reached the program should display the amount that the user is over or under budget.

    This is my code so far:

    include <stdio.h>

    include <stdlib.h>

    FILE*stream;

    int main(void) {

    double budget; int i = 0; printf("Enter the budget for this month: "); scanf_s("%lf", &budget); errno_t err = fopen_s(&stream, "data.txt", "r"); fscanf_s(stream, "%d", &i); while (!feof(stream)) { printf("%d", i); fscanf_s(stream, "%d", &i); } fclose(stream); system("pause"); return 0; 

    }

    I am not very comfortable with files, where am I going wrong?

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

    Putting an access database online

    Posted: 27 Mar 2018 05:02 PM PDT

    Hi. I made an access database for a research project I am doing. I would like to somehow put it online to allow people to visit a website and query it. My department has a website that I can publish web pages to designed in html but don't know much beyond that.

    I'm pretty stuck. I have done a lot of google searching and come across some programs you can buy that will do this. I have come across articles that suggest you can do this natively in access, but I seem to be missing the web template even though I have the latest version of access (did they remove it trying to push powerapps?). Somebody suggestedmaybe using PHP but I don't really know what that is or where to start. I've tried searching a lot of stuff but I don't have a background in this so I don't really even know what to be looking for.

    Any advice or tutorials somebody could give would be appreciated.

    To sum it up. I have an access database. I want to put it into an html page to allow users to query the database. How do I do this?

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

    Outputting vector<char> in C++

    Posted: 27 Mar 2018 08:47 PM PDT

    Hi r/AskProgramming! I am working on a project for school and keep hitting a wall with one section of code. The goal is to output underscores for the length of the word entered by the user. I have defined and initialized the vector using this statement:

    vector<char> letterLocations(lengthOfWord, '_'); 

    My test case has been for lengthOfWord = 5. I am attempting to output by calling the following function:

    void outputLettersGuessed(vector<char> letterLocations, int length) { for(int k = 0; k < length-1; k++) { cout << letterLocations[k] << " "; } return; } 

    The output I get is four consecutive underscores. The goal of this code is for the user to play Twisted Hangman, where the computer eliminates words containing the user guessed letter until no more words remain without that letter. I have reason to believe that my vector is storing the letters, because for a test case where the word is narrowed down to TRYST, the last T is stored in the vector. However it will not output the final T or the final underscore. Any help is appreciated and I can post more of my code if it would be useful. Thanks!

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

    Which is easier to load on mobile, bots or players?

    Posted: 27 Mar 2018 01:12 PM PDT

    Have a bit of a dispute with a friend, I said that the new battle royale game he plays is using bots, mentioning how if you exit and reopen the game the other "players" stay in the same spot. I also stated that loading in 99 other players using WiFi would be very laggy, but he claims bots would be far worse, though neither of us really knows what we're talking about. Would bots be easier, why, and would real players make the game unplayable for a mobile device even if it's worse?

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

    Windows boot & shut time measurements

    Posted: 27 Mar 2018 11:48 AM PDT

    So I received this task and I'm not sure where to start? Should I use CMD to program this or can it be done in python/java?

    Also I can't find the startup folder on windows 10.

    Boot and Shutdown Times Measurement

    Perform boot time measurement of your computer (or a computer you got access to)

    • Add a shortcut to the program 'Paint' to the windows 'Startup' folder (under Start  All Programs  Startup), in order for it to launch automatically every time your Windows OS starts.

    • Boot Time – Time passing from the moment you press the 'Power On' button until the 'Paint' program appears on screen. (In case your computer is protected by a password login, divide the time up to the login request and after the login request)

    • Shutdown time – Time passing from the moment you press the shutdown icon under the 'Start' menu until the computer completely shuts down.

    Measure 5 times of each time measurement, Boot and Shutdown times. Collect the results.

    1. Boot Time Improvement

    Suggest several ways to improve (shorten) the boot time of your computer.

    1. Implement one of the ways you suggested on your computer (Do not perform ANY hardware changes, nor irreversible software changes, i.e. do not delete any file) Measure again the boot time, measure it 5 times. Collect the results. Is it improved? If so, by how much?

    2. Remove the 'Paint' program shortcut from the Startup folder and revert all other changes you have done in order to improve the Boot Time.

    3. Write a short report (in English) and present the results in a table (or tables) and graphically.

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

    What language is the best for backwards compatibility?

    Posted: 27 Mar 2018 11:46 AM PDT

    If you wanted to build programs once and use them forever (assuming you might have to fix bugs over time) which language would you use? C? Java? etc?

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

    [C] Declaring a static struct in the Kernel syscall file.

    Posted: 27 Mar 2018 04:39 PM PDT

    Hello,

    If I have a struct set up in a header file; say, something similar to this:

    struct { int x } foo; 

    How would I go about declaring an instance of this structure at compile time? I ask this because I am creating a data structure inside the Linux kernel and manipulating it using system calls so it has to be declared at compile time in order for the syscall functions to work.

    Thank you.

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

    How to properly convert a python "game" to JavaScript?

    Posted: 27 Mar 2018 04:08 PM PDT

    Hi! The last months i have sporadically developed a project on my own when the studies have been on a manageable level. It has been a lot of fun to try GUI-development with TKinter and hack python in my own pace.

    No matter how much fun it is, there is some shortcomings that collides with my vision. One of them is a flexible way to develop UI and a better way to host it over a longer time (ie. a web-server, most probably my own raspberry pi or some other alternative).

    Therefore i think the next logical step is to convert everything into JavaScript (ES6-standard?), which sounded easy at the time. So i've spent the last few days researching, looking at source-code of other JS-games and experimenting a bit.

    The issue however is the gap to actually get some sort of feedback that i am doing something correctly, as I've yet to get something on the screen. I've tried dabbling into HTML, but i'm almost exhausted trying to wrap my head around all the different solutions.

    What exactly is needed to get some visual feedback/sensible angle of approach on this?

    To those who are curious: github (Dont mind the gui-implementation, that will hopefully be scrapped sooner than later)

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

    i need help with my character movment code

    Posted: 27 Mar 2018 02:23 PM PDT

    i have been trying to figure out what is wrong with my code and i stumped so i would like someone who is more experienced with code to help me out im trying to learn how to code i have all my gravity vsp hsp set up i dont understand the problem

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

    How to build a bot in iOS?

    Posted: 27 Mar 2018 12:01 PM PDT

    I'd like to create a bot that is capable of interacting with another app as if it was a user. I've never done iOS dev before, so I don't know what exactly I'm looking for. Should I use something like Appium? Are there other preferable frameworks for this task? It would need to be able to swipe and tap as well parse data from the views.

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

    Trying to implement the MVP (Passive view) design pattern in a WinForms application - Am I doing it right?

    Posted: 27 Mar 2018 05:20 PM PDT

    First of all, I'm really new to the MVP design pattern (Passive-View) and I've been trying to implement it in a WinForms application.

    Before I'm going any further, I'd be very happy if you guys can give me feedback on my current work.

    Solution Explorer structure

    The Form

    Model:

    public class PersonModel { public string FirstName { get; set; } public string LastName { get; set; } public string Gender { get; set; } public PersonModel(string firstName, string lastName, string gender) { FirstName = firstName; LastName = lastName; Gender = gender; } } 

    Presenter:

    public class ManagePersonPresenter { private readonly IManagePersonFormView _view; private readonly List<PersonModel> _models; public ManagePersonPresenter(IManagePersonFormView view) { _view = view; _models = new List<PersonModel>(); Initialize(); } private void Initialize() { _view.AddButtonEnabled = false; _view.InputGenderMale = true; } public void OnSaveButtonClicked() { var person = new PersonModel(_view.InputFirstName, _view.InputLastName, GetGender()); _view.AddButtonEnabled = false; _view.InputFirstName = null; _view.InputLastName = null; _models.Add(person); _view.ShowMessage("Successfully added person '" + person.FirstName + @"'."); RefreshTable(); } public void OnTextChanged() { if (_view.InputFirstName == string.Empty || _view.InputLastName == string.Empty) { _view.AddButtonEnabled = false; } else { _view.AddButtonEnabled = true; } } public void RefreshTable() { var dt = new DataTable(); dt.Columns.Add("First name"); dt.Columns.Add("Last name"); dt.Columns.Add("Gender"); foreach (var person in _models) { dt.Rows.Add(person.FirstName, person.LastName, person.Gender); } _view.DtPersons = dt; } private string GetGender() { return _view.InputGenderMale ? "Male" : "Female"; } } 

    View:

    public interface IManagePersonFormView { string InputFirstName { get; set; } string InputLastName { get; set; } bool InputGenderMale { get; set; } bool InputGenderFemale { get; set; } DataTable DtPersons { set; } bool AddButtonEnabled { get; set; } void ShowMessage(string message); } 

    Form:

    public partial class FrmManagePersons : Form, IManagePersonFormView { private readonly ManagePersonPresenter _presenter; public FrmManagePersons() { InitializeComponent(); _presenter = new ManagePersonPresenter(this); } public string InputFirstName { get => txtBoxFirstName.Text; set => txtBoxFirstName.Text = value; } public string InputLastName { get => txtBoxLastName.Text; set => txtBoxLastName.Text = value; } public bool AddButtonEnabled { get => btnSavePerson.Enabled; set => btnSavePerson.Enabled = value; } public bool InputGenderMale { get => rdBtnGenderMale.Checked; set => rdBtnGenderMale.Checked = value; } public bool InputGenderFemale { get => rdBtnGenderFemale.Checked; set => rdBtnGenderFemale.Checked = value; } public DataTable DtPersons { set => dtGridPersons.DataSource = value; } public void ShowMessage(string message) { MessageBox.Show(message, @"Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void btnSavePerson_Click(object sender, EventArgs e) { _presenter.OnSaveButtonClicked(); } private void txtBoxFirstName_TextChanged(object sender, EventArgs e) { _presenter.OnTextChanged(); } private void txtBoxLastName_TextChanged(object sender, EventArgs e) { _presenter.OnTextChanged(); } private void dtGridPersons_SelectionChanged(object sender, EventArgs e) { dtGridPersons.ClearSelection(); } private void btnRefreshTable_Click(object sender, EventArgs e) { _presenter.RefreshTable(); } } 
    submitted by /u/HelloImQ
    [link] [comments]

    Adding a Date Variable to our CRM template

    Posted: 27 Mar 2018 10:34 AM PDT

    I am not proficient in coding so please excuse my ignorance. Below is a CRM email template that we are using. Would it be possible to edit this code to make the "Wednesday or Thursday" part of the email update based on the actual date so that it outputs the next consecutive days of the week. For instance if today were Monday it would read "Is there a time Tuesday or Wednesday" that we"...

    Thanks so much, greatly appreciated.

    <p>Dear Mr X.</p>

    <p>The content of our email would be here describing our product to potential clients.</p>

    <p> </p>

    <p>Is there a time Wednesday or Thursday that we could have a brief 15-minute phone conversation?</p>

    <p>[Signature]</p>

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

    how would i go about creating a code to rip info from a game?

    Posted: 27 Mar 2018 10:25 AM PDT

    im trying to put together some data analysis for gaming league, i have the analysis part sorted but right now im doing all the data transfer by hand. would i be able to create a code to rip the info i need and fill my excel tables? here is a screen shot of the info i need to rip https://steamuserimages-a.akamaihd.net/ugc/781785533840397244/9BD047D3CF0E75278ED8E453DAE70162BA5A3CEA/

    the info i need is the unit doing the killing, what it has killed, also in the history section there is a timestamp on when the killing took place that i would also like to take across

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

    Best prep for the Amazon 2 hour online test?

    Posted: 27 Mar 2018 06:22 AM PDT

    I've only done one of these before and it was: Create a 'connect four' game in 2 hours. Then option to submit a 2nd version after 24 hours. Pick any language you want.

    I picked Objective-C and made the logic work, no UI in 2 hours, the 2nd version had working UI.

    I've worked with maybe a dozen languages and I'm rusty on many as I only do iOS dev now.

    I'm guessing it's going to be an algorithm test and I really suck at these as I haven't done those things since college, they're just not real world for the jobs I've had.

    So, I'm sure many here have had the Amazon test... what was your test and what mistakes did you make? I'm I going to be judged on the Big O(n) stuff?

    One of the reasons for asking is that I don't know if this is an iOS specific job.

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

    [General Question] - Given Facebook's recent news cycle, what are good practices that you all would like to see on new social media sites?

    Posted: 27 Mar 2018 09:57 AM PDT

    I love programming, and like everyone else has said, when you don't pay for a product, you are the product. Which led me to think about what you all thought were the best practices for revenue generation, user-data transparency, advertisement transparency, and the works when it comes to Mobile development.

    Most mobile applications cannot afford to have a payment method associated with the app, as it deters initial users, so that is mostly out.

    So that leads to using user data for advertising purposes, which seems to get people riled up when they really find out what is happening. So /r/AskProgramming, what would you like to see happen with future Social Media apps, in regard to the above?

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

    Any guide on a proper way to build a python library to access a RESTful API?

    Posted: 27 Mar 2018 07:23 AM PDT

    Can anyone recommend a simple library built to access a RESTful API I can look at? Or some guide(s)/frameworks to do this? I am trying to build a model based framework in python to access a RESTful API. I know of ways to accomplish, but I am sure there are some very clean ways of doing what I am asking.

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

    What is a 'cycle' in an array? Never heard of it before.

    Posted: 27 Mar 2018 04:35 AM PDT

    Just browsing some code Q&A and found this:

    https://www.youtube.com/watch?v=VX2oZkDJeGA

    He's checking to see if an array has a cycle.

    The example array given is: [1, 2, 1, 3, 4, 8] and he says it has a cycle.

    He then gives the example [1, 2, 3, 4, 5, 6] and that doesn't have a cycle.

    Q. what is a cycle?

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

    How do I scrape a table with no class or ID tag?

    Posted: 27 Mar 2018 07:03 AM PDT

    It lists the "Location" but I want to find the "33 Montrose Ave." for a set of tables like this one. I was using BeautifulSoup and Requests to pull the .url and parse it to HTML. If i could find the "location" text and use something like nextSibling etc. that would be great. Thank you!

    Here is the code:

    <div align="center"></font> <table border="1" cellpadding="0" cellspacing="1" width="100%" bordercolor="#c0c0c0" bordercolordark="#003399" bordercolorlight="#666666"> <tr> <td width="30%" align="left"><font face="Arial" size="2" face="Arial"><b>Location </font><font face="Arial" color="#0000FF" size="2"> 33 MONTROSE AVE</font></b></td> <td width="30%" align="center"><font face="Arial" size="2" face="Arial"><b>Property Account Number </font><font face="Arial" color="#0000FF" size="2"> 72995</font></b></td> <td width="30%" align="right"><font face="Arial" size="2" face="Arial"><b>Parcel ID </font><font face="Arial" color="#0000FF" size="2"> 40-069-0C8</font></b></td> </tr> </table>

    This is what I have:

    import requests from bs4 import BeautifulSoup

    website = requests.get("http://wakefield.patriotproperties.com/Summary.asp?AccountNumber=6867")

    content = website.content

    soup = BeautifulSoup(content, "html.parser")

    html_table = soup.findAll("table")[1] # second table. html_trs = html_table.findAll("tr") for tr in html_trs: html_tds = tr.findAll("td") for td in html_tds: html_bs = td.findAll("b") loctext = html_bs[1].text # second b loctext = loctext.lstrip() print("loctext=", loctext)

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

    Where to start with developing simple Google Spreadsheet program?

    Posted: 27 Mar 2018 07:05 AM PDT

    I'm trying to do a project where people with access to a read-only Google Spreadsheet can input text into a box and have it displayed in the spreadsheet with correct spacing and a timestamp. My only programming experience is a intro Java class, and that focused more on syntax and basic logic rather than how to use libraries and API. How would I start doing this? Look up how to use Google Apps? What I learned didn't really prepare me to make actual applications.

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

    I need help with a question related to encode of a generator matrix.

    Posted: 27 Mar 2018 03:45 AM PDT

    Its easier to post question as link because its somewhat long: https://imgur.com/a/D49nW

    my question is; I couldn't understand how to get the string that is going to be encoded, like "1001" in the example.

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

    Send sms/email when rfid is scanned

    Posted: 27 Mar 2018 12:27 AM PDT

    Each user is given a rfid tag and I want to send an e-mail or sms every time the tag is scanned. How to implement using PHP or which language would be suitable. Thanks

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

    Need help with overriding.

    Posted: 26 Mar 2018 11:34 PM PDT

    I am trying to avoid using If statements and instead, use Overriding to execute what I am trying to do.

    Let's say I have a super class called Mammal. Now let's say I create a Human child class that extends to Mammal. Now I have created a Human object called Bob. (Human Bob = new Human("fisherman") ;). Lastly, I create another Human object called Ned. (Human ned = new Human("boxer" ) ;).

    Let's say the arguments I've added simply set a string instance variable to the type of human they are. Let's say I want to call a method called Fight but I only want the method to work if the object in question is a "boxer". I don't want to make a fight method with an If statement in it. I strictly want to use overriding. I feel like this explanation wasn't clear enough but I'm hoping one of you understands what I'm trying to say.

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

    Does anyone know how to manually display a linked list in alphabetical order?

    Posted: 26 Mar 2018 11:21 PM PDT

    Hello, I have been diligently learning how to code a linked list for my grade 12 high school class. I have been asking around and have figured out how to get the add function to work. However, I am trying to print it in alphabetical order and am stuck on what to do. Any help would be appreciated and no hate, I am a beginner coder.

    public void Add(Node n) { Node current = this.head; if (current == null) { head = n; } else { Node prev = null; while (current != null) { prev = current; current = current.next; } prev.next = n; } listcount++; } 
    submitted by /u/blankbleak
    [link] [comments]

    No comments:

    Post a Comment