w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to allow public or private downloads of static files with PHP 5.4 Web Server?
if(php_sapi_name() === 'cli-server') { if(is_file(__DIR__.preg_replace('#(?.*)$#', '', $_SERVER['REQUEST_URI']))) { return false; } } The solution for PHP 5.4 web server, along with starting the server itself with: php -S localhost: 80 -t /path/to/web /path/to/web/index.php This way, if /css/style.css exists it will be served statically, but /files/dynamic.css will pass through the front controller.

Categories : PHP

GWT client communicates with public server
You cannot make XHR requests to a different server from where you download your page, unless you enable CORS in the server. google.com has not enabled CORS, so you cannot request their pages usin XHR. If you own the domain you want to request enable CORS, here you have a filter example for a java backend. If you simply want to display a 3party web in your ui you can insert it as an iframe, but be aware that you cannot read the iframe content because it is in a different domain. Note that CORS works in almost browsers, but for IE/8-9 you have to use XDomainRequest

Categories : Gwt

Is there any pattern that provide similarities of public static, private and public methods and vars in JS?
"Static" methods in JavaScript are usually achieved by simply assigning a function to a property of the constructor function object: function MyClass() {} // Constructor MyClass.staticMethod = function () {};

Categories : Javascript

Singleton object w/ Private/Public: Public function dependency problems
You can simply define the functions inside (or alongside) the constructor and just "attach" them to the new instance. This way the functions are free to refer to one another as required: function PKMNType_Engine(){ "use strict"; function getEffectiveness(defenseType, offenseType){ return 1; } return { PKMNTypes_getEffectivness: getEffectiveness, PKMNTypes_getMatchup: function(type1, type2, offensiveType){ var output = getEffectiveness(type1, offensiveType) * getEffectiveness(type2, offensiveType); return output; } }; }

Categories : Javascript

Should the constructor of a private inner class be declared public or private?
As far as other classes are concerned, it shouldn't since the inner class is declared as private. They can't see it at all. It shouldn't make a difference to the enclosing class since it contains the inner class.

Categories : Java

Validating non-private IP addresses with PHP
I guess thats because 127.0.0.1 is not realy a private IP range, but a loopback IP range, as explained here Normally, when a TCP/IP application wants to send information, that information travels down the protocol layers to IP where it is encapsulated in an IP datagram. That datagram then passes down to the data link layer of the device's physical network for transmission to the next hop, on the way to the IP destination. However, one special range of addresses is set aside for loopback functionality. This is the range 127.0.0.0 to 127.255.255.255. IP datagrams sent by a host to a 127.x.x.x loopback address are not passed down to the data link layer for transmission. Instead, they “loop back” to the source device at the IP level. In essence, this represents a “short-circuiti

Categories : PHP

