Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

REVIEW: A Crane Among Wolves by June Hur

Hope is dangerous. Love is deadly.

1506, Joseon. The people suffer under the cruel reign of the tyrant King Yeonsan, powerless to stop him from commandeering their land for his recreational use, banning and burning books, and kidnapping and horrifically abusing women and girls as his personal playthings.

Seventeen-year-old Iseul has lived a sheltered, privileged life despite the kingdom’s turmoil. When her older sister, Suyeon, becomes the king’s latest prey, Iseul leaves the relative safety of her village, traveling through forbidden territory to reach the capital in hopes of stealing her sister back. But she soon discovers the king’s power is absolute, and to challenge his rule is to court certain death.

Prince Daehyun has lived his whole life in the terrifying shadow of his despicable half-brother, the king. Forced to watch King Yeonsan flaunt his predation through executions and rampant abuse of the common folk, Daehyun aches to find a way to dethrone his half-brother once and for all. When staging a coup, failure is fatal, and he’ll need help to pull it off—but there’s no way to know who he can trust.

When Iseul’s and Daehyun’s fates collide, their contempt for each other is transcended only by their mutual hate for the king. Armed with Iseul’s family connections and Daehyun’s royal access, they reluctantly join forces to launch the riskiest gamble the kingdom has ever seen:

Save her sister. Free the people. Destroy a tyrant.

READ THIS NOTE, ESPECIALLY THE END

Author’s Note – King Yeonsan (deposed name: Yeonsangun) ruled from 1495 to 1506 and was considered the worst tyrant in Korean history. Supposedly, he ruled decently for the first nine years of his reign, but in 1504—after learning of how his mother had been executed—he went on a revenge spree that began the bloodiest purge of his reign.
Emboldened by the absolute power he held, Yeonsan began committing widespread atrocities—stealing land from the people to turn into his personal hunting grounds, executing his own family members, murdering government officials in the cruelest ways, and kidnapping and enslaving women from every province.
I believe it’s important to tell history as it is, with all its violence and corruption, and so I did not shy away from the realities of Yeonsan’s reign. His crimes were so numerous, though, that I couldn’t mention them all in the story. But for the ones I did, I’d like to offer the following content warnings:
rape (mentioned), sexual abuse, misogyny, kidnapping women and girls, sex trafficking, incest (mentioned), violence, murder, animal cruelty, suicide (mentioned), infanticide (mentioned), psychological trauma, panic attacks

Dear Ms. Hur,

Two years ago, I read and enjoyed “The Red Palace” which had some dark stuff in it. Well, this one tops that. I’m glad that you included what you did in your author’s note and I hope people pay attention to the warnings. This book is being tagged (given the age of the MCs) as young adult but given the nature of the content, I would be very careful about how old readers are who read it.

Iseul was the pampered youngest daughter of a high ranking Joseon Korean magistrate when her world came crashing down. Her parents were murdered by soldiers on order of the king leaving Iseul and her older sister to seek refuge with their grandmother (who is only mentioned in the book). Then her sister (with whom Iseul has a fractious relationship – all due to Iseul) is kidnapped and taken by the king as a concubine – one among almost a thousand most of whom are subjected to sexual abuse. Iseul is convinced that this is all her fault and she’s going to make it right. How, she has no clue but she’s gonna do it.

Arriving at an inn not far from the capital, Iseul is taken under the wing of the innkeeper and a former investigator. Yul promises to treat Iseul like family in exchange for Iseul helping at the inn (something she only sporadically does) while Wonsik tries to tutor her in how to investigate a series of murders and discover who the serial killer is (something Iseul pouts about as Wonsik actually wants her to use her brain while she just wants him to tell her what she wants to know). Then an illegitimate prince gets involved (as he also scrambles day by day to keep his psycho half-brother the king from killing him). Iseul wants to save her sister while Daehyun has grander plans – to overthrow the king in a coup. Will they get what they want or die trying?

