php – How to optimize code in a custom wordpress page template?

I’m pretty new to php coding, but i know wordpress for a long time. Also experimenting with bootstrap. I created a new Page Template and modified it a bit. What I’m looking for is to optimize this php code:

<div class="row">
<div class="col kb_landing_left">
    <?php
        global $post; 
        $post = get_post(56); 
        setup_postdata($post);
        get_template_part( 'template-parts/content', 'page', get_post_format() );
    ?>
</div>
<div class="col -sm-6">
    <div class="row">
        <div class="col kb_landing_right">
    <?php
        global $post; 
        $post = get_post(1); 
        setup_postdata($post);
        get_template_part( 'template-parts/content', 'page', get_post_format() );
    ?>
        </div>
    </div>

    <div class="row">
        <div class="col kb_landing_right">
    <?php
        global $post; 
        $post = get_post(3); 
        setup_postdata($post);
        get_template_part( 'template-parts/content', 'page', get_post_format() );
    ?>
        </div>
    </div>
    
    <div class="row">
        <div class="col kb_landing_right">
    <?php
        global $post; 
        $post = get_post(2); 
        setup_postdata($post);
        get_template_part( 'template-parts/content', 'page', get_post_format() );
    ?>
        </div>
    </div>
</div>

As you can see, it’s calling for 4 specific post IDs, since i want them to appear on my homepage in a bootsrap grid. I guess this could be done better by using an array?

Any suggestion is very much appreciated! Stay healthy!

repository – How to create an ubuntu custom repo for different dists and archs?

We want to make it possible for users of our software to just run sudo apt install <package>.

I have seen several pages with instructions of how to do this.
Some are outdated, and some only address simple scenarios, like all packages in the same directory, e.g.

https://www.percona.com/blog/2020/01/02/how-to-create-your-own-repositories-for-packages/
or this one which explains amd64 but not multi dists:
https://medium.com/sqooba/create-your-own-custom-and-authenticated-apt-repository-1e4a4cf0b864.

Our software has binary compiled components which are different for ubuntu distro versions (e.g. 18.04 vs 20.04) and architecture (amd64, x86).

How do I structure this correctly?
Anyone has a link to some blog/instructions/how to?

Ubuntu is main target, but debian would be nice to have.

react native – Create in app gallery from images retrieved from device custom folder

takePicture = async () => {
        if (this.camera) {
          if (Platform.OS === 'android') {
            await this.checkAndroidPermission();
          }
            const options = { quality: 1 };
            const data = await this.camera.takePictureAsync(options);
            //save photo
            CameraRoll.save(data.uri, {type: 'photo', album: 'Custom Folder Photos'}).then(onfulfilled => {
                ToastAndroid.show(`Vocajam Photos: ${onfulfilled}`, ToastAndroid.SHORT);
            }).catch(error => {
                ToastAndroid.show(`${error.message}`, ToastAndroid.SHORT);
            });
        }
    };


    recordVideo = async () => {
      if (this.camera) {
          if (!this.state.recording)
              this.startRecording();
          else this.stopRecording();
      }
  }

  startRecording = async () => {
    this.setState({ recording: true });
    this.countRecordTime = setInterval(() => this.setState({ seconds: this.state.seconds + 1 }), 1000);
    const cameraConfig = { maxDuration: this.state.maxDuration };
    const data = await this.camera.recordAsync(cameraConfig);
    this.setState({ recording: false });
    CameraRoll.save(data.uri, {type: 'video', album: 'Custom Folder Videos'}).then(onfulfilled => {
        ToastAndroid.show(`Custom Videos: ${onfulfilled}`, ToastAndroid.SHORT)
    }).catch(error => ToastAndroid.show(`${error.message}`, ToastAndroid.SHORT));
}