Client-Server Program: Client can connect to server easily but server can't respond cause target machine actively refuses connections
You need to design your client and server so that the client-to-server connection remains open to recieve the responce and then do something like this: public static bool sendTo(IPEndPoint ip, String data) { TcpClient client = null; NetworkStream stream = null; StreamWriter writer = null; StreamReader reader = null; try { client = new TcpClient(); client.Connect(ip); stream = c.GetStream(); writer = new StreamWriter(stream); writer.WriteLine(data); writer.Flush(); reader = new StreamReader(stream); string response = reader.ReadLine(); if (response == "roger-alpha-tango") { return true; } } catch { return false; } finally { i

Categories : C#

Private and Public Key
The short answer: No First you are transmitting an private key over unprotected HTTP. Second it is totally unclear what you want to achieve using a public/private key. From your description I read that you want to use it for authentication and signature. But why is the private key stored on the server? usually it is the other way around: The client has public and private key. It sends the public key to anybody who wants but th private key NEVER LEAVES THE DEVICE!

Categories : Java

Pushing to TFS git using public/private key
As per DaveShaw's comment, it's currently not supported as there is a Change request on the visual studio feedback portal. https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3801342-add-support-for-ssh-keys-as-alternate-authenticati

Categories : GIT

Private or Public TFS Build
If I were you: Edit the current build definition template to add a new boolean property (let's say Private Build). To do this, locate the Metadata argument in your XAML file and click edit, add your parameter and you can specify the visibility for your parameter Add 2 different build definitions one for private and the other for public. Private will have the "PrivateBuild" true and other one will have it as false. Read this property within your workflow and decide whether you have to run Octopack or not.

Categories : Tfs

When to use the public or private property?
You don't need a private property, only a private field would be enough so replace: private Visibility isVisible {get; set;} with private Visibility isVisible; If I am supposed to uses the public properties - what is the need for having the private ones? You cannot use Auto-properties with INotifyPropertyChanged. That is why you need a backing field for your property IsVisible. See: An elegant way to implement INotifyPropertyChanged

Categories : C#

c++: public private error
in the Class declaration it should look like class myClass{ public: myClass(); private: double x,y,z; } that is how you should use public and private, but otherwise I can't see what is wrong, plase provide the header file or the class declaration.

Categories : C++

Is app-id in private alpha public
From Google Play Support: Alpha- or beta-test apps will only appear in Google Play for testers that opt-in and not to any other users. If you've done testing yourself and just want some documentation backing it up, you can't get much better than that.

Categories : Android

Java Testing (Public, Private)
The best way would be to make it public but if that is not possible then you can also use reflection to test it. Full details can be seen here What's the proper way to test a class with private methods using JUnit?

Categories : Java

reCAPTCHA needs to be configured with a public & private key
You can create the keys that @millimoose is referring to on https://www.google.com/recaptcha/admin/create Documented here https://developers.google.com/recaptcha/intro

Categories : Asp Net

Can a class have both public and private constructor?
Can a class have both public and private constructor? Yes, it is possible. A private constructor is needed to set the private field whose type is a private inner class. Is this encouraged or discouraged ? It depends on the situation. Whether you want other class to initialize the state of your object or not. Here I think you have created class CopyTree to return the Copy of Tree which is a private class. So TreeNode class would be encapsulated, hence it leaves you with option of using private constructor capture idiom. what is a better solution for a scenario listed below ? In my view private constructor capture idiom is the better solution. For more information: you could search for private constructor capture idiom. An example is given in Solution 53 of Java Puzzler

Categories : Java

Inheritance and private/public variables
Use the existing public accessors. For example, use getBookID() in the subclass rather than attempting to access the superclass's private field directly. @Override public String toString() { String stg = getBookID() + ' ' + getTitle() + addSpaces(title, 30) + getAuthor() + addSpaces(author, 30) + getGenre() + addSpaces(genre, 15) + getStatus() + addSpaces(status, 5) + getLocation() + addSpaces(Location, 20) + getCondition(); return stg; } An alternative would be to make the field protected. However, this allows a potentially arbitrary number of subclasses to couple directly to your superclass's representation. Encapsulating the data behind a method is usually preferable. Incidentally, you might find String.format() useful. For the sy

Categories : Java

Write public/private key to the SharedPreferences and use it
Ok. I found some solution and change something. This is new class for public/private key storing and getting it again from stored string. This class works for me ! import java.security.KeyFactory; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.SecureRandom; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; import org.bouncycastle.util.encoders.Base64; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; public class KeyGenerator extends Activity{ SharedPreferences SP; SharedPreferences.

Categories : Android

Private and Public attributes using Python
You misspelled self.title, so that won't work correctly. sell_book won't run because the if statement is missing a colon. Your indentation is incorrect: class methods need to be inside the class. You aren't even running the code because the call to main() is inside your main() function. These errors can be fixed: class Book(object): def __init__(self, author, title, copies): self.__author = author self.title = title self.__copies = copies def display(self): print "author:", self.__author, " " print "Title:", self.title, " " print "Number of copies:", self.__copies, " " def sell_book(self, sold): if self.__copies < 0: print "The last cop

Categories : Python

Possible to convert RSA private+public key to .pfx file?
You can use the commandline tool openssl to convert certificatats. Try openssl pkcs12 -export -out newCertificate.pfx -inkey myKey.pem -in myCertificate.cer -name "myCertificateName@myDomain.net"

Categories : Dotnet

OOP - using private properties and public getter
Using Accessors satisfies the Uniform Access Principle. Quoting Wikipedia: The Uniform Access Principle was put forth by Bertrand Meyer. It states "All services offered by a module should be available through a uniform notation, which does not betray whether they are implemented through storage or through computation." This principle applies generally to object-oriented programming languages. In simpler form, it states that there should be no difference between working with an attribute, precomputed property, or method/query. In his blog, Fowler explains It effectively means that a client of the person should neither know nor care whether the age is stored or computed. This gives the person object the flexibility to change between the two easily as well as removing what is usual

Categories : PHP

VBA Userform set Controls as Private instead of Public
From what I've read (in Professional Excel Development by Bovey, et. al., as well as in other sources), the standard VBA solution for this is to 1) Use a Class Module to define an interface, which lists the functions (properties, subs, etc.) you want to expose. 2) In your Form Module, put an "Implements" statement and then add code that will be accessed by the public routines declared in the interface. 3) Then, in your application, use the interface rather than the form itself. So in a class module called, let's say, iProgressBar, list what you want to be publicly avaiable: Public Property Let Information(ByVal sNew As String) End Property Public Property Get Information() As String End Property Public Sub UpdateProgress(ByVal dNew As Double) End Sub 'etc... That is your interface.

Categories : Vba

in vb.net how do I declare a public variable from a private sub
When you create dynamic control, you can add a handler for it Dim mylbl As New Label mylbl.Name = "button1" mylbl.Text = "hi" Me.Controls.Add(mylbl) AddHandler lbl.Click, AddressOf AllLabels_Click This is your Handler Sub Sub AllLabels_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim lbl As Label = CType(sender, Label) MsgBox(lbl.Text) End Sub

Categories : Vb.Net

public ip of the ec2 instances redirecting to private ip
The EC2 instance is provided a public dns entry that looks something like ec2-xxx-xxx-xxx.xxx.us-west-2.compute.amazonaws.com. If you use this public domain name from an EC2 instance your private IP is returned and not the public IP. From outside AWS, the EC2-generated domain name will return the true public IP. If you put the public IP into godaddy dns, I don't see how it could possibly know the private IP. If you put in 1.2.3.4 for chef.myserver.com then 1.2.3.4 will be returned. If you cnamed godaddy to your ec2-generated dns, change it to an A record and put in the actual elastic IP address.

Categories : Ubuntu

How to know if the method is Public, Protected or Private in PHP?
You can do this using ReflectionClass and ReflectionMethod: public function check_here() { $obj = new ReflectionClass($this); return $obj->getMethod('function_three')->isPublic(); }

Categories : PHP

Use of public destructor when the constructor is private
You make constructor private if you want to prevent creating more then one instance of your class. That way you control the creation of intances not their destruction. Thus, the destructor may be public.

Categories : C++

PHP PDO: Should we set pdo's `function __construct` to `private` or `public`?
No. You're thinking about this wrong. Your public methods are the API that you're giving to other developers who use your class. At the end of writing your class, imagine you're handing your documentation for it to another developer. You'll list "endpoints" which other developers can use. These currently are: __construct() connection() Clearly you want connection() to be more something along the lines of connect() as it makes more sense for another developer looking at your code to see what it does. Even makeConnection() is better. Singletons are BAD Setting a constructor to private is usually for the following reason: a singleton. You want to avoid global state, singletons etc - they're bad practice, make testing hard and more. In languages where objects live in shared memory,

Categories : PHP

Why must the methods of a private inner interface be public?
All methods of an inteface are public and abstract. That is the rule. Only making them public makes sensee because they are to be implemented by implementing classes which may be from different packages. and even if it is an inner interface, it still is interface So rules do not change.

Categories : Java

How to use public and private key encryption technique in C#
Code example: private static string _privateKey; private static string _publicKey; private static UnicodeEncoding _encoder = new UnicodeEncoding(); private static void RSA() { var rsa = new RSACryptoServiceProvider(); _privateKey = rsa.ToXmlString(true); _publicKey = rsa.ToXmlString(false); var text = "Test1"; Console.WriteLine("RSA // Text to encrypt: " + text); var enc = Encrypt(text); Console.WriteLine("RSA // Encrypted Text: " + enc); var dec = Decrypt(enc); Console.WriteLine("RSA // Decrypted Text: " + dec); } public static string Decrypt(string data) { var rsa = new RSACryptoServiceProvider(); var dataArray = data.Split(new char[] { ',' }); byte[] dataByte = new byte[dataArray.Length]; for (int i = 0; i < dataArray.Length; i++) { dataByte[i] = C

Categories : C#

Private vs Public Javascript Functions
Init is a property of the Engine object that refers to a function. You can access it like any other property. Login is a local variable within the anonymous, "immediately invoked function expression" (IIFE); like other local variables, its name is only visible within the declaring function

Categories : Javascript

Change Cloudinary's images from private to public
It's on Cloudinary's road map to support changing between public and private file types. Currently you can re-upload private images as public images (using Cloudinary URLs as input for upload). Another option is to enable 'Strict Transformations' mode (From the Dashboard's settings page) and use our explicit API to create the required derived images without allowing the transformation globally. Here's the 'explicit' documentation (PHP): http://cloudinary.com/documentation/php_image_upload#refresh_images

Categories : Misc

Using an RSA Public key to decrypt a string that was encrypted using an RSA private key
The problem isn't with the padding. In fact, removing padding values from decrypted ciphertext is actually very simple. The problem was with the software at this location: You can see the author found a solution using some code from here: http://www.codeproject.com/KB/security/PrivateEncryption.aspx And with Microsoft's implementation of System.Numeric which simply cannot handle larger integers... To fix the issue, I looked at previous releases of code on the codeproject site and ended up with this PublicDecrypt method. public static byte[] PublicDecryption(this RSACryptoServiceProvider rsa, byte[] cipherData) { if (cipherData == null) throw new ArgumentNullException("cipherData"); BigInteger numEncData = new BigInteger(cipherData); RSAPara

Categories : C#

Getting "public variable" in a "private method" using CoffeeScript
This is a common error in CoffeeScript. Look at the compiled JavaScript: Example = (function() { var getText; Example.text = 'Hello world! ;)'; getText = function() { return this.text; }; function Example() { alert(getText()); } return Example; })(); Using @ in the class definition creates a static method or variable. That is, it's attached to the class object. If you're trying to make it an instance variable, set it in your constructor. constructor: -> @text = 'Hello world! ;)' alert(getText()) If you're trying to access the static property, refer to the class name. getText = -> Example.text

Categories : Javascript

C#, making public members their methods private
In your case, it will "just work". Since Rectangle is a struct, your property will return a copy of the Rectangle. As such, it will be impossible for anybody to modify your Rectangle directly unless you expose methods to allow this. That being said, it's impossible, in general, to provide access to a type without also providing access to methods defined on the type. The methods go along with the type. The only alternative in those cases would be to create a new type that exposed the data you choose without the data or methods you wish to be exposed, and provide access to that.

Categories : C#

Managing Access to private and public activities
I would store the users login information via SharedPreferences. But please be sure to encrypt them in some way. If you dont, everyone can copy the shared_preferences.xml from the phone and see the password in cleartext if its rooted. A good way to manage the login state would be a LoginManager like this: public class LoginManager { private static LoginManager singelton; private Context context; private boolean loggedIn; private LoginManager(Context c) { this.context = c; } public static LoginManager getInstance() { return singelton; } public static void create(Context c) { singelton = new LoginManager(c); } public boolean isLoggedIn() { return loggedIn; } public boolean login(String name, String pass

Categories : Android

private to public domain redirecting in apache
Mod_proxy isn't going to fix your problem. You're going to need to remove all the hostnames from your content from private. So instead of having links like: <a href="http://private:60001/something/"> They need to look like: <a href="/something/"> Otherwise you can look into mod_proxy_html, which will actually mangle the page's content (as opposed to just the request) and map the links in the content on private so that they link to public. See this link for some examples. Essentially, something along the lines of: ProxyHTMLLogVerbose On ProxyHTMLLinks a href ProxyHTMLLinks link href ProxyHTMLLinks form action ProxyHTMLLinks script src for ProxyHTMLLinks img src longdesc usemap ProxyHTMLLinks iframe s

Categories : Apache

Import Public Private key pair to a Keystore
The keytool command that you used creates a self-signed certificate. When you receive the new certificate signed by the CA, you can import that certificate into the keystore, which will then replace the self-signed certificate. About your Java question, you will either need to generate a self-signed certificate based on the public key that you created (and signed by the private key), or you will need to wait for the CA to return your signed certificate and use that with the private key in SetKeyEntry.

Categories : Java

How to make private and public user's fields in rails?
If you have a method e.g. current_user (current logged in user, if you use e.g. devise) then you can do something like <%= @user.birth_date if @user == current_user %>

Categories : Ruby On Rails

Getting “private method” in a “public function” class using CoffeeScript
You're using someFunction = rather than someFunction:. This won't do what you expect. You're calling someFunction, when in fact you probably want to be calling @someFunction.

Categories : Javascript

Java Security - RSA Public Key & Private Key Code Issue
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.math.BigInteger; import java.security.Key; import java.security.KeyFactory; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.PrivateKey; import java.security.PublicKey; import java.security.spec.KeySpec; import java.security.spec.RSAPrivateKeySpec; import java.security.spec.RSAPublicKeySpec; import javax.crypto.Cipher; import javax.crypto.CipherInputStream; import javax.crypto.CipherOutputStream; class RSA{ public static

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.