Categories
CMS Drupal Mastering Development

Create and display field dynamically in Ajax

I’ve created a field dynamically based on a checkbox title I just clicked before, here the code : $form[‘myfield’][‘widget’][‘#ajax’] = [ ‘callback’ => ‘myCallback’, ‘event’ => ‘change’, ‘wrapper’ => ‘my-container’ ]; Callback : function myCallback(array &$form, FormStateInterface $form_state) { $fieldName = "field_desc_" . strtolower(str_replace(‘ ‘, ‘_’, $form_state->getTriggeringElement()[‘#title’])); $field_storage = FieldStorageConfig::loadByName(‘node’, $fieldName); $field = FieldConfig::loadByName(‘node’, ‘content_type’, […]

Categories
Mastering Development

Create a prolog program that finds the culprit of a crime given the following facts

Zebra Technique Example – https://www.eecs.yorku.ca/course_archive/2020-21/F/3401/slides/zebra.prolog I believe the suspects can be organized as follows: **- suspect(Angela, _, _, female) suspect(Mary, _, _, female) suspect(David, _, _, male)** also i know that the ages are arranged as follows: **- suspect( _, Leung, 5, _) suspect(_, Diamond, 7, _) suspect(_, Grant, 8, _)** this is where i […]

Categories
CMS Mastering Development Wordpress

How to make a pagination with dropdown selection?

This is the code for the dropdown pagination. It uses a js controller too, but it works fine, so, I’m not adding it. $total = $wp_query->max_num_pages; // only bother with the rest if we have more than 1 page! if ( $total > 1 ) { // get the current page if ( !$current_page = […]

Categories
Mastering Development

What would be the best practice to merge additional variables to data based on specific row information when web scraping in R using ‘rvest’?

I’m currently web scrapping the IMDB website to extract movie data. I would like to know how you would solve this problem. library(tidyverse) library(data.table) library(rvest) library(janitor) #top rated movies website url <- ‘https://www.imdb.com/chart/top/?ref_=nv_mv_250’ # extract the title of the movies using rvest titles <- url %>% read_html() %>% html_nodes(‘ .titleColumn a’) %>% html_text() %>% as.data.table() […]

Categories
Mastering Development

Convert a list from findall predicate to a string prolog

I am struggling to identify a way to convert a list to string. This list is the output from a findall predicate. see below my code. edge(a,b). edge(a,c). edge(b,c). edge(c,d). edge(c,e). edge(d,e). edge(f,g). edge(g,h). route(X, Z, []) :- edge(X, Z). route(X, Z, [Y|T]) :- edge(X, Y), route(Y, Z, T). allways(X, Y) :- findall(E, (route(X, Y, […]

Categories
Mastering Development

I have defined multiple predicates that seem to share a common form

All of these predicates are defined in pretty much the same way. The base case is defined for the empty list. For non-empty lists we unify in the head of the clause when a certain predicate holds, but do not unify if that predicate does not hold. These predicates look too similar for me to […]

Categories
Mastering Development

too many values to unpack (expected 3) pygame click issue

I am currently working on a CS50 project studying the AI required for tic-tac-toe. however I can’t get the runner.py file to run, as I get the following error: Traceback (most recent call last): File "/Users/newtracksuit/Downloads/tictactoe/runner.py", line 57, in click, _, _ = pygame.mouse.get_pressed() ValueError: too many values to unpack (expected 3) here is the […]

Categories
Mastering Development

bulk insert into sql server using package database/sql package

I am trying to insert multiple records in sql server using Go. I am using below code. but getting this error "mssql: Incorrect syntax near ‘?’." . func BulkInsert(unsavedRows []*ExampleRowStruct) error { valueStrings := make([]string, 0, len(unsavedRows)) valueArgs := make([]interface{}, 0, len(unsavedRows) * 3) for _, post := range unsavedRows { valueStrings = append(valueStrings, "(?, […]

Categories
Mastering Development

F# exception error when defining pattern matching function with lists of tuples

I’d like to create a function that compares 2 lists of tuples and returns tuple elements that match in both lists. So far I have defined my function like this: let rec matchNames l1 l2 = match (l1,l2) with | (n1,_,_) :: l1′ , (n2,_,_) :: l2′ when n1 = n2 -> n1 :: matchNames […]

Categories
Mastering Development

ERROR:9:42: Syntax error: Operator expected prolog

So, I am trying to create a microworld for my prolog assignment and whenever I try to consult the .pl file it gives me a bunch of errors which are basically all the same as they start with ""ERROR:softwares_and_hardwares.pl:9:42: Syntax error: Operator expected"" and in the next line, the same ones with the numbers changed. […]