‏إظهار الرسائل ذات التسميات Error. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات Error. إظهار كافة الرسائل

الأحد، 5 يناير 2014

In java how to fix HTTP error 416 Requested Range Not Satisfiable? (While downloading web content from a web page)

I am trying to download the html content of a web page for e.g http://www.jobstreet.com.sg/ I am getting the 416 status. I found one solution which correctly improves the status code as 200 but still not downloading the proper content. I am very close but missing something. Please help.

Code with 416 status:

public static void main(String[] args) { String URL="http://www.jobstreet.com.sg/"; HttpClient client = new org.apache.commons.httpclient.HttpClient(); org.apache.commons.httpclient.methods.GetMethod method = new org.apache.commons.httpclient.methods.GetMethod(URL); client.getHttpConnectionManager().getParams().setConnectionTimeout(AppConfig.CONNECTION_TIMEOUT); client.getHttpConnectionManager().getParams().setSoTimeout(AppConfig.READ_DATA_TIMEOUT); String html = null; InputStream ios = null; try { int statusCode = client.executeMethod(method); ios = method.getResponseBodyAsStream(); html = IOUtils.toString(ios, "utf-8"); System.out.println(statusCode); }catch (Exception e) { e.printStackTrace(); } finally { if(ios!=null) { try {ios.close();} catch (IOException e) {e.printStackTrace();} } if(method!=null) method.releaseConnection(); } System.out.println(html);}

Code with 200 status (but htmlContent is not proper):

public static void main(String[] args) {

String URL="http://www.jobstreet.com.sg/"; HttpClient client = new org.apache.commons.httpclient.HttpClient(); org.apache.commons.httpclient.methods.GetMethod method = new org.apache.commons.httpclient.methods.GetMethod(URL); client.getHttpConnectionManager().getParams().setConnectionTimeout(AppConfig.CONNECTION_TIMEOUT); client.getHttpConnectionManager().getParams().setSoTimeout(AppConfig.READ_DATA_TIMEOUT); String html = null; InputStream ios = null; try { int statusCode = client.executeMethod(method); if(statusCode == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) { method.setRequestHeader("User-Agent", "Mozilla/5.0"); method.setRequestHeader("Accept-Ranges", "bytes=100-1500"); statusCode = client.executeMethod(method); } ios = method.getResponseBodyAsStream(); html = IOUtils.toString(ios, "utf-8"); System.out.println(statusCode); }catch (Exception e) { e.printStackTrace(); } finally { if(ios!=null) { try {ios.close();} catch (IOException e) {e.printStackTrace();} } if(method!=null) method.releaseConnection(); } System.out.println(html);}

View the original article here

الجمعة، 27 ديسمبر 2013

AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer:buffer withPresentationTime returning error NSURLErrorCannotCreateFile

I am creating a video file from an array of images. I am able to create video file on simulator, however when I try to run the same code on device it gives following error:

NSURLErrorDomain Code=-3000 "Cannot create file" UserInfo=0x200be260 {NSUnderlyingError=0x200bb030 "The operation couldn’t be completed. (OSStatus error -12149.)", NSLocalizedDescription=Cannot create file}

I have searched a lot but couldn't find anything.

Here is the code for creating path.

NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/movie.mp4"]];-(void)exportImages:(NSArray *)imageArray asVideoToPath:(NSString *)path withFrameSize:(CGSize)imageSize framesPerSecond:(NSUInteger)fps {NSLog(@"Start building video from defined frames.");NSError *error = nil;NSURL *url = [NSURL fileURLWithPath:path];AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL: url fileType:AVFileTypeMPEG4 error:&error];NSParameterAssert(videoWriter);NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys: AVVideoCodecH264, AVVideoCodecKey, [NSNumber numberWithInt:imageSize.width], AVVideoWidthKey, [NSNumber numberWithInt:imageSize.height], AVVideoHeightKey, nil];AVAssetWriterInput* videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings];AVAssetWriterInputPixelBufferAdaptor *adaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:videoWriterInput sourcePixelBufferAttributes:nil];NSParameterAssert(videoWriterInput);NSParameterAssert([videoWriter canAddInput:videoWriterInput]);videoWriterInput.expectsMediaDataInRealTime = YES;[videoWriter addInput:videoWriterInput];//Start a session:[videoWriter startWriting];[videoWriter startSessionAtSourceTime:kCMTimeZero];CVPixelBufferRef buffer = NULL;//convert uiimage to CGImage.int frameCount = 0;for(UIImage * img in imageArray) { buffer = [self pixelBufferFromCGImage:[img CGImage] andSize:imageSize]; while (1) { if (adaptor.assetWriterInput.readyForMoreMediaData) { break; } } BOOL append_ok = NO; int j = 0; while (!append_ok && j < 30) { NSString *border = @"**************************************************"; NSLog(@"\n%@\nProcessing video frame (%d,%d).\n%@",border,frameCount,[imageArray count],border); CMTime frameTime = CMTimeMake(frameCount,(int32_t) fps); append_ok = [adaptor appendPixelBuffer:buffer withPresentationTime:frameTime]; if(!append_ok){ NSError *error = videoWriter.error; if(error!=nil) { NSLog(@"Unresolved error %@,%@.", error, [error userInfo]); } } j++; } if (!append_ok) { printf("error appending image %d times %d\n, with error.", frameCount, j); } frameCount++;}//Finish the session:[videoWriterInput markAsFinished];[videoWriter finishWritingWithCompletionHandler:^{ NSLog(@"Write Ended");}];

}


