javascript – Existe a possibilidade de se fazer um Bind do Form de uma janela modal bootstrap sem usar a chamada de load?

Estou usando o ajax para efetuar para fazer uma requisição e abrir uma janela modal bootstrap em seguida. O problema é que quando eu uso o ajax,faço uma requisição para minha controller, e o retorno (conteúdo da modal) eu carrego da seguinte forma:

//carregamento da modal
$('#contentModalFinanceiroParcela').html(data);

//exibição da modal
$('#modalFinanceiroParcela').modal({
    keyboard: true,
}, 'show');

Até aí, tudo perfeito. O problema é que a partir daí, não consigo fazer o bind do form para registrar o evento do submit do mesmo. Na função bindFormFinanceiroParcela, por mais que eu passe o “dialog”, o bind não funciona.

bindFormFinanceiroParcela(document.getElementById("contentModalFinanceiroParcela"));

Pesquisando nos fóruns, descobri que o processo funciona se eu carregar a modal usando o comando “load”, como abaixo, só que eu não posso fazer assim, senão ele fará uma segunda requisição para a controller, pois anteriormente, eu já usei o ajax.

//Dessa maneira funciona, mas nao posso usá-lo.
$('#contentModalFinanceiroParcela').load(url, function () {
    $('#modalFinanceiroParcela').modal({
        keyboard: true
    }, 'show');

    // Inscreve o evento submit
    bindFormFinanceiroParcela(this);

    stopLoadPage();
});

Existe a possibilidade de eu fazer o bind do form sem usar o comando “load” citado no script acima?

SCRIPT ATUAL:

//Criar o bloco da janela modal no body
if (!$("#modalFinanceiroParcela").data('bs.modal'))
    CreateModalFinanceiroParcela();

//load the modal content via ajax request
$('#contentModalFinanceiroParcela').html(data);

$('#modalFinanceiroParcela').modal({
    keyboard: true,
}, 'show');

bindFormFinanceiroParcela(document.getElementById("contentModalFinanceiroParcela"));


function bindFormFinanceiroParcela(dialog) {
    // Inscreve o formulário na janela modal com o evento submit
    $('form', dialog).submit(function (e, i) {
        if ($(this).valid() || i) {
            startLoadOneMoment();
            // Realiza una requisição ajax
            $.ajax({
                url: this.action,
                type: this.method,
                data: $(this).serialize(),
                success: function (result) {
                    // Se a requisição for satisfatória, recarrega a página atual
                    if (result.success) {
                         window.location = window.location;                       
                    } else {
                        $('#contentModalFinanceiroParcela').html(result);
                        bindFormFinanceiroParcela();
                    }
                    stopLoadOneMoment();
                }
            });
            return false;
        } else {
            return false;
        }
    });

proxy – nginx and wordpress – site2.com need to load content of of site1.com/site2 without url change

  • I have 1st domain name site1.com – self-hosted wordpress and contains posts and pages. (everything good, no issue at all)
  • I have 2nd domain name site2.com – nothing hosted (dns pointing to same server as site1.com domain)

I need to configure the nginx server in such a way that, when users access site2.com, they should get the content of site1.com/site2 wordpress page. (Then the others pages links inside that page are fine as site2.com is considered part of site1.com and users can click the load content with site1.com links)

Details

  • I have tried proxy_pass etc but didn’t worked any.
  • site2.com -> site1.com/site2 redirection is working with several techniques but I dont need that as I need site2.com landed with same url on top but site1.com/site2 content.
  • nginx version: nginx/1.14.2
  • OS – Debian GNU/Linux 10 (buster)
  • If there are other ways (non-nginx), still acceptable.

Thanks in advance.

networking – Unable to load a specific file from my home connection, although it works from anywhere else

I am currently unable to load this FontAwesome file: http://use.fontawesome.com/releases/v5.6.3/css/all.css

I figured this out after investigating why one of my professional web-based tool suddenly stopped working. It’s because they don’t provide a fallback for this file, so as a result some buttons were missing, rendering the interface unusable.

I first tried disabling all extensions and switching to other browsers, but the problem persisted.

I then tried with curl, and it fails as well:

$ curl -vvv http://use.fontawesome.com/releases/v5.6.3/css/all.css
*   Trying 23.111.9.35...
* TCP_NODELAY set
* Connected to use.fontawesome.com (23.111.9.35) port 80 (#0)
> GET /releases/v5.6.3/css/all.css HTTP/1.1
> Host: use.fontawesome.com
> User-Agent: curl/7.54.0
> Accept: */*
> 
* Recv failure: Connection reset by peer
* stopped the pause stream!
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer

At that point, I switched from my home network (ADSL) to the 4G connection from my phone, and that fixed the problem.

What could possibly be wrong? This is a very common file and I don’t see any outcry online so I assume the problem is on my side, or on the side of my internet provider, rather than with FontAwesome hosting.

My colleagues can load this file without issue. I tried from a separate computer from my home network and the problem is the same.

Where to go from there?

networking – Reverse Load Balancer: Out Balancer?

Load balancing in is a common topic, but there isn’t as much said about load balancing out. I may have an application that can prepare 1mm requests/s but is unable to send them all out at that speed because of network restraints.

Is there a concept of an out-balancer? Are there any ready-made solutions out there that can take, say, a csv of 1mm requests and distribute them across nodes and send them?

enter image description here

The “Out Balancer Coordinator” could just be a queue. But that’s getting into DIY territory where I’m wondering if something like this already exists.

email server – lsyncd causes huge write load on destination

It seemed a nice idea to use lsyncd to maintain a replica of the mailboxes on my mail server. It works nicely. Unfortunately, the result has been a level of writes on the server holding the replica almost 100 times the total write load on the mail server itself. This is a problem, as it may well cause premature failure of the SSD at the destination.

Is there any way to improve the behaviour of lsyncd in this respect? Or is there a better solution for this application?

python – PyOpenGL – How load obj file that has color defined in the mtl file

I have two files, drone2.obj and drone2.mtl. I believe the .mtl file uses RGB color codes for the color instead of using .jpg/.png textures. Here’s what drone2.obj looks like when I load it with 3D Builder and PyOpenGL:
enter image description here

I’ve read several tutorials( Youtube channels sentdex, atibyte, The Cherno). I also tried the website learnopengl.com, opengl-tutorial.org, and codeloop.com. I’ve also used Udemy. None of these specifically show how to load a model that uses RGB colors defined in the .mtl file. I’m not sure what keywords to use in order to find a tutorial on how to load these .mtl RGB values for the .obj file in OpenGL.

Can someone please help me properly load the .obj/.mtl colors in PyOpenGL? Here is my code and the .mtl values:

import glfw
from OpenGL.GL import *
from OpenGL.GL.shaders import compileProgram, compileShader
import pyrr
from ObjLoader import ObjLoader


vertex_src = "http://stackoverflow.com/""
# version 330

layout(location = 0) in vec3 a_position;
layout(location = 1) in vec2 a_texture;
layout(location = 2) in vec3 a_normal;

uniform mat4 model;
uniform mat4 projection;
uniform mat4 view;

out vec2 v_texture;

void main()
{
    gl_Position = projection * view * model * vec4(a_position, 1.0);
    v_texture = a_texture;
}
"http://stackoverflow.com/""

fragment_src = "http://stackoverflow.com/""
# version 330

in vec2 v_texture;

out vec4 out_color;

uniform sampler2D s_texture;

void main()
{
    out_color = texture(s_texture, v_texture);
}
"http://stackoverflow.com/""


# glfw callback functions
def window_resize(window, width, height):
    glViewport(0, 0, width, height)
    projection = pyrr.matrix44.create_perspective_projection_matrix(45, width / height, 0.1, 100)
    glUniformMatrix4fv(proj_loc, 1, GL_FALSE, projection)


# initializing glfw library
if not glfw.init():
    raise Exception("glfw can not be initialized!")

# creating the window
window = glfw.create_window(640, 480, "My OpenGL window", None, None)

# check if window was created
if not window:
    glfw.terminate()
    raise Exception("glfw window can not be created!")

# set window's position
glfw.set_window_pos(window, 400, 200)

# set the callback function for window resize
glfw.set_window_size_callback(window, window_resize)

# make the context current
glfw.make_context_current(window)

# load here the 3d meshes

drone_indices, drone_buffer = ObjLoader.load_model("drone2.obj")

shaderObj = compileProgram(compileShader(vertex_src, GL_VERTEX_SHADER), compileShader(fragment_src, GL_FRAGMENT_SHADER))

# VAO and VBO
VAO = glGenVertexArrays(2)
VBO = glGenBuffers(2)

# VAO
glBindVertexArray(VAO(0))
# Vertex Buffer Object
glBindBuffer(GL_ARRAY_BUFFER, VBO(0))
glBufferData(GL_ARRAY_BUFFER, drone_buffer.nbytes, drone_buffer, GL_STATIC_DRAW)
# vertices
glEnableVertexAttribArray(0)
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, drone_buffer.itemsize * 8, ctypes.c_void_p(0))
# textures
glEnableVertexAttribArray(1)
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, drone_buffer.itemsize * 8, ctypes.c_void_p(12))
# normals
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, drone_buffer.itemsize * 8, ctypes.c_void_p(20))
glEnableVertexAttribArray(2)

glUseProgram(shaderObj)
glClearColor(0, 0.1, 0.1, 1)
glEnable(GL_DEPTH_TEST)
glEnable(GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

projection = pyrr.matrix44.create_perspective_projection_matrix(45, 640 / 480, 0.1, 100)
#drone_pos = pyrr.matrix44.create_from_translation(pyrr.Vector3((0, -5, -10)))
drone_pos = pyrr.matrix44.create_from_translation(pyrr.Vector3((0, 0, 0)))

# eye, target, up
view = pyrr.matrix44.create_look_at(pyrr.Vector3((0, 0, 8)), pyrr.Vector3((0, 0, 0)), pyrr.Vector3((0, 1, 0)))

model_loc = glGetUniformLocation(shaderObj, "model")
proj_loc = glGetUniformLocation(shaderObj, "projection")
view_loc = glGetUniformLocation(shaderObj, "view")

glUniformMatrix4fv(proj_loc, 1, GL_FALSE, projection)
glUniformMatrix4fv(view_loc, 1, GL_FALSE, view)

# the main application loop
while not glfw.window_should_close(window):
    glfw.poll_events()

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

    rot_y = pyrr.Matrix44.from_y_rotation(0.8 * glfw.get_time())
    model = pyrr.matrix44.multiply(rot_y, drone_pos)

    # draw the drone character
    glBindVertexArray(VAO(0))
    glUniformMatrix4fv(model_loc, 1, GL_FALSE, model)
    glDrawArrays(GL_TRIANGLES, 0, len(drone_indices))

    glfw.swap_buffers(window)

# terminate glfw, free up allocated resources
glfw.terminate()

Here are the .mtl values:

# Blender MTL File: 'drone2.blend'
# Material Count: 6

newmtl drakgray
Ns 225.000000
Ka 0.800000 0.800000 0.800000
Kd 0.067358 0.067358 0.067358
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 3

newmtl flare
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl gray
Ns 56.250000
Ka 0.200000 0.200000 0.200000
Kd 0.229457 0.229457 0.229457
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 3

newmtl red
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.287604 0.005644 0.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2

newmtl silver
Ns 506.250000
Ka 1.000000 1.000000 1.000000
Kd 0.815288 0.815288 0.815288
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 3

newmtl white
Ns 81.000006
Ka 0.500000 0.500000 0.500000
Kd 0.668079 0.668079 0.668079
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 3

This is what the beginning of drone2.obj looks like:

# Blender v2.82 (sub 7) OBJ File: 'drone2.blend'
# www.blender.org
mtllib drone2.mtl
o Cylinder
v 0.848355 0.230875 -0.375419
v 0.921437 0.252606 -0.360946
<...>

How can I know the progress when importing data into MySQL using LOAD DATA INFILE?

I have a 1 billion record stored in csv file. I’m using LOAD DATA INFILE to import the record to the table.

create table weibo_bind
(
    column1 bigint
        primary key,
    column2 bigint
);

And my csv file is column1,column2.

LOAD DATA INFILE '/path/to/demo.csv' IGNORE INTO TABLE weibo_bind FIELDS TERMINATED BY ',' LINES TERMINATED BY 'n' IGNORE 1 ROWS;

But how can I debug or how can I check the progress of importing? Because it takes a lot of time to import.

Or is there any way to speed up?

I’m using

mysql Ver 8.0.22, Innodb

javascript – Load text data using Flask db

I would like to know the most elegant way to store text data (song names and song lyrics) in an SQLite database that I use in my Flask application.

What I am thinking is to make song_name the primary key, song_lyrics a VARCHAR(5000) column, and song_explanations which I would like to be an array of VARCHARs but I think I have to just put it in as a comma-separated string.

The end goal is to be able to 1) click a button on my web page 2) load appropriate data and have it highlighted like on Genius.com 3) when user clicks on highlighted lyric, an explanation pops up
Thus, I feel like I need to store the lyrics in a clever way in order to 1) have the lyrics break instead of just one long string 2) know which lines to highlight

Any thoughts?

gui design – Which button is better when you want to load results from a filter?

I am redesigning an application and, one of our tasks is to redesign the UI and clarify/connect UI with the action intended.
I noticed we are using different buttons for the same target action which is basically:

1 – Get results on a screen by submitting a button (after you choose which filters you want on).

Which option would be more user friendly and why and what are the advantages and main differences in-between these buttons?

Nowadays, on the web age, people got used to the same function applied to software and web applications. Would simply “Search” be the best option?

Search

update

go

reload

apply

Load Results