c ++ – A versatile algebraic variable class template with full operator support

I've been working on this concept in the last few days where a variable_t is of any kind T; assuming it is at least arithmeticand all that exists C ++ language operator to do that arithmetic. comparison. In front&post Officegrowth&decrement, and bit by bit Operations make sense.

I have expressed my intentions within the source code in the comments. Contact them to understand why I chose a particular course of action. My class is currently just headers to keep things as simple as possible. Since all operators are supported, most operators have two variants: a variable_t As a rhs Value that may or may not be the same type lhs Type, and the other version accepts a simple value of any T Type for his rhsand again it may or may not be the same
type as lhs Art.

This generates a lot of boilerplate code. Forgive me if this class seems to be analyzing for a long time, but I believe that it does the calculations and conversions as I intended. Again, you can read in the comments on how this class template should behave.

I also have support for std :: ostream and std :: istream to insert and extract its member data in and out electricity Objects. There are also two versions of feature templates that generate one variable_t Based on the parameter value or type passed to the function to construct this type, this is handy in use automobile when declaring a type variable_t to create his instantiation.

#pragma once

#include 

Namespace math {

/ ******************************************************************************************* * ************************
* REMARKS:
*
* The design of variable_t has the following characteristics:
* The LHS always takes precedence over the RHS and this is intentional.
*
* The type conversion is always based on the type of the left side.
* Memory width (size) and precision are not always kept as a cut
* and or narrowing is expected.
*
* If broadening or higher precision needs to be maintained, it will be done automatically
* is done with the keyword auto and variable_t Creation functions.
*
* ---------------------------------------- //
* Example: - reduction expected //
* ---------------------------------------- //
*
* // This causes f1 to still be a float type.
* variable_t f1 (5,2f);
* variable_t d1 (7,9)
* variable_t ui64 (100);
* f1 + = d1 / ui64;
*
* f1 == 5,279
* ---------------------------------------- //
*
* If the auto keyword is used as such:
* auto x = d1 + f1;
* then x should be a variable_t in this case
     * and broadening and precision reserved
*
* This type of design is intentional, as I believe it exists
* The user has more flexibility to have the choice to either cut off
* Data if the extra bits are not needed or to get data if
* it is necessary.
*
* This allows the library to be versatile and prevents users
* You do not have to be forced to adhere to a specific compliance or policy
* Give them the flexibility they need.
*
* ------------------------------------------------- ------------------
*
* Any division by 0 causes the LHS to be 0.
* no expetions are thrown. This is something the user
* must be aware, and that is intended!
*
* Example:
* // Generated
* auto t1 = variable (3.5); variable_t t1 (3,5);
* auto t2 = variable (4); variable_t    t2 (4);
*
*
* auto t3 / = (t1 + 0.5 - t2);
*
* t3 / = (3.5 + 0.5 - 4)
* t3 / = (0) variable_t t3 (0,0);
*
* ------------------------------------------------- ------------------
*
* For all bitwise operators that normally perform bit-wise calculations
* assumes that both arguments are of type Integral. To achieve this
* class to support all bitwise operators is bitwise allowed
* Operations on floating-point types, but the user must be aware of this
* The fact that both the LHS and the RHS are implicitly converted or converted to the Int type
* then the bitwise calculation is performed and the resulting value is
* Assign the returned lhs value to the lhs type.
*
* Example:
*
* ---------------------------------------- //
*
* variable_t f1 {5,2};
* variable_t d1 {7.9};
* variable_t ui64 {0};
*
* ui64 = f1 & d1;
*
* // ui64 has a value of 5.
*
* // Let's look at the conversions
* // f1 converts to int = 5;
* // d1 converts to int = 7;
* // 5 & 7 = 5;
* // then 5 is converted back to uint64_t and assigned
* // to ui64
* /

template
    Class variable_t {
Ty t;
Public:
// -----------------------------------------------
// constructors and access operators

// default constructor
Inline variable_t (): t {0} {}
// Explicit constructor
explicit inline variable_t (tt val): t {val} {}

// copy constructor, where both types are the same
inline variable_t (const variable_t& rhs) {this-> t = rhs (); }

// copy constructor, where both types are different
template
        inline variable_t (const variable_t& rhs) {this-> t = static_cast(rhs ()); }

// Basic operator () returns an internal private member
// instead of having or using an accessor function
Ty operator () () const {return t; }
// As above: any value passed has no effect, as it returns only member
// This is not required, just another way to access the internal member
Ty operator[](unsigned n) const {return t; }

// overloaded operator (), which takes a value of type Ty and changes its status or value
variable_t& operator () (const Ty t) {
variable_t v {t};
* this = v;
return * this;
}

// ---------------------
// assignment operators

// assignment: Both types are the same: variable_t = variable_t
        inline variable_t& operator = (const variable_t& rhs) {
this-> t = rhs ();
return * this;
}

// assignment: Both types are different: variable_t = variable_t - rhs is converted to lhs
template
        inline variable_t& operator = (const variable_t& rhs) {
this-> t = static_cast(rhs ());
return * this;
}

// assignment: Both types are the same: variable_t = Ty
inline variable_t& operator = (const Ty & rhs) {
this-> t = rhs;
return * this;
}

// assignment: Both types are different: variable_t = T - rhs is thrown to lhs
template
        inline variable_t& operator = (const T & rhs) {
this-> t = static_cast(Rhs);
return * this;
}

// composite assignment

// Addition
template
        inline variable_t& operator + = (const variable_t& rhs) {
this-> t + = static_cast(rhs ());
return * this;
}
template
        inline variable_t& operator + = (const T & rhs) {
this-> t + = static_cast(Rhs);
return * this;
}

// subtraction
template
        inline variable_t& operator - = (const variable_t& rhs) {
this-> t - = static_cast(rhs ());
return * this;
}
template
        inline variable_t& operator - = (const T & rhs) {
this-> t - = static_cast(Rhs);
return * this;
}

// multiplication
template
        inline variable_t& operator * = (const variable_t& rhs) {
this-> t * = static_cast(rhs ());
return * this;
}
template
        inline variable_t& operator * = (const T & rhs) {
this-> t * = static_cast(Rhs);
return * this;
}

// classification
template
        inline variable_t& operator / = (const variable_t& rhs) {
if (rhs () == 0) {
this-> t = 0;
}
otherwise {
Ty inv = 1 / static_cast(rhs ());
this-> t * = inv;
}
return * this;
}
template
        inline variable_t& operator / = (const T & rhs) {
if (rhs == 0) {
this-> t = 0;
}
otherwise {
Ty inv = 1 / static_cast(Rhs);
this-> t * = inv;
}
return * this;
}

// module
template
        inline variable_t& operator% = (const variable_t& rhs) {
this-> t% = static_cast(rhs ());
return * this;
}
template
        inline variable_t& operator% = (const T & rhs) {
this-> t% = static_cast(Rhs);
return * this;
}

// Bitwise &
template
        inline variable_t& operator & = (const variable_t& rhs) {
int val = static_cast(this-> t);
val & = static_cast(rhs ());
variable_t v {static_cast(Val)};
* this = v;
return * this;
}
template
        inline variable_t& operator & = (const T & rhs) {
int val = static_cast(this-> t);
val & = static_cast(Rhs);
variable_t v {static_cast(Val)};
* this = v;
return * this;
}

// Bitwise |
template
        inline variable_t& operator | = (const variable_t& rhs) {
int val = static_cast(this-> t);
val | = static_cast(rhs ());
variable_t v {static_cast(Val)};
* this = v;
return * this;
}
template
        inline variable_t& operator | = (const T & rhs) {
int val = static_cast(this-> t);
val | = static_cast(Rhs);
variable_t v {static_cast(Val)};
* this = v;
return * this;
}

// Bitwise ^
template
        inline variable_t& operator ^ = (const variable_t& rhs) {
int val = static_cast(this-> t);
val ^ = static_cast(rhs ());
variable_t v {static_cast(Val)};
* this = v;
return * this;
}
template
        inline variable_t& operator ^ = (const T & rhs) {
int val = static_cast(this-> t);
val ^ = static_cast(Rhs);
variable_t v {static_cast(Val)};
* this = v;
return * this;
}

// Bitwise <<
template
        inline variable_t& operator << = (const variable_t& rhs) {
int val = static_cast(this-> t);
val << = static_cast(rhs ());
variable_t v {static_cast(Val)};
* this = v;
return * this;
}
template
        inline variable_t& operator << = (const T & rhs) {
int val = static_cast(this-> t);
val << = static_cast(Rhs);
variable_t v {static_cast(Val)};
* this = v;
return * this;
}

// bitwise >>
template
        inline variable_t& operator >> = (const variable_t& rhs) {
int val = static_cast(this-> t);
val >> = static_cast(rhs ());
variable_t v {static_cast(Val)};
* this = v;
return * this;
}
template
        inline variable_t& operator >> = (const T & rhs) {
int val = static_cast(this-> t);
val >> = static_cast(Rhs);
variable_t v {static_cast(Val)};
* this = v;
return * this;
}

// ------------------------------------
// arithmetic

// Unary - Addition
inline variable_t operator + () const {
Return variable_t(+ this-> t);
}

// Unary - negation
inline variable_t operator- () const {
Return variable_t(-this-> t);
}

// compliment
inline variable_t& operator ~ () {
this-> t = ~ this-> t;
return * this;
}

// binary

// Addition
template
        inline variable_t operator + (const variable_t& rhs) const {
Return variable_t(this-> t + static_cast(rhs ()));
}
template
        inline variable_t operator + (const T & rhs) const {
Return variable_t(this-> t + static_cast(Rhs));
}

// subtraction
template
        inline variable_t operator- (const variable_t& rhs) const {
Return variable_t(this-> t - static_cast(rhs ()));
}
template
        inline variable_t operator- (const T & rhs) const {
Return variable_t(this-> t + static_cast(Rhs));
}

// multiplication
template
        inline variable_t operator * (const variable_t& rhs) const {
Return variable_t(this-> t * static_cast(rhs ()));
}
template
        inline variable_t operator * (const T & rhs) const {
Return variable_t(this-> t * static_cast(Rhs));
}

// classification
template
        inline variable_t operator / (const variable_t& rhs) const {
variable_t var (* this);
if (rhs ()! = 0) {

Ty inv = 1 / static_cast(rhs ());
var.t = var.t * inv;
}
otherwise {
var = variable_t(0);
}

return var;
}
template
        inline variable_t operator / (const T & rhs) const
variable_t var (* this);
if (rhs! = 0) {
Ty inv = 1 / static_cast(Rhs);
var.t = var.t * inv;
}
otherwise {
var = variable_t(0);
}
return var;
}

// module
template
        inline variable_t operator% (const variable_t& rhs) const {
Return variable_t(this-> t% static_cast(rhs ()));
}
template
        inline variable_t operator% (const T & rhs) const {
Return variable_t(this-> t% static_cast(Rhs));
}


// Bitwise &
template
        inline variable_t operator & (const variable_t& rhs) const {
int lhs = static_cast(this-> t);
int val = lhs & static_cast(rhs ());
Return variable_t(static_cast(Val));
}
template 
        inline variable_t operator & (const T & rhs) const {
int lhs = static_cast(this-> t);
int val = lhs & static_cast(Rhs);
Return variable_t(static_cast(Val));
}

// Bitwise |
template
        inline variable_t operator | (const variable_t& rhs) const {
int lhs = static_cast(this-> t);
int val = lhs | static_cast(rhs ());
Return variable_t(static_cast(Val));
}
template
        inline variable_t operator | (const T & rhs) const {
int lhs = static_cast(this-> t);
int val = lhs | static_cast(Rhs);
Return variable_t(static_cast(Val));
}

// Bitwise ^
template
        inline variable_t operator ^ (const variable_t& rhs) const {
int lhs = static_cast(this-> t);
int val = lhs ^ static_cast(rhs ());
Return variable_t(static_cast(Val));
}
template
        inline variable_t operator ^ (const T & rhs) const {
int lhs = static_cast(this-> t);
int val = lhs ^ static_cast(Rhs);
Return variable_t(static_cast(Val));
}

// Bitwise <<
template
        inline variable_t operator << (const variable_t& rhs) const {
int lhs = static_cast(this-> t);
int val = lhs << static_cast(rhs ());
Return variable_t(static_cast(Val));
}
template
        inline variable_t operator << (const T & rhs) const {
int lhs = static_cast(this-> t);
int val = lhs << static_cast(Rhs);
Return variable_t(static_cast(Val));
}

// bitwise >>
template
        inline variable_t operator >> (const variable_t& rhs) const {
int lhs = static_cast(this-> t);
int val = lhs >> static_cast(rhs ());
Return variable_t(static_cast(Val));
}
template
        inline variable_t operator >> (const T & rhs) const {
int lhs = static_cast(this-> t);
int val = lhs >> static_cast(Rhs);
Return variable_t(static_cast(Val));
}

// ------------------------------------------------ -
// Increment - Decrement operators
variable_t& operator ++ () {
this-> t ++;
return * this;
}

variable_t operator ++ (int) {
auto v (* this); // copy
operator ++ (); // pre-increment
return v; // return old value
}

variable_t& Operator - () {
this-> t--;
return * this;
}

variable_t& operator - (int) {
auto v (* this); // copy
Operator--(); // pre-decrement
return v; // return old value
}


// ------------------------------------------------
// comparison operators
template
        Inline Boolean operator == (const variable_t& rhs) const {
return (this-> t == static_cast(rhs ()));
}

template
        Inline Boolean operator == (const T & rhs) const {
return (this-> t == static_cast(Rhs));
}

template
        Inline bool operator! = (const variable_t& rhs) const {
return! (* this == rhs);
}

template
        Inline bool operator! = (const T & rhs) const {
return! (this == rhs);
}

template
        Inline Boolean <(const variable_t& rhs) const {
return (this-> t <static_cast(rhs ()));
}

template
        Inline Bool operator<(const T& rhs) const {
            return (this->t <static_cast(Rhs));
}

template
        Inline Boolean operator <= (const variable_t& rhs) const {
return (this-> t <= static_cast(rhs ()));
}

template
        Inline Bool operator<=(const T& rhs) const {
            return (this->t <= static_cast(Rhs));
}

template
        Inline Boolean> (const variable_t& rhs) const {
return (this-> t> static_cast(rhs ()));
}

template
        Inline bool operator> (const T & rhs) const {
return (this-> t> static_cast(Rhs));
}

template
        Inline Boolean operator> = (const variable_t& rhs) const {
return (this-> t> = static_cast(rhs ()));
}

template
        Inline bool operator> = (const T & rhs) const {
return (this-> t> = static_cast(Rhs));
}

};