I applaud the use of this unusual setting and the fact that readers are not molly coddled by having Korean words, terms and things used and then immediately translated into English. The meanings are made plain through the descriptions and if that doesn’t work then there’s always Google. Also booyah for (as stated in the author’s note) not shying away from the brutality of what was actually happening in this time. Yes, it’s hard to read but how much harder must it have been to try to live through it.

While I enjoyed being set down in Joseon Korea again, there were a lot of things that didn’t work for me here. Iseul is, quite frankly, a spirited young woman who hasn’t an ounce of common sense. I understand that she was raised to be waited on by servants, has no life skills, is probably still upset about how her life has been upended, and probably looking for a way to get it back. However she’s ready to snap at anyone who (she thinks) is getting in her way and charge off into danger without bothering to think things through. That these people she’s snapping at are often trying to help her or that if her harebrain (lack of) plans might get her killed or kidnapped herself don’t stop her. I’ll give her courage. I’ll give her determination. But she doesn’t seem to learn and she’s also at times an idiot.

Daehyun is a bit smarter and can roll with a dangerous situation while keeping a cool head. He’s had to as the king loves playing “games” that usually end with a courtier being killed for the king’s amusement. Daehyun has plans though. If he and a small, loyal band can seize the moment, they can dethrone the tyrant making everyone’s life hell. Except he knows that this rag-tag band isn’t enough so some (I’ll be honest, boring) scenes of behind-the-scenes political negotiation to induce powerful men to join them take place. First though he has to attempt to keep Iseul from doing anything stupid and rescue her a time or three when she does.

The story has tons of secondary and tertiary characters. Honestly, too many. And it’s not trying to keep the Korean names straight that was my problem. I would feel the same if this were a historical set during the English War of the Roses. After a while, people began to blur. After a while, plot points began to blur as well. There’s Iseul saving her sister, Daehyun plotting, Wonsik giving Iseul tips on murder investigation, Yul keeping the inn afloat, the whackjob king, sleazy courtiers, a group of court jesters who skip in and out, lots of running around the countryside, a violent coup, and tons of background details. As the plot revved up and sped towards the finish I had already gotten more than a bit lost.

I cheered when (some of) the mistreated women rescued themselves. I did love that Iseul refused to give up trying to get her sister out of a living nightmare and then further protected her from the terrible fate that met many of the other women the king had kidnapped and debauched (and society is rarely forgiving of a woman’s loss of “honor”). I never quite got what Daehyun saw in Iseul beyond that she’s feisty as she never grew much as a character. I questioned the need for the murders in the story and also began mentally picking apart and poking holes in how the serial killer managed all that was done. The reality of the post-coup was depressing as well. I think if I had read this book when I was younger, I might like it more but I didn’t and I don’t. C

~Jayne

AmazonBNKoboBook DepositoryGoogle

Retrieve a value from a request with content type application/json

I have the following script that is sending data to a controller in MVC:

$.ajax({
    url: '/products/create',
    type: 'post',
    contentType: 'application/json; charset=utf-8',
    data: JSON.stringify({
        'name':'widget',
        'foo':'bar'
    })
});

My controller looks like this:

[HttpPost]
public ActionResult Create(Product product)
{
    return Json(new {success = true});
}

public class Product 
{ 
    public string name { get; set; }
}

Is there a way I can get the "foo" variable in my controller action without

  • modifying the model
  • modifying the signature of the action

If it was a regular form submission, I would have access to Request.Form["foo"], but this value is null since it was submitted via application/json.

I want to be able to access this value from an Action Filter and that is why I don't want to modify the signature/model.

How to Watch the 2024 BAFTA TV Awards Online

The 2024 BAFTA TV Awards are here. The ceremony will be broadcast on BBC One and stream on BBC iPlayer on Sunday night in the U.K., starting at 7 p.m. BST. Viewers in the U.S., Canada, Australia and more can watch on BritBox, starting at 2 p.m. ET. Winners will also be announced on BAFTA’s […]

Fatal error: glibc. Trying to put char in file

I'm trying to put and get+print four char characters in a file by promting the user for four chars. However, there is an error (Fatal error: glibc detected an invalid stdio handle).

