w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Trying to output command-line arguments results in a seemingly random hexadecimal number
Instead of using a _TCHAR, it will probably be simpler (and maybe make it work) to use a normal char instead. To answer your second question, in C#, the string[] args is populated with ONLY the arguments passed to your program. In C/C++, argv is populated with the path to your compiled program and THEN the actual arguments.

Categories : C++

How to redirect both stdout and stderr to file AND still output ONLY stderr?
That is very easy: $ ( ./command.sh >> log ) 2>&1 | tee -a log You write the stdout of command to the log file in a sub shell; than you write stderr to pipe; and than, my means of tee, save it to the log and copy the same to the console. Example of usage: $ cat command.sh #!/bin/sh echo out echo err > /dev/stderr $ ( ./command.sh >> log ) 2>&1 | tee -a log err $ cat log out err

Categories : File

How to set intellij to show logs in the logs tab and not the output tab
In the application server Run/Debug configuration open the Logs tab and specify the full log file path there. You can just search your disk for algo_js.log file and specify its location.

Categories : Spring

Debugging Seemingly Random Exceptions in Xcode
First, set an exception breakpoint in Xcode. It will stop before the exception is thrown, so you know who caused it. What seems to be happening is that you have code for (id object in somearray) ... and while that loop is running, someone modifies somearray. That is fatal. You probably have to think about how you are writing your code. For example, you can just write for (id object in [somearray copy]) ... and then you can modify somearray as much as you like. Maybe your code just isn't thread safe and another thread modifies somearray while one thread is iterating through it.

Categories : IOS

Unexpected seemingly random errors in Android studio
It seems that various libraries I had imported were not being properly pulled across various machines: I would pull from github and the various support libraries and associated maven files were not being correctly pulled. Studio's built in handling of various xml files if auto-completion is used corrected the problem by deleting and then retyping a particular line of code.

Categories : Android

Passing N files as arguments (also in random positions) in bash script
You want to iterate your list of filenames with shift after you get your arguments, shift $(( OPTIND-1 )) while [ -f $1 ] do #do whatever you want with the filename in $1. shift done

Categories : Bash

Exceptions swallowed when capturing Invoke-Expression output and redirecting stderr
$Error is an array that buffers errors. The most recent error is stored in $error[0]. You could use this in combination with $LASTEXITCODE and $? For your case I think -ErrorVariable is more appropriate. It is a common variable. See get-help about_commonparameters for more information. The syntax is -ErrorVariable [+]<variable-name>. For example, the following command creates the $e variable and then stores any errors from Invoke-Expression in it: Invoke-Expression $cmd -ErrorVariable e Note that $e can contain more than one error. So, to answer your question about how to capture all output, and still show errors: $output = Invoke-Expression $cmd -ErrorVariable e

Categories : Powershell

Output positions of Matlab figures
Try displaying your images with 'InitialMagnification' set to 'fit': >> figure(1); imshow( A, 'InitialMagnification', 'fit' ); If this does not work, you might try set 'Position' of figure after showing the image. Alternatively, you might want to consider using imagesc with axis image to display the images.

Categories : Matlab

Web Deploy Command Line Logs in Event Logs (Updated / Inserted / Deleted Files) in event logs
I don't believe you can log the activities to the event log, but what you can do is use the -xml parameter to output the changes in XML format. You could then use this to log to the event log via a Powershell script, for example.

Categories : Iis

Python: subprocess.call, stdout to file, stderr to file, display stderr on screen in real time
You can do this with subprocess, but it's not trivial. If you look at the Frequently Used Arguments in the docs, you'll see that you can pass PIPE as the stderr argument, which creates a new pipe, passes one side of the pipe to the child process, and makes the other side available to use as the stderr attribute.* So, you will need to service that pipe, writing to the screen and to the file. In general, getting the details right for this is very tricky.** In your case, there's only one pipe, and you're planning on servicing it synchronously, so it's not that bad. import subprocess proc = subprocess.Popen(['path_to_tool', '-option1', 'option2'], stdout=file_out, stderr=subprocess.PIPE) for line in proc.stderr: sys.stdout.write(line) log_file.write(line) pro