stopRecording = () => {
    this.camera.stopRecording();
    clearInterval(this.countRecordTime);
    this.setState({ seconds: 0 });

differentiability – How to write a custom function to judge whether a binary function is differentiable at a certain point

We know that the necessary and sufficient conditions for a function of two variables to be differentiable at a certain point are complex.

enter image description here

Suppose the function $z = f (x_ 1, x_ 2, …, x_n) $ is defined in the neighborhood $U$ of the point $P_ 0 (x_ {10}, x_ {20}, …, x_{n0}) $ , then the sufficient and necessary conditions for the function $z = f (x_ 1, x_ 2, …, x_n) $ to be differentiable at the point $P_ 0 (x_ {10}, x_ {20}, …, x_{n0}) $ are: The n first-order partial derivatives of the function $z = f (x_ 1, x_ 2, …, x_n) $ at the point $P_ 0 (x_ {10}, x_ {20}, …, x_{n0}) $ all exist, and $$f (x_ 1, x_ 2, …, x_n) – f (x_ {10}, x_ 2, …, x_n) –
f (x_ 1, x_ {20}, …, x_n) – f (x_ 1, x_ 2, …, x_{n0}) +
f (x_ {10}, x_ {20}, …, x_{n0}) = O (rho) $$
;

Where $(x_ 1, x_ 2, …, x_n) in U$, $rho = sqrt{(x_ 1 – x_ {10})^2 + (x_ 2 – x_ {20})^2 + … + (x_n –
x_ {n0})^2}$
.

I already know that the following binary function $f(x,y)$ is differentiable at point {0,0}, but its two first-order partial derivatives are not continuous at {0,0}:
$$f(x, y)=begin{cases}(x^2 + y^2) sin(frac{1}{(x^2 + y^2)}), &(x, y) neq (0, 0) cr 0 , &(x, y)=(0, 0)end{cases}
$$

I want to write a custom function to judge whether any binary function is differentiable at a certain point. How should I write this function?

For example, through this custom function, we can judge that the following binary function is not differentiable at {0,0}:

$$f(x, y)=begin{cases}frac{x^2y}{x^4 + y^2}, &(x, y) neq (0, 0) cr 0, &(x, y)=(0, 0)end{cases}
$$

how can show a custom text or page to special country IP’s that banned by CSF or another tools


hello,

I banned special countries on my server by CSF firewall,

exist ways that can show a text or redirect to a page?

for example ” you are can not visit this site by this location, if you are using VPN please turn off and try again “

I want do this by this CSF, if this action does not exist on CSF, please intro tools that I can do this goal,

thank

how can i set a custom header with javascript or php?

How can i set a custom header using javascript or php? I am trying to add a custom header to my html form but i’m new to programming so i’m still learning.

I’d like to add a custom header to my form and my current form code is this one:

<form>
[set-custom-header]
<input type="text" name="username" value="">
<input type="text" name="setterId" value="">
<input type="submit" value="send">
</form>

I’d like to set a custom header on that form, what could i use? Is it possible to do that without using xhr?

Thanks,

How to force custom default Sort By options for all folder types in Windows Explorer

Quick note to eager mods: this is not a duplicate 🙂

My question has 3 parts:

  • I wish to understand how Windows Explorer works in the sense of why this happens. I know folders can be of different types (general, music library, photo gallery etc) and that windows automatically decides which is which continuously based on what’s in a folder. There’s also different (types of) drives in a system, external drives, music player drives, phone drives whatever. All of these in addition to it being a folder by folder setting, contribute to the problem but I can’t piece together how come the Sort By items lists get reset.

    • For instance: I go to D:Downloads in Explorer and go to Sort By and go to More and scroll all the way down to Date Modified, and click okay, then go to Sort By again and select Date Modified. Cool. Now, I go in my browser and save a file, browser asks where to save, I browse to D:Downloads GUESS WHAT? DATE MODIFIED ISN’T THERE. Ok, I set it again there as well. I open another program with another windows shell browse menu, date modified isn’t there either. I set all of them, reboot and/or install a totally useful windows update, it gets reset again.
    • ^ Why is it not even actually per folder but per shell, and why does the Sort By list get reset? Where is this setting stored?
  • I normally would have asked what most seemingly related questions on this topic on SU ask:

    • How to change my Sort By options and then apply them to all folders. – Bad question to ask and answer, because it will get reset, or will not really be applied to all types of folders and all future drives and connected devices.
    • How to force all the folders on my system to be a “general items” folder so that then I can change the Sort By options for all my general items folders. – Also a bad question because a. I want to have different types of folders not just general items folders, and b. it as sure as anything in the universe, will eventually get reset by MS whether on purpose, or design stupidity.
  • If you’ve made it this far and with this knowledge think you have an elegant answer please help us. Otherwise, I’m gonna ask a different question:

    • Is there any sort of shell extension hack or background process or something, that we can use, that continuously overwrites the Windows Explorer Sort By list with the Sort By criteria of –OUR– choosing? Thank you very much.

In the last years, Windows As A Service releases have brought huge overhauls and investments, questionable at best (e.g. making windows drivers hostage to the invasive app store nobody wants), and yet everyday-things like this problem have remained broken and unanswered for decades. Makes you question whether anyone working at MS uses their own product non-superficially. No, but I’m sure they care, I guess they gosh just still don’t have enough telemetry to know that this totally-in-your-face basic QA problem is a problem…

custom post types – How to get rewrited name of cusom taxonomy?

I have registered custom post taxonomy with rewrited name:

register_taxonomy('behold_gallery-albums-subject', 'behold_gallery',array(
    'hierarchical'              => true,
    'labels'                    => $labels,
    'show_ui'                   => true,
    'show_admin_column'         => true,
    'rewrite'                   => array( 'slug' => 'kategorie-galerii', 'with_front' => true ),
    'update_count_callback'     => '_update_post_term_count',
    'query_var'                 => true,
));

so name of my custom taxonomy is ‘behold_gallery-albums-subject’ but is rewrited to ‘kategorie-galerii’.

If I want to get name of this taxonomy, I can use this

$postsTaxonomy = get_sub_field('archive__post-choose-taxonomy'); // ACF
$postsTerm = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
$postsTerm_id = $postsTerm->term_id;
$PostsTaxName = get_taxonomy($postsTaxonomy)->labels->name;

but how can I get this rewrited name, not the ‘original’?

Thanks!