template
    automatic variable (const T & t) {
Return variable_t(T);
}

template
    automatic variable (T & T) {
Return variable_t(T);
}

template
    inline std :: ostream & operator << (std :: ostream & os, const variable_t& v) {
return os << v ();
}

template
    inline std :: istream & operator >> (std :: istream & is, variable_t& v) {
T val;
is >> val;
v = variable_t(Val);
Return is;
}
}

To keep it short, I did not specify a use case application code. just the header file itself. I've tested most operators and they seem to behave as expected so far. Feel free to experiment with this class.

The idea is that you can easily mix different types and do any kind of computation that you normally can not do that easily because this class handles all type conversions. However, there are some underlying aspects of this class that the user needs to know before using them. They are described in the comments.


How I want to use this class:

  • It is used in other classes I work on that are not shown here
    • term_t – a single term of an algebraic expression like 2x ^ 2 + 3x from where 2x ^ 2 is a term and 3x is another term. Here the variable_t Class would be used instead of the x in these terms.
    • template Class expression_t; – The full rhs or lhs Algebraic expression.

What I would like to know:

  • What are your general thoughts about this overall design?
  • Are there any possibilities for improvement?
  • Are there any corner cases or pitfalls that I have overlooked or overlooked?
  • Would this be considered under modern C ++ practices?
    • I have no support for c ++ 20 so the proposed <=> Operator is not available to me. I am currently bound to c ++ 17
  • Are there any other operators that should be included or excluded?
  • What could I do to make it as universal, portable, readable and reusable as possible?

