w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
serve pdf files using node js & express
You can use express.static, set it up early in your app: app.use('/pdf', express.static(__dirname + '/pathToPDF')); And it will automatically do the job for you when browser navigates to e.g. '/pdf/fooBar.pdf'.

Categories : Node Js

SQL Server Express 2012 Installation fails with Could not find the Database Engine startup handle in SQL Server Express 2012
I have found the solution. It was, in fact, a r/w rights error. I have added following users to my profile folder: IUSR Local Service Network IIS_IUSRS Service I know I went overkill here but I wanted to be sure without giving everyone access rights. I will disable them one by one and find the right one(s) needed to properly run SQL Server Express 2012.

Categories : Misc

Any way to serve static html files from express without the extension?
A quick'n'dirty solution is to attach .html to requests that don't have a period in them and for which an HTML-file exists in the public directory: var fs = require('fs'); var publicdir = __dirname + '/public'; app.use(function(req, res, next) { if (req.path.indexOf('.') === -1) { var file = publicdir + req.path + '.html'; fs.exists(file, function(exists) { if (exists) req.url += '.html'; next(); }); } else next(); }); app.use(express.static(publicdir));

Categories : Node Js

node.js and express. Serve html5 video with mp4 & ogg files that are not directly accessible
Declare it as a static assets folder: app.use(express.static(__dirname + 'videos/')); Example: videos/ ├── vid1 │ ├── vid2 │ └── vid3 public/ ├── css/ │ ├── ... │ └── ... ├── js/ │ ├── ... │ └── ... └── img/ ├── ... └── ....

Categories : HTML

Generate SOAP from sql serve database in asp.net
Ok, for thoses that have the same questions, here is a tuto i've found that cover a lot of things : http://msdn.microsoft.com/fr-fr/library/vstudio/cc668796.aspx It's in french but it's quiet complete and well explained.

Categories : C#

Can I serve media to web browser from MongoDB
If you want to store binary files in the database, you can serve them directly without writing them to a filesystem first. All you have to do is write a PHP script (or whatever) to send the data in response to an incoming HTTP request, with the proper media type in the response HTTP header. So if we're talking about images, in your HTML you'd do something like this: <img src="/your_img_script.php?image=1234"></img> Then just write your_img_script.php to lookup image ID 1234 and dump the data out with a image/jpeg (or whatever) content type header.

Categories : PHP

How to serve local files via browser
This works in chrome and ie. For a txt file on a shared drive (that I have access to), it opens the file in the browser. <a href="file://\serverd$Tempclipboard.txt">test</a> You have to ensure the user has access to the shared drive for this to work. Otherwise you'll need to host the file somewhere (e.g. via the webserver).

Categories : Java

Startup script to generate uninstall command
@ECHO OFF SETLOCAL FOR /f "tokens=1*" %%i IN (yourtextfilename.txt) DO ( IF /i %%i==%COMPUTERNAME% ECHO MSIEXEC /x install.msi key=%%j ) This should do as you require - yourtextfilename.txt contains the data, presumably on a shared drive; finds the line where the computername in column 1 is the same as the computername returned by %computername% in the target computer's environment. (all case-insensitive EXCEPT %%i and %%j which must match and be the same case) Command simply ECHOed - remove the ECHO keyword after verification to activate.

Categories : Windows

How do I configure Sinatra to serve 403 (Forbidden) on a specific exception?
Maybe what you're looking for is the "error" block? http://www.sinatrarb.com/intro.html#Error error MyCustomError do return status 403 end raise MyCustomError unless valid?(thing)

Categories : Ruby

Express to generate JSON
The path that does what you want is /, not /RestaurantDesc/. Look at the first parameter to app.get(). Here's what I get with http://54.218.73.244:7004/ { "restaurants": [ { "restaurantID": 1, "restaurantNAME": "CopperChimney", "url": "http://54.218.73.244:7002/CopperChimney" }, { "restaurantID": 2, "restaurantNAME": "Aroy", "url": "http://54.218.73.244:7002/Aroy" }, { "restaurantID": 3, "restaurantNAME": "MarkBoulevard", "url": "http://54.218.73.244:7002/MarkBoulevard" }, { "restaurantID": 4, "restaurantNAME": "Indian", "url": "http://54.218.73.244:7002/Indian" } ], "RestaurantTimings": [ { "_id": 1, "RestaurantTime": "8pm to 11pm" }, { "_id": 2,

Categories : Node Js

Out-of-browser specific settings do not affect in-browser applications
I am the guy who upvoted your question as I had a similar problem. The solution was so simple I could hardly believe it when I found out. Syntax error in my XAML. I declared FontSize="20px" instead of FontSize="20". Duh.