After debugging I found the fault at the line fputc(c[3], putc). After prompting the user for the fourth time, it cannot put the fourth char c[3] in the file.

Please help me to understand.

Here's my code:

    FILE* putc = fopen("test3.txt", "w");

    if(putc == NULL)
    {
        return 1;
    }

    char c[4];

    for(int i = 0; i < 4; i++)
    {
        printf("char: ");
        scanf("%s", &c[i]);
        fputc(c[i], putc);
    }


    fclose(putc);

    FILE* getc = fopen("test3.txt", "r");

    if(getc == NULL)
    {
        return 1;
    }

    char abc;

    while ((abc = fgetc(getc)) != EOF)
    {
        printf("%c", abc);
    }
    printf("\n");

    fclose(getc);

Passing pointer to C struct to ioctl in Python

I am writing a Python script that needs to use the FS_IOC_ADD_ENCRYPTION_KEY ioctl.

This ioctl expects an argument of type (pointer to) fscrypt_add_key_arg, which has this definition in the Linux kernel header files:

struct fscrypt_add_key_arg {
    struct fscrypt_key_specifier key_spec;
    __u32 raw_size;
    __u32 key_id;
    __u32 __reserved[8];
    __u8 raw[];
};

#define FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR        1
#define FSCRYPT_KEY_SPEC_TYPE_IDENTIFIER        2
#define FSCRYPT_KEY_DESCRIPTOR_SIZE             8
#define FSCRYPT_KEY_IDENTIFIER_SIZE             16

struct fscrypt_key_specifier {
    __u32 type;     /* one of FSCRYPT_KEY_SPEC_TYPE_* */
    __u32 __reserved;
    union {
            __u8 __reserved[32]; /* reserve some extra space */
            __u8 descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE];
            __u8 identifier[FSCRYPT_KEY_IDENTIFIER_SIZE];
    } u;
};

This is my Python code:

import fcntl
import struct

FS_IOC_ADD_ENCRYPTION_KEY = 0xc0506617

policy_data.key_descriptor: str = get_key_descriptor()
policy_key: bytes = get_policy_key(policy_data)

fscrypt_key_specifier = struct.pack(
    'II16s',
    0x2,
    0,
    bytes.fromhex(policy_data.key_descriptor)
)

fscrypt_add_key_arg = struct.pack(
    f'{len(fscrypt_key_specifier)}sII8I{len(policy_key)}s',
    fscrypt_key_specifier,
    len(policy_key),
    0,
    0, 0, 0, 0, 0, 0, 0, 0,
    policy_key
)

fd = os.open('/mnt/external', os.O_RDONLY)
res = fcntl.ioctl(fd, FS_IOC_ADD_ENCRYPTION_KEY, fscrypt_add_key_arg)

print(res)

When I execute this code I get an OSError:

Traceback (most recent call last):
  File "/home/foo/fscryptdump/./main.py", line 101, in <module>
    res = fcntl.ioctl(fd, FS_IOC_ADD_ENCRYPTION_KEY, fscrypt_add_key_arg)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 22] Invalid argument

I have double-checked the documentation of that ioctl and I think the values I am passing are correct, but there probably is a problem in the way they are packed.

How can I solve this?

Google Analytics API and .Net

Google announced the Analytics Data Export API some days ago, thereby making it much easier to get analytics data for a site. The API debuted with Java and JavaScript clients, but no direct .Net support (other than going straight for the XML). It seems the API is similar to the other Google Data APIs though, and there's a .Net client for those. Has anyone tried using the components in that library to get at the analytics data?

I'm in the process of building an ASP.Net MVC site and thought I'd use Google Analytics to generate "Most viewed" lists and stuff like that (since Google is probably better at weeding out spurious requests, robots, etc.). If you have any thoughts on that idea, I'd much appreciate hearing them too.

Brian Wilson Placed Under Conservatorship Due to Cognitive Decline

A judge ruled this week that music legend Brian Wilson should be placed under a conservatorship due to a “major neurocognitive disorder.”

