iis – AWS Lightsail Load Balancer and Too Many Redirects

I have spent several hours trying to figure out why once I put my instance containing my website behind a load balancer, I keep getting the “Too Many Redirects” error. I have a Windows Server instance behind my load balancer with an SSL certificate on my load balancer. Originally, I had an SSL certificate on my instance because we weren’t sure about load balancing yet, and was handling the http -> https redirects on my server with url rewrite. However, now I am getting this error. I have disabled the rewrite rules on my server and yet I’m still getting all my responses with a 307 status. Any help is much appreciated, as I’m almost out of hair to pull out. Also please let me know if you need more information, I just wasn’t sure what else to include in the question.

usability – What is better: to have a modal open instantly and then load its contents, or to load its contents and then open it?

The first option… but with more feedback.

You should have the modal appear immediately. This is important so that the user knows that their action has been successful (i.e. you don’t want them to keep clicking because they think nothing is happening).

However, having a blank modal is not good. Because the user will be confused as to why it is empty (even if this is a brief duration). What you should do is initially show some sort of loading/progress indicator. This is important so that the user knows the application is still working and to expect the results shortly (once they have loaded).

As the GET request is (usually) quite short, you don’t want to make this loading indicator too “in your face”. However, it should be clear enough that it is also suitable for those rare occasions where that GET request takes longer than expected.


Additional note, it might be worth making the loading indicator static if it’s only going to be visible for a short time.

Perhaps even just a simple bit of text: “Loading…” or “Fetching data…”.

Have a play around and see what works best with your test data.

A company hosting over 37,000 websites. High speed load times, Buy Today 40% Discounts – SEO Help (General Chat)

Best, Reliable, Affordable, Cheap Hosting Platform. Business Hosting with 99.99% uptime, Unlimited Disk, Bandwidth, Domains, Reseller Hosting, Reliable and 

>>>>www.domainracer.com<<<<

domainracer051-728.jpg

web hosting meaning web hosting india types of web hosting free web hosting cheap web hosting web hosting services.

.

python – Load data from SQLite table, modify them and save in to new SQLite table

My goal was to create a script that would:

  1. Pull certain data from an existing SQLite table
  2. Apply a simple mathematical formula
  3. Save the new values to another SQLite table

I’m just starting to learn Python (programming in general) and to be honest a lot of that is unclear to me. But using the internet and a lot of existing examples, I created something, and that something does its job, but I want to know what I did well and what I did not so well so that I can correct it and learn for the future.

import sqlite3 as sql
from sqlite3 import Error

def create_connection(db_file):
    """create a database connection to the SQLite database""" 
    database_connection = None
       
    try:
        database_connection = sql.connect(db_file)
        return database_connection 
    except Error as e:
        print(e) 
    return database_connection

def get_data(database_connection, get_data_sql):
    """get data from sqlite table"""
    try:
        c = database_connection.cursor()
        c.execute(get_data_sql)
        return c.fetchall()
    except Error as e:
        print(e)

def true_odds_calculation_3way(home_odds, draw_odds, away_odds):
    """use margin weights proportional to the odds method 
    to calculate true odds in games  with 3 possible outcomes"""
    margin = (1/home_odds)+(1/draw_odds)+(1/away_odds)-1
    home_true = ((3*home_odds)/(3-(home_odds*margin)))
    draw_true = ((3*draw_odds)/(3-(draw_odds*margin)))
    away_true = ((3*away_odds)/(3-(away_odds*margin)))
    
    # limiting floats to 3 decimal points
    margin_3way = float("{:.3f}".format(margin))
    home_true_3way = float("{:.3f}".format(home_true))
    draw_true_3way = float("{:.3f}".format(draw_true))
    away_true_true_3way = float("{:.3f}".format(away_true))
    
    true_odds_3way = (home_true_3way, draw_true_3way, away_true_true_3way)
    
    return true_odds_3way, margin_3way

