w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Haproxy 1.4 connecting to an https backend servers
haproxy 1.4 does not support SSL. Either update to 1.5 or look at using something like stunnel. I have used both in a very large enterprise implementation and both products work well. If you want to stick with haproxy 1.4 then the stunnel route is VERY easy. Simply install stunnel on your haproxy servers, listen on a local port, have haproxy connect to that local port and then configure stunnel to point to the remote https endpoint. Besides global settings in stunnel, the actual config would be 3 lines name listen port on localhost destination host and port

Categories : Ubuntu

How Enable cookie-based persistence in a backend Haproxy even browser disabled cookies
You can look at doing something with a "stick table" https://code.google.com/p/haproxy-docs/wiki/stick_table You will have to make sure that your stick table is synced to all load balancers or make sure that the end user traffic lands on the same load balancer every time. I know that later versions of haproxy (1.5.17+) support syncing the stick table, I do not know about earlier versions.

Categories : Misc

Obj-C: How to make UDP packet's Source Port consistent in GCDAsyncUdpSocket? source port alway change
The reason of variable port number is I am using ARC. The instance might not be released at next time alloc and init. Everytime I call this part code I create a new GCDAsyncUdpSocket object, then try to bind the port and then send the message. These objects are being dealloced only at a later time when I use ARC. So, actually I am trying to bind to the port several times which is not possible. Once the port is bound, I cannot bind it any more.

Categories : IOS

Are the URLs encouraged by AngularJS routing consistent with REST principles?
It's technically not RESTful, because everything after the hash (#) will never make it to the server. I don't think $routeProvider is necessarily encouraging those URLs as much as it's worrying about older browsers that don't support HTML5/popState. If you want to get away from using hash in your URLs, you can include the $locationProvider and call .html5Mode(true): http://docs.angularjs.org/guide/dev_guide.services.$location Just to clarify, even if you switch to use the $locationProvider, your URLs will be the only thing RESTful about your site. REST is more than just pretty/usable URLs... if you're using AngularJS, you'll still (read: you still should be) just be serving up HTML and not actually modifying anything on the server from your site. If you're thinking about REST, you sho

Categories : Rest

How to get a consistent MongoDB backup for a single node setup
In production environment, MongoDB is typically deployed as replica set(s) to ensure redundancy and high availability. There are a few options available for point in time backup if you are running a standalone mongod instance. One option as you have mentioned is to do a mongodump with –oplog option. However, this option is only available if you are running a replica set. You can convert a standalone mongod instance to a single node replica set easily without adding any new replica set members. Please check the following document for details. http://docs.mongodb.org/manual/tutorial/convert-standalone-to-replica-set/ This way, if there are writes while mongodump is running, they will be part of your backup. Please see Point in Time Operation Using Oplogs section from the follo

Categories : Mongodb