The legendary singer-songwriter will now enter a guardianship controlled by his manager LeeAnn Hard and publicist Jean Sievers.

According to a report from USA Today, Wilson did not object to the ruling.

Brian Wilson performs Pet Sounds at the Pantages Theatre on May 26, 2017 in Los Angeles, California.
Brian Wilson performs Pet Sounds at the Pantages Theatre on May 26, 2017 in Los Angeles, California. (Photo by Kevin Winter/Getty Images)

Brian Wilson’s Conservatorship: Everything We Know

Best known for his work with the Beach Boys, Wilson, 81, has been battling dementia for several years.

In January, his wife, Melinda Wilson, passed away suddenly at the age of 77.

The situation left Brian in need of a caretaker. And thankfully, it sounds like he will now receive the help that he needs.

Brian Wilson and his wife Melinda Ledbetter pose for photographers during the photocall for the film "Love & Mercy" presented in the Berlinale Special of the 65th Berlin International Film Festival Berlinale in Berlin, on February 8, 2015.
Brian Wilson and his wife Melinda Ledbetter pose for photographers during the photocall for the film “Love & Mercy” presented in the Berlinale Special of the 65th Berlin International Film Festival Berlinale in Berlin, on February 8, 2015. (Photo credit should read JOHN MACDOUGALL/AFP via Getty Images)

“The court finds from clear and convincing evidence that a conservatorship of the person is necessary and appropriate in that (Wilson) is unable to care for (his) person,” Judge Gus T. May wrote in Thursday’s ruling.

“The conservatorship is the least restrictive alternative needed for the protection of conservatee.”

May added that Hard and Sievers have been granted the authority to “authorize the administration of medications appropriate for the care and treatment”

Brian Wilson, leader and co-founder of the rock band the Beach Boys, performs on the  Pet Sounds: The Final Performances Tour at ACL Live on May 13, 2017 in Austin, Texas.
Brian Wilson, leader and co-founder of the rock band the Beach Boys, performs on the Pet Sounds: The Final Performances Tour at ACL Live on May 13, 2017 in Austin, Texas. (Photo credit should read SUZANNE CORDEIRO/AFP via Getty Images)

Brian Wilson Pays Tribute to Late Wife

Wilson has not made any sort of public statement since he paid tribute to his wife shortly after she passed.

“Our five children and I are just in tears. We are lost,” Wilson wrote on his website at the time.

“Melinda was more than my wife. She was my savior. She gave me the emotional security I needed to have a career,” he continued.

Brian Wilson attends Official Academy Screening of "Love & Mercy" hosted by The Academy of Motion Picture Arts and Sciences at The Academy Theatre at Lighthouse International on June 4, 2015 in New York City.
Brian Wilson attends Official Academy Screening of “Love & Mercy” hosted by The Academy of Motion Picture Arts and Sciences at The Academy Theatre at Lighthouse International on June 4, 2015 in New York City. (Photo by Rob Kim/Getty Images for The Academy of Motion Picture Arts and Sciences)

“[Melinda] encouraged me to make the music that was closest to my heart. She was my anchor. She was everything for us. Please say a prayer for her.”

Wilson’s struggles with mental health and his relationship with Melinda were portrayed in the 2014 biopic Love & Mercy.

Celebrity Conservatorships Have Earned a Bad Reputation

Brian Wilson performs Pet Sounds at the Pantages Theatre on May 26, 2017 in Los Angeles, California.
Brian Wilson performs Pet Sounds at the Pantages Theatre on May 26, 2017 in Los Angeles, California. (Photo by Kevin Winter/Getty Images)

The legal battle over Britney Spears’ conservatorship raised the public’s awareness about such arrangements.

Obviously, in that case, the guardianship was not in Britney’s best interest. And the people who seized control of her life abused their power.

However, in the case of Brian Wilson, it seems all involved parties agree that a conservatorship is the best option.

Here’s hoping this living legend will receive all the help he needs.

Brian Wilson Placed Under Conservatorship Due to Cognitive Decline was originally published on The Hollywood Gossip.

JSDOC Reference key of other type

