Questions tagged [static]

The concept of "static" is commonly employed in programming languages to refer to a function or storage area that is not tied to any particular object instance. When discussing this topic, it is typically recommended to pair the usage of the term with a specific programming language tag.

Utilizing CSS for fixed positioning and media queries

I'm currently facing an issue with media queries and a sidebar div that has a fixed position. The problem arises when the viewport becomes too narrow, causing the main content to shift to the left and end up below the sidebar. I attempted to resolve this b ...

Next.js continues to generate a 404 error page instead of displaying the details of the blog post

I am having trouble with generating my blog details page as I keep getting a 404 error. The data is being fetched from a headless cms called contentful. Below is the structure of my files and code: https://i.stack.imgur.com/kK8B6.png Additionally, here i ...

In Typescript, inheritance of classes with differing constructor signatures is not permitted

While working on implementing a commandBus, I encountered an issue when trying to register command types with command handlers for mapping incoming commands. My approach was to use register(handler : typeof Handler, command : typeof Command), but it result ...

Is there a way to reset static data in a TypeScript subclass? (or alternative method for managing global data)

I have a particular set of static data that I would like to access through an API using basic logic. Specifically, this data pertains to metadata about Java classes. My approach involved incorporating the API into a few static methods within a class, alon ...

The PHP static variable resets every time the page is reloaded

Let me simplify the task at hand: The goal is to have a static variable x in my script that increases each time the submit button is clicked. <?php function IncX(){ static $x = 0; $x++; echo $x; } ?> <body> <form> <input ...

Python: How to maintain the static nature of a class variable even when importing a module in various ways

Consider the organizational structure of the package shown below: myApp |-- myPackage | |-- __init__.py | +-- myModule.py |-- __init__.py +-- main.py A single class is defined in myModule.py as follows: class MyClass( object ): _myList = [] ...

PHP Chaining... It's so confusing to me!

I am experimenting with creating a chaining function to manipulate strings retrieved from an XML file. A single original string might require multiple replacements, some sourced from the XML file. Here is the conventional and messy wrapped approach: str ...

How to change static properties in child classes in PHP

<?php class Base { protected static $c = 'base'; public static function getC() { return self::$c; } } class Derived extends Base { protected static $c = 'derived'; } echo Base::getC(); // output "base" echo Derived::getC(); // output " ...

Is SimpleHTTPServer included in the package?

Lately, I've been experimenting with the Python SimpleHTTPServer in Mac OS X Bash instead of MAMP to assist with front-end templating. I appreciate its user-friendly nature, but I'm curious if there is a method to incorporate includes for repeated sections ...

Boosting PHP performance with static fields and accelerators

I am curious about how PHP interprets static (class) fields. For example, in Java when a class is loaded, the static fields are associated with that Class object, creating a shared global variable among applications running on the same JVM and classloader. ...

I am looking to serve static HTML files in Express.js while also retaining app.get() methods for handling server-side logic

It may sound trivial, but I am struggling with displaying HTML files within app.get() methods using Express. Most solutions I have found involve using app.use(express.static(__dirname + '/public'));, which limits server-side logic. What I want i ...

Reduce the size of static-generated assets using Next.js

After creating static files with Next js, I uploaded them to Amazon S3. However, I noticed that the generated .js and .css files are not compressed as needed for Google Analytics. The issue is: Text-based resources must be served with compression (gzip, d ...

Detecting file changes in ExpressJS after writing data to a file.This

I'm facing an issue with my endpoints. One endpoint is responsible for writing JSON data to a static file, while another endpoint is supposed to retrieve and send that data. The problem arises when I make changes to the file but the endpoint still sends ...

What is preventing this Node JS code from successfully serving a static PNG file?

To the administrators, I have spent hours scouring various resources for answers related to Node Js, Express, and serving static files. Despite my efforts on stackoverflow and other platforms, I have yet to find any solution that works for me. If my questi ...

Fetching constant values from MySQL

I am working with a CMS that relies on a SQL query to populate dropdown options. Typically, this involves retrieving rows from a table and displaying them as options in the dropdown menu. However, there are times when I need to have just two static options ...

Serving static files in Next.js with specific extensions without triggering a download

I'm facing an issue where I need to serve the stellar.toml file in domain/.well-known/stellar.toml with the content type as text/plain. The current configuration works only when the stellar file is saved without an extension. It is essential for me t ...

How to implement a Django block for loading CSS files

I have multiple pages and I need to load unique CSS for each page. I am using this method for all static files. In the head of my index.html file, I have the following code: {% block css %} {% endblock %} However, in my contact.html file, I have the fol ...

Enforced guidelines: The method model::tableStruct() cannot be abstract in a static function

This strange message keeps appearing in php 5.4 for some unknown reason. Here is how my class is structured: abstract class model{ private static $tableStruct = array(); abstract protected static function tableStruct(); public static functio ...

Authenticating NextJS static sites using SSG (Static Site

Scenario My project involves creating a platform where users can pay to access blog content from various bloggers. Chosen Solution I decided to use NextJS for building static content (SSG). With the fallback option, I am able to generate static content e ...

Error in serving static files in React build through Express server

Hello everyone, I am fairly new to react and facing some challenges while trying to convert my MEAN stack app into an express and reactjs application. The main issue I am encountering is related to getting my build files to load correctly. It seems like my ...

Why is it that a static variable cannot be accessed using the `this` keyword in a static method when the static method is called in any route's controller in NODEJS?

Is it possible to access static variables in a static method using the 'this' keyword? The answer is yes, but there seems to be an issue when passing that static method in any route. The 'this' keyword refers to the class, yet its value is undefined. How c ...

Deploying static files with Django in a production environment

My Django application is functioning properly on Ubuntu 14.04 with nginx 1.10, Django 1.10.2, and uWSGI 2.0.14. It is able to load static files such as JavaScript, CSS, and images, but the CSS files are not being applied to my website. Below is the configu ...

Struggling to understand how to define and utilize Static variables in TypeScript? If you're finding that they are consistently coming up

export class myClass implements OnInit { counter = 0; static counter: any; onListItemClick(PackDef: PackDefinition): void { this.itemClicked.emit(PackDef); this.counter++; console.log(this.counter); } } and.. import { myClass } from '../../ ...

Serve static content securely using HTTPS

Having trouble finding an example of implementing Node.js with Express for serving static content over HTTPS? You're not alone. While there are plenty of resources on using Express with HTTPS and serving a static directory separately, combining all three s ...

What are the appropriate situations for utilizing getStaticPaths()?

Right now, an API call is being made in a main component and the fetched data is saved in a Singleton. This singleton data needs to be accessed by the getStaticPaths() function. However, due to the fact that getStaticPaths() pre-renders it, the singleton ...

The getStaticProps function returns a null value, whereas the identical code functions properly in a create-react-app environment

I recently switched my create-react-app to a next.js app in order to implement SSG. I successfully tested the getStaticProps function using a jsonplaceholder API and was able to retrieve data and display it. However, when I changed the API, it started retu ...

Having trouble configuring the cache-control header for my static assets in Express

Utilizing Express on the server side and React (create-react-app) on the frontend. My React application creates all the bundled assets stored in the client/build/static directory. Within this directory, there are three subfolders: css, js, and media. I no ...

utilizing a variable class name to invoke static methods in PHP

Is it possible to access a static method using a variable as the class name? I am encountering issues with this and would like to achieve something like the following: class foo { public static function bar() { echo 'test'; } } ...