Quantcast
Channel: Programming Forums
Viewing all 51036 articles
Browse latest View live

i want to dump a non indexed database. :).

$
0
0
`storage.googleapis.com/someapp/*`

I don't have index access.

I have access to all files given the correct filepath. AKA storage.googleapis.com/someapp/file.jpg

now I need a way to generate filenames.jpg after storage.googleapis.com/someapp/ filenames.jpg.

and if file exist copy url to a file.

so aka I want to dump a non indexed database. :).

how do I get about making a function to generate filenames.. (I don't even understand what those names are and or have any structure to them.)

let me give you some file name examples. (57c862a6527b11e34008402f.jpg), (56d1c90d56f0f91f60ccc129.jpg)

Restart method when inside failed 'if body'

$
0
0

Hey, got a quick question that I'm sure is easy for you guys... I'm a newbie, but hey everybody gotta start one day :)

So I'm trying to write a little guessing game, basic stuff.
Now as you read from the code, the player should choose between 1 and 6, the rest is obvious. But now what if he chooses a number that is outside the given range? How can I tell the program to rerun the method in the case that this 'if' statement is true?
As it is right now, a number outside this range just results in the printing of "invalid number" and ends, but that obviously makes the rest obsolete... not ideal, pls help! thanks


public static void main(String[] args) {

        Scanner scanner= new Scanner(System.in);

        System.out.println("Welcome dear player! I guessed of a number between 1 and 6. Try to guess it!");
        System.out.print("Your guess: ");

        int randomNumber = ThreadLocalRandom.current().nextInt(1, 6);
        int playerNumb= scanner.nextInt();

        if(playerNumb<1 || playerNumb>6) {
            System.out.println("That is an invalid number my friend. Try again");
            return;
            }
        else {
            if (playerNumb < randomNumber || playerNumb > randomNumber) {
                System.out.println("Hard luck! Maybe next time.");
            }
            else {
                System.out.println("Correct! Aren't you lucky.");
            }
        }
    }

Uninstalling windows program with Python

$
0
0
 WMIC program where name="{program name}" call uninstall /nointeractive 


I know this should work and it does for other programs that I want to uninstall. The problem that I have is a particular software that can be uninstalled with above command line but it leaves traces in the registry. The ghost program can be seen in the Add or Remove Program after above command.


I have tried to run uninstaller with msexec, but it leaves the data in registry as well. Deleting the data from registry removes it from Add and remove program.

The only way that does clear uninstall for me is below command, although it prompts the graphical interface. It is as if like clicking uninstall from Add or Remove Programs.

"C:\Program Files (x86)\InstallShield Installation Information\{2ACE62F7-EA5E-42BC-A030-C3661D27AB5C}\{program executable}.exe" -runfromtemp -l0x0409  -removeonly 


1. Are there any better ways to uninstall a program with python?
2. How can I retrieve the uninstall string from registry of a particular program with python?
3. Is their a way to do this silently?

Getting SQL Conversion Error

$
0
0
I am pulling the ID of the Vendor in order to upload the path to there logo in a separate table. This is what I have.

 'Add SQL Parameters
        SQL.AddParam("@venName", TbName.Text.Trim)

        'Run Query
        SQL.RunQuery("SELECT vendorID FROM Vendors WHERE vendorID=@venName")
        For Each i As Object In SQL.DBDS.Tables(0).Rows
            VenID = i.item("vendorID")
            TbVenID.Text = VenID.ToString
        Next
    End Sub



I am getting this error: Conversion failed when converting the nvarchar value 'Test Company 4'to data type int

I feel i should point out that "Test Company 4" is held in the database as a varChar not an nvarchar.

The TbVenID text box is just there to test I will remove it when its working.

citation generator

$
0
0
I want to make a citation generator for (standard indian legal citation, relatively new citation system) my DSA project usig python. The problem is I dont know where to begin. I have searched the internet several times to no luck. Any idea about what goes behind citation generators???

chat room with animated gifts

$
0
0
i was wondering if anyone could tell me how to add animated gif file support to a basic chat room

Program design including Data Structures C++

$
0
0
hello everyone! i have a homework assignment in C++ for the problem, Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type dayType:Set the day.

Print the day.

Return the day.

Return the next day.

Return the previous day.

Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.

Add the appropriate constructors and call the methods to test the class.