def true_odds_calculation_2way(over_odds, under_odds):
    """use margin weights proportional to the odds method 
    to calculate true odds in games  with 2 possible outcomes"""
    margin_ou = ((1/over_odds)+(1/under_odds)-1)
    over_true = ((2*over_odds)/(2-(over_odds*margin_ou)))
    under_true = ((2*under_odds)/(2-(under_odds*margin_ou)))
    
    # limiting floats to 3 decimal points
    margin_2way = float("{:.3f}".format(margin_ou))
    over_true_2way = float("{:.3f}".format(over_true))
    under_true_2way = float("{:.3f}".format(under_true))

    true_odds_2way = (over_true_2way, under_true_2way)
    
    return true_odds_2way, margin_2way

def add_data(database_connection, add_data_sql, data):
    """add new calculated data to another sqlite table"""
    try:
        c_2 = database_connection.cursor()
        c_2.execute(add_data_sql, data)
        database_connection.commit()
    except Error as e:
        print(e)
   
def main():
    
    database = 'Test.db'
    # get data from existig table
    sql_get_pinnacle_odds = """SELECT Pinnacle_Home_Closing, Pinnacle_Draw_Closing, Pinnacle_Away_Closing,
                            Pinnacle_Home_Opening, Pinnacle_Draw_Opening, Pinnacle_Away_Opening,
                            Pinnacle_Over_Closing, Pinnacle_Under_Closing, Pinnacle_Over_Opening, Pinnacle_Under_Opening FROM Model;"""
    # add data in another table
    sql_add_data = """ INSERT INTO True_Odds VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"""
    
    # create a database connection
    database_connection = create_connection(database) 
    
    # get data
    if database_connection is not None:     
        # get data from table
        pinnacle_closing_lines = get_data(database_connection, sql_get_pinnacle_odds)
        for i in pinnacle_closing_lines:
            
            true_pinnacle_closing_odds ="True Closing Odds" # Just for better orientation
            true_closing_odds, margin1 = true_odds_calculation_3way(i(0), i(1), i(2))
            true_1x2_closing = (true_pinnacle_closing_odds) + true_closing_odds + (margin1)
            
            true_pinnacle_opening_odds ="True Opening Odds" # Just for better orientation
            true_opening_odds, margin2 = true_odds_calculation_3way(i(3), i(4), i(5))
            true_1x2_opening = (true_pinnacle_opening_odds) + true_opening_odds + (margin2)
            
            true_pinnacle_ou_closing_odds ="True Closing OU Odds" # Just for better orientation
            true_closing_ou_odds, margin3 = true_odds_calculation_2way(i(6), i(7))
            true_ou_closing = (true_pinnacle_ou_closing_odds) + true_closing_ou_odds + (margin3)
            
            true_pinnacle_ou_opening_odds ="True Opening OU Odds" # Just for better orientation
            true_opening_ou_odds, margin4 = true_odds_calculation_2way(i(8), i(9))
            true_ou_opening = (true_pinnacle_ou_opening_odds) + true_opening_ou_odds + (margin4)
             
            true_pinnacle = true_1x2_closing + true_1x2_opening + true_ou_closing + true_ou_opening
            
            # save data from table
            add_data(database_connection, sql_add_data, true_pinnacle)
    else:
        print("Error!")
  
if __name__ == '__main__':
    main()

First I wanted to create a script that would automatically add new columns to the existing SQLite table and populate them with the calculated values. But I failed.

Since I am still collecting data in a SQLite table from which this script will pull them and calculate new values, after I finish, I will assign a unique value to that table and insert it via the script into a new table where I will record the results and eventually merge these two tables into one. So I will be sure that everything will be in order.

oracle – Application connection pooling load balancing the transactions on 18c RAC

Application connecting a 2 node 18c RAC.
JVMs are using connection pool and transactions are routed to the nodes via the connections in the pool. So the initial load across the nodes are distributed by SCAN listener. But the question is how does the existing connections in the pool distributes the next slot of transactions evenly across the 2 nodes, so that they are equally balanced.

Python and sqlite – Load data from sqlite table, modify them and save in to new sqlite table

My goal was to create a script that would:

  1. Pull certain data from an existing sqlite table
  2. Apply a simple mathematical formula
  3. Save the new values to another sqlite table