Routing for root gives "can't convert String into Hash"?
Although both should work based on the documentation (http://guides.rubyonrails.org/routing.html). Try changing: root 'election#new' to: root to: 'elections#new' # elections (pluralized) for controller name. Update: So root 'elections#new' works as specified in the linked doc in rails 4.0 but not in Rails 3.2'. Rails 3.2 requires the to: option.

Categories : Ruby On Rails

Hash escape in URL (routing.yml/path) Symfony 2
As stated in my answer here the hashtag is not intended to be in symfony routing. You can do the suggested workaround. But first you should consider, do you really need url-fragments in routing? PHP's rawurlencode() encodes all chars except a-zA-Z0-9-._~ according to RFC 3986. But we want to allow some chars to be used in their literal form (reasons below). Other chars inside the path must of course be encoded, e.g. ? and # (would be interpreted wrongly as query and fragment identifier), ' and " (are used as delimiters in HTML).

Categories : Symfony2

what type of password hash? possible mysql hash?
You can't decrypt the password. MySQL passwords are encrypted using a one-way encryption function. Per the manual: Encryption performed by PASSWORD() is one-way (not reversible). It is not the same type of encryption as used for Unix passwords; for that, use ENCRYPT().

Categories : Mysql

How do you parse a street address from a single cell in Excel into individual cells when the address format isn't consistent?
I guess you can do a combination of MID & FIND to extract parts of the address, e.g. =IF(IFERROR(MID(A1,1,FIND(",",A1,FIND(",",A1)+1)),1)=1,MID(A1, 1, FIND(",",A1)-1),MID(A1,1,FIND(",",A1,FIND(",",A1)+1)-1)) will extract the address from cell A1, depending of the number of commas it finds (1 or > 1). ZIP and state won't be too difficult following the above mentioned pattern. I think the problem is extracting the city as you don't know where to set the limit between the city name and the street unless you have a finite set of street types, e.g. ct, st, way etc.

Categories : Excel

Is ember-data an adequate solution for managing communication between a single page app and a C++ (QT) backend?
Yes that scheme makes sense. It is not uncommon for ember-data to be used with systems that both persist and modify data on the backend. If that modification happens quickly, the backend can trigger frontend refresh in it's response to an update. Otherwise like you said it could trigger a refresh on the frontend. I've seen both of these approaches working for ember-data apps.

Categories : Ember Js

The given value of type String from the data source cannot be converted to type bigint of the specified target column
I found an answer in this bytes.com thread. All you have to do is map the columns of the source to the destination table with the use of SqlBulkCopyColumnMapping. bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(0, 1)); bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(1, 2)); bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(2, 3)); bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(3, 6)); //look here, index is different bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(4, 8)); //and again bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(5, 9)); I also found the same solution here before finding the above, but in my case I had some fields missing in the source. The fields were in the correct order although it referred to the actual INDEX/ORD

Categories : C#

SqlBulkCopy - The given value of type String from the data source cannot be converted to type money of the specified target column
@Corey - It just simply strips out all invalid characters. However, your comment made me think of the answer. The problem was that many of the fields in my database are nullable. When using SqlBulkCopy, an empty string is not inserted as a null value. So in the case of my fields that are not varchar (bit, int, decimal, datetime, etc) it was trying to insert an empty string, which obviously is not valid for that data type. The solution was to modify my loop where I validate the values to this (repeated for each datatype that is not string) //--- convert decimal values foreach (DataColumn DecCol in DecimalColumns) { if(string.IsNullOrEmpty(dr[DecCol].ToString())) dr[DecCol] = null; //--- this had to be set to null, not empty else dr[DecCol] = Helpers.CleanDec

Categories : C#

SQL Bulk Copy "The given value of type String from the data source cannot be converted to type datetime of the specified target column" using ASP.NET
SqlBulkCopy.WriteToServer(DataTable) fails with confusing messages if the column order of the DataTable differs from the column order of the table definition in your database (when this causes a type or length incompatibility). Apparently the WriteToServer method does not map column names.

Categories : C#

How do you set "Content-Type" when saving to S3 using django-storages with S3boto backend?
According to this answer, the Content-Type isn't metadata but rather headers that you set up when you upload the file.

Categories : Django

ExtJS Large Single Page App on routing and class loading
It ain't that heavy up-front. Use Sencha cmd to only require the classes that you actually use. You don't have to load extjs-all.js . You CAN load 1000 controllers with 20 event handlers in under 1 second, it's the view rendering that takes time. Best practices for initializing and deconstructing controllers I don't understand your question about lazy loading widgets. Don't instantiate them until you need them, and destroy them when you don't. You can have some load-on-demand modules as well, using Ext.Loader. There are no good routing docs, but take a look at how MS Prism does it.

Categories : Javascript

Return single :key from nested hash in ruby
def values(hsh, key) return [] if !hsh.kind_of? Hash v = hsh[key] ? [hsh[key]] : [] hsh.values.select{|i| i.kind_of? Hash or i.kind_of? Array}.each do |val| if val.kind_of? Hash v+= values(val, key) else val.each {|i| v+= values(i, key)} end end return v end puts values(h, :blending_mode).inspect # h is the Hash from your gist # => ["normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal", "normal

Categories : Ruby