Ive done everything but i have encountered multiple errors as it determines my dayNumber as undeclared identifier once it gets to implementation file and whenever i put 0 for monday it will not also display the previous day and rest of the code. Any help or guidence will be greatly appreciated. Thank you!


//main file
#include <iostream>
#include <string>
#include "Header.h"

using namespace std;

int main()
{
dayType today;
int day;
int changeDay;

cout << "------------------------------------------------------" << endl;
cout << "Default day is Sunday" << endl;
cout << "Type the number corresponding to set the day" << endl;
cout << "0 Mon (Monday)" << endl;
cout << "1 Tue (Tuesday)" << endl;
cout << "2 Wed (Wednesday)" << endl;
cout << "3 Thu (Thursday)" << endl;
cout << "4 Fri (Friday)" << endl;
cout << "5 Sat (Saturday)" << endl;
cout << "6 Sun (Sunday)" << endl;

do
{
cin >> day;
} while (day < 0 || day < 6);

today.setDay(day);
today.printDay();

cout << "------------------------------------------------------" << endl;
cout << "If it were tomorrow, then the following sensence would be true: " << endl;
today.returnNextDay();
today.printDay();
today.dayNumber--;

cout << "------------------------------------------------------" << endl;
cout << "If it were yesterday, then the following sensence would be true: " << endl;
today.returnPreviousDay();
today.printDay();
today.dayNumber++;

cout << "------------------------------------------------------" << endl;
cout << "Add a number if days to today to see what day it will be" << endl;
cin >> changeDay;

today.calculateDay(changeDay);
today.printDay();

return 0;

};

dayType::dayType()
{
dayNumber = 1;
thisDay[0] = "Mon";
thisDay[1] = "Tues";
thisDay[2] = "Wednes";
thisDay[3] = "Thurs";
thisDay[4] = "Fri";
thisDay[5] = "Satur";
thisDay[6] = "Sun";
};



// header file
#pragma once
#include <iostream>
#include <string>
using namespace std;

class dayType
{
public:
dayType();

string thisDay[7];
int tempDay;
int dayNumber;

void setDay(int thisDay);
void printDay();
void returnDay(int &thisDay);
void returnNextDay();
void returnPreviousDay();
void calculateDay(int changeDay);

};




//implement file
#include <iostream>
#include <string>
#include "Header.h"

using namespace std;


void dayType::setDay(int thisDay)
{
dayNumber = thisDay;
};

void dayType::printDay()
{
cout << "Today is: " << thisDay[dayNumber] << "day" << endl;
};

void returnDay(int &thisDay)
{
thisDay = dayNumber;
};

void dayType::returnNextDay()
{
dayNumber++;
};

void dayType::returnPreviousDay()
{
dayNumber--;
}

void dayType::calculateDay(int changeDay)
{
tempDay = (dayNumber = changeDay);
dayNumber = (tempDay % 7);
};

Python online playground

$
0
0
Hello,

I am looking for an online service that provides the opportunity for students to program some scripts for tanks /robots/cars... etc and then compete against each other. I have found various javascript options, but none with Python. I hoped someone might know anything about it.

Thank you!

JSON request error. Mollybet API

$
0
0
Hi guys,

We have been going in circles with the below errors and cant seem to get past this step.
Any help would be greatly appreciated.

This is in regards to section 4.3.1 Create a new bet placement order with API https://api.mollybet.com/docs/v1/#create-a-new-bet-placement-order.

The client used is c# Httpclient, and we are sending the parameters as JSON body.

JSON request parameters:

{
   "betslip_id":"aff87f1773774ef7b04e81992c038e8f",
   "price":"2.06",
   "stake":"[\"EUR\", 13]",
   "duration":"15",
   "accounts":"[\"ibc\", \"_99899bb2_\"]",
   "adaptive_bookies":"[ibc]",
   "ignore_system_maintenance":false,
   "no_put_offer_exchange":false,
   "bookie_min_stakes":"{}",
   "user_data":null
}