I’m just starting to learn python (programming in general), and to be honest a lot of that is unclear to me. But using the internet and a lot of existing examples, I created something, and that something does its job, but … I want to know what I did well and what I did not so well, so that I can correct it and learn for the future.

This is my code:

import sqlite3 as sql
from sqlite3 import Error

def create_connection(db_file):
    """create a database connection to the SQLite database""" 
    database_connection = None
       
    try:
        database_connection = sql.connect(db_file)
        return database_connection 
    except Error as e:
        print(e) 
    return database_connection

def get_data(database_connection, get_data_sql):
    """get data from sqlite table"""
    try:
        c = database_connection.cursor()
        c.execute(get_data_sql)
        return c.fetchall()
    except Error as e:
        print(e)

def true_odds_calculation_3way(home_odds, draw_odds, away_odds):
    """use margin weights proportional to the odds method 
    to calculate true odds in games  with 3 possible outcomes"""
    margin = (1/home_odds)+(1/draw_odds)+(1/away_odds)-1
    home_true = ((3*home_odds)/(3-(home_odds*margin)))
    draw_true = ((3*draw_odds)/(3-(draw_odds*margin)))
    away_true = ((3*away_odds)/(3-(away_odds*margin)))
    
    # limiting floats to 3 decimal points
    margin_3way = float("{:.3f}".format(margin))
    home_true_3way = float("{:.3f}".format(home_true))
    draw_true_3way = float("{:.3f}".format(draw_true))
    away_true_true_3way = float("{:.3f}".format(away_true))
    
    true_odds_3way = (home_true_3way, draw_true_3way, away_true_true_3way)
    
    return true_odds_3way, margin_3way

def true_odds_calculation_2way(over_odds, under_odds):
    """use margin weights proportional to the odds method 
    to calculate true odds in games  with 2 possible outcomes"""
    margin_ou = ((1/over_odds)+(1/under_odds)-1)
    over_true = ((2*over_odds)/(2-(over_odds*margin_ou)))
    under_true = ((2*under_odds)/(2-(under_odds*margin_ou)))
    
    # limiting floats to 3 decimal points
    margin_2way = float("{:.3f}".format(margin_ou))
    over_true_2way = float("{:.3f}".format(over_true))
    under_true_2way = float("{:.3f}".format(under_true))

    true_odds_2way = (over_true_2way, under_true_2way)
    
    return true_odds_2way, margin_2way

def add_data(database_connection, add_data_sql, data):
    """add new calculated data to another sqlite table"""
    try:
        c_2 = database_connection.cursor()
        c_2.execute(add_data_sql, data)
        database_connection.commit()
    except Error as e:
        print(e)
   
def main():
    
    database = 'Test.db'
    # get data from existig table
    sql_get_pinnacle_odds = """SELECT Pinnacle_Home_Closing, Pinnacle_Draw_Closing, Pinnacle_Away_Closing,
                            Pinnacle_Home_Opening, Pinnacle_Draw_Opening, Pinnacle_Away_Opening,
                            Pinnacle_Over_Closing, Pinnacle_Under_Closing, Pinnacle_Over_Opening, Pinnacle_Under_Opening FROM Model;"""
    # add data in another table
    sql_add_data = """ INSERT INTO True_Odds VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"""
    
    # create a database connection
    database_connection = create_connection(database) 
    
    # get data
    if database_connection is not None:     
        # get data from table
        pinnacle_closing_lines = get_data(database_connection, sql_get_pinnacle_odds)
        for i in pinnacle_closing_lines:
            
            true_pinnacle_closing_odds ="True Closing Odds" # Just for better orientation
            true_closing_odds, margin1 = true_odds_calculation_3way(i(0), i(1), i(2))
            true_1x2_closing = (true_pinnacle_closing_odds) + true_closing_odds + (margin1)
            
            true_pinnacle_opening_odds ="True Opening Odds" # Just for better orientation
            true_opening_odds, margin2 = true_odds_calculation_3way(i(3), i(4), i(5))
            true_1x2_opening = (true_pinnacle_opening_odds) + true_opening_odds + (margin2)
            
            true_pinnacle_ou_closing_odds ="True Closing OU Odds" # Just for better orientation
            true_closing_ou_odds, margin3 = true_odds_calculation_2way(i(6), i(7))
            true_ou_closing = (true_pinnacle_ou_closing_odds) + true_closing_ou_odds + (margin3)
            
            true_pinnacle_ou_opening_odds ="True Opening OU Odds" # Just for better orientation
            true_opening_ou_odds, margin4 = true_odds_calculation_2way(i(8), i(9))
            true_ou_opening = (true_pinnacle_ou_opening_odds) + true_opening_ou_odds + (margin4)
             
            true_pinnacle = true_1x2_closing + true_1x2_opening + true_ou_closing + true_ou_opening
            
            # save data from table
            add_data(database_connection, sql_add_data, true_pinnacle)
    else:
        print("Error!")

        