Categories : Python

How disable http logs from Rspec output?
faraday does not log anything per default: irb(main):001:0> require "faraday" => true irb(main):002:0> Faraday.get 'http://sushi.com/nigiri/sake.json' => #<Faraday::Response:0x007ff48f0422a8 @env={:method=>:get, :body=>"", :url=>#<URI::HTTP:0x007ff48f03bd40 URL:http://sushi.com/nigiri/sake.json>, :request_headers=>{"User-Agent"=>"Faraday v0.8.7"}, :parallel_manager=>nil, :request=>{:proxy=>nil}, :ssl=>{}, :status=>302, :response_headers=>{"date"=>"Thu, 25 Jul 2013 14:36:42 GMT", "server"=>"Apache/2.2.22 (Ubuntu)", "x-powered-by"=>"PHP/5.3.10-1ubuntu3.6", "location"=>"http://sushi.com/?f", "vary"=>"Accept-Encoding", "content-length"=>"20", "connection"=>"close", "content-type"=>"text/html", "set-cookie"=>"WEBU

Categories : Ruby On Rails

Where is my nginx being configured? Changing nginx.conf still brings me to the 'Welcome to nginx' page
when you rewrited the nginx.conf in the folder of source code of nginx and installed it firstly, it will be copied to /usr/local/nginx/conf/nginx.conf (without specially modification of the configure in the folder of source code). But when you do this secondly, the nginx.conf in the folder of source code will be copied to /usr/local/nginx/conf/nginx.conf.defualt,and it usually don't work unless you use nginx -c /usr/local/nginx/conf/nginx.conf.defualt to assign its configure file evertime. There is a line NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" in your script above,which indicates the configure file clearly. To handle this, I suggest rewrite /usr/local/nginx/conf/nginx.conf (not the one in the folder of source code) instead.

Categories : Nginx

Nginx no longer starts and doesn't give output
You seem to have a problem here: #server { listen 80 default; server_name anything; # Everything is a 404 location / { return 404; } } server is commented out, but the other lines in that set are not. If you intended on commenting out the entire server block, you'll need to use: #server { # listen 80 default; # server_name anything; # # Everything is a 404 # location / { # return 404; # } #}

Categories : Ruby On Rails

How to conveniently store common logs and client specific logs
I would have an xml file that contain the appenders to specify what packages go into what log file. You can then load the xml file in your application entry point. Below is an example I have used in my current project <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <!-- appenders --> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out" /> <param name="threshold" value="error" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[%t] %p %c - %m%n" /> </layout> </appender> <appender name="codebaseXAppender" class="org.apache.log4j.RollingFileAppender"> <

Categories : Java

Parsing a CSV - random output
I'm guessing that the issue you're having is an End of Line (EOL) mismatch. Basically, the fgetcsv() function breaks up a file based on a new-line character, but it's expecting a different character than the one that's being using the file (for instance, vs vs ). The result is that the function is just grabbing the first 1000 characters (as per the function call) and treating it as the first line, then it's grabbing the next 1000 character, etc... this would result in somewhat random outputs. You might be able to try something like: ini_set('auto_detect_line_endings', true); before you grab the file. Or you could go through and manually modify the CSV to standardize the EOL characters/open the spreadsheet in a file-conversion which allows you to change the EOL character (i.e. Uni

Categories : PHP

Not getting random numbers in output
myOutput.print(numbers + " "); You are printing Random class instance here. You need to do something like: myOutput.print(numbers.nextInt(100)+ " "); Read Random class documentation EDIT: No, just array will print again similar output (Object String), if you want to output the random value stored in array, you need to do something like: myOutput.print(array[i] + " ");

Categories : Java

Linked Lists in C, Random output?
Parameters of C functions are passed by value. Thus, the changes that you make to the values of head and tail in the add() function will not be reflected in main() from which add() is called. And, it doesn't seem that you've supplied a second parameter for printf(), so the %d format is not going to get the integer value that it will be looking for.

Categories : C