Obtaining the hash of a file using the stream capabilities of crypto module (ie: without hash.update and hash.digest)
From the quoted snippet in the question: [the Hash class] It is a stream that is both readable and writable. The written data is used to compute the hash. Once the writable side of the stream is ended, use the read() method to get the computed hash digest. So what you need to hash some text is: var crypto = require('crypto'); // change to 'md5' if you want an MD5 hash var hash = crypto.createHash('sha1'); // change to 'binary' if you want a binary hash. hash.setEncoding('hex'); // the text that you want to hash hash.write('hello world'); // very important! You cannot read from the stream until you have called end() hash.end(); // and now you get the resulting hash var sha1sum = hash.read(); If you want to get the hash of a file, the best way is create a ReadStream from th

Categories : Node Js

MySQL InnoDB: Having a multiple column key vs a single md5 hash key
In InnoDB the primary key is a clustered key - the data on the disk is physically organized based on the order of the PK. This means that if you are not using auto-increment or something other that increases the value of PK over time, you will got a lot of random writes and this will kill your performance as soon as the size of the table is larger than the buffer_pool size. Having in mind this, md5() won't be much better than the compound index for the inserts. Having smaller PK is good for 2 reasons: the size of the PK affects the size of all secondary indexes (because all secondary indexes contain the PK) and using smaller indexes is better ('cause you can load more values into memory at once)

Categories : Mysql

Ruby, turn array of hashes into single hash
Something like this: Hash[a.map(&:values)] # => {1=>"x", 2=>"y"} if you want the other way: Hash[a.map(&:values).map(&:reverse)] # => {"x"=>1, "y"=>2} incorporating the suggestion from @squiguy: Hash[a.map(&:values)].invert

Categories : Ruby