Categories : Windows Phone 8

How a server get to know the incoming request from a specific region to serve a web page in the locale language
The server looks at the Accept-Language header on the incoming HTTP request. The value of the header indicates the language and/or country that the user expects to be applied in the response. For example: Accept-Language: en-us,fr;q=0.5 There may some esoteric techniques for determining location from IP address, but these are not generally needed.

Categories : Java

Visual Studio Express 2012 for Web - don't generate bin and obj folders
Yes, it is possible. I relied on the following nice overview on how to hijack a build process: http://sedodream.com/2013/06/01/HijackingTheVisualStudioBuildProcess.aspx Three main tricks: 1) project_name.csproj is the one you need to modify, it is XML MSBUILD file. 2) You cannot remove dependency from WebApplication.targets, you need to "deactivate" them as below. <Import Project="$(MSBuildExtensionsPath32)MicrosoftVisualStudiov11.0WebApplicationsMicrosoft.WebApplication.targets" Condition="false" /> 3) You have to implement general contract for clean/build/rebuild targets. Mine looks like: <Target Name="Build"> <Exec Command="call node_modules.bin sc.cmd src/main.ts --out js/game.min.js &gt; $(Temp) scout.txt" IgnoreExitCode="true" WorkingDirectory="$(S

Categories : Visual Studio

How do I create an .htaccess to serve index if the last node is a directory, else, serve a file?
place this code in .htaccess under the root directory of your site Options -MultiViews RewriteEngine ON RewriteCond %{REQUEST_FILENAME} -d RewriteRule (.+) /$1/index.php [QSA,L] RewriteCond %{DOCUMENT_ROOT}/$1.php -f RewriteRule ^(.+?)/?$ /$1.php [QSA,L]

Categories : Apache

Express request routes twice on browser page load
This was confusing as all over the internet this issue is solved by rectifying the favicon thing. But this was stupid jquery $.get() call which was firing blank (it was calling the same url as the page url) when the variable was not present. I wrapped the ajax call and problem solved.

Categories : Javascript

Sending confirmation alerts from Node/Express to Browser without reloading page
What you're looking for is connect-flash: https://github.com/jaredhanson/connect-flash See the example https://github.com/jaredhanson/connect-flash/blob/master/examples/express3/views/index.ejs to display flash in your rendered template, or make an alert with the message if you want.

Categories : Javascript