How does one reference the key of another object within a @type or @typedef?

/**
 * @typedef {{name: {name: string}}} moo
 * @typedef {{name: moo.name}} moo2
 */

I would expect vscode to resolve moo2 as having structure {name: {name: string}}, but it does not.

REVIEW: The Brides of High Hill (The Singing Hills Cycle Book 5) by Nghi Vo

The Cleric Chih accompanies a beautiful young bride to her wedding to the aging ruler of a crumbling estate situated at the crossroads of dead empires. The bride’s party is welcomed with elaborate courtesies and extravagant banquets, but between the frightened servants and the cryptic warnings of the lord’s mad son, they quickly realize that something is haunting the shadowed halls.

As Chih and the bride-to-be explore empty rooms and desolate courtyards, they are drawn into the mystery of what became of Lord Guo’s previous wives and the dark history of Do Cao itself. But as the wedding night draws to its close, Chih will learn at their peril that not all monsters are to be found in the shadows; some monsters hide in plain sight.

Though all the novellas are standalone, I would recommend reading at least one or two earlier ones to get a feel for the world and more information on the background of Chih and Almost Brilliant.

Dear Nghi Vo,

A new Singing Hills novella with Cleric Chih! This time it’s got some weird goings on, a strange family, a mystery. But where is Almost Brilliant?

Cleric Chih, a story gatherer from the Singing Hills Monastery, is on the road, traveling with a young bride and her parents on her way to meet a man her parents want her to marry. Pham Nhung is very young, sweetly charming, and acts and is treated as if she’s more fragile than fine porcelain. When the retinue reaches the compound, Nhung takes Chih with her ahead of the rest and surveys the strong walls that surround it, wondering aloud if she will find her future here.

The events get weirder after that when a bizarre young man warns Chih to have Nhung ask the lord what happened to his other brides. Wandering around the grounds that night, Chih and Nhung enter several buildings with Nhung coyly asking Chih to go in first and check for monsters. The mystery of the place deepens when the lord’s son, the young man from earlier, warns Chih and reveals something awful about his situation there and old family secrets. But the monsters Chih is expecting aren’t the ones they find.

“The world starts with a story. So do dynasties and eras and wars. So does love, and so does revenge. Everything starts with a story.”

Once again, a perfectly paced story unfolds in novella format. Some novellas end up too rushed or too thinly written with not enough to keep me interested. With the Singing Hills stories, I know that this won’t be the case. Words are carefully used to create and shade in the background worldbuilding which is filled with characters given nutshell sketches that tell us all we need to know about who they are without wasting pages on unneeded information.

The terrible situation is slowly built up, little by little with an aftertaste of unease, like a fire started and then allowed to heat up before bursting out in raging flames. There are subtle clues but they are softly dropped into the story and the reader is allowed to notice them and ponder what they mean before all the plot points are tied together and everything is let loose.

What didn’t work quite as well for me is

Spoiler: Show

how it’s revealed at the end that we haven’t been told everything.
Also some threads are left hanging and unresolved. Cleric Chih is going to have a hell of a story to add to the ones at the Singing Hills Monastery but I didn’t feel as if I got all the resolutions by the end that I wanted to have explained. B

~Jayne

AmazonBNKoboBook DepositoryGoogle

Drake: Shooting Near Rapper’s Toronto Home Leaves Security Guard Wounded

Drake’s Toronto mansion was taped off by police last night following a shooting near the property.

According to a report from Page Six, the victim has now been identified as a security guard employed by Drake. The 48-year-old is believed to be in stable condition.

According to a tweet from Toronto police, shots were fired around 2:10 a.m. ET near the corner of Bayview and Lawrence Avenues.

The suspect is believed to have fled in a car immediately after the shots were fired.

Drake attends Drake's Till Death Do Us Part rap battle on October 30, 2021 in Long Beach, California.
Drake attends Drake’s Till Death Do Us Part rap battle on October 30, 2021 in Long Beach, California. (Photo by Amy Sussman/Getty Images)

Shooting Near Drake’s Home: Everything We Know So Far