Entities – Setup – Profile entity type missing form class

The following error is displayed

Drupal Component Plugin Exception InvalidPluginDefinitionException:
The entity type "Profile" has not specified a form class "Employee". in the
Drupal Core Entity EntityTypeManager-> getFormObject () (line 223 of
/Library/WebServer/Documents/profiledemo/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php).

I researched and found the solution for entity types of users and nodes, but I'm not sure what it can be for the profiles.

Function mymodule_entity_type_build (Array & $ entity_types) {
$ entity_types['user']-> setFormClass (& # 39; step1 & # 39 ;, "Drupal  user  RegisterForm"); // works for user registration form
}

Note what replacement is required for

"Drupal user RegisterForm"

Is this the attempt when the application class is used to break MVVM patterns?

In my application, I use two view models. MainViewModel If he is angry, if MianWindow will be initialized. And Update viewmodel is violent when update Window will be initialized.

The Update VM should use data from a collection owned by the Main VM and has its instance aready, and I have to refer to it somehow. And I wondered, refers to this collection MainViewModel vm = (MainViewModel) win.DataContext; does the MVVM pattern or testability somehow break or is it some kind of antipattern? Or maybe the collections have to be handed over Update VM as a parameter and sent back? Many Thanks.

The code:

public class UpdateViewModel: ViewModelBase
{
public UpdateViewModel ()
{
Jockeys = new ObservableCollection();

PopulateCollections ();
}

private void PopulateCollections ()
{
MainWindow win = Application.Current.Windows.OfType() .FirstOrDefault ();
MainViewModel vm = (MainViewModel) win.DataContext;

Jockeys = vm.jockeys; //It is OK?

vm.Jockeys // is it ok?
}

public observable collection Jockeys {get; private set; }

}

c ++ – If a class A contains a class B as an element variable, what are the pros and cons of A if it contains the object B compared to a pointer to object B?

What are the benefits of A when using the stack to allocate object B versus using the heap store over pointers? Consider

Class B {
Public:
B () {
}
void fun () {
}
};

Class a {
Public:
A (): b () {
}

void fun () {
b.fun ();
}
Private:
Bb;
};

Where the object b is used by ON, vs

Class a {
Public:
A (): b (new B ()) {
}
void fun () {
b-> fun ();
}

~ A () {
delete b;
}
Private:
B * b;
}

int main () {
A a;
a joke();
}

What are the advantages of the former over the latter, since Class B is used exclusively in Class A. In the former case, object B is allocated in the stack, while in the latter case object B is allocated on the heap. When should one use the former against the latter?

Consider B as a class that reads UDP protocols from a socket. Class A thus repeatedly calls B's read function to read from the log. Everything about B is known at compile time.

Javascript – adding events in the same class multiple times

I'm not sure how to label this post because I'm a bit confused here. My code updates a field in the line. This happens in two separate functions. It works fine, but I'm wondering if it's possible to handle it in just one function.

Here is the HTML Code. The form is displayed on hover Only and value is updated at change,

{% csrf_token%} {{}} Prestation.d_length

And the Javascript:





// Editable in line fields

$ (& # 39;. Editable & # 39;). hover (function () {
var el_text = this.lastElementChild;
var el_input = this[1];
$ (el_text) .toggleClass (& # 39; collapse & # 39;);
$ (el_input) .toggleClass (& # 39; collapse & # 39;);
});

$ (& # 39;. Editable & # 39;). change (function () {
event.preventDefault ();
var el_text = this.lastElementChild;
var action = this.action;
var method = this.method;
var data = $ (this) .serialize ();

$ .ajax ({
URL: Action,
Type: Method,
Data: data,
}). done (function (resp) {
el_text.textContent = resp.data
});
});

I'm not sure if it's right to add multiple functions to a class.

Ashburn SEO Dedicated | Clean IPs as low as $ 0.10ct / ip! | 13x / 23s different class A / B / C | NO IPJ!

ASHBURN SEO SPECIAL:

Quad Core, 2.4 GHz,
32 GB RAM
140 GB hard drive
1G port
BANDWIDTH: 10 TB / 100 MB
Operating system: CentOS 6.6 x 64bit
Port 25 / SMTP traffic blocked by default
Basic management
1 x / 22 IPv4 addresses

We have THREE servers at this location with a clean 1 x 22 available. These are available for shoe stores, cockroaches, or similar purposes that need this geographic location for latency purposes. These will be sold subject to availability. No tests may be performed before purchase. If you have set up your own server, LOAs are also available (term commit). Your final IPv4 price depends on the RIR, allocation size, runtime commitment, and the quality of IPs you need. NOTE: WE HAVE / 24 – / 16 OVER ALL REGIONS. YOUR FINAL PRICE IS DETERMINED BY THE QUALITY OF IPV4 YOU NEED (ie, clean compared to the one used), the TERM COMMIT, the ASSIGNMENT SIZE, the prepayment, and the REGION (ie, Reif, cheaper than Arin).

NOTE: If required we can also make a DSL line with "Carrier IPS" (ie Verizon, Comcast etc.) out of Ashburn. Contact sales@@blazingswitch.com directly with your needs and budget.

====================================== === ==========

LOS ANGELES SEO DEDICATED / 22 SPECIAL:

Four core
8 GB RAM
250 GB hard drive
1G port
BANDWIDTH: 10 TB / 100 MB
Operating system: CentOS 6.6 x 64bit
Port 25 / SMTP traffic blocked by default
Basic management
1024 IPv4 addresses at 0.7 ct / ip **

We have TWO servers at this location (Los Angeles) with a clean 1 x 22, which are available at a reduced price. These will be sold subject to availability. No tests may be performed before purchase. You have 24 hours from delivery time to report problems. If you have set up your own server, LOAs are also available (commit) @ $ 3000.00 for a 6-month term. Your final IPv4 price depends on the RIR, allocation size, runtime commitment, and the quality of IPs you need. We have allocations of / 24 – / 16 available in different regions, prices vary according to need and duration. Server upgrade available at additional monthly recurring costs.

** This price is a discount of 12 months in advance, which is delivered on a server.

====================================== === ==========

MIXED SUBNET SEO SPECIAL:

Quad Core, 2.4 GHz,
32 GB RAM
140 GB hard drive
1G port
BANDWIDTH: 10 TB / 100 MB
Operating system: CentOS 6.6 x 64bit
Port 25 / SMTP traffic blocked by default
Basic management

– 193.xxx.xx.0 / 23
– 194.xxx.xx.0 / 23
– 80.xx.xx.0 / 23
– 85.xx.xx.0 / 23
– 193.xx.xx.0 / 23
– 37.xxx.xxx.0 / 23
– 92.xxx.xx.0 / 23
– 193.xxx.xx.0 / 23
– 194.xxx.xx.0 / 23
– 80.xx.xx.0 / 23
– 193.xx.xx.0 / 23
– 37.xxx.xxx.0 / 23
– 92.xxx.xx.0 / 23

We have ONE server with this mixed bag of RIPE assortments. This is the perfect solution for a SEO, VPN or proxy web hosting company looking for mixed long-term CIDR clean areas. The ranges are delivered on a server and are based on the US .. server upgrades, which are available at an additional cost. These are sold as a package, so you should take ALL. We are not interested in separating them if we can find a good customer for them.

====================================== === ==========

CPU: E3-1230
RAM: 16 GB
STORAGE: 1 TB SATA
BANDWIDTH: 10 TB / 100 MB
Operating system: CentOS 6.6 x 64bit
Port 25 / SMTP traffic blocked by default
Basic management

SEO IPS:

* Best Effort Straight Allocation / 24's & Higher from $ 0.30ct / ip (up to a / 16)!
* 1 / ip x 1400 different ARIN classes A / B / C or 10 x / 28 different classes A / B / C @ $ 2 / ip
* 100% Virgin Clean Ranges 24 & # 39; s @ $ 1.50 / ip

The discounted direct allocation price depends on the RIR (Arin, maturity, etc.), the size of your allocation, and the term commitment. The longer the allocation, the cheaper the price. ARIN is more expensive than other RIRs. For discounted allocations, a server with purchase is required. Server and IPv4 vary depending on location and inventory at the time of purchase. If you are just looking for a LOA, add 0.10 ct / ip. The price is grandfather. So, if you lose the area for non-payment, abuse, etc., there is no guarantee that you will get the area back for the same price. The promotion is based on limited availability. For those who need 10-30,000 ips, different staggering prices may apply. Mixed subnet servers (1 / ip x 1400 or 10 x / 28 for different classes-a / b / c) are a premium service and are chargeable (details below). In addition, port 25 / SMTP is blocked. The above discounts apply only to / 24 direct assignments, not less.

If you have any questions, please do not hesitate to contact us sales@blazingswitch.com,

====================================== === ==========

ADDITIONAL GEO LOCATIONS SUPPLEMENTED:

– Ashburn, VA
– Atlanta AT1
– Austin
– Dallas-1
– Dallas-2
– Denver
– Detroit
– Las Vegas
– Los Angeles-1
– Los Angeles-2
– Los Angeles-3
– New York-1
– New York-2
– Phoenix
– Pittsburgh
– San Jose
– Seattle-1
– Seattle-2
– Tampa

INTERNATIONAL:
– Amsterdam
– Barcelona
– Dubai
– Dublin
– Frankfurt-FR5
– Guadalajara
– Hong Kong
– Istanbul
– Johannesburg
– Korea
– Leeds, United Kingdom
– London, United Kingdom
– Mexico
– Mexico City
– Milano
– Paris
– Rome
– Singapore
– Sydney
– Tokyo TY2
– Toronto

Note: Some of these locations are premium services / prices. However, if you really need these locations for data centers or RDP locations, they are possible if you have the budget.

====================================== === ==========
THE FOLLOWING AVAILABLE AS PREMIUM SERVICES
======================================= == ===========

PREMIUM SEO MIXED SUBNET SERVER:

CPU: E3-1230
RAM: 16 GB
STORAGE: 1 TB SATA
BANDWIDTH: 10 TB / 100 MB
Operating system: CentOS 6.6 x 64bit
IPS: 16 x / 28 each on a different class C

Port 25 / SMTP traffic blocked by default
Basic management
LOCATION: United States
Available as a premium service

CPU: quad-core processor
RAM: 8 GB DDR
STORAGE: 500 GB SATA
PORT: 1 Gbps port speed
BANDWIDTH: 20 TB of traffic
Operating system: CentOS 6.6 x 64bit
IPS: 1 / ip x 100 different class C

Port 25 / SMTP traffic blocked by default
Basic management
Available as a premium service

CPU: quad-core processor
RAM: 8 GB DDR
STORAGE: 500 GB of memory
PORT: 1 Gbps
BANDWIDTH: 20 TB of traffic
Operating system: CentOS 6.6 x 64bit
IPS: 2048 IPv4 addresses (8x / 24 each on a different class B)

Port 25 / SMTP traffic blocked by default
Basic management
Available as a premium service

NOTE:
Not available in all data center locations and limited by inventory. Additional configurations available in ARIN & RIPE.

* 1200+ x / 29 available in the USA.
* 130+ x / 29 available in the EU.
* 5000+ Class C, 250+ Class B

====================================== === ==========

PREMIUM SERVICE:

* Mixed class A / B / C subnets
* SEO / GEOIP (databases / swip updated with the location you need)
* IPv4 ROTATIONS
* Pre-tested, clean social network / data scrapper IPv4
* Multiple areas of different shipping notifications
* Clean, clean IPv4 addresses

Premium Services are only available for the purchase of discounts or promotions if announced. These are available at extra cost.

======================================= == ===========

If you need a mixed A / B / C subnet server or a dedicated GEOIP server, we have it in both VPS and Dedicated.

* 4 x / 26 – yes
* 8x / 27 – yes
* 16×28 – yes

These configurations are not available at all sites / data centers.

GEO / SEO LOCATIONS AVAILABLE:

– Atlanta
– Bend OR
– Buffalo
– Charlotte, NC.
– Chicago
– Dallas
– Detroit
– Houston
– Jacksonville, FL
– Las Vegas
— Los Angeles
– Miami
– Monticello, IA
– New York / New Jersey
– Orlando
– Pasadena, CA.
– Phoenix
– Portland
– San Jose
– Seattle
– South Bend, IN

INTERNATIONAL:

– Australia, New Zealand
– Belgium
– Bulgaria
— Germany
– India
– Italy
– Netherlands
– Portugal
– Romania
— Sweden
— Turkey
– Ukraine
— Great Britain
– Vietnam

Inventory changes daily, which is possible in different data centers. However, these are premium services that would not fall under a kind of advertising price. Further locations and options can be found on our website. Please contact the sales department if you have special requirements with your budget.

======================================= == ===========

SERVER ORDERS:
you Got to consist Pre-screen at registration to be eligible for the service. When you sign up for a proxy, VPN, or use information that does not match your geoip, you are often flagged as a possible fraud in the billing software and your order is rejected. In addition, some orders have been received requiring manual review based on the MaxMind and FraudRecord rating prior to final approval. The delivery time is usually 48 to 72 business hours from receipt of payment, depending on the hardware and the complexity of the IPv4 network.

PAYMENTS:
We accept payments by Paypal, credit card and bank transfer.

ADDITIONAL COMMENTS:
If you are disconnected or abused for non-payment, you are not eligible to make additional purchases.

UPDATE GEOIP:
We can also assign SWIP and update GEOIP via MaxMind / Databases for your locations.

======================================= == ===========

What makes us different?

* IPv4 from all over the world in different RIRs for maximum diversity
* Hundreds of Class A / B / C areas in different data centers
* Knowledge of the SEO industry as a developer
* Focus on long-term relationships. No Churn & Burn clients or resources.
* IPv4 for every realistic budget
* Willingness to work with your individual needs
* Verizon Wireless RDP lines with unlimited revolutions that you control!

======================================= == ===========

ASK?
Open a SUPPORT TICKET before ordering.

* Cheap BUDGET IPv4 for those who offer SEO / Proxy / VPN solutions where IP quality is not as important.
* Pre-tested clean IPs available
* GEOip available
* Verizon RDP (unlimited IP rotations you control)
* LOAs (Runtime Commit / Pre-Pays) available
* 1000 x 29 on different class C

With over ONE MILLION of IPv4 addresses in many different regions and CIDRs, we have something for everyone up to an assignment of / 16 depending on usage. Contact us via support ticket with your needs. The more details you can specify, the easier we can match ips to your final needs.

object-oriented – PHP Error Handler class

I have set up an error handling class to handle all server errors. I know that there are already some, but I like to make my own to better learn and understand how things work.
I'm currently using this in a framework I'm working on (again for study purposes), and it works the way it should.

With this error handler you can:

  1. Select whether the error should be logged
  2. Select the file in which you want to log it
  3. Send the error to an e-mail if enabled
  4. Add a custom error page
  5. Set a custom generic error message if no error page is set

How it works and is set up:

  1. You set up your app settings:




/ * App settings
====================================================

// app name
define ("APP_NAME", "Test App");

// App URL
define ("APP_URL", "https://testapp.com");

// Support e-mail
define ("APP_SUPPORT_EMAIL", "support@testapp.com");



/ * Error handling settings (used in ErrorHandler.php)
====================================================

// set debug mode
define ("DEBUG_MODE", true);

// Log errors
define ("LOG_ERRORS", true);

// Send bug reports to email
define ("SEND_ERROR_EMAILS", true);

// Send e-mail to send the error reports
define ("ERROR_REPORTING_EMAIL", "security@testapp.com");

// Path to the error log file
define ("ERROR_LOG_PATH", $ _SERVER['DOCUMENT_ROOT']msgstr "/../ logs / error_log.log");

// path to error page "500"
define ("ERROR_PAGE_PATH", $ _SERVER['DOCUMENT_ROOT']msgstr "/../ framework / defaults / pages / error500.php");

// default error message (if no error page has been set or found)
define ("PUBLIC_ERROR_MESSAGE", "Looks like an error has occurred, we're already testing it!");

Then load the error handler either with an automatic loader or directly (depending on how the developer chooses it). Then set the error handler as the default.
set_error_handler (array (new ErrorHandler (), & # 39; handleError & # 39;));

And for the actual error handling class:

debugMode = (defined (& # 39; DEBUG_MODE & # 39;)? DEBUG_MODE: $ this-> debugMode);
$ this-> logErrors = (defined (& # 39; LOG_ERRORS & # 39;)? LOG_ERRORS: $ this-> logErrors);
$ this-> sendEmail = (defined (& # 39; SEND_ERROR_EMAILS & # 39;)? SEND_ERROR_EMAILS: $ this-> sendEmail);
$ this-> securityEmail = (defined (& # 39; ERROR_REPORTING_EMAIL & # 39;) && filter_var (ERROR_REPORTING_EMAIL, FILTER_VALIDATE_EMAIL)? ERROR_REPORTING_EMAIL: $ this-> securityEmail);
$ this-> publicErrorMessage = (defined (& # 39; PUBLIC_ERROR_MESSAGE & # 39;)? PUBLIC_ERROR_MESSAGE: $ this-> publicErrorMessage);
$ this-> appName = (defined (& # 39; APP_NAME & # 39;)? APP_NAME: $ this-> appName);
$ this-> appSupportEmail = (defined (& # 39; APP_SUPPORT_EMAIL & # 39;) && filter_var (APP_SUPPORT_EMAIL, FILTER_VALIDATE_EMAIL)? APP_SUPPORT_EMAIL: $ this-> appSupportEmail);


// Create new class properties from defined constants, if set
$ this-> errorLogPath = (defined (& # 39; ERROR_LOG_PATH & # 39;)? ERROR_LOG_PATH: $ _ SERVER['DOCUMENT_ROOT']msgstr "/../ logs / error_log.log");
$ this-> errorPagePath = (defined (& # 39; ERROR_PAGE_PATH & # 39;)? ERROR_PAGE_PATH: $ _ SERVER['DOCUMENT_ROOT']msgstr "/../ framework / defaults / pages / error500.php");
}



/ * Handle errors
=================================================
public function handleError ($ errno, $ errstr, $ errfile = false, $ errline = false) {

// save the error data
$ this-> errno = $ errno;
$ this-> errstr = $ errstr;
$ this-> errfile = $ errfile;
$ this-> errline = $ errline;


// Get the current file in which this error occurred
$ link_array = explode (& # 39 ;, $ this-> errfile);
$ this-> failedOnFile = end ($ link_array);


// if logging of errors is enabled
if ($ this-> logErrors) {
$ this-> saveToLog ();
}


// if e-mail reporting is enabled
if ($ this-> sendEmail && $ this-> securityEmail) {
$ this-> sendToEmail ();
}


// Load the error page
$ this-> loadErrorPage ();
}



/ * Save the error in a log
=================================================
private function saveToLog () {

// Get the error string
$ errorString = $ this-> getErrorString ();


// save the error in the log
error_log ($ errorString, 3, $ this-> errorLogPath);
}



/ * Send the error to the selected e-mail
=================================================
private function sendToEmail () {

// Get the error string
$ errorString = $ this-> getErrorString (true);


// put the email headers
$ headers = "MIME version: 1.0". " r  n";
$ headers. = "Content Type: Text / HTML; Character Set = UTF-8". " r  n";
$ headers. = "From:". $ this-> appName. "Security <".$this->security email. ">  r  n";
$ headers. = "Answer to:". $ this-> securityEmail. "". " r  n";


// Send the e-mail
@mail ($ this-> securityEmail, "An error has occurred", $ errorString, $ headers);
}



/ * Load the error page
=================================================
private function loadErrorPage () {

// If there is no error page path or the file does not exist, a message is issued
if (! $ this-> errorPagePath ||! file_exists ($ this-> errorPagePath)) {

// Output a general error message
echo $ this-> publicErrorMessage;


// If the debug mode is activated, the error is output
if ($ this-> debugMode) {
echo "

"; echo $ this-> getErrorString (true); } Exit(); / * If an error page path exists and exists, enclose it * The file itself has access to the error string * Outputs when debug mode is enabled. * Custom error files can be used by defining the constant ERROR_PAGE_PATH * / }otherwise{ include ($ this-> errorPagePath); Exit(); } } / * Set up the error string to be logged or e-mailed * Receives an argument for the type of output. * Lines are separated by n or
(based on the $ output argument). ================================================= private function getErrorString ($ output = false) { // Switch between the error numbers and set up the error type variable switch ($ this-> errno) { case E_NOTICE: case E_USER_NOTICE: case E_DEPRECATED: case E_USER_DEPRECATED: case E_STRICT: $ errorType = "NOTE"; break; case E_WARNING: case E_USER_WARNING: $ errorType = "WARNING"; break; case E_ERROR: case E_USER_ERROR: case E_RECOVERABLE_ERROR: $ errorType = "FATAL"; Default: $ errorType = "UNKNOWN"; } // Set up the delimiter based on the $ output argument if ($ output) { $ separator = "
"; }otherwise{ $ separator = " n"; } // Set up the error string $ errorString = $ errorType. & # 39; ['.$this->errno.'] At: #date ("j M y -g: i: s A (T)", time ()). ":". $ Separator. ""; $ errorString. = "File:". $ this-> errfile. "(Line:". $ This-> errline. ")". $ separator. ""; $ errorString. = "Message:". $ this-> errstr. "". $ separator. ""; $ errorString. = "Backtrace:". $ this-> backTraceError (). "". $ separator. ""; $ errorString. = "--------------------------------------". $ Separator. ""; // Return the error string return $ errorString; } / * Function for tracing the error ================================================= private function backTraceError () { // set up backtrace variables $ rawBacktrace = debug_backtrace (); $ cleanBacktrace = $ backtraceSeparator = & # 39; & # 39 ;; $ i = 0; // go through the backtrace foreach ($ rawBacktrace as $ a_key => $ a_value) { // If no file or line is specified, skip this iteration if (! isset ($ a_value['file']) || ! isset ($ a_value['line'])) { continue; } // Start saving the back trace from the file in which the error occurred. Skip the rest if (! isset ($ backtraceStarted) && basename ($ a_value['file'])! = $ this-> failedOnFile) { continue; }otherwise{ $ backtraceStarted = true; } // Add this file to the backtrace $ cleanBacktrace. = $ backtraceSeparator.basename ($ a_value['file']). & # 39;[#39;$a_value['$A_value['$a_value['$a_value['line'], & # 39]& # 39 ;; // set the delimiter for the next iteration $ backtraceSeparator = & # 39; <& # 39 ;; // increment the counter $ i ++; } // Return the backtrace return $ cleanBacktrace; } }

The output of the error looks like this:

WARNING [2] At: 20.06.19 - 16:28:02 (UTC):
File: /home/framework/core/Application.php (line: 9)
Message: Use of an undefined constant s - assuming & # 39; s & # 39; (this will trigger a bug in a future version of PHP)
Retrace: ErrorHandler.php [49] <application.php [9] <index.php [17]
------------------------------------------

I tried to make it as individual as possible. Since this is part of the framework I'm working on, it comes with a default setting error500.php File, but if there is none, a general message appears. Developers also have the option of using their own error pages.
The error pages have access to the properties of the error handling class because they are included so that the error and other data for debugging can be displayed.

Any feedback would be great!

JSON selection class in Python

I have created a simple little class called JSONSelector can select relevant data from a JSON object (a dictate in Python). So far I have: It's based on some SQL statements, NumPy methods, and JavaScript iteration methods:

Class JSONSelector:
def __init __ (self, json):
self.json = json

def __str __ (self):
return "{} ({})". format (type (self) .__ name__, str (self.json))
__repr__ = __str__

def select (self, selectors):
if selectors == "*":
Return type (self) (self.json)
otherwise:
temp = {}
for sel in selectors:
temp[sel] = self.json.get (sel, None)
Return type (self) (temp)

def where (self, cond):
temp = {}
for key, value in self.json.items ():
if cond (key, value):
temp[key] = Value
Return type (self) (temp)

def astype (self, type_):
temp = {}
for key, value in self.json.items ():
temp[key] = Type_ (value)
return JSONSelector (temp)

def sort (self, ** kwargs):
Return type (self) (dict (sort (self.json.items (), ** kwargs))

def foreach (self, func):
for key, value in self.json.items ():
if func (key, value) == False: break

def print (self, func = None):
if not func:
print (yourself)
return
otherwise:
print (func (self))
return

Here is a test case with an explanation:

a = JSONSelector ({
"Stuff": 5,
"seeded": 6,
"Number 7",
"more_stuff": 8
})

a.select ("*")  # Select all entries from the dictation
.where (Lambda key, value: type (value) is int)  # where the value is an integer
location (key = lambda x: x[1])  # Sort by value
.astype (str)  # Converts the values ​​to str
.foreach (lambda key, value: print (key + ":" + value)) # Scroll through all entries

I want to know if any of my codes are redundant, where I can shorten things and if something is wrong. Thank you in advance!

jquery – Removes the class of an element two levels above the clicked element

Galera, I have several DIVs right now:

XXX XXXX

If my user clicks on the DIV to see the functionality, I would like him to remove the class (dark blue) from the DIV "image functionality".

I can do all the rest of the process, but I can not remove that DIV. I can not just ask him to give a FIND, since I only have to remove the specific DIV that was clicked on.
I tried to do it with parent (), but I can only go back one level. I have also done some tests with the parentElement, but it does not allow the removeClass ("dark blue") to be used together.

Tests performed:

$ (this) .parent ("image functionality"). removeClass ("dark blue");
this.parentElement.parentElement.parentElement.removeClass ("dark blue");
this.parentElement.parentElement.parentElement.parent (".function-image") removeClass (".blue")

Confusion with C ++ pointers and class member variables

I wonder, what is the life cycle of a class member (attribute).

Currently I have this class:

Class snake {

Private:
std :: vector positions = std :: vector();

Public:
void addNode (position * position);
};

And I'm not sure if addNode needs to get a pointer or an object?
I suspect that if addNode gets a position as a parameter, the object will die as soon as it is outside the range in which it was created, e.g.

... code here ...
{
Position p = position (..);
snake.addNode (p);
}
// p should die here so it can cause a null pointer on the program

On the other hand, if addNode receives a pointer, then p would not die if I did not delete it (so it will not cause a null pointer), maybe you can help me sort out this big mess about pointers I just have.

Many Thanks.