exit from express middleware with specific http status
You are suppose to pass errors to the next() function. function SomeMiddleware(req, res, next) { if(user.notRealOrSomething) { return next(throw new HttpException(401, "Tough luck buddy")); } next(); } Any argument you pass to next will be considered an error except 'route' which will skip to the next route. When next is called with an error the error middleware will be execute. function (err, req, res, next) { // err === your HttpException } Express.js will treat any middleware with 4 arguments as error middleware. Error-handling middleware are defined just like regular middleware, however must be defined with an arity of 4, that is the signature (err, req, res, next): All of this is pretty well documented at: http://expressjs.com/guide/error-handling.html

Categories : Javascript

Setting a handlebars helper to return a specific value per request in express
This is because your using a single instance of Handlebars and with lots of requests your polluting one request with another. I use hbs (https://github.com/donpark/hbs) as it creates a new instance of handlebars for each request/render for you.

Categories : Node Js

exit from chain of route specific middleware in express/ nodejs
You can call next( 'route' ), as said on the express api reference, application routing section: Multiple callbacks may be given, all are treated equally, and behave just like middleware, with the one exception that these callbacks may invoke next('route') to bypass the remaining route callback(s). Example var express = require('express') , app = express() ; // keep an eye on the function names app.post( '/some/path', middleware1, middleware2, function route1( req, res, next ) { // write response }); app.all( '*', function route2( req, res, next ) { // do something like handle a 404 request }); app.use(function errorHandler( err, req, res, next ) { // handle error }); function middleware1( req, res, next ) { // ... if ( !success ) { // bypasses

Categories : Javascript

Opening specific email in Outlook express or Apple desktop mail inbox
You can't. Its not possible for HTML or JavaScript code to load a windows or mac executable. All you can do is specify <a href="mailto:abc@gmail.com">Send Mail</a> and the browser decides which mail client to open, based on the user preferences

Categories : Javascript

Generate report with specific date
I think you need apostrophees around the dates. Otherwise the dbms might think it is a arithmetic operation instead of a date. In other words you probably have this: "Select * from Order1 Where Order_Date between 2005-06-25 and 2008-04-13" and thus 2005 - 06 - 25 = 1974 and 2008 - 04 - 13 = 1991 results in: "Select * from Order1 Where Order_Date between 1974 and 1991" Instead what you want is this: "Select * from Order1 Where Order_Date between '2005-06-25' and '2008-04-13'"

Categories : Java

Possible to generate an XML file from specific divs?
Please refer to any of the following: http://java-source.net/open-source/html-parsers Also you can try to use: Html.fromHtml(source) (http://developer.android.com/reference/android/text/Html.html)

Categories : Android

Generate a URL for a specific route pattern in ASP MVC
You can use Url.Action which will create the URL for you. var url = Url.Action("Jobs", "Index", new { filter = "Active" }); You can also use this in your JavaScript files which comes in useful when attempting to get the URL in the View. You can do this with Razor @Url.Action("Jobs", "Index", new { filter = "Active" });

Categories : C#

How to generate specific Ids for usb port in java?
Did you tried The JSR-80 API (javax.usb) as explain here http://www.ibm.com/developerworks/library/j-usb/index.html

Categories : Java

Using express to generate output .... for JSON output
You can change your following function: function ( error, results ) { response.json({ 'first' : first, 'second' : second }); } to function ( error, results ) { // case 1: since results is a js array object you can do following and is recommended res.json({first: results[0], second: results[0]}); // case 2:else you can do the following thing as well. (Not recommended in this case of async) /* var jsonObj = JSON.parse('{first :' + first +', second : ' + second + '}'); response.json(jsonObj); */ } The following will be the output: { first :[{"_id":1,"name":"devrath","age":24},{"_id":2,"name":"Dheeraj","age":25},{"_id":3,"name":"Vikas","age":26}], second : [{"_id":1,"place":"Hassan","phone":1},{"_id":2,"place":"Pune","phone":2},{"_id":3,

Categories : Node Js

Generate text field with specific class
Just the set the className property in the same way that you're setting the name, type and ID: text.className = "inputtype"; Do the same for the browse button: upload.className = "someclass"; For multiple classes, separate them with a space. Note that className overwrites the whole class list.

Categories : Javascript

How to generate a specific query in SQL Server 2012
Try something like this: SELECT MODEL, GENDER, COLOR, SUM(CASE WHEN MONTH(ORDER_DATE) = 1 THEN 1 ELSE 0 END) Jan, SUM(CASE WHEN MONTH(ORDER_DATE) = 2 THEN 1 ELSE 0 END) Feb, SUM(CASE WHEN MONTH(ORDER_DATE) = 3 THEN 1 ELSE 0 END) Mar, SUM(CASE WHEN MONTH(ORDER_DATE) = 4 THEN 1 ELSE 0 END) Apr FROM PRODUCT_MODELS t1 INNER JOIN PRODUCT_TYPES t2 ON t1.PRODUCT_MODEL_ID = t2.PRODUCT_MODEL_ID INNER JOIN PRODUCT_ORDERS T3 ON t2.PRODUCT_TYPE_ID = t3.PRODUCT_TYPE_ID INNER JOIN ORDERS T4 ON T3.ORDER_ID = T4.ORDER_ID GROU

Categories : SQL

Jetty Startup issue: WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/,null}
It seems that your eclipse STS workspace is out of sync with the content published in the server. Try to clean the server, clean the working directory, clean all projects and Republish the project into the server. If this does not work, try these steps to regenerate your eclipse workspace: close eclipse and do a maven clean install from the command line delete all eclipse related files: .project, .classpath and .settings reopen eclipse, and configure maven to use the same maven as the command line import the project using 'Import as Maven Project' scrap your Jetty and redownload a clean one Create a new Jetty server, point it to the new Jetty and add your application to it Republish the application and start the server

Categories : Eclipse

Generate a specific amount of random numbers that add up to a defined value
You will have no problem meeting any two out of your three constraints, but all three might be a problem. As you note, the standard way to generate N random numbers that add to a sum is to generate N-1 random numbers in the range of 0..sum, sort them, and take the differences. This is basically treating your sum as a number line, choosing N-1 random points, and your numbers are the segments between the points. But this might not be compatible with constraints on the numbers themselves. For example, what if you want 10 numbers that add to 1000, but each has to be less than 100? That won't work. Even if you have ranges that are mathematically possible, forcing compliance with all the constraints might mean sacrificing uniformity or other desirable properties. I suspect the only way to

Categories : R

How to generate a list with brace expansion in specific order
That's not implemented, but you could use an ugly hack like echo $(eval echo {a,b,c,d}_{0..3}) to achieve it by actively first evaluating the latter brace and in the second step the first brace. Keep in mind though that the intermediate step must be small enough to be still parsable by the shell ;-)

Categories : Bash

What's the best way to generate random strings of a specific length in Python?
CODE: from random import choice from string import ascii_uppercase print(''.join(choice(ascii_uppercase) for i in range(12))) OUTPUT: 5 examples: QPUPZVVHUNSN EFJACZEBYQEB QBQJJEEOYTZY EOJUSUEAJEEK QWRWLIWDTDBD EDIT: If you need only digits, use the digits constant instead of the ascii_uppercase one from the string module. 3 examples: 229945986931 867348810313 618228923380

Categories : Python

How can you imitate a (specific) browser when using a webview?
Webview.getSettings().setUserAgentString(<Set the Browser NameString>); The above setting might help you. It might be the case that userAgentString will set the browser type as well

Categories : Android

Getting the browser to use a specific name for file being downloaded
The code you have shown will produce a file with a name of '/var/www/client/image.jpg' which is obviously not a valid file name, which is why your file gets named after the script. $fileName is the desired name of the output file, $fullpath should be the absolute path to the desired file, php's relative paths do not work like HTML's paths do. '/' will not point you to the document root folder.

Categories : PHP

Embed specific Web Browser in C++ application
No, you cannot "embed" a specific version of Internet Explorer in your application. But you probably don't need to: when you use the IE COM WebBrowser Control in your application, by default it runs in IE7 Compatibility mode. Later modes are only used if you explicitly set the FEATURE_BROWSER_EMULATION registry key listing your executable name.

Categories : C++

GWT - Loading browser-specific JavaScript
You can try conditional comments: <!--[if IE 9]> <script src="ie9svgfix.js"></script> <![endif]-->

Categories : Gwt

How to create CSS browser-specific borders
If FireFox is bugging out, it may be worth going down the route of images for firefox. You could have some classes: .tr, .tl, .br, .bl { display: none; /* Don't show for normal browsers. */ } @-moz-document url-prefix() { /* Activate for FF. */ div { /* Probably best to tie this to a class / id. */ position: relative; } .tr, .tl, .br, .bl { display: inline; position: absolute; } .tr { /* top right */ background-image: url("curved_top_right.gif"); top: 0; right: 0; } .tl {} /* top left - Use .tr as a ref */ .bl {} /* bottom left - Use .tr as a ref */ .br {} /* bottom right. - Use .tr as a ref */ } Then in your Html <div> <div class="tr"></div> <div class="tl"></div> <div

Categories : CSS

How to generate a stepped gradation between two specific colors into separate classes
Found this formula, which is wrong (changed 200 to 255), and modified it to the following: div { $startColor: #f1a100; $endColor: #2ec3fb; $divider: 255; $steps: 10; $scaler: $divider / $steps; @for $i from 1 through $steps { $scaledStep: $i * $scaler; $redStart: red($startColor); $greenStart: green($startColor); $blueStart: blue($startColor); $redEnd: red($endColor); $greenEnd: green($endColor); $blueEnd: blue($endColor); $R: ($redStart * (($divider - $scaledStep) / $divider)) + ($redEnd * ($scaledStep / $divider)); $G: ($greenStart * (($divider - $scaledStep) / $divider)) + ($greenEnd * ($scaledStep / $divider)); $B: ($blueStart * (($divider - $scaledStep) / $divider)) + ($blueEnd * (

Categories : CSS

How to open specific browser using selenium webdriver
Just specify the path to the binary of the version..may be, like- FirefoxBinary binary = new FirefoxBinary(new File("path_to_bin")); FirefoxProfile profile = new FirefoxProfile(); WebDriver driver = new FirefoxDriver(binary, profile);

Categories : Java

I want to make browser remember the specific dom in jquery
You could store that data into cookies if you need to collect clicks visits etc trough the whole site. http://www.electrictoolbox.com/jquery-cookies/ is a jQuery plugin that can help you setup/manage cookies in jQuery. To set up a cookie after "including" the jQuery-cookies use: $.cookie("clicked", 0); Storing the whole DOM does not seem to good of an Idea to me if you only want to check on how often a div was clicked etc. So lets just call the cookie clicked and give it the value 0. Now you prob have some onClick functions just get the cookie value and iterate it with 1 once clicked like so: var clicked = $.cookie("clicked"); clicked += 1; $.cookie("clicked", clicked);

Categories : Jquery

How to Generate A Specific Number of Random Indices for Array Element Removal F#
I won't give you F# code for this (because I don't know F#...), but I'll describe the approach/algorithm that you should use. Basically, what you want to do is pick n random elements of a given list list. This can be done in pseudocode: chosen = [] n times: index = rng.upto(list.length) elem = list.at(index) list.remove-at(index) chosen.add(elem) Your list variable should be populated with all possible indices in the source list, and then when you pick n random values from that list of indices, you have random, distinct indices that you can do whatever you want with, including printing values, removing values, knocking yourself out with values, etc...

Categories : Arrays



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