The c# code that generates the JSON :

 private void doPlace(string betSlipId,double price , double stake , string bookie, string accountName)
    {
        try
        {
            //string placebetLink = "https://pro.sportmarket.com/trade/place_order";
            //var postData = new FormUrlEncodedContent(new[]
            //{
            //    new KeyValuePair<string,string>("betslip_id",betSlipId),
            //    new KeyValuePair<string,string>("price" , price.ToString()),
            //    new KeyValuePair<string, string>("request_uuid",getRandom()),
            //    new KeyValuePair<string, string>("timeout","20"),
            //    new KeyValuePair<string,string>("stake",stake.ToString()),
            //    new KeyValuePair<string,string>("accounts",accountName),
            //    new KeyValuePair<string,string>("adaptive",bookie),
            //    new KeyValuePair<string, string>("ignore_autoplacing","false"),
            //    new KeyValuePair<string, string>("csrfmiddlewaretoken", csrToken)
            //});

            //HttpResponseMessage placeResponse = httpClient.PostAsync(placebetLink, postData).Result;
            //placeResponse.EnsureSuccessStatusCode();

            //string content = placeResponse.Content.ReadAsStringAsync().Result;
            //ApiClient.DefaultRequestHeaders.TryAddWithoutValidation("X-Requested-With", "XMLHttpRequest");
            httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
            string stakeStr = string.Format("[\"EUR\", {0}]", stake);
            string placebetUrl = string.Format("{0}v1/orders/", endPonit);
            //var postData = new FormUrlEncodedContent(new[]
            //{
            //    new KeyValuePair<string,string>("betslip_id",betSlipId),
            //    new KeyValuePair<string,string>("price" , price.ToString()),
            //    new KeyValuePair<string,string>("stake",stakeStr),
            //    new KeyValuePair<string,string>("duration","15"),
            //    new KeyValuePair<string,string>("accounts",accountName),
            //    new KeyValuePair<string,string>("adaptive_bookies",string.Format("[{0}]",bookie)),
            //    new KeyValuePair<string, string>("ignore_system_maintenance","false"),
            //    new KeyValuePair<string, string>("no_put_offer_exchange","false"),
            //    new KeyValuePair<string, string>("bookie_min_stakes","{}"),
            //    new KeyValuePair<string, string>("user_data","")

            //});

            PlaceRequest requestJson = new PlaceRequest();
            requestJson.betslip_id = betSlipId;
            requestJson.price = price.ToString();
            requestJson.stake = stakeStr;
            requestJson.accounts = accountName;
            requestJson.duration = "15";
            requestJson.adaptive_bookies = string.Format("[{0}]", bookie);
            requestJson.ignore_system_maintenance = false;
            requestJson.no_put_offer_exchange = false;
            requestJson.bookie_min_stakes = "{}";

            string jsonStr = JsonConvert.SerializeObject(requestJson);

            HttpResponseMessage placeResponse = ApiClient.PostAsync(placebetUrl, new StringContent(jsonStr, Encoding.UTF8, "application/json")).Result;
            placeResponse.EnsureSuccessStatusCode();

            string content = placeResponse.Content.ReadAsStringAsync().Result;
        }
        catch (Exception e)
        {

        }



make it so that when you change one attribute you change another

$
0
0
I'm trying to build a class composed of two subclasses. When you change the attribute of the parent class, you automatically change the attributes of two child classes. First, the example is simplified, the real world situation is more complicated. I realize some people might want me to use inheritance but I prefer nested classes to inheritance. I don't like cluttering up my namespace with attributes that I don't need and nested classes allow me to do that, so just indulge me here, ok? I know from the example below it seems like I'm creating a bunch of useless work but trust me I need two classes nested within a class because the two classes are used for different operations. So what I'm trying to do here is set it up so that when you change the `subj` you automatically change those attributes in the two nested classes. Also I used `setattr` because eventually I'm going to be looping through a list of attributes. Let me know if you think this is the best way of doing things.



class sent:
    def __init__(self):
        self.subj = "b"
        self.sent2().main(self)
        self.sent3().main(self)

    @property
    def subj(self):
        return self._subj

    @subj.setter
    def subj(self, value):
        self._subj = value
        self.sent2.subj = value
        self.sent3.subj = value

    class sent2:
        def main(self, cls):
            self.subj = cls.subj

    class sent3:
        def main(self, cls):
            self.subj = cls.subj

c = sent()
setattr(c, "subj", "e")

Angular (2) global value

$
0
0
I have an ASP.NET Core, Angular (2) application. [That is, Angular 7, not AngularJS.]

Do you have an idea, or reference(s), of how I can reference a value or service globally?

In a number of components and check if logged in and get the username. I am then using a hack, i.e. jQuery, to show the username in the navbar above the component:

  constructor(private officeService: OfficeService, private hostElement: ElementRef) { }

  ngOnInit() {
    this.officeService.LoggedIn()
      .subscribe(log => {
        if (log.loggedIn) {
          this.userName = log.userName;
          kendo.jQuery('#username').text(' ' + this.userName);

          this.getOffices();
        } else {
          kendo.jQuery('#username').text('Log in');

          window.location.href = '/Identity/Account/Login?ReturnUrl=%2Foffices';
        }
      });
  }

If I can access the loggedIn property and userName I will be able to switch 'log in' to 'log out' and show the username.

I found this link which some of which might be relevant.

What is holding me back slightly is the redirection if the user is not logged in. It looks like I might end up performing the same checking via of service (checking if logged in) for both the navbar and each other component.

how we did find x=5 at the end and what is mean x+=n tracing

$
0
0
#include<iostream>
using namespace std;
int n=2; // global variable
void function (int x){
    x+=n; // global variable
    n++;
    cout<<"x="<<x<<endl;
}
int main(){
    int a;
    a=n++; // global variable
    cout<<"a="<<a<<"n="<<n<<endl;

    function (a);
    int x,n; // global
    x=a/2;
    n=x+1;
    cout<<"x="<<x<<"n="<<n<<endl;
    cout<<"the global pf n is "<<::n<<endl;
    
    return 0;
    
}
:code:

pleas anyone can explain the tracing for this

why doesnt show my error messages

$
0
0
Why it doesnt show my error messages?
But if i use only if(isset($_POST['Submit'])){} it works with showing my error messages.. but then it uploads image but other inputs are empty and showing errors..

How to do and what to do?

My code:

if( isset($_POST['Submit'])
    && isset($_POST['name'])
    && trim($_POST['name']) != ''
    && isset($_POST['manager'])
    && trim($_POST['manager']) != ''
    && isset($_FILES['logo'])
    && $_FILES['logo']['size'] > 0
    && isset($_POST['csrf_i'])
    && isset($_SESSION['csrf_i'])
    && $_POST['csrf_i'] == $_SESSION['csrf_i'] ){
    
    $path = "../img/logo/";
    $file = $_FILES['logo']['name'];
    $handle = new Upload($_FILES['logo']);
    if ($handle->uploaded) {
    $handle->file_new_name_body = getToken(4) . date("dmY") . getToken(4) . date("Hi").getToken(7);
    $handle->file_max_size = '4194304'; //4MB
    $handle->Process($path); 
    }

    $logo = "img/logo/".$handle->file_dst_name;
    $name    = $_POST['name'];
    $manager = $_POST['manager'];

    $validator = new Validator();

    $validator->set('Team name', $name)->min_length(2)->is_required();
    $validator->set('Manager', $manager)->min_length(2)->is_required();
    $validator->set('Logo', $file)->is_selected();

    if ($validator->validate()){
        try {
            $insert_stmt=$db->prepare('INSERT INTO teams(name, logo, manager) VALUES (:name, :logo, :manager)'); //sql insert query     
            $insert_stmt->bindParam(':name',$name); 
            $insert_stmt->bindParam(':logo',$logo);
            $insert_stmt->bindParam(':manager',$manager);

            if($insert_stmt->execute()){
                echo "Team created....."; //execute query success message
                header("refresh:3;teams.php"); //refresh 3 second and redirect to teams.php page
            }
            exit;
        } catch(PDOException $e) {
            echo $e->getMessage();
        }
    }else{
        $errors = $validator->get_errors();
        foreach ($errors as $err => $error) {
            foreach ($error as $key => $value) {
                echo $value . "<br>";
            }
        }
    }
}

What causes the error: "Could not use "; file already in use&#

$
0
0
I created a simple project months ago using VS 2017. I tested it multiple times on multiple days and resolved all errors. However when my teammate put it through a stress test, he got an error saying "Could not use "; file already in use".

What normally causes it? Our database is Access only.

Java - Relative Layout Manager?

$
0
0
Hi all,

I was wondering if anyone knowns of a layout manager (Swing) that is similar to the relative layout within Android. I have tried googling about and cannot find one which is fustrating. But I know I overlook things and miss the obvious sometimes as i'm trying to find something a little too complex.

Thanks for your help in advance
Jordan

Clarke and Wright code in C++

$
0
0
Hello !!

Does anyone have the initial Clarke and Wright saving code in C++? So I can modify it based on my problem.
I am facing difficulties in building my first-time heuristic from scratch.

Thank you.

for loop

$
0
0
Hi !
can someone please explain to me exactly how the for loop work?! I mean when exactly the "i++" modified? when entering the loop or once returning from the loop it gets modified? also is it first gets modified and then check the condition of for loop or first checking the condition and then adding the "i"?

what's the difference between: "++i", "i++";

also what's the difference between those:
for(int i=0; i<10;i++);
for(int i=0;i<10,++i);
a[i]=a[i++];
a[++i]=a[i];
a[i++]=a[i];
:code:

thanks in advance and much appreciate your help!!

Errors everywhere :(

$
0
0
 private void SizeQbuttonActionPerformed(java.awt.event.ActionEvent evt) {                                            
        //Variables are initialized here
        int Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, OrderPlanetSum;
        //This requests user input from the text fields in the UI
        Mercury = Integer.parseInt(Msize.getText());
        Venus = Integer.parseInt(Vsize.getText());
        Earth = Integer.parseInt(Esize.getText());
        Mars = Integer.parseInt(MAsize.getText());
        Jupiter = Integer.parseInt(Jsize.getText());
        Saturn = Integer.parseInt(Ssize.getText());
        Uranus = Integer.parseInt(Usize.getText());
        Neptune = Integer.parseInt(Nsize.getText());
        
        //This is the correction code for what is shown to you if you get the ordering question wrong
        if (Mercury != 1) {
            OrderCorrectionTextBox.setText("Here is an abreviation that can\n help you remember the planetary order. My Very Educated Mother Just Showed Us Nine.");
            
        if (Venus != 2) {
            OrderCorrectionTextBox.setText("Here is an abreviation that can\n help you remember the planetary order. My Very Educated Mother Just Showed Us Nine.");
        
        if (Earth != 3) {
            OrderCorrectionTextBox.setText("Here is an abreviation that can\n help you remember the planetary order. My Very Educated Mother Just Showed Us Nine.");
            
        if (Mars != 4) {
            OrderCorrectionTextBox.setText("Here is an abreviation that can\n help you remember the planetary order. My Very Educated Mother Just Showed Us Nine.");
            
        if (Jupiter != 5) {
            OrderCorrectionTextBox.setText("Here is an abreviation that can\n help you remember the planetary order. My Very Educated Mother Just Showed Us Nine.");
            
        if (Saturn != 6) {
            OrderCorrectionTextBox.setText("Here is an abreviation that can\n help you remember the planetary order. My Very Educated Mother Just Showed Us Nine.");
            
        if (Uranus != 7) {
            OrderCorrectionTextBox.setText("Here is an abreviation that can\n help you remember the planetary order. My Very Educated Mother Just Showed Us Nine.");
            
        if (Neptune != 8) {
            OrderCorrectionTextBox.setText("Here is an abreviation that can\n help you remember the planetary order. My Very Educated Mother Just Showed Us Nine.");
        }
        }
        }
        }
        }
        }
        }
            
            
    }                                           

    private void Wrong3ActionPerformed(java.awt.event.ActionEvent evt) {                                       
        ClassificationAnswerTextBox.setText("You got this one right!");


Okay so I'm not sure if posting massive amounts of code like that is the right thing to do.. But I need some help. I'm trying to create a program that tests grade 9 students on astronomical objects, and as soon as I double clicked a button I wanted to put some code in on my GUI, as soon as I did it, I ended up getting errors everywhere. The program seemed to not be able to recognize the variables I have for my GUI anymore. It only seems to recognize my ints/doubles...

Auto Update application

$
0
0
I'm trying to do an auto update for my application. My auto update is for user can update it when I upgrade my application. So, i just don't know what to search for and the code that can i use to do. Anyone can help me!!!

Library for drawing pixels and keyboard/mouse events?

$
0
0
I just need to draw pixels (on console) and handle keyboard/mouse events. What library would you suggest? Needs to be cross-platform.
Viewing all 51036 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>