Failure to update an entity in the appengine backend using auto-generated backend API
The issue seems to be arising in the containsEvent() method. From your local, after editing eventsincloud, you are passing a JSON to your endpoint method updateEvent. This then calls containsEvent, passing on a JSON as the parameter event and here you are calling the method getKey() on event. The app engine method getKey() is to be used for getting key value from an entity instance and not from a JSON representation of an entity. You can modify your updateEvent to query an entity by its Id , similar to getEvent . You can either find the id in your cloud or get it at local as you do in eventLocal.getId(), which is a local method for getting Id stored in your JSON. Then in your endpoint method, you can use the id to query the required entity (a working code should be already in place in getE

Categories : Android

Sending a message from cloud backend (Mobile Backend Starter)
I also had the same issue with onBroadcastMessageReceived() in GuestbookActivity . To make it receiving broadcast messages I commented listed below condition in CloudBackendActivity. private void _onPostCreate() { // if (!isSubscribedToBroadcastMessage) { // isSubscribedToBroadcastMessage = true; CloudCallbackHandler<List<CloudEntity>> handler = new CloudCallbackHandler<List<CloudEntity>>() { @Override public void onComplete(List<CloudEntity> results) { onBroadcastMessageReceived(results); } }; cloudBackend.subscribeToCloudMessage( CloudBackendMessaging.TOPIC_ID_BROADCAST, handler); // } this.onPostCreate(); } So the issu

Categories : Android

In a file/array, search for hash key, and replace it with the hash value, do this for all hash keys/values
You exhaust your file the first time through your loop using the initial $find and $replace key/value pair. There are two potential solutions: Open the file for reading during each iteration of your while loop (expensive) Move the foreach loop to the outside of the while and iterate the hash each time (less expensive) example: REPLACE: for my $line (@gtfarray) { while(my ($find, $replace) = each %hash) { if($line =~ s/$find/$replace/g) { push @newgtf, $line; next REPLACE; # skip to next iteration } } # if there was no replacement, push the old line push @newgtf, $line }

Categories : Perl

Call a BackEnd-Method from FrontEnd written in BackEnd
I recommend attaching a CSS class name via the CssClass property of your dynamically created button. Then have jQuery handle the click of the button via event delegation using the on () function. Read jQuery on() function documentation for more information. Once you have jQuery handing the event client side, then you have several choices of interacting with the server (__dopostback, ASP.NET AJAX Page Methods, ASP.NET Web API, asmx web services, WCF, etc.).

Categories : Asp Net

Filtering list with discriminating union type to a single type
Use List.choose -- it's like List.filter and List.map rolled into one. let circles = l |> List.choose(fun x -> match x with | Circle l -> Some l | _ -> None) for x in circles do printf "circle %d" x

Categories : F#

Routing based on logged in user type
I think that, if you control the users role in the TWIG templates and showing them the only links that they could access (and, of course, protecting the routes with firewalls in the security.yml) may work.

Categories : Misc

Post routing disambiguation based on content type
First, create the following class: public class ButtonAttribute : ActionMethodSelectorAttribute { public string ButtonName { get; set; } public override bool IsValidForRequest( ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo) { return controllerContext.Controller.ValueProvider .GetValue(ButtonName) != null; } public ButtonAttribute(string buttonName) { ButtonName = buttonName; } } Then, in the view, add the name attribute to your buttons: <form action="~/Sample/Post" method="post"> <input type="text" name="x" value="test" /> <input type="number" name="y" value="123" /> <input type="submit" value="First button" name="submit1" /> <input type="su

Categories : C#

Symfony 2 multiple bundles annotation type routing
The command php app/console router:debug is the best way to debug routes in Symfony2. According to the details you provided everything seems to be correct and you are saying that removing one of the route prefix "fixes" your issue. Visualizing your routes in an array _mobile: # defines the prefix /mobile mobile: # key that defines how you include your controller's route main: /mobile/main # "main" is the route name which is duplicated below _admin: # defines the prefix /admin admin: # key that defines how you include your controller's route main: /admin/main # this route override the original "main" route In Symfony2 a route isn't defined by the addition of the prefix name and the route name but solely by the route name. If you have two routes named main then S

Categories : Symfony2

cannot apply indexing with [] to an expression of type System.Web.Routing.RouteValueDictionary
Although RedirectToRouteResult is defined in System.Web.Mvc assembly, RouteValueDictionary is defined in System.Web assembly (since it's part of the ASP.Net Routing mechansim that was introduced prior to the MVC framework). Try to add a reference to System.Web in your test project and see if that helps.

Categories : Asp Net Mvc

Php hash return type: Not string(64)?
You are using third parameter set to true in hash function, so your output is in binary format, that is not suitable to be viewed in standard output. Previous hash may contain some control chars that suppresses part of next output. Binary data should be viewed in hex form (third parameter set to false) or saved to file and browsed by hex editor.

Categories : PHP

Multiple views over a single Kendo data source
You can have multiple controls share a DataSource, as seen on the Shared DataSource demo page. I also recall hearing of one DataSource wrapping another DataSource, allowing the two to sort differently. I can't find a link for this right now though.

Categories : Kendo Ui

Use a single base www directory as the source for multiple platforms?
There are different ways each developer follows to have a single code base. In my case, i create two folders Android and Iphone with iphone's www folder being a symlink to the Android's www folder. If i want to have separate script files to be used for iphone and android, i have this code in the index.html file <!--iPhone <script src="iphone/cordova-2.5.0.js"></script> <script src="iphone/DatePicker.js"></script> --> <!-- android --> <script src="android/cordova-2.5.0.js"></script> <script src="android/datePickerPlugin.js"></script> if i want to run for iphone, i change the comment tags to un comment iphone and comment android

Categories : Android

K negative edges - single source shortest path
If it is a nondirectional graph, there is no single shortest path because even with a single negative edge, you could just go back and forth on that negative edge and have an infinite number of paths of negative infinity. However, assuming a directional graph with no negative cycles, you could use Breadth First Search and keep track of both the negative edges you've already hit and the shortest path to each node you've discovered so far. If you see a node you've already visited, you only go there again if it would be better than the previous path you took to get there. Since there are no negative cycles the algorithm must terminate. After the algorithm terminates the target node should have the best path that was used to get there.

Categories : Algorithm

i need to add a link to a single image that already has a change source function
This may be a better solution: <head> <script type="text/javascript"> var images = ["image1.gif","image2.gif",...,"image27.gif"]; var thumbs = ["image1t.gif","image2t.gif",...,"image27t.gif"]; var basePath = "thestudio/"; var currentImage = 0; function changeImage() { var img = document.getElementById("image"); var thumb = document.getElementById("thumb"); img.src = basePath + images[currentImage]; thumb.src = basePath + thumbs[currentImage]; currentImage ++; if (currentImage >= images.length) { currentImage = 0; // this will cause it to loop } } </script> </head> <body onLoad="changeImage();"> <div id="slideshow"> <img id="image"> </div> <a onClick="changeImage();" href="#">&

Categories : Javascript

How to track multiple open source projects inside of a single project with git?
I've gone ahead and added in my first git submodule. Works well! Thannk you James Allardice. I'm using Sourcetree app for managing Git and I couldn't add a subtree, just a submodule. The only problem, the submodule doesn't show me with tracking if there is any new commits on the upstream project, I just have to check those repos every time I start working in Sourcetree app.

Categories : GIT

Merging multiple powerpoint slides into one and maintain single point of source?
The simplest and probably most reliable solution would be to put all of the slides into one file and then create custom shows, one for each target audience. Another approach would be to have a main "menu" presentation, one slide with links to sub-presentations, one per audience. Each of those presentations would have its own "menu" slide that links to A.pptx, B.pptx etc. as needed. At the end of A.pptx, add an End Presentation link; click on that (or just press ESC to quit the presentation) and you'll be returned to the sub-menu presentation.

Categories : Vba

Use requirejs to build project to single file and then optimize it (creating source map)
It seems that i have misunderstood what requirejs does when it optimizes and creates source maps. It turns out requirejs creates a map and source file for every single JS file in your project as well as a source map for the optimized JS file (typically called main.js). If you're only after a source map for the main.js file then you can delete all the others. Hope this helps somebody else!

Categories : Javascript

502 Bad Gateway HAproxy
First, enable haproxy logging. It will simply tell you why it is giving the 502's. My guess is that the backend "localhost:8080" is simply not able to keep up or is not able to get a connection within 4000ms "timeout connect 4000".

Categories : Linux

HAProxy Comodo SSL
It sounds like you need to install your certificate chain. Comodo (and most other CA's) will have a chain that must be followed by the browser. In your cert file just add the intermediate and root ca certs in addition to your actual cert. My file looks like this: -----BEGIN MY CERTIFICATE----- -----END MY CERTIFICATE----- -----BEGIN INTERMEDIATE CERTIFICATE----- -----END INTERMEDIATE CERTIFICATE----- -----BEGIN INTERMEDIATE CERTIFICATE----- -----END INTERMEDIATE CERTIFICATE----- -----BEGIN ROOT CERTIFICATE----- -----END ROOT CERTIFICATE----- -----BEGIN RSA PRIVATE KEY----- -----END RSA PRIVATE KEY-----

Categories : Ssl

Transform source file and sort elements based on class using a single XSLT
You need to do the xsl:perform-sort on a sequence. I modified your XSLT slightly by removing the template that matches / and modifying the template that matches ol. (And added xsl:strip-space for nicer looking output. You might want to remove it if your input has important white space.) XML Input (added some HD to a few li) <html> <head> <title></title> </head> <body> <!-- This is my first comment --> <ol> <li>3 Song 1</li> <li>4 Song 2</li> <li>5 Song 3 HD</li> <li>7 Song 4</li> <li>8 Song 5</li> <li>10 Song 6 HD</li> <li>14 Song 7</li>

Categories : HTML

Unless constructor argument passed is a hash type, croak on invalid arguments?
We can look at the various ways your dump method can be called. If we pass a "hash list", the number of elements is even (@_ % 2 == 0). Also, if at least one key-value pair is present, the first argument (a key) is a string, so not defined reftype $_[0] holds. If we pass a hash reference, then the argument list should only hold this reference, and no other values: @_ == 1. The first argument will be a hash: reftype($_[0]) eq 'HASH'. So to put the arguments in a hash reference, one could do something like: sub dump { my $invocant = shift; my $hashref; if (@_ == 1 and reftype $_[0] eq 'HASH') { $hashref = $_[0]; } elsif (@_ % 2 == 0 and (@_ == 0 or not defined reftype $_[0])) { $hashref = +{ @_ }; } else { croak "Unknown argument format: either pass a hashref, or an

Categories : Perl



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