The officers who responded to the call discovered a seriously wounded man who was taken to a nearby hospital.

Thankfully, no one else was harmed. Drake was not injured, and it’s unclear if he was at home at the time of the shooting.

The security guard’s injuries have been described by The New York Post as non-life-threatening.

Drake performs on the Coachella stage during day 2 of the Coachella Valley Music And Arts Festival (Weekend 1) at the Empire Polo Club on April 15, 2017 in Indio, California.
Drake performs on the Coachella stage during day 2 of the Coachella Valley Music And Arts Festival (Weekend 1) at the Empire Polo Club on April 15, 2017 in Indio, California. (Photo by Christopher Polk/Getty Images for Coachella)

Initially, it was hoped that the conflict that led to the shooting had nothing to do with Drake.

The cause of the dispute remains unclear, but it looks increasingly as though the rapper was being targeted.

Social media speculators are already jumping to the conclusion that the incident was related to the ongoing feud between Drake and Kendrick Lamar.

The war of words between Drake and Kendrick is the most high-profile hip hop beef in recent memory.

Recording artist Drake performs onstage at the 2016 iHeartRadio Music Festival at T-Mobile Arena on September 23, 2016 in Las Vegas, Nevada.
Recording artist Drake performs onstage at the 2016 iHeartRadio Music Festival at T-Mobile Arena on September 23, 2016 in Las Vegas, Nevada. (Photo by Kevin Winter/Getty Images)

Many have compared the situation to the deadly war between Tupac Shakur and the Notorious B.I.G. that played out in the mid-nineties.

Earlier this week, Kendrick released a scathing diss track titled “Not Like Us.” The song featured an aerial photo of Drake’s home on its cover.

Drake vs. Kendrick Lamar Feud: Already Over, or Just Getting Started?

Kendrick Lamar performs on stage during the Coca-Cola Music Mix at the NCAA March Madness Music Festival Day 2 at  Discovery Green on April 2, 2016 in Houston, Texas.
Kendrick Lamar performs on stage during the Coca-Cola Music Mix at the NCAA March Madness Music Festival Day 2 at Discovery Green on April 2, 2016 in Houston, Texas. (Photo by Gustavo Caballero/Getty Images for Turner)

The bad blood between the rappers has been simmering at least since last year. It boiled over in a big way in recent weeks, with both artists releasing multiple diss tracks directed at one another.

“Not Like Us,” the latest from Kendrick, begins with the line “I see dead people” and contains ominous references to the ways in which Drake’s recent remarks have sparked outrage.

It’s important to note that these are just lines in a song, and at present, there’s no reason to believe that last night’s shooting had anything to do with the feud between Kendrick and Drake.

Drake texts while watching Game Six of the Eastern Conference First Round between the Toronto Raptors and the Philadelphia 76ers at Scotiabank Arena on April 28, 2022 in Toronto, Canada.
Drake texts while watching Game Six of the Eastern Conference First Round between the Toronto Raptors and the Philadelphia 76ers at Scotiabank Arena on April 28, 2022 in Toronto, Canada. (Photo by Cole Burston/Getty Images)

According to the Post, Drake’s house is at the center of the investigation. But that does not mean that the rapper was being targeted.

That said, Drake and his loved ones are likely taking extra precautions today.

We’ll have further updates on this developing story as new information becomes available.

Drake: Shooting Near Rapper’s Toronto Home Leaves Security Guard Wounded was originally published on The Hollywood Gossip.

Find remaining queens for nqueens problem

As the title says, I have to find the remaining queens for the nqueens problem, but I have not use recursive calls and I have to use stacks and backtracking. Currently I have:

#include <stdio.h>
#include <stdbool.h>

#define MAX_N 11

typedef struct {
    int row;
    int col;
} Queen;

typedef struct {
    int top;
    Queen items[MAX_N];
} Stack;

void initStack(Stack* stack) {
    stack->top = -1;
}

void push(Stack* stack, Queen queen) {
    if (stack->top < MAX_N - 1) {
        stack->top++;
        stack->items[stack->top] = queen;
    }
}

