static

Static Data Structures on Embedded Devices (Android in particular)

I've started working on some Android applications and have a question regarding how people normally deal with situations where you have a static data set and have an application where that data is needed in memory as one of the standard java collections or as an array. In my current specific issue i have a spreadsheet with some pre-calc...

How to extend methods to a class not to its instances.

Hi. Extending methods to any instance is really easy: public static string LeaveJustNumbers(this string text) { return Regex.Replace(text, @"[\D]", ""); } ... string JustNumbers = "A5gfb343j4".LeaveJustNumber(); But what if i want to extend methods to a sealed class like string, to work like: string.Format("Hi:{0}","Fraga"); I...

Why insert static files ( css, images, js, ecc ) in a subdomain ?

Why so many big and little sites inserts static files ( css, images, js, ecc ) in a subdomain like media.example.com or s2.static.example.com ? What are the advantages ? Why not just a directory like example.com/media/ ? ...

Is it bad practice to have state in a static class?

I would like to do something like this: public class Foo { // Probably really a Guid, but I'm using a string here for simplicity's sake. string Id { get; set; } int Data { get; set; } public Foo (int data) { ... } ... } public static class FooManager { Dictionary<string, Foo> foos = new Dictionary...

How are static variables with the same name in different functions identified by the System?

AFAIK, we can have two static variables with the same name in different functions? How are these managed by the compiler and symbol table? How are their identities managed seperately? ...

Injecting values for static constants in Spring

In one of my classes there is a public static String member and I need set this value in the applicationContext.xml! That is, is it possible for us to inject a value for this static property? ...

Static Memory allocation & Portability

I have read Static Memory Allocation are done during Compile time. Is the 'address allocated' used while generating executables ? Now, I am in doubt how the memory allocation is handled when the code executable is transferred completely onto a new system. I searched for it but I didn't get any answer on the internet. ...

Java: implementation of simple commands

I have created a pkg for my regular simple commands. They are non-static, to be more extensible, but somewhat more time-consuming to use because of creating object to use one. My other classes use them. $ ls *.java CpF.java IsBinary.java RmLn.java Tools.java F2S.java IsRoot.java SaveToDisk.java WordCount.j...

htaccess hotlinking problem

Hi! Iam fighting following problem with little success. I want to block hotlinking to images in static folder from other domains than my_domain.com htaccess looks like this: RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?my_domain\.com [NC] RewriteRule \.(gif|jpe?g|js|css)$ - [F,NC,L] Rewr...

PHP static objects giving a fatal error

I have the following PHP code; <?php component_customer_init(); component_customer_go(); function component_customer_init() { $customer = Customer::getInstance(); $customer->set(1); } function component_customer_go() { $customer = Customer::getInstance(); $customer->get(); } class Customer { public $id; stati...

How does GCC compile applications that reference a static library

I've read that the gcc compiler can perform certain optimization when compiling an application that references a static library, for instance - it will "pull" in only that code from the static library that the application depends upon. This helps keep the size of the application's executable to a minimum if portions of the static library...

static const double in c++

Is this the proper way to use a static const variable? In my top level class (Shape) #ifndef SHAPE_H #define SHAPE_H class Shape { public: static const double pi; private: double originX; double originY; }; const double Shape::pi = 3.14159265; #endif And then later in a class that extends Shape, I use Shape::pi. I ge...

question about static variables and extern in plain C

Is there a difference between declaring a static variable outside of a function and declaring a static variable inside a function? Also, what's the difference between declaring a variable as static and just declaring an extern variable? ...

How did it happen that "static" denotes a function/variable without external linkage in C and C++?

In C static can mean either a local variable or a global function/variable without external linkage. In C++ it can also mean a per-class member variable or member function. Is there any reference to how it happened that the static keyword that seems totally irrelevant to lack of external linkage is used to denote lack of external linkag...

Constant member

I have structure defined in some header (D3DXVECTOR3) How can I declare: static member in the class of that type and initialize it? maybe constant member of that type and init it? when i use some constructor i get error only integral can be initialized. ...

Modify static variables while debugging in Eclipse

As an extension the the question "Modify/view static variables while debugging in Eclipse", I'd like to be able to modify static variables while debugging in Eclipse. For instance and local variables, I can just choose the variable in the "Variables" view of Eclipse, and use the context menu "Change value..." to change the value. This ...

Why are static classes considered “classes” and “reference types”?

I’ve been pondering about the C# and CIL type system today and I’ve started to wonder why static classes are considered classes. There are many ways in which they are not really classes: A “normal” class can contain non-static members, a static class can’t. In this respect, a class is more similar to a struct than it is to a static cla...

Java: Cipher package (encrypt and decrypt). invalid key error

Hello folks, i am doing a class with static methods to encrypt and decrypt a message using javax.crypto. I have 2 static methods that use ecipher and dcipher in order to do what they are supossed to do i need to initialize some variables (which are static also). But when i try to use it i get InvalidKeyException with the parameters i giv...

How does the compiler know to call function once per static variable?

E.g foo1() { static const char* str = foo2(); } const char * foo2 () { ... } How does the compiler makes sure it calls foo2 just once. ...

Initilizing a static class member that depends on a private template type (C++)

Hi, I have the following situation: class Test { private: class SubType { //... }; static std::vector<SubType> v; }; Because v is static, I initilize it in the cpp file with std::vector<Test::SubType> Test::v; But this does not work, the compiler tells me that "Test::SubType" is private. What can I do about thi...