if __name__ == '__main__':
    main()

First I wanted to create a script that would automatically add new columns to the existing sqlite table and populate them with the calculated values. But I failed.
Since I am still collecting data in a sqlite table from which this script will pull them and calculate new values, after I finish, I will assign a unique value to that table and insert it via the script into a new table where I will record the results and eventually merge these two tables into one.
So I will be sure that everything will be in order.

php – How to load the page first then download the file with content-disposition?

Let me start by explaining what I want to achieve first. I have a download page where the user enters a URL with params example.com/join/123/456, where 123 is userId and 456 roomId it then connects with the API to fetch some data and append it to the file name.
Ideally, I want the page to load first and then download the file. I know I should reverse the process by loading the page and then to make the AJAX call to php but I am lost here.

This is my PHP script, I have used dummy api here which is not even used for the name change as I got this part covered. So the API will return a string which will be used to change the file’s name.

if ( is_page( 'xxx' ) && get_query_var('userId') && get_query_var('roomId')) {    
    $request = wp_remote_get( 'https://jsonplaceholder.typicode.com/todos/1' );
if( is_wp_error( $request ) ) {return false;}
    
$body = wp_remote_retrieve_body( $request );
$data = json_decode( $body );
if( !empty( $data ) ) {
$file_url = 'file-url';
$file = get_query_var('userId'); //gets the param from URL 
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary"); 
header('Content-Disposition: attachment; filename="'. ($file) .'.exe"');
readfile($file_url);}

I have tried calling this script through AJAX call but I am not quite sure what I am doing with it. I also thought of fetching the string from API through AJAX and then pass it over to the php function.

I would really appreciate your help on how to resolve this issue.
Thank you

haproxy – Too many redirects NSX Load Balancer (HA Proxy) Application rule

We are trying to do a redirect from / to /access/signin however with the following application rule we see too many redirects (looping) for HTTPS, HTTP is working fine.

acl TEST-RDR hdr_dom(Host) -i www.test.com
acl TEST-RDR path_beg /access/signin
http-request redirect location https://www.test.com code 301 if TEST-RDR

Any advice or pointers would be really helpful, I am new to Application rules and trying to convert an F5 iRule (below)

when HTTP_REQUEST {
set host_info (string tolower (HTTP::host))
set uri_info (string tolower (HTTP::uri))
switch -glob $host_info {
“www.test.com” {
switch -glob $uri_info {
“/access/signin*” {
HTTP::respond 301 Location “https://www.test.com”
}
“/” {
HTTP::respond 301 Location “https://(HTTP::host)(HTTP::uri)”
}
}
}
.test.com” {
switch -glob $uri_info {
“/access/signin*” {
HTTP::redirect “https://(HTTP::host)(HTTP::uri)”
}
}
}
}
}

performance – Clustered Index during data load in MS SQL Server

Until today, I was under impression that it’s been considered as a best practice to disable the indexes in sql tables during the data load. And with the fact that one cannot disable the clustered indexes in MS Sql server, you would have to delete that and then perform the data load operation. But today, I performed the data load operation of around 30M records with 10-15 columns of different column types and I was surprised to see the result where keeping the clustered index out performs the load compared to dropping the clustered index, loading data and then creating the clustered index.

In my test, the data which was being inserted was presorted in the source table and that might be one reason for the difference, but I just want to understand is it still considered as a best practice to drop the clustered index prior to data load and recreate it after or keeping the clustered index is the optimal way?