View the original article here

Grid view row command showing error

I am getting this error:

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

This is my code:

protected void GridViewCommandEventHandler(object sender, GridViewCommandEventArgs e){ if (e.CommandName == "view") { int row_id = Convert.ToInt32(e.CommandArgument); var result = (from test in je.jobposting where test.id==row_id select test).FirstOrDefault(); Session["id"] = result; } else { int row_id = Convert.ToInt32(e.CommandArgument); var result = (from test in je.jobposting where test.id==row_id select test).FirstOrDefault(); je.DeleteObject(result); je.SaveChanges(); Response.Redirect (""); }}

View the original article here

الخميس، 26 ديسمبر 2013

Fabric - render OverlayImage code raise Type Error

The fiddle is here : http://jsfiddle.net/mC4jM/

var canvas = new fabric.Canvas ("c2");canvas.backgroundColor = "#ddd";canvas.add(new fabric.Circle({ radius: 30, fill: '#f55', top: 100, left: 100 }));canvas.setOverlayImage('http://jsfiddle.net/img/logo.png', canvas.renderAll.bind(canvas));

When you select area of the canvas, it will raise Type Error, and google chrome indicates its at line 5853 in fabric.js:

ctx.drawImage(this.overlayImage, this.overlayImageLeft, this.overlayImageTop);

I used fabric.js 1.4.0 and tested in google chrome and FF.

Uncaught TypeError: Type error fabric.StaticCanvas.fabric.util.createClass.renderTop fabric.util.object.extend.__onMouseMove fabric.util.object.extend._onMouseMove

View the original article here

URL Rewrite giving 500 internal error

I'm trying to perform a URL Rewrite but giving me a 500 Internal Server Error

I have an index.php file that can take a parameter which I called cmd so the URL should look like:

http://localhost/some_folder/index.php?cmd=some_parameter

What I'm trying to achieve is allowing users to just type any of the following:

http://localhost/some_folder/some_parameter

OR

http://localhost/some_folder/index/some_parameter

Here is my .htaccess file:

RewriteEngine On # Turn on the rewriting engineRewriteRule ^index.php/?$ index.php?cmd=shifts [NC,L]

I also tried:

Options +FollowSymLinksRewriteEngine onRewriteRule /cmd/(.*)/ index.php?cmd=$1

I don't know what I am doing wrong here!


View the original article here

الثلاثاء، 24 ديسمبر 2013

MySQL Proxy Error: Cannot Load Module "mysql.password"

I am trying to test out a MySQL Proxy Script to handle authentication. And I keep getting errror

2013-12-25 00:25:31: (critical) (lua-error) [E:\Downloads\MySQL\proxy\script.txt][string "E:\Downloads\MySQL\proxy\script.txt"]:2: module 'mysql.password' not found: no field package.preload['mysql.password'] no file 'E:\Downloads\MySQL\proxy\lib\mysql-proxy\lua\mysql\password.lua' no file 'E:\Downloads\MySQL\proxy\bin\lua-mysql\password.dll' no module 'mysql.password' in file 'E:\Downloads\MySQL\proxy\bin\lua-mysql.dll'

Following is my code. By the looks of the message I am missing some files. But I could not find any help by searching. Any help will be appreciated.

local proto = assert(require("mysql.proto"))local password = assert(require("mysql.password"))function read_auth() print(" username : " .. proxy.connection.client.username) print(" password : " .. string.format("%q", proxy.connection.client.scrambled_password)) local c = proxy.connection.client local s = proxy.connection.server if c.username == "test" and -- the username we want to map password.check( s.scramble_buffer, c.scrambled_password, password.hash(password.hash("test")) -- its valid password ) then proxy.queries:append(1, proto.to_response_packet({ username = "root", response = password.scramble(s.scramble_buffer, password.hash("admin")), charset = 8, -- default charset database = c.default_db, max_packet_size = 1 * 1024 * 1024 }) ) return proxy.PROXY_SEND_QUERY -- works if you use lp:mysql-proxy r694 or later endend

View the original article here

500 internal server error - php

I am running the 1 website on my server. That website has a search facility.

When I search for a category named "apple" at that time its showing 10 results and I am getting search result page fine and fast. [RECORDS ARE PAGINATED 10 records per page]

Now, When I search for "orange" named category at that time its giving me an internal server 500 error. It's just because it's trying to pull 300000 records from the database. [After 2 mins I am getting this error on page]

So How can I resolve this issue? I have checked queries too and its all fine. I need to record faster with no errors like internal server.

Is there any way to resolve this?

Please help! Thank you....


View the original article here

Error when pushing to github? [on hold]

I am trying to push to a project onto github using git push -u origin master but am getting the following error:

error: src refspec master does not match any.error: failed to push some refs to 'https://github.com/mantismamita/kirstens-git.git'

This is my first attempt at actually pushing anything and a day ago I misspelled my github password when prompted. I've tried closing and reopening terminal, waiting a day, and even password caching but haven't had any luck. Any help explaining this error would be greatly appreciated.

Second commit:

! [rejected] master -> master (non-fast-forward)error: failed to push some refs to 'https://github.com/mantismamita/kirstens-git.git'hint: Updates were rejected because the tip of your current branch is behindhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')hint: before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

UPDATE: SOLVED (see comments)


View the original article here