w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

Logging of sql statements in OrmLite (ServiceStack)
You have to create your own implementation of ProfiledDbConnection class writing log to NLog. Now when you create instanace of OrmLiteConnectionFactory class set connection filter, which you can do like that: var db = new OrmLiteConnectionFactory( "ConnectionString", true, SqliteOrmLiteDialectProvider.Instance) { ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current) }; Here you have src of ProfiledDbConnection https://github.com/ServiceStack/ServiceStack/blob/master/src/ServiceStack/MiniProfiler/Data/ProfiledDbConnection.cs

Categories : Misc

JDBC - SQL statements execution time logging
Measuring time and logging it seems like a job for AOP. If you are using EJB, a simple interceptor should solve your problem(for example http://www.javacodegeeks.com/2013/07/java-ee-ejb-interceptors-tutorial-and-example.html). If its Spring(judging from JDBCTemplate), try Aspectj.

Categories : Java

Performance Differences of Nested If Else Statements vs. ElseIf Statements
It depends on your code. The if statement is only accessed when a condition is met, otherwise it is ignored. the if elseif else block is the same but it is testing for many conditions and depending on which one is met a different action might have to be performed in order to get the results u want. My opinion is "It depends upon cases". If you want to execute everything in your code,then use elseif.. if you want to ignore something use if..

Categories : Dotnet

Multiple If-Else Statements VS. Switch Statements within While Loop for C Language
No, that code is not possible to write with a switch. The values for case must be constant, and integer. You can have case 4611: but not `case a > 360". So, unless you want hundreds of case statements (you don't) the code is not easily translatable to use a switch. UPDATE One way to make it (in my opinion) more elegant is to order the ranges, and reduce repeat by relying on the lower bound already having been checked in all else ifs: while(1) { const float A = get_angle(); if (A > 1 && A <= 180) { put_speed (600, 200); } else if (A <= 360) { put_speed(600, 100); } else if (A <= 540) { put_speed(100, 600); } else if (A <= 700) { put_speed(200, 600); } else {

Categories : C

Python: Logging module for print statements: Duplicate log entries
Here's at least a partial answer to your first question. You're getting those blank lines on eachprintbecauseprintstatements in Python 2.x potentially callstdout.write()twice, once with the data from evaluating the expression in the statement, and then again if the optional newline hasn't been suppressed by a trailing comma. Also, if anINFO level message is sent to a logger set at alevelof'NOTSET', the message will also be echoed on sys.stderrby default according to the logger documentation -- which is why you see the console output even when the Tee is in effect. There are no duplicate log entries that I can see. To prevent the blanks lines, try using thisTeeclass definition. Note thewrite()method modifications (updated to be a singleton to match your "EDIT SECTION (3)"): class Tee(ob

Categories : Python

Right way to push to production without console and debug statements in node.js?
Is this an option? https://npmjs.org/package/remove-console-logs Per the docs: This is just a small tool which parses your JS and replaces any console.* calls with 0. It uses falafel to walk the AST. Falafel uses esprima to parse your JS. Finally, optimist is used for cli argument parsing

Categories : GIT

DRY With Different Try Statements and Identical Catch Statements
You could pass an Action into a function that handles the exceptions: private void HandleErrorsFor(Action action) { try { action(); } catch (Exception ex) { //repeated exception handling... { } //... public void DoSomething() { HandleErrorsFor(() => { //try block #1 }); HandleErrorsFor(() => { //try block #2 }); } It's a bit easier to read and avoids the repeated code.

Categories : C#

How to do logging of C# Console application using EL 6.0
The new version 6 makes comprehensive use of the factory pattern, hence you need to set the logger up differently in version 6: Try the following: IConfigurationSource configsrc = ConfigurationSourceFactory.Create(); LogWriterFactory logWriterFactory = new LogWriterFactory(configsrc); Logger.SetLogWriter(logWriterFactory.Create()); Logger.Write("logtest", "General"); Your description of your database logging requirements isn't quite clear, but I think these Code examples and links should be what you are looking for.

Categories : C#

Python, logging print statements while having them print to stdout
You can add this to your script: import sys sys.stdout = open('logfile', 'w') This will make the print statements write to logfile. If you want the option of printing to stdout and a file, you can try this: class Tee(object): def __init__(self, *files): self.files = files def write(self, obj): for f in self.files: f.write(obj) f = open('logfile', 'w') backup = sys.stdout sys.stdout = Tee(sys.stdout, f) print "hello world" # this should appear in stdout and in file To revert to just printing to console, just restore the "backup" sys.stdout = backup

Categories : Python

Nesting "and" statements with "or" statements
Enclose the compound statements in extra brackets to explain to the compiler how to order the logical statments... Try this: If (cell.Value) = "FTV1" _ Or (cell.Value) = "FTV2" _ Or (cell.Value) = "FTV3" _ Or (cell.Value) = "FTV4" _ Or (cell.Value) = "FTV5" _ Or (cell.Value) = "ISTCR" _ Or (cell.Value) = "CAST" _ Or (cell.Value) = "Rig" _ Or ((cell.Value) > 50000 And (cell.Value) < 52000) _ Or ((cell.Value) > 55000 And (cell.Value) < 56000) Then

Categories : Excel

Turn off console logging in Google App Engine Application
You should confirm that the LogManager is using your logging.properties. An easy way to test that would be to change the ConsoleHandler formatter from java.util.logging.SimpleFormatter to java.util.logging.XMLFormatter then see if your output is xml. If it is xml then you could try commenting out the handlers= line. If the output is still from the SimpleFormatter then: Check the path to the logging.properties. Ensure a SecurityManager is not preventing changes to logging. Write code to walk all of the loggers and output the classname of all attached handlers. Then update your logging.properties to disable any other handlers that might be writing to the console. Write code to walk all of the loggers and disable and all console handlers. System.out.close(); System.err.close(); new FileO

Categories : Google App Engine

Alternative to multiple if else statements in javascript
You could use an array: var $hp = ["h6 + p", "h5 + p", "h4 + p", "h3 + p", "h2 + p", "h1 + p"], $fullercolor_bg = "rgba(240,234,222,0.9)"; $hp.forEach(function(v) { if($(v).mouseIsOver()) { $(v).prev().css({ backgroundColor: $fullercolor_bg }); } else { $(v).prev().css({ backgroundColor: "transparent" }); } }); In your case I think it's simpler to use multiple CSS selectors within the variable. This may or may not work depending on the implementation of mouseIsOver: var $hp = $("h6 + p, h5 + p, h4 + p, h3 + p, h2 + p, h1 + p"), $fullercolor_bg = "rgba(240,234,222,0.9)"; if($hp.mouseIsOver()) { $hp.prev().css({ backgroundColor: $fullercolor_bg }); } else { $hp.prev().css({ backgroun

Categories : Javascript

using Ajax and Javascript - executing both if/else statements
In order to get to 4, the readyState has to go through 0, 1, 2 and 3. Each time it will fail your if statement - after all, that's why we test for it. You should do something like: if( this.readyState != 4) return; if( this.status == 200) { /* do something with this.responseText */ } else { /* handle error condition with this.status and this.statusText */ } Note the use of this - it's better to use the keyword, just in case you later use the variable for something else, you avoid closure problems. EDIT: And another thing, you should move your new XMLHttpRequest code etc. inside the function that uses it - not all browsers are happy with reusing the same object for multiple requests.

Categories : Javascript

Javascript How Get Value after running multiple IF statements
I think you can still do this asynchronously. First you will need to get all the properties out of your object: //Gather up all the properties; var properties = []; for(var property in object) if(object.hasOwnProperty(property) { properties.push(property); } //Array of results var resultsArray = []; //This is a named, self-invoked function that basically behaves like a loop. The //loop counter is the argument "i", which is initially set to 0. The first if //is basically the loop-termination condition. If i is greater than the //total number of properties, we know that we're done. // //The success handler of the ajax call is where the loop is advanced. This is also //where you can put your if condition to check if something is true, so that you //can insert the data into the results

Categories : Javascript

Javascript function skips statements
I think you should just check that the string is empty instead of the length of the value: document.UserData.input1.value.length: if (document.UserData.input1.value == '') Oh, as someone else has pointed out, it also looks like there's an extra semi-colon at the end of your first line.

Categories : Javascript

JavaScript SQLite Prepared Statements
The JavaScript API for SQLite does not support prepared statements. The Firefox API for connecting to databases from within chrome (i.e., an add-in), adds an executeCached method which will cache the statement for re-use, but this is not included in the Web SQL Database specification and not available anywhere else.

Categories : Javascript

Apsalar & Facebook SDK - Both need return statements in application:openURL:sourceApplication:annotation
You might be able to safely use both. It depends on whether they'll safely ignore the URLs that the other one is supposed to handle. It might be worth contacting the support teams for both pieces of software to determine what each one will do when it's given a URL that wasn't intended for it. - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { [Apsalar startSession:@"yourAPIKey" withKey:@"yourSecret" andURL:url]; return [FBSession.activeSession handleOpenURL:url]; }

Categories : IOS

reduce multiple similar if/else statements - javascript
It looks like your intervals are multiples of 250. You can use that to advantage: function winResize(w) { var index = Math.min(10, Math.floor(w / 250)); if (index > 0) { $('body').alterClass('col_*', 'col_' + index); } }

Categories : Javascript

emulated prepared statements vs real prepared statements
You are correct, real prepared statements must be supported by the server. A real prepared means querying the database in two steps. The fist step consists in sending a query template, that the server can pre-compile. The database engine also prepares in advance the execution plan (mostly, what indexes will be used to serve the actual query). The second step is giving actual values to the placeholders and run the actual query with these parameters. This typically allows faster execution of several similar queries, because 1. the query has already been pre-compiled (the execution plan is already computed) and 2. only the parameters values are sent subsequently. A emulated query is just a syntactic sugar, that only allows easier sending (not faster execution) of several, successive, simi

Categories : Mysql

Using Javascript if statements with and operator and selectors to create navigation bar
jsFiddle Demo You should probably do something more along these lines by taking advantage of jQuery's hover: $('#submenu').hide(); $('#portmenu, #first, #second, #third').hover(function(){ //in $('#submenu').show(); },function(){ //out $('#submenu').hide(); });

Categories : Javascript

Nested (Condition) ? true:false statements in JavaScript
Generally speaking using binary operations should be faster than conditional statements with branching because of branch prediction, caching, yada yada yada. But your code is fine. I like the && || but it's just a preference and not based on anything empirical. var data = {a: 1, b: 2, c: 3}; var result = data.x || data.y && "y" || data.z && "z" || data.w && "w" || null; I didn't feel like typing .hasOwnProperty. EDIT After actually looking at your code var paintMode = data.regions || data.vpcs || data.zones || data.subnets || data.clusters || null; if(paintNode) { for(var i=0; i<paintMode.length; i++) paintGroups(paintMode[i]); }

Categories : Javascript

wamp server not running PHP code in javascript statements
Either try alert("<?php echo .... or check php.ini for short_open_tag = on, see here.

Categories : PHP

javascript statements not working... and getting 'failed to load resource' error
Aside from all the problems with your html structure, I suspect the root problem you're running into is that your browser can't find the delete.php file, which I assume is in the same directory that the file this code is from is in. While on a server that form of path-relative addressing will work, generally speaking browsers will prevent loading of files from the host file system for security purposes. Change your action to access delete.php via your localhost web server (i.e. http://localhost/troubleshoot/delete.php) and you should be able to load the file.

Categories : PHP

execute sql statements read from a file
It seems that you forgot closing ) between j and VALUES. At first try executing such line using specialized SQL editor from vendor. I'm not sure if MySQL ODBC is able to execute many statements at once. If not then you will have to parse input file. If each INSERT is in separate file the it is easy: for line in open(...): sql_insert = line.strip() if sql_insert: cursor.execute(sql_insert) If not then you must parse it other way. Maybe split it into statements by using );. It depends from your input file.

Categories : Python

PHP Composer include file with defined "use namespace as" statements, append to each file
Unless you modify the PHP runtime, this is not possible. namespace and use declarations are only valid in the physical file they appear in. These declarations do not span across includes. If they did you'd have a real nightmare managing namespaces and aliases. Declaring these at the top of each file is simply something you'll have to live with. Most languages that have features similar to PHP's namespaces do the same. Link to documentation.

Categories : PHP

if statements to evaluate multiple file dates
Personally for one weeks experience I would say you've jumped into the deep end. I'm not going to provide code, rather direct you to improve your learning, this is referred to psuedo code Look into streamwriter/reader and filewriter and fileinfo. From this you can then read files, delete/rename/whatever you want really. You then need to try and understand how could I validate what I'm doing. Unfortunately for a beginner this is harder than you may think, possibly harder than the first two points for some people. Think from simple onwards, we developers usually over complicate things. This part is actually rather easy so long your file stuff is correct! You may want to look into unit testing as this may help your validation.

Categories : C#

How to extract/split SQL statements in a huge .sql file to get only certain tables?
If you created the file with mysqldump, I believe you can use text utilities to extract the CREATE TABLE and INSERT statements. Specifically, you can use sed addresses to extract all the lines between two regular expressions. It won't have trouble with a 22 gig file. I dumped my sandbox database (a small database I use mainly for answering questions on SO) for testing. In the version of MySQL that I have installed here, this sed one-liner extracts the CREATE table statement and INSERT statements for the table "DEP_FACULTY". $ sed -n -e '/^CREATE TABLE `DEP_FACULTY`/,/UNLOCK TABLES/p' mysql.sql > output.file This regular expression identifies the start of the CREATE TABLE statement. /^CREATE TABLE DEP_FACULTY/ CREATE TABLE statements seem to always be immediately followed by I

Categories : Mysql

Bunch of Could not find schema Information for element statements for xaml file
I think there is no way to fix this issue. I had this issue also in the past and after googling I ended up that it is a nown issue in Visual Studio 2010. The problem I also noticed was that in my application (with multiple projects) Visual Studio did not build a part of my projects any more. Only deleting the ouput files helped. Therefore I switched to Sharp Develop. Until now I dont have any strange issues with XAML or references any more. But maybe also a switch to VS2012 will help.

Categories : Wpf

Does the order of #include directives and "using" statements matter at the beginning of a C++ header file?
It really doesn't matter which includes you put first, so long as all of the includes are within the#if !defined(HEADER_H_), but I like to put all of my standard libraries at the first,however this is entirely up to you.

Categories : C++

Python - How do i write only case statements and instances start with $ from input text file?
import re def main(): caselines_index = [] results = [] cases = [] nvp_add_searchterm = "nvp_add(.+?)" searchterm = "($.+?)[,)]" readlines = [] with open("file.txt", 'r') as file: readfile = file.read() for line in readfile.split(' '): readlines.append(line.strip()) for line in readlines: if 'case "' in line: caselines_index.append(readlines.index(line)) print caselines_index a = 0 for line_index in caselines_index: int_line_index = int(line_index) index_of_line_index = caselines_index.index(line_index) case_text = ' '.join(readlines[int_line_index:caselines_index[index_of_line_index + 1]]).strip() case = [readlines[int_line_index].strip(), case_text] cases.append(case) with open("result.txt", 'w+'

Categories : Python

Can a C# Multithreaded Application use seprate WorkingDirectories per thread?
has anyone figured out a way to MAKE it possible? It's simply not possible. You can't even have different working directories per App Domain. The windows rule is: one Environment set per Process. Running in .NET won't change the basic rules. Instead of that, if you experienced problem in loading assemblies, consider adding the corresponding folder to the PATH environment variable.

Categories : C#

Reading data from Excel sheets and building SQL statements, writing to output file in Python
try this.. # use 'a' if you want to append in your text file outFile = open(r'D:Scriptsupdate.txt', 'a') for i in myList: outFile.write(" UPDATE PERSON SET LegacyID = '%s' WHERE personid = '%s'" %( int(i[1]), str(i[0])))

Categories : Python

In debug mode, mocha doesn't stop on debugger statements in a spec file when using node-inspector
It seems that everybody should be seeing the same problem with node-inspector version 0.2.0beta4. The problem is in the way how breakpoints are managed: The front-end remembers break-points in browser's local storage and restores them after the relevant file is loaded. When you start mocha with --debug-brk and stop on the first line, your specfiles are not loaded yet, so the front-end does not restore your breakpoints. When you resume mocha execution, front-end can't restore breakpoints quickly enough in the short window between a specfile is parsed and run. In fact mocha may exit before the V8 debugger has a change to notify front-end about new scripts being parsed! Another workaround for this issue is to add debugger; statement in the specfile where you want to trigger a breakpoint.

Categories : Node Js

How to configure wso2 servers logging the same level of detail as console output in wso2carbon.log file
By default the console output and the wso2carbon.log file should be the same. I checked and both have the same output. In "Configure Log4J Appenders" see whether you have DEBUG as the Threshold for both CARBON_LOGFILE and CARBON_CONSOLE.

Categories : Wso2

How do I return false and stop an email being sent if one or more if statements is false Javascript?
function checkForm(){ var validate = true; if (streetAddress.value == "") { addressErrorMsg.style.display="block"; validate = false; } if (fullname.value == "") { nameErrorMsg.style.display="block"; validate = false; } return validate; }

Categories : Javascript

Store console logs of IE web page in a file
You can right click on the console and choose "Copy all" You get text like this: HTML1200: cnet.com is on the Internet Explorer Compatibility View List ('C:UserscolinpAppDataLocalMicrosoftInternet ExplorerIECompatDataiecompatdata.xml'). news.cnet.com HTML1504: Unexpected end tag. news.cnet.com, line 45 character 2212 HTML1512: Unmatched end tag. news.cnet.com, line 118 character 11 HTML1514: Extra "<body>" tag found. Only one "<body>" tag should exist per document. news.cnet.com, line 118 character 19 HTML1512: Unmatched end tag. news.cnet.com, line 136 character 2605 HTML1512: Unmatched end tag. news.cnet.com, line 136 character 2605 SCRIPT438: Object doesn't support property or method 'stringify' adtechRichMediaLib_2_15_7.js, line 8 character 94381 TWITTER: Conten

Categories : Vbscript

No file creation with logging module in py2app mac application
The mac app appears to run in a virtual environment. I can force the app to run with a console window open and print sys.argv[0] I see that I'm four folders deep in my .app file. This is where the log file is being created. I'm unable to navigate here in finder. If i set the absolute path of the log file four folders up (the location of the .app file) the log file stays after execution.

Categories : Python

logging error messages in a log file for the client using a web application
Perhaps something like Log4Net would be sufficient for your needs. In the end you could even provide a UI to handle these problematic entries in your application. So why not store them in your db and then show them in a custom UI where users can handle the issues one by one in a collaborative manner?

Categories : C#

for and not statements
Here's one way, using sets and assuming that both objects and list are iterable: for x in set(objects).difference(lst): # do something First of all, you should not call a variable list, that'll clash with a built-in name. Now the explanation: the expression set(objects).difference(lst) performs a set difference, for example: lst = [1, 2, 3, 4] objects = [1, 2, 5, 6] set(objects).difference(lst) => set([5, 6]) As you can see, we found the elements in objects that are not in the list.

Categories : Python



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