Can I split a gravity forms postcode field by the space so just the first half of the postcode is entered automatically into a text field

reaching out on this one. I’m using gravityforms address field and need a simple text field to display just the first half of the postcode.

Example

Postcode Field: E14 4RD Text Field: E14

No idea where to start I’ve Googled and asked on gravityforms forum but no luck.

Any pointers would be great

Is it possible to populate field with array in Sequelize?

I am new to Sequalize. Tried to figure this out but cant wrap my head around how it works. So I need to JOIN three tables based on two others

I have my models defined by sequelize-auto. Here is my init-models file

var DataTypes = require("sequelize").DataTypes; var _lesson_students = require("./lesson_students"); var _lesson_teachers = require("./lesson_teachers"); var _lessons = require("./lessons"); var _students = require("./students"); var _teachers = require("./teachers");  function initModels(sequelize) {   var lesson_students = _lesson_students(sequelize, DataTypes);   var lesson_teachers = _lesson_teachers(sequelize, DataTypes);   var lessons = _lessons(sequelize, DataTypes);   var students = _students(sequelize, DataTypes);   var teachers = _teachers(sequelize, DataTypes);    lesson_students.belongsTo(lessons, { as: "lesson", foreignKey: "lesson_id"});   lessons.hasMany(lesson_students, { as: "lesson_students", foreignKey: "lesson_id"});   lesson_teachers.belongsTo(lessons, { as: "lesson", foreignKey: "lesson_id"});   lessons.hasMany(lesson_teachers, { as: "lesson_teachers", foreignKey: "lesson_id"});   lesson_students.belongsTo(students, { as: "student", foreignKey: "student_id"});   students.hasMany(lesson_students, { as: "lesson_students", foreignKey: "student_id"});   lesson_teachers.belongsTo(teachers, { as: "teacher", foreignKey: "teacher_id"});   teachers.hasMany(lesson_teachers, { as: "lesson_teachers", foreignKey: "teacher_id"});   // removing unused ids   lesson_students.removeAttribute('id')   lesson_teachers.removeAttribute('id')         return {     lesson_students,     lesson_teachers,     lessons,     students,     teachers,   }; } module.exports = initModels; module.exports.initModels = initModels; module.exports.default = initModels; 

Result eventually should be an object with populated fields. It should look like something like this

{    id : 9    date: ‘2019-09-01’     title: ‘Orange’,    status: 1    students: [ // populated array of students       { id: 1,          name: ‘John’          visit: true,    }],    teachers: [ // populated array of teachers       { id: 1,          name: ‘Alice’       }] } 

At the moment i figured out how to get this result

{     id: 10,     date: '2019-06-24',     title: 'Brown Color',     status: 0,     lesson_teachers: [ [lesson_teachers] ],     lesson_students: [ [lesson_students] ]   } 

by following code

resultLessons = await models.lessons.findAll({     include: [{       model: models.lesson_teachers, as: 'lesson_teachers',     }, {       model: models.lesson_students, as: 'lesson_students'      }],   })   const lessons = resultLessons.map((lesson) => (lesson.dataValues))   console.log(lessons) 

So question is how do I populate [lesson_teachers] and [lesson_students] with actual data? (like method .populate in mongoose)

Thanks a lot in advance

How do I calculate Field of View and camera position from 2 images?

I am trying to re-construct the camera logic of RE4 that is applied when the player aims a gun.

I have attached a hack to RE4 which enables the user to change the camera’s FOV. Because of that I already know that the FOV for aiming with a gun is 50. The FOV during normal gameplay is 75.

I have then taken 2 screenshots:

  • Screenshot #1 shows normal / idle gameplay
  • Screenshot #2 shows aiming gun gameplay

These are the 2 screenshots. The red frame indicates the area that is still visible when the player aims. As one can see, the left side is heavily cropped while the right side is not cropped at all. This makes me wonder what the logic is here.

I have tried to replicate this behaviour, but I don’t manage to make my scene look exactely like that.

I would therefore like to ask if there is perhaps a mathematical approach that I can use to calculate the camera position offset that is being applied when the player aims his gun.

Thank you!

enter image description here

enter image description here

How to get Relationship Field dual-column showing IDs instead of post titles in ACF plugin?

by default, in the ACF plugin, the relationship field allows the user to choose a relation with another post in the default dual column view. In my case, I am using the Relationship field in order to connect dealer post-types to products.

Since I am importing Product data from CSV, I would need to import Relationship fields as well, and I am doing this using WP All Import Pro plugin. If I try to export a product in order to create the proper CSV format, I can see all set up relationships using the Dealer post-type title. I would need to type in CSV the dealers IDs instead of their full title, because the titles could change at some point.

Is that something possible through a function? Also, apart from dealers IDs, is it possible to achieve using another IDs set up using ACF (that is to say, another ID which is not the default one assigned by WP)?

For now, I am using Post Object return format, I’ve tried with Post ID return format but does not work (I am not sure if this could work since I am trying to do something out of my knowledge…).

Thank you in advance, nflor

Steam plotting of vector field showing empty output

I am trying to plot the stream lines for a vector field function, whose definition is exported to the wdx file uploaded here. The following simple code returns an empty plot:

ReadyFieldXY =  Import["C:\ReadyFieldXY.wdx"]; a0 = 0.00055; StreamPlot[Abs[ReadyFieldXY], {x, -a0/2, a0/2}, {y, -a0/2, a0/2}] 

enter image description here

I am not sure what is wrong here. Any suggestions would be appreciated.

Stroring field name instead of referencing using objectId

This is my first question here

For example: I have a post document which contains list of people who like it and my question is Should i store each person in the array using objectId or username(it’s also a unique identifier) the reason i ask is that when we view a likes of a particular post i want to show only their username and profile pic in this case I think storing username will be much faster than query each objectId and fetch their username, but after all i still need to fetch their profile pic using either one of them.

Guide me if i’m wrong or misunderstood sth.

you can send me if you have any blogs related to this.

how to display image in custom post type from frontend form using advanced custom field?

here is my code: employeedetails.php

<div class="container submit-message">     <h1>Employee Form</h1>     <form id="enquiry_email_form" action="#" method="POST" data-url="<?php echo admin_url('admin-ajax.php'); ?>" enctype="multipart/form-data">     <div class="form-group">             <label for="">Enter Title</label>             <input type="text" class="form-control" name="title" id="title"/>         </div>         <div class="form-group">             <label for="">Enter Description</label>             <input type="text" class="form-control" name="description" id="description"/>         </div>         <div class="form-group">             <label for="">Enter Your Name</label>             <input type="text" class="form-control" name="post_name" id="post_name"/>         </div>         <div class="form-group">             <label for="">Enter Your Designation</label>             <input type="text" name="post_designation" id="post_designation" class="form-control"/>         </div>         <div class="form-group">             <label for="">Salary</label>             <input type="text" class="form-control" name="post_salary" id="post_salary"/>         </div>         <div class="form-group">             <label for="">Enter Joining Date</label>             <input type="date" class="form-control" name="post_date" value="<?php echo date('Y-m-d'); ?>" id="post_date"/>         </div>            <div class="form-group">             <label for="">Select Image</label>             <input type="file" id="post_img" name="post_img" src="<?php bloginfo('template_url'); ?>" value="" accept="image/*""/>         </div>         <div class="form-group">             <button type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-pencil"></i> Submit</button>         </div>     </form> </div> 

$ (document).ready(function() { $ (“#enquiry_email_form”).on(“submit”,function(event){ event.preventDefault(); /* Clear result div $ (“#data”).html(”); */ var form= $ (this); var ajaxurl = form.data(“”); // var image = $ (‘#post_img’).prop(‘files’)[0]; var post_title = form.find(“#title”).val(); var post_description = form.find(“#description”).val(); var post_name = form.find(“#post_name”).val(); var post_designation = form.find(“#post_designation”).val(); var post_salary = form.find(“#post_salary”).val(); var post_date = form.find(“#post_date”).val(); var post_img = form.find(“#post_img”).val(); /*console.log(post_title); console.log(post_description); console.log(post_name); console.log(post_designation); console.log(post_salary); console.log(post_date); console.log(post_img);*/ /*if(detail_info.post_title === “” || detail_info.post_description === “” || detail_info.post_designation === “” || detail_info.post_salary === “” || detail_info.post_date === “” || detail_info.post_img === “”) { alert(“Fields cannot be blank”); return; }*/ $ (“.btn btn-primary”).text(‘submitting…’); $ .ajax({ url: “/wp-admin/admin-ajax.php”, type: ‘POST’, data: { action: ‘save_post_details_form_employee’, // this is going to be used inside wordpress functions.php post_title : post_title, post_description : post_description, post_name : post_name, post_designation : post_designation, post_salary : post_salary, post_date : post_date, post_img : post_img }, success: function(data) { //alert(“Insert Success”); //console.log(data); // Show successfully for submit message $ (“.submit-message”).html(‘Thank you for submitting’); } }); }); });

How to add additional field

If a user want to add. For example I have 3 fields (Brother Name, Marital Status, Occupation) . There should be a button + or – , when click the same 3 fields (Brother Name, Marital Status, Occupation) should be added below the 1st. Im creating form in forminator, Any other option in forminator or other plugin option plz suggestion. Thanks

enter image description here

One-row postgres query as CTE/subquery much slower when passing subquery field into function / maybe related to inlining?

I’m using postgres 13.3 with inner and outer queries that both only produce a single row (just some stats about row counts).

I can’t figure out why Query2 below is so much slower than Query1 (they should basically be almost exactly the same, maybe a few ms difference at most)…

Query1: This query takes 49 seconds:

WITH t1 AS (         SELECT             (SELECT COUNT(*) FROM racing.all_computable_xformula_bday_combos) AS all_count,             (SELECT COUNT(*) FROM racing.xday_todo_all) AS todo_count,             (SELECT COUNT(*) FROM racing.xday) AS xday_row_count         OFFSET 0 -- this is to prevent inlining )  SELECT             t1.all_count,             t1.all_count-t1.todo_count AS done_count,             t1.todo_count,             t1.xday_row_count FROM t1 

Query2: This query takes 4 minutes and 30 seconds (only one line difference):

WITH t1 AS (         SELECT             (SELECT COUNT(*) FROM racing.all_computable_xformula_bday_combos) AS all_count,             (SELECT COUNT(*) FROM racing.xday_todo_all) AS todo_count,             (SELECT COUNT(*) FROM racing.xday) AS xday_row_count         OFFSET 0 -- this is to prevent inlining )  SELECT             t1.all_count,             t1.all_count-t1.todo_count AS done_count,             t1.todo_count,             t1.xday_row_count,             -- the line below is the only difference to Query1:             util.divide_ints_and_get_percentage_string(todo_count, all_count) AS todo_percentage FROM t1 
  • Before this point, and with some extra columns in the outer the query (which should have made almost zero difference), the whole query was insanely slow, like 25 minutes, which I think was due to inlining maybe? Hence the OFFSET 0 being added into both queries (which does help a lot).
  • I’ve also been swapping between using the above CTEs vs subqueries, but with the OFFSET 0 included it doesn’t seem to make any difference.

Here’s the definitions of the functions being called in Query2:

CREATE OR REPLACE FUNCTION util.ratio_to_percentage_string(FLOAT, INTEGER) RETURNS TEXT AS $  $   BEGIN     RETURN ROUND($  1::NUMERIC * 100, $  2)::TEXT || '%'; END; $  $   LANGUAGE plpgsql IMMUTABLE;   CREATE OR REPLACE FUNCTION util.divide_ints_and_get_percentage_string(BIGINT, BIGINT) RETURNS TEXT AS $  $   BEGIN          RETURN CASE          WHEN $  2 > 0 THEN util.ratio_to_percentage_string($  1::FLOAT / $  2::FLOAT, 2)         ELSE 'divide_by_zero'          END         ;  END; $  $   LANGUAGE plpgsql IMMUTABLE; 
  • As you can see it’s a very simple function, which is only being called once, from the single row the whole thing produces… how can this cause such a massive slowdown? And why is it affecting whether postgres inlines the initial subquery/WITH (or whatever else might be going on here)

EXPLAIN ANALYZE outputs:

  • Query1: https://explain.depesz.com/s/bq7u
  • Query2: https://explain.depesz.com/s/9w3rY

php mysql create an entry into a field. (INSERT INTO) WHILE logged in currentuser/session

I did the php registration system and it works https://www.tutorialrepublic.com/php-tutorial/php-mysql-login-system.php

but i created extra fields in the DB so the user can add some data to the database.

All search results are only to add to database from scratch, not from CURRENT SESSION USER. or they are just how to make php user reg systems but no further PHP CURRENT SESSION user interaction with DB

DB structure is just like on that site, i posted above, but created a URL field so a user can save their favorite URL. DB = **users > username > URL ** once i get that working im going to figure out how a user can append to the field and keep adding URLs

i came up with this.. .

if (isset($  _SESSION['loggedin']) && $  _SESSION['loggedin'] == true) { echo "<a href="file.php?save=yes>Add to Favorites</a>";}   if(isset($  _GET['save'])){          echo "got a save";      userID = $  _SESSION["username"];      echo $  userID; //it does give the current username, meaning im logged in , session-start is on the header .        $  URL = $  _GET['URLforbookmark'];      $  sql = "INSERT INTO users (URL, UserID)      VALUES ('$  URL', '$  UserID')";            if (mysqli_query($  sql)) {         echo "New record created successfully !";      } else {         echo "Error: " . $  sql . " " . mysqli_error($  sql);      }      mysqli_close($  sql); } 

Feedback Error reads: Error: INSERT INTO users (test, UserID) VALUES (‘theusersfavorurl’, ”)

thank you !