• Breaking News

    Friday, February 9, 2018

    Can someone explain the difference between Apache and Nginx, with respect to their architecture? Ask Programming

    Can someone explain the difference between Apache and Nginx, with respect to their architecture? Ask Programming


    Can someone explain the difference between Apache and Nginx, with respect to their architecture?

    Posted: 09 Feb 2018 08:48 AM PST

    Not getting intended output in JAVA parking ticket simulator

    Posted: 09 Feb 2018 09:35 PM PST

    public class ParkingTicketSimulator { public static void main(String[] args) { // Create a ParkedCar object. // The car was parked for 125 minutes. ParkedCar car = new ParkedCar("Volkswagen", "1972", "Red", "147RHZM", 125); // Create a ParkingMeter object. 60 minutes were purchased. ParkingMeter meter = new ParkingMeter(60); // Create a PoliceOfficer object. PoliceOfficer officer = new PoliceOfficer("Joe Friday", "4788"); // Let the officer patrol. ParkingTicket ticket = officer.patrol(car, meter); // Did the officer issue a ticket? if (ticket != null) System.out.println(ticket); else System.out.println("No crimes committed!"); } }

    public class ParkedCar {

    private String make, model, color, licenseNo; public int parkTime; public ParkedCar(String carMake, String carModel, String carColor, String carLicenseNo, int carParkTime) { make = carMake; model = carModel; color = carColor; licenseNo = carLicenseNo; parkTime = carParkTime; } public String carMake() { return make; } public String carmodel() { return model; } public String carColor() { return color; } public String carLicenseNo() { return licenseNo; } public int carParkTime() { return parkTime; } 

    }

    public class ParkingMeter { private int timePurchased;

    public ParkingMeter(int parkTimePurchased) { timePurchased = parkTimePurchased; } public int time() { return timePurchased; } 

    }

    public class ParkingTicket { private ParkedCar car; private PoliceOfficer police; private final double initialTicket = 25.0, additionalTicket = 10.0; private int parkedOver; private double fineAmount = 0.0;

    public ParkingTicket(ParkedCar cars, int overTime, PoliceOfficer officer) { car = cars; parkedOver = overTime; police = officer; } public double parkingFine() { if (parkedOver >= 60) { fineAmount += initialTicket; parkedOver -= 60; } while (parkedOver > 0) { if (parkedOver >= 60) { fineAmount += additionalTicket; parkedOver -= 60; } else { fineAmount += additionalTicket; parkedOver -= parkedOver; } } return fineAmount; } public String make() { return car.carMake(); } public String model() { return car.carmodel(); } public String color() { return car.carColor(); } public String license() { return car.carLicenseNo(); } public String officerName() { return police.officerName(); } public String officeBadge() { return police.officerNo(); } 

    }

    public class PoliceOfficer {

    private String name, badgeNo; public PoliceOfficer(String officerName, String officerNo) { name = officerName; badgeNo = officerNo; } public String officerName() { return name; } public String officerNo() { return badgeNo; } public ParkingTicket patrol(ParkedCar car, ParkingMeter meter) { int overTime = car.carParkTime() - meter.time(); ParkingTicket ticket = null; if (car.carParkTime() > meter.time()) { ticket = new ParkingTicket(car, overTime, this); } return ticket; } 

    }

    It outputs "ParkingTicket@6d06d69c" compiler does not show any errors

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

    Suggest Language/Framework for class project

    Posted: 09 Feb 2018 12:30 PM PST

    I need to create a mini project for my DBMS class. The only requirement being that i have to use SQL queries. Im confused on what language to use for the application.

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

    Planning Object-oriented designs

    Posted: 09 Feb 2018 12:10 PM PST

    I've been doing programming of some kind for a few years now (mostly just working on my own, though I recently got a related job), and I feel like I've never really gotten the hang of using objects to their full potential.

    My question: what process do you go through to design your classes? How do you go from "I need to make a thing that does X" to "I will have four classes, A will inherit from B... etc"?

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

    (C#) How to set path for filewatcher when directory changes name

    Posted: 09 Feb 2018 02:04 PM PST

    What can I do so I don't have to manually change the directory name (currently 0.1.304) in fileWatcher.Path every time it changes due to software updates?

    fileWatcher.Path = @"C:\ABC\DEF\0.1.304"; fileWatcher.NotifyFilter = NotifyFilters.LastWrite; fileWatcher.Filter = "Note.txt"; 
    submitted by /u/hodg21
    [link] [comments]

    C++ Multiple Variables used for one equation

    Posted: 09 Feb 2018 01:47 PM PST

    Hello,

    I am trying to figure out how I can use multiple variables I have previously initialized in the same equation.

    For exmaple:

    a1 = 5;

    a2 = 6;

    a3 = 7;

    a4 = 8;

    a1+a2=x;

    a3+a4=y;

    I would like to combine the two to make one equation and just have the variables alternated out instead of having to rewrite the same equation over and over with the required variables.

    Thank you!

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

    MATLAB nested loop issue

    Posted: 09 Feb 2018 01:30 PM PST

    I am given the following problem:

    "The Wind Chill Factor (WCF) measures how cold it feels with a given air temperature T (in degrees Fahrenheit) and wind speed V (in miles per hour). One formula for WCF is WCF = 35.7 + 0.6T – 35.7(V0.16) + 0.43T(V0.16). Write a function called wcf to receive the temperature and wind speed as input arguments, and return the WCF. Using loops, print a table showing wind chill factors for temperatures ranging from -20 to 55 in steps of 5, and wind speeds ranging from 0 to 55 in steps of 5. Call the function to calculate each wind chill factor."

    From my understanding, the problem is asking for a WCF for every combination of temperature (from -20 to 55 degrees) and wind speed (from 0 to 55).

    This is my code, which does not seem to work according to nest loop procedure:

    clear clc %Calculates wind chill factor given values of temperature and wind %speed and prints a table of these factors m=zeros; for temp = -20:5:55 for wind_speed = 0:5:55 wind_chill=wcf(temp,wind_speed); m(1,temp/5+5) = temp; m(2,temp/5+5) = wind_speed; m(3,temp/5+5) = wind_chill; end end x = table(m(1,:)',m(2,:)',m(3,:)'); x.Properties.VariableNames = {'Temp','Wind_Speed','Wind_Chill'}; disp(x) 

    (END OF CODE)

    Now, please correct me if I am wrong, but the way my code is set up, it should first make temp = -20, then proceed to make wind_speed = 0, and calculate wcf and call it wind_chill. Then, it puts -20 in the first row, first (which is variable and changes for each iteration) column of matrix m. Then, it puts 0 in the second row, first column of matrix m. Then, it puts the value of wcf in the third row, first column of matrix m. Now, it should still keep the temp as -20 but now make wind_speed equal to 5, and go through all the stuff after that, and continue this loop up to wind_speed = 55. Once these calculations have been made, it should make temp = -15 and eventually create a giant table of values.

    Obviously, I must be doing something wrong. For the life of me, I can't figure it out.

    Here is the output that I am currently getting with this code:

    Temp WindSpeed Wind_Chill ___ __________ __________

    -20 55 -60.413 -15 55 -53.331 -10 55 -46.248 -5 55 -39.166 0 55 -32.084 5 55 -25.002 10 55 -17.919 15 55 -10.837 20 55 -3.755 25 55 3.3273 30 55 10.409 35 55 17.492 40 55 24.574 45 55 31.656 50 55 38.738 55 55 45.821 

    Not only do I not understand why it won't iterate through all the wind speeds, but why is it displaying only 55? If anything wouldn't it display only 0? Why would it be skipping straight to the end? I'm dumbfounded, so I would really appreciate some help! Thanks!

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

    (C#) When using AJAX/WebMethods, is it bad practice if you have a lot of processing in the backend but MUST use static variables?

    Posted: 09 Feb 2018 10:41 AM PST

    Reason being, when using WebMethods, the method must be static, and so every time a variable is used, it must be static as well. I got something to work, but somehow I can't help but think it is not done using best practices. I need AJAX to make an async call to the codebehind and this seems to be the only way to do it.

    Thoughts? Thanks in advance.

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

    Show / Hide forms using Dropdown Selection (PLanguage PHP)

    Posted: 09 Feb 2018 06:05 AM PST

    how can i show or hide a respective form based on my dropdown selection. My dropdown is currently bind to my database "tblusertype" which shows "Administrator , Student , Teacher and Outsider as an option. I haven't tried anything to make it work. thanks in advance. below is my code in my dropdown

    <select class="form-control show-tick" name="dpusertype" data-live-search="true">

    <option selected="selected"></option>

    <?php

    while ($row = mysqli_fetch_assoc($result)) { echo '<option value="' . $row['usertype_name'] . '">' . $row['usertype_name'] . '</option>'; }

    ?> </select>

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

    How do I turn this code to add an extra dropdown menu?

    Posted: 09 Feb 2018 09:46 AM PST

    If I wanted to make news a drop down also how would I change it? many thanks! https://www.w3schools.com/css/tryit.asp?filename=trycss_dropdown_navbar

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

    Is there a lib to write a custom DVD movie player?

    Posted: 09 Feb 2018 09:29 AM PST

    I need to write a DVD movie player with custom subtitle rendering. I figured to hook into existing video player like VLC or mplayer classic. However all those projects are very large and complex nowadays and I wonder if there is a simple alternative where I can write my own player using existing libraries.

    Alternatively it would also be enough to write a tool that simply extracts subtitles from a DVD Movie.

    Any recommendations? I am mostly using C++ but I am open for alternatives.

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

    Is this a hashtag? e038b970-63d8-4779-9797-45e8a87520ac

    Posted: 09 Feb 2018 07:57 AM PST

    I'm trying to decifer what this code stands for. I'm in a queue to be served and wondering how far back in the line I am. I think this code indicates what number in line I am.

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

    Does hackerrank display my test results to the public based on my email? Can I practice indefinitely without revealing every attempt? Their FAQ is unclear.

    Posted: 09 Feb 2018 01:57 AM PST

    Hi, apologies if this is not the right sub (alternative suggestions welcome.)

    I'm going to perform a hackerrank test for a particular potential job. Before I click "go", I want to try it on my own and practice practice practice.

    Now-- either my practice results are entirely my own business, and I can choose when and what to display based on my own judgement...

    Or, I need to worry about registering at hackerrank as some alternative email address(es) that I don't share with potential employers., so that I can take tests with abandon / push myself without worrying about publishing low scores.

    Note: I would naturally presume the former, but that means that (outside controlled tests like this one for a particular employer) one's score is not a good reflection of native ability but could reflect the statistical spikes expected from trying a thousand times.

    Thanks for tips.

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

    Multi-location assignment

    Posted: 09 Feb 2018 04:25 AM PST

    I'm not sure if I have worded the title correctly, so please bear with me while I explain and I apologize for confusions.

    I'm playing around with an idea and part of that is to create a post submission (the site is a social network) where the visibility of this post is defined by the poster - where the poster can select region/state/city..

    I'm thinking of this from both a UI perspective and a database layout.

    UI:
    Check boxes to select the region (Northeast, Midwest etc), States and down to cities, with the fairly intuitive selection of checked being true/yes. Checking a parent node automatically checks descendants (I think of this as a tree).
    A user can of course choose a region and uncheck a specific city.

    DB:
    This is where it gets interesting.
    Organizing individual cites, states and regions and joining them is a simple matter, but how can we organize the posting selections? There is certainly the naive/simplistic manner of listing each city/state/region, but is there a more organize manner of doing this?

    Meaning, rather than have a table with a post_id and other ancillary foreign key references, one row for each city/state/region (probably, just the cities and take care of their grouping at the UI side, though that would not make for a clean segregation of duties between back and front ends).

    If it matters, the database I am using is Postgres 10.

    Has someone experienced something like this?

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

    Arduino: Need help with code for motor driver / linear actuator

    Posted: 09 Feb 2018 12:52 AM PST

    Please help! We're not sure why but the actuator keeps stuttering. Any suggestions or resources are welcome.

    (skip to 25sec for stuttering) video of problem: https://streamable.com/ri5fv

    code:

    void setup() { // put your setup code here, to run once:

    Serial.begin(9600); pinMode(2, INPUT);

    }

    void loop() { // put your main code here, to run repeatedly:

    analogWrite(2, analogSignal(2.3));

    // float idle = analogSignal(2.5); // float maxExtendVoltage = analogSignal(0.0); // float maxRetractVoltage = analogSignal(5.0); // // // For extending // analogWrite(A0,idle); // delay(4000); //4 second delay // // for (float i = idle; i>= maxRetractVoltage; i--){ // // analogWrite(A0,analogSignal(i)); //
    // } //
    // analogWrite(A0,idle); // delay(4000); //
    //
    // // For retracting // for (float i = analogSignal(idle); i<= maxExtendVoltage; i++){ // // analogWrite(A0,analogSignal(i)); //
    // }

    }

    int analogSignal(float voltage) {

    int analogSignal = (voltage*1023.0)/(5.0); return analogSignal;

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

    Good folder structure for a "large" project?

    Posted: 09 Feb 2018 12:22 AM PST

    Hello

    I'm currently working on an interpreter, and I already have 5K+ lines of code, and I'll end up with a lot, lot more when it's finished (probably close to 15/20k for the fully working mvp).

    This is my current folder structure: https://github.com/Pierre-vh/Moonshot/tree/beta

    /Moonshot/ : Solution directory /Moonshot/src/ : All the source code, .h and .cpp /Moonshot/src/Fox : Front-end (parser,lexer,ast,etc) /Moonshot/src/Common : Common utilities that might be used by Front end and back end /Moonshot/src/Common/External : External libraries /Moonshot/src/Badger : Back-end (IR,IR optimizations & evaluation (will be done later) /Moonshot/src/Tests : "Unit" tests. C++ classes that call precise functions in the interpreter to test if they're working corretly without throwing errors /Moonshot/misc/ : miscellaneous files, personal notes and thoughts on the project in general /Moonshot/res/tests/ : Tests files used by tests /Moonshot/doc/ : Documentations and utilities files : Grammar,guidelines,file header. (There's a file in there todo-stdlib that i'll move to misc when I get home) 

    Currently I plan to move the External folder to the /Moonshot/ folder and maybe rename it to "3rdparty" (is it an appropriate name?), I'll also rename my .h to .hpp.

    Some people also suggested me to separate my .hpp/.cpp file in /header/ and /src/ folder, however, this is the core logic of the interpreter and not meant to be a public API (I'll build an api later when the interpreter is complete), so I think the folder structure should be :

    /Moonshot/src/ : Interpreter source code (.hpp and .cpp mixed, my current folder -> I don't change anything) /Moonshot/lib/ : Library (API/Interpreter driver) source code (.cpp) /Moonshot/header/ : Library (API/Interpreter driver) header files (.hpp) 

    Is this a correct structure? Is there anything I should take care of?

    Also, should I use something like Doxygen and add comments above every function of every hpp to have a more "standard" documentation? (With a automatically generated Website to navigate it as a nice Doxygen bonus)

    This is my first large project, and I'm very young (just turned 18) and inexperienced so I'm probably making a lot of mistakes, but I'd like to learn from them and make my project easy to read and use for contributors/potential users. Even if my project ends up going nowhere, I'd still learn a lot from sticking to coding standards.

    Thanks a lot!

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

    [Android] [Kotlin] AlertDialog setButtonPositive() : problem with onClickListener

    Posted: 08 Feb 2018 11:08 PM PST

    Hello there !

    I'm trying to contribute to an open-source project. There is an action that is done without asking user if he is sure so I'd like to create an AlertDialog to ask and then proceed if user said "Yes".

    What I made so far :

    AlertDialog.Builder(activity) .setTitle("Delete everything.") .setMessage("This action cannot be undone.") .setPositiveButton("Yes", DialogInterface.OnClickListener() { @Override fun onClick() { // Delete everything } } ) .setNegativeButton("No", null) .show() 

    My problems :

    Redundant SAM-constructor : What is a SAM-constructor ? Why does it happen ?

    I tried to move my Listener in a variable with something like this :

    val deleteOnClickListener = DialogInterface.OnClickListener() { // delete everything } 

    But then I don't know, and this is my second problem, what I'm supposed to put in place of DialogInterface and Int. I looked at the documentation so I know what it is but I can't figure out what it is in my case.

    I'm thanksful to everyone who is willing to help me !

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

    Any good intermediate tutorials for angular.js?

    Posted: 08 Feb 2018 10:41 PM PST

    Everything I find is super beginner level, so I'm wondering if anybody knows of any good online resources for angular that assume some familiarity with programming in general and js. Or good books, too. I'm just trying to bone up before I start my new job a week from Monday. Thanks!

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

    No comments:

    Post a Comment