random number different output everytime
First of all, you can never be sure that a configuration does not repeat. There are just 6 permutations of 3 elements, so each 6th rerun (statistically) the configuration would repeat, assuming that you have 3 items in the list. Next, about your hangs. You are removing items from the list, and then ask the program to find an element there. Imagine this situation: your names are Fred, Eric, Mike. The choices are Fred - Eric Eric - Fred So you get only Mike in the list and only Mike in the list of santas. See the problem? There is no way to choose a santa. This can be solved in a few ways. The most simple way is to shuffle names, assume that they are corresponding by indices and check whether anybody is santa for himself. If so, reshuffle. This still has the mentioned problem, but just

Categories : Java

Unable to remove the random numbers after the output
The std::cout << language(); is printing an integer for you since language() returns an int. If you don't want anything to print after your text, then remove the std::cout << in your main.

Categories : C++

Arduino output pin outputs random activity
Unused index: Everywhere you loop over three values, whereas you only use two items in the array. So you'd better change all your sizes to 2 instead of 3, or you can define a NB_INPUT constant at the top of your source code, that you can change easily for more flexibility: #define NB_INPUT 2 ... for (int i = 0; i<NB_INPUT; ++i) { ... RXOK in setup(): your comment about arrays is justified, the first bug I can see in your code is that you read from the RXOK array, whereas you did not put any values in it. If you're sure that RXSG gets only zeroes from pulseIn() on the first pass of the Read RX values loop it can be ok, but I doubt it is. e.g.: for (int i=0; i<3; ++i) RXOK[i] = 0; So you should put values in RXOK values in setup(). constant indexes in a for loop: T

Categories : C

Get iPhone Logs(not crash logs)
Got a breakthrough!!. We need to re-direct NSLog to a file like this and then access the file. - (void)redirectNSLogToDocumentFolder{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fileName =[NSString stringWithFormat:@"%@.log",[NSDate date]]; NSString *logFilePath = [documentsDirectory stringByAppendingPathComponent:fileName]; freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr); } http://objcolumnist.com/2009/12/19/redirecting-nslog-to-a-log-file/

Categories : IOS

Java Program output printed in random position in Eclipse console
Which logging framework do you use with SLF4J? It could be that the logging framework is configured to write the log messages asynchronously in a background thread. You can try to replace the log call with a System.out.println() and see if that produces the output you expect. If it does you may want to reconfigure the logging framework to log the messages synchronously.

Categories : Eclipse

c++ generating random numbers without repetition .output screen is just blank with a blinking cursor.
Your duplicate checking loop has a flaw: the check is set to the result of checking the last pair of values, rather than the result of checking all the preceding pairs. You need to set check = true before the inner loop, then proceed to verifying all items from zero to i-1. If the check becomes false at any point, stop the loop: check = true; for (j = 0 ; (check) && (j < i) ; j++) { check = (num[i] != num[j]); } In addition, you need to fix the randrange, because your current implementation returns values in range 2..11: int randrange(int low,int high) { return rand()%(high-low+1)+low; }

Categories : C++

Restarting nginx: nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable
Passenger takes what you set in the file nginx.conf by passenger_ruby, for example: passenger_root /home/dev/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.5; passenger_ruby /home/dev/.rvm/wrappers/ruby-1.9.3-p448/ruby;

Categories : Ruby

Very non-random factor of Math.random when filling an array with random numbers
If the length is even, you add all the numbers once and subtract all of them once – of course, the result is 0. Example with length==6: /*i==0*/ sum += rand[0] + rand[5]; /*i==1*/ sum -= rand[1] + rand[4]; /*i==2*/ sum += rand[2] + rand[3]; /*i==3*/ sum -= rand[3] + rand[2]; /*i==4*/ sum += rand[4] + rand[1]; /*i==5*/ sum -= rand[5] + rand[0]; Did you try any uneven lengths?

Categories : Java

Can a server run Nginx for some sites and Apache Nginx Reverse Proxy for others?
server { server_name example.com; location / { # assuming apache is on port 81 for example proxy_pass http://127.0.0.1:81; # to make apache detect the host header proxy_set_header Host $host; } # if you have assets folders, you can let nginx serve them directly, # instead of passing them to apache location /images { # or /css or /js .. etc try_files $uri =404; } } Note: in the case of assets, sometimes some sites serve assets through rewrites, or even handled by the application it self, you can pass it to apache by adding that in the assets location as a fallback like this location /images { try_files $uri @apache; } location @apache { proxy_pass http://127.0.0.1:81; } In apache you create a virtual host <Virtua

Categories : Apache

(C#) How can I take numbers from my random number generator and output the highest and lowest number in a message box?
If you put all the numbers in a collection you can use the LINQ to Objects extension methods Min and Max Random random = new Random(); List<int> randos = new List<int>(); for (int i = 0; i < 11; i++) { randos.Add(random.Next(1000)); } int min = randos.Min(); int max = randos.Max(); Console.WriteLine("The minimum value is " + min); Console.WriteLine("The maximum value is " + max); Because you cannot get the min or max until you've generated the full list, that code needs to be outside of the for loop and you need to put all the random values in a collection so that they persist. I think your problem lies in an attempt to do it all a streaming manner when you must first have a fully formed collection. Also, if you want to pop up a message box then you should probably

Categories : C#

AS3 Boolean seemingly not working
Pathing There are some un-addressed variables in your issue, foremost being the pathing you're taking to check your variable. This is relevant because of namespaces/scope affect what each piece of code has access to. If your functions and variables shared the same space (i.e., global/document/timeline), then any reference the the same named variable will always return the same value, unless (as LoremIpsum noted) it's being shadowed by a local variable by the same name. Obviously, this is not the case since you're using public function which is a class-only declaration. If the boolean you're looking for is on the timeline, and the class wants to read that variable, you need to have a valid path to it. Instantiated classes that are DisplayObjects and have been added to the DisplayList

Categories : Actionscript

Why is my dynamic HTML seemingly randomly placed?
First of all, I would clear the first book left. You can do that with section.wrapper:first-child{ clear: left; } Then, you should probably find out the heights of all elements that you're dynamically creating, and set all elements to the height of the largest element, otherwise things get messy. When one is too tall on the left, two elements will end up to the right of it, floating up against the side of the left element. I wrote something to find the height of the largest element: largest = 0; $(".wrapper").each(function () { if ($(this).height() > largest) { largest = $(this).height(); } }); $(".wrapper").css("height", $largest); Place that code right after this line: }); //getJSONNBCCJr Finally, you should really be floating all your .wrapper s

Categories : Jquery

Seemingly silly query about parameters
You need to create a link with that ID: if you're doing a get-request that would be something like this: @Html.ActionLink("Add service to invoice", "Controller", "AddServiceToInvoice", new {id = Model.InvoiceViewModel.InvoiceId}) Otherwise if you want to do a post you need to create a form: @using Html.BeginForm(action, controller, FormMethod.Post) { <input type="hidden" value="@Model.InvoiceViewModel.InvoiceId" /> <input type="submit" value="Add service to invoice" /> }

Categories : C#

Seemingly automatic pointer freeing
Because you are returning pointers to objects whose lifetime has expired. In particular, chWordsList inside the return value points to an object whose lifetime ends when the function returns. When you dereference that pointer you get undefined behavior (UB); therefore any result would not be surprising. What you need to do is malloc memory for the chWordList instead of declaring it as a local array: char **chWordList = malloc(intFileSize * sizeof(char*))

Categories : C

Javascript seemingly existing object
Maybe you need to change your loop to use indexes: var i = 0, position = {}; for (i = 0; i < gl.box.length; i += 1) { position = gl.boxes[i].element.position(); uri += "boxName[" + i + "]=" + gl.boxes[i].boxName + "&" + "boxX[" + i + "]=" + position.left + "&" + "boxY[" + i + "]=" + position.top + "&"; }

Categories : Javascript

Grails log4j appender configuration seemingly ignored
Try applying the apender to your info level log4j = { ... root{ info 'stdout' } ... } I think what you are missing is loggers do not know where to send the messages. Generally you can do that by error myAppender: "grails.app.controllers.BookController", myFileAppender: ["grails.app.controllers.BookController", "grails.app.services.BookService"], rollingFile: "grails.app.controllers.BookController" or define it at the root level for all levels. Take a look at Documentation 4.1.2 Logging log4j = { appenders { console name: 'stdout', layout: pattern(conversionPattern: '%d{yyyy-MM-dd HH:mm:ss,SSS Z} [%t] %-5p %c{1}:%L %x - %m%n') } error stdout: 'org.codehaus.groovy.grails.web.servlet',

Categories : Grails

Activity Crashing for seemingly no reason ? -Android
Your setContentView should come first before initialization of view. Replace this TextView textView = (TextView) findViewById(R.id.xxtt); setContentView(R.layout.xtxt); By setContentView(R.layout.xtxt); TextView textView = (TextView) findViewById(R.id.xxtt); in onCreate You can findViewById of the current view hierarchy set to the activity. Since you have not set the layout to the activity your findViewById fails. You are probably getting NUllPointerException because of this. Edit: It is better to initialize your views in onCreate since it is called once during the lifecyle of the activity. Quoting from the docs http://developer.android.com/reference/android/app/Activity.html onCreate(Bundle) is where you initialize your activity. Most importantly, here you will usua

Categories : Android

Highcharts columns have no width (seemingly arbitrarily)
That's really odd. But, you're first data series is in reverse date order. If you fix that, the chart is right. http://jsfiddle.net/pUTQd/ series: [{ name: 'Average Response Time', data: [[Date.UTC(2013, 7, 2), 354.5], [Date.UTC(2013, 7, 3), 1981.875], [Date.UTC(2013, 7, 4), 434.5], [Date.UTC(2013, 7, 5), 678.1], [Date.UTC(2013, 7, 6), 87.465] ], dataGrouping: { enabled: false }, pointPadding: .05 }], (note I just changed the dates, I didn't change the data)

Categories : Javascript

My boolean statement works one way but not in a seemingly unchanged way
You are getting the value of day from console and checking in loop, by using boolean variable the check is not done each time but the previous value persists. If you want to do the same thing do it in a function and call it from inside the loop.

Categories : Java

Why is my seemingly self-contained web page deaf to jQuery?
There's a few things. If you're not using a webserver but opening the file directly in the browser you'll need to change: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> to <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> And you should add the script tags at the bottom of the file BEFORE the closing </body> tag, not after it, and the style tags should be inside the <head> tags, i.e. before the closing </head> tag.

Categories : Jquery

Why is this seemingly simple Xpath navigation not working?
It may sound kind of simplistic, but the element you are looking for is the only doc element that is using the css class "basic-text-white". I would think this would be a lot easier to find and extract than a long xpath. Web-scraping is never a stable thing, but I would think this is probably as stable as the xpath. Trying to debug the xpath just about makes my eyes bleed.

Categories : C#

CUDA kernel seemingly ignoring "if" statement
From the doc, atomicCAS returns the old value, that means, that in your list, your two outcomes are wrong. Your X will always be set to the old value of localMap[fn], regardless which value it had. What is set according to the comparison with the -1, is the new value of localMap[fn]. When it is -1, it is set to rnumber, else it is left intact. So the behaviour you see with the values of X, rnumber and localMap are as expected. I cannot help with your second problem, as I dont use NSight, and dont know how it works - according to your code, your true branch should be evaluated (but be careful: your false branch also - as it is multi threaded some threads can have the condition evaluated to true, and some to false - my guess/assumption would be that you must tell somehow your debugger whi

Categories : C++

NullReference at seemingly innocent WeakReference access?
This ended up being a very hard to spot logic bug that was in plain sight. The offending if statement really was more like this: if(lastString!=null && limiter==null || limiter=lastLimiter) The true grouping of this is more like this: if((lastString!=null && limiter==null) || limiter=lastLimiter) And as Murphy's law would dictate, somehow, in this one unrelated test case, lastLimiterand lastString got set to null by a method used no where but this one single test case. So yea, no bug in the CLR, just my own logic bug that was very hard to spot

Categories : C#



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