Queen pop(Stack* stack) {
    if (stack->top >= 0) {
        stack->top--;
        return stack->items[stack->top];
    }
    Queen emptyQueen = { -1, -1 }; // Return an invalid queen
    return emptyQueen;
}

// Helper function to check if a queen can be placed at (row, col)
bool isValid(Queen queens[], int numQueens, int row, int col) {
    for (int i = 0; i < numQueens; i++) {
        if (queens[i].row == row || queens[i].col == col ||
            queens[i].row - queens[i].col == row - col ||
            queens[i].row + queens[i].col == row + col) {
            return false; // Queens attack each other
        }
    }
    return true;
}

void solveQueens(int max_queens, Queen* initQs, int numInitQ) {
    Queen queens[MAX_N];
    Stack stack;
    initStack(&stack);

    // Initialize with initial queens
    for (int i = 0; i < numInitQ; i++) {
        queens[i] = initQs[i];
    }

    int numQueens = numInitQ;
    int row = numInitQ; // Start from the next row

    while (numQueens < max_queens) {
        bool found = false;
        for (int col = 0; col < max_queens; col++) {
            if (isValid(queens, numQueens, row, col)) {
                queens[numQueens] = (Queen){ row, col };
                numQueens++;
                found = true;
                break;
            }
        }
        if (!found) {   //backtrack, pop the queen
            queens[numQueens - 1] = pop(&stack);
            numQueens--;
            row = queens[numQueens - 1].row + 1;
            if(numQueens <= numInitQ){  //there are not enough queens in total, therefore no solution
                printf("no solution\n");
                return;
            }
        } else {
            push(&stack, queens[numQueens - 1]);
            row++;
        }
    }

    // Print the solution
    for (int i = 0; i < numQueens; i++) {
        printf("%d %d\n", queens[i].row, queens[i].col);
    }
}

for testing, I have used the main function:

int main() {
    Queen initialQueens[] = { {0, 0} }; // Example initial queens
    int numInitialQueens = 1;
    int maxQueens = 4; // Change this to the board size
    solveQueens(maxQueens, initialQueens, numInitialQueens);
    return 0;
}

Which expectedly prints No Solution. However, when I try to make the board size 5 (setting maxQueens to 5) the function enters an infinite loop. My theory is that this is probably caused by the function finding a valid queen, but the total number of queens is not enough, which causes it to backtrack repeatedly. Don't take my word for the error, I could be way off but it might be a lead. Anyone got any fixes and suggestions?

Why don't local variable initialisation instructions contribute to the executable size as much as global variables do?

The text I am reading says:

Global variables are located in executable image, so using number of global variables will increase the size of executable image.

Questions:

  1. What does 'located in executable image' mean? From what I have read the global variables are located in the 'data' section of the executable. I presume that local variable initialisation instructions are stored in the 'text' section. So why don't the local variable initialisation instructions take up about the same amount of space as the global variables do?

  2. By executable, does it mean here the executable loaded into the memory or the executable that is only on the non-volatile memory? Will the global variables also take up more space for executable that is not loaded into the RAM?

  3. Are there books or concise reading resources I may refer to that will help me with such lower level concepts?

I expected the size of the local variable initialization instructions to take up the same amount of space in executable as global variables do. Consider the following program:

#include <stdlib.h>

int global_var = 10

int main(void){

    int local_var = 20;
    return EXIT_SUCCESS;
}

When converted to machine level executable (assuming its not loaded into memory/not a process), I assume both definition and initialisation of global_var and local_var will be encoded as machine level code, albeit in different sections (data and text) of executable. So why will global_var take up more space?

PostgreSql Row-Level Locks

I am trying to understand Postgresql Row-Level Locks could someone help me understand when to use each type of lock.

     FOR UPDATE; FOR NO KEY UPDATE; FOR SHARE; FOR KEY SHARE;

I tried to go over the documentation but still, I couldn't understand the difference and didn't know when to use what and how does it make a difference.

I am expecting someone could help me understand the use case of each lock and give me clarity on when to choose each.

❌
❌