Search Results

Search found 562 results on 23 pages for 'pragma'.

Page 9/23 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Nginx proxy cache (proxy_pass $request_uri;)

    - by imastar
    I need to create proxy web using nginx. If I access http://myweb.com/http://www.target.com/ the proxy_pass should be http://www.target.com/ Here is my configuration: location / { proxy_pass $request_uri; proxy_cache_methods GET; proxy_set_header Referer "$request_uri"; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_ignore_headers Cache-Control; proxy_hide_header Pragma; proxy_hide_header Set-Cookie; proxy_set_header Cache-Control Public; proxy_cache cache; proxy_cache_valid 200 10h; proxy_cache_valid 301 302 1h; proxy_cache_valid any 1h; } Here is the log error 2013/02/05 12:58:51 [error] 2118#0: *8 invalid URL prefix in "/http://www.target.com/", client: 108.59.8.83, server: myweb.com, request: "HEAD /http://www.target.com/ HTTP/1.1", host: "myweb.com"

    Read the article

  • How can I remove HTTP headers with .htaccess in Apache?

    - by Daniel Magliola
    I have a website that is sending out "cache-control" and "pragma" HTTP headers for PHP requests. I'm not doing that in the code, so I'm assuming it's some kind of Apache configuration, as suggested by this question (you don't really need to go there for this question's context) I don't have anything in my .htaccess files, so it's gotta be in Apache's configuration itself, but I can't access that, this is a shared hosting, I only have FTP access to my website's directory. Is there any way that I can add directives to my .htaccess files that will remove the headers added by the global configuration, or otherwise override the directive so that they're not added in the first place? Thank you very much Daniel

    Read the article

  • Unity3D - Android pause screen - double click issue

    - by user3666251
    I made a pause script for the game im developing for android. I added the script to the GUITexture I created and placed on the top right side of the screen.The issue stands at the part where if the player clicks the pause button then clicks resume then he wants to pause the game again.When he clicks pause the second time the buttons dont show up unless he clicks again. This is the script : #pragma strict var paused = false; var isButtonVisible : boolean = true; function OnMouseDown(){ this.paused = !this.paused; Time.timeScale = 0; isButtonVisible = true; } function OnGUI(){ if ( isButtonVisible ) { if(this.paused){ if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2+3,200,50),"Restart")){ Application.LoadLevel(Application.loadedLevel); Time.timeScale = 1; isButtonVisible = false; } if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2-50,200,50),"Resume")){ Time.timeScale = 1; isButtonVisible = false; } // Insert the rest of the pause menu logic if (GUI.Button(Rect(Screen.width/2-100,Screen.height/2+56,200,50),"Main Menu")){ Application.LoadLevel ("MainMenu"); isButtonVisible = false; Time.timeScale = 1; } } } } Thank you.

    Read the article

  • Am I an idealist?

    - by ereOn
    This is not only a question, this is also a call for help. Since I started my career as a programmer, I always tried to learn from my mistakes. I worked hard to learn best-practices and while I don't consider myself a C++ expert, I still believe I'm not a beginner either. I was recently hired into a company for C++ development. There I was told that my way to work was "against the rules" and that I would have to change my mind. Here are the topics I disagree with my hierarchy (their words): "You should not use separate header files for your different classes. One big header file is both easier to read and faster to compile." "Trying to use different headers is counter-productive : use the same super-set of headers everywhere, and enforce the use #pragma hdrstop to hasten compilation" "You may not use Boost or any other library that uses nested directories to organize its files. Our build-machine doesn't work with nested directories. Moreover, you don't need Boost to create great software." One might think I'm somehow exaggerated things, but the sad truth is that I didn't. That's their actual words. I believe that having separate files enhance maintainability and code-correctness and can fasten compilation time by the use of the proper includes. Have you been in a similar situation? What should I do? I feel like it's actually impossible for me to work that way and day after day, my frustration grows.

    Read the article

  • How can I avoid a 302 for Fetch as Bot?

    - by CookieMonster
    I originally posted this on Stackoverflow, but I believe here is a better place to ask. My web application is very similar to notepad.cc which redirects to a randomly generated URL upon access, e.g. http://myapp.com/roTr94h4Gd. (Please note that notepad.cc is not my site.) Probably because of this redirect feature, when I do "fetch as Google" or "fetch as Bingbot", I get a 302 and no html content. Not even a <html></html> tag. HTTP/1.1 302 Moved Temporarily Server: nginx/1.4.1 Date: Tue, 01 Oct 2013 04:37:37 GMT Content-Type: text/html Transfer-Encoding: chunked Connection: keep-alive X-Powered-By: PHP/5.4.17-1~dotdeb.1 Set-Cookie: PHPSESSID=vp99q5e5t5810e3bnnnvi6sfo2; expires=Thu, 03-Oct-2013 04:37:37 GMT; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Location: /roTr94h4Gd How should I avoid 302 in this case? I suppose I could modify my site to prevent the redirect, but it is a necessary feature of my web app to generate a random URL on each access. I added <meta name="fragment" content="!"> tag into my index page and set it to return a static snapshot of my page when the flag is set. But this still returns a 302. I also added a header to return 200 before redirecting, but this had no effect, either. Could someone tell me a good suggestion to solve this problem?

    Read the article

  • How can I use the dualforward parameter in my unity shader to use lightmaps and normal maps together?

    - by Raphaeltm
    I'm using the free version of unity and I would like to combine lightmaps with specularity and normal maps. After doing a -bunch- of research, I've figured out that there doesn't seem to be any easy way to do this in the free version of unity, which doesn't support deferred rendering/easy use of dual lightmaps. However, it looks like it's possible, by writing a custom shader, using the "dualforward" parameter in a shader, switching the lightmapping mode to "dual lightmaps" and turning on "Use in forward ren." (basically, writing a shader that specifies the use of dual lightmaps, which should allow for a combination of lightmaps and normal maps) So I downloaded the source code for the default shaders (because all I need is a normal specular bumped shader) and added "dualforward" to the parameters: Shader "Bumped Specular Dual Lightmaps" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 400 CGPROGRAM #pragma surface surf BlinnPhong dualforward sampler2D _MainTex; sampler2D _BumpMap; fixed4 _Color; half _Shininess; struct Input { float2 uv_MainTex; float2 uv_BumpMap; }; void surf (Input IN, inout SurfaceOutput o) { fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); o.Albedo = tex.rgb * _Color.rgb; o.Gloss = tex.a; o.Alpha = tex.a * _Color.a; o.Specular = _Shininess; o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); } ENDCG } FallBack "Specular" } This, however, doesn't seem to work. When I keep the "dualforward" param, every object that uses it seems to be lit by the one directional light in the scene. When I remove the "dualforward" param, it they look like normal lightmapped objects with no normal maps or specularity. I noticed that the support for "dualforward" seems to be new in v.3.4.2, so I made sure to download it (I was running 3.4.1), but it still doesn't work. Anybody have any advice for me?

    Read the article

  • CCSpriteHole in cocos2d 2.0?

    - by rakkarage
    i was using this cocos2d class CCSpriteHole in cocos2d 1.0 fine... http://jpsarda.tumblr.com/post/15779708304/new-cocos2d-iphone-extensions-a-progress-bar-and-a i am trying to convert it to cocos2d 2.0... i got it to compile by changing glVertexPointer to glVertexAttribPointer like in the 2.0 version of CCSpriteScale9 here http://jpsarda.tumblr.com/post/9162433577/scale9grid-for-cocos2d and changing contentSizeInPixels_ to contentSize_... -(id) init { if( (self=[super init]) ) { opacityModifyRGB_ = YES; opacity_ = 255; color_ = colorUnmodified_ = ccWHITE; capSize=capSizeInPixels=CGSizeZero; //Not used blendFunc_.src = CC_BLEND_SRC; blendFunc_.dst = CC_BLEND_DST; // update texture (calls updateBlendFunc) [self setTexture:nil]; // default transform anchor anchorPoint_ = ccp(0.5f, 0.5f); vertexDataCount=24; vertexData = (ccV2F_C4F_T2F*) malloc(vertexDataCount * sizeof(ccV2F_C4F_T2F)); [self setTextureRectInPixels:CGRectZero untrimmedSize:CGSizeZero]; } return self; } -(id) initWithTexture:(CCTexture2D*)texture rect:(CGRect)rect { NSAssert(texture!=nil, @"Invalid texture for sprite"); // IMPORTANT: [self init] and not [super init]; if( (self = [self init]) ) { [self setTexture:texture]; [self setTextureRect:rect]; } return self; } -(id) initWithTexture:(CCTexture2D*)texture { NSAssert(texture!=nil, @"Invalid texture for sprite"); CGRect rect = CGRectZero; rect.size = texture.contentSize; return [self initWithTexture:texture rect:rect]; } -(id) initWithFile:(NSString*)filename { NSAssert(filename!=nil, @"Invalid filename for sprite"); CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage: filename]; if( texture ) return [self initWithTexture:texture]; return nil; } +(id)spriteWithFile:(NSString*)f { return [[self alloc] initWithFile:f]; } - (void) dealloc { if (vertexData) free(vertexData); } -(void) updateColor { ccColor4F color4; color4.r=(float)color_.r/255.0f; color4.g=(float)color_.g/255.0f; color4.b=(float)color_.b/255.0f; color4.a=(float)opacity_/255.0f; for (int i=0; i<vertexDataCount; i++) { vertexData[i].colors=color4; } } -(void)updateTextureCoords:(CGRect)rect { CCTexture2D *tex = texture_; if(!tex) return; float atlasWidth = (float)tex.pixelsWide; float atlasHeight = (float)tex.pixelsHigh; float left,right,top,bottom; left = rect.origin.x/atlasWidth; right = left + rect.size.width/atlasWidth; top = rect.origin.y/atlasHeight; bottom = top + rect.size.height/atlasHeight; // // |/|/|/| // CGSize capTexCoordsSize=CGSizeMake(capSizeInPixels.width/atlasWidth, capSizeInPixels.height/atlasHeight); // From left to right //Top band // Left vertexData[0].texCoords=(ccTex2F){left,top}; vertexData[1].texCoords=(ccTex2F){left,top+capTexCoordsSize.height}; vertexData[2].texCoords=(ccTex2F){left+capTexCoordsSize.width,top}; vertexData[3].texCoords=(ccTex2F){left+capTexCoordsSize.width,top+capTexCoordsSize.height}; // Center vertexData[4].texCoords=(ccTex2F){right-capTexCoordsSize.width,top}; vertexData[5].texCoords=(ccTex2F){right-capTexCoordsSize.width,top+capTexCoordsSize.height}; // Right vertexData[6].texCoords=(ccTex2F){right,top}; vertexData[7].texCoords=(ccTex2F){right,top+capTexCoordsSize.height}; //Center band // Left vertexData[8].texCoords=(ccTex2F){left,bottom-capTexCoordsSize.height}; vertexData[9].texCoords=(ccTex2F){left,top+capTexCoordsSize.height}; vertexData[10].texCoords=(ccTex2F){left+capTexCoordsSize.width,bottom-capTexCoordsSize.height}; vertexData[11].texCoords=(ccTex2F){left+capTexCoordsSize.width,top+capTexCoordsSize.height}; // Center vertexData[12].texCoords=(ccTex2F){right-capTexCoordsSize.width,bottom-capTexCoordsSize.height}; vertexData[13].texCoords=(ccTex2F){right-capTexCoordsSize.width,top+capTexCoordsSize.height}; // Right vertexData[14].texCoords=(ccTex2F){right,bottom-capTexCoordsSize.height}; vertexData[15].texCoords=(ccTex2F){right,top+capTexCoordsSize.height}; //Bottom band //Left vertexData[16].texCoords=(ccTex2F){left,bottom}; vertexData[17].texCoords=(ccTex2F){left,bottom-capTexCoordsSize.height}; vertexData[18].texCoords=(ccTex2F){left+capTexCoordsSize.width,bottom}; vertexData[19].texCoords=(ccTex2F){left+capTexCoordsSize.width,bottom-capTexCoordsSize.height}; // Center vertexData[20].texCoords=(ccTex2F){right-capTexCoordsSize.width,bottom}; vertexData[21].texCoords=(ccTex2F){right-capTexCoordsSize.width,bottom-capTexCoordsSize.height}; // Right vertexData[22].texCoords=(ccTex2F){right,bottom}; vertexData[23].texCoords=(ccTex2F){right,bottom-capTexCoordsSize.height}; } -(void) updateVertices { float left=0; //-spriteSizeInPixels.width*0.5f; float right=left+contentSize_.width; float bottom=0; //-spriteSizeInPixels.height*0.5f; float top=bottom+contentSize_.height; float holeLeft=holeRect.origin.x*CC_CONTENT_SCALE_FACTOR(); float holeRight=holeLeft+holeRect.size.width*CC_CONTENT_SCALE_FACTOR(); float holeBottom=holeRect.origin.y*CC_CONTENT_SCALE_FACTOR(); float holeTop=holeBottom+holeRect.size.height*CC_CONTENT_SCALE_FACTOR(); // // |/|/|/| // // From left to right //Top band // Left vertexData[0].vertices=(ccVertex2F){left,top}; vertexData[1].vertices=(ccVertex2F){left,holeTop}; vertexData[2].vertices=(ccVertex2F){holeLeft,top}; vertexData[3].vertices=(ccVertex2F){holeLeft,holeTop}; // Center vertexData[4].vertices=(ccVertex2F){holeRight,top}; vertexData[5].vertices=(ccVertex2F){holeRight,holeTop}; // Right vertexData[6].vertices=(ccVertex2F){right,top}; vertexData[7].vertices=(ccVertex2F){right,holeTop}; //Center band // Left vertexData[8].vertices=(ccVertex2F){left,holeBottom}; vertexData[9].vertices=(ccVertex2F){left,holeTop}; vertexData[10].vertices=(ccVertex2F){holeLeft,holeBottom}; vertexData[11].vertices=(ccVertex2F){holeLeft,holeTop}; // Center vertexData[12].vertices=(ccVertex2F){holeRight,holeBottom}; vertexData[13].vertices=(ccVertex2F){holeRight,holeTop}; // Right vertexData[14].vertices=(ccVertex2F){right,holeBottom}; vertexData[15].vertices=(ccVertex2F){right,holeTop}; //Bottom band //Left vertexData[16].vertices=(ccVertex2F){left,bottom}; vertexData[17].vertices=(ccVertex2F){left,holeBottom}; vertexData[18].vertices=(ccVertex2F){holeLeft,bottom}; vertexData[19].vertices=(ccVertex2F){holeLeft,holeBottom}; // Center vertexData[20].vertices=(ccVertex2F){holeRight,bottom}; vertexData[21].vertices=(ccVertex2F){holeRight,holeBottom}; // Right vertexData[22].vertices=(ccVertex2F){right,bottom}; vertexData[23].vertices=(ccVertex2F){right,holeBottom}; } -(void) setHole:(CGRect)r inRect:(CGRect)totalSurface { holeRect=r; self.contentSize=totalSurface.size; holeRect.origin=ccpSub(holeRect.origin,totalSurface.origin); CGPoint holeCenter=ccp(holeRect.origin.x+holeRect.size.width*0.5f,holeRect.origin.y+holeRect.size.height*0.5f); self.anchorPoint=ccp(holeCenter.x/contentSize_.width,holeCenter.y/contentSize_.height); //[self updateTextureCoords:rectInPixels_]; [self updateVertices]; [self updateColor]; } -(void) draw { BOOL newBlend = NO; if( blendFunc_.src != CC_BLEND_SRC || blendFunc_.dst != CC_BLEND_DST ) { newBlend = YES; glBlendFunc( blendFunc_.src, blendFunc_.dst ); } glBindTexture(GL_TEXTURE_2D, [texture_ name]); glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4F_T2F), &vertexData[0].vertices); glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4F_T2F), &vertexData[0].texCoords); glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4F_T2F), &vertexData[0].colors); glDrawArrays(GL_TRIANGLE_STRIP, 0, 8); glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4F_T2F), &vertexData[8].vertices); glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4F_T2F), &vertexData[8].texCoords); glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4F_T2F), &vertexData[8].colors); glDrawArrays(GL_TRIANGLE_STRIP, 0, 8); glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4F_T2F), &vertexData[16].vertices); glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4F_T2F), &vertexData[16].texCoords); glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, sizeof(ccV2F_C4F_T2F), &vertexData[16].colors); glDrawArrays(GL_TRIANGLE_STRIP, 0, 8); if( newBlend ) glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST); } -(void)setTextureRectInPixels:(CGRect)rect untrimmedSize:(CGSize)untrimmedSize { rectInPixels_ = rect; rect_ = CC_RECT_PIXELS_TO_POINTS( rect ); //[self setContentSizeInPixels:untrimmedSize]; [self updateTextureCoords:rectInPixels_]; } -(void)setTextureRect:(CGRect)rect { CGRect rectInPixels = CC_RECT_POINTS_TO_PIXELS( rect ); [self setTextureRectInPixels:rectInPixels untrimmedSize:rectInPixels.size]; } // // RGBA protocol // #pragma mark CCSpriteHole - RGBA protocol -(GLubyte) opacity { return opacity_; } -(void) setOpacity:(GLubyte) anOpacity { opacity_ = anOpacity; // special opacity for premultiplied textures if( opacityModifyRGB_ ) [self setColor: (opacityModifyRGB_ ? colorUnmodified_ : color_ )]; [self updateColor]; } - (ccColor3B) color { if(opacityModifyRGB_){ return colorUnmodified_; } return color_; } -(void) setColor:(ccColor3B)color3 { color_ = colorUnmodified_ = color3; if( opacityModifyRGB_ ){ color_.r = color3.r * opacity_/255; color_.g = color3.g * opacity_/255; color_.b = color3.b * opacity_/255; } [self updateColor]; } -(void) setOpacityModifyRGB:(BOOL)modify { ccColor3B oldColor = self.color; opacityModifyRGB_ = modify; self.color = oldColor; } -(BOOL) doesOpacityModifyRGB { return opacityModifyRGB_; } #pragma mark CCSpriteHole - CocosNodeTexture protocol -(void) updateBlendFunc { if( !texture_ || ! [texture_ hasPremultipliedAlpha] ) { blendFunc_.src = GL_SRC_ALPHA; blendFunc_.dst = GL_ONE_MINUS_SRC_ALPHA; [self setOpacityModifyRGB:NO]; } else { blendFunc_.src = CC_BLEND_SRC; blendFunc_.dst = CC_BLEND_DST; [self setOpacityModifyRGB:YES]; } } -(void) setTexture:(CCTexture2D*)texture { // accept texture==nil as argument NSAssert( !texture || [texture isKindOfClass:[CCTexture2D class]], @"setTexture expects a CCTexture2D. Invalid argument"); texture_ = texture; [self updateBlendFunc]; } -(CCTexture2D*) texture { return texture_; } @end but now positioning and scaling seem to not work? and it starts in the wrong position... but changing the opacity still works. so i was wondering if anyone can see why my 2.0 version is not working? or if maybe there is a better way to do a sprite hole with cocos2d/opengl 2.0? shaders? thanks

    Read the article

  • Nginx + PHP-FPM ignores no-cache headers

    - by Eric Winchell
    I'm using the following header on a php page. // Prevent page caching. header('Expires: Tue, 20 Oct 1981 05:00:00 GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', FALSE); header('Pragma: no-cache'); I'm also using a rand=999999999 (with a real random number) in the URLs. But pages are still being cached. Reload works, but first load is cached. Anyone know where I can change this?

    Read the article

  • Is a 302 redirect to a random URL from the homepage an SEO problem?

    - by CookieMonster
    I originally posted this on Stackoverflow, but I believe here is a better place to ask. My web application is very similar to notepad.cc which redirects to a randomly generated URL upon access, e.g. http://myapp.com/roTr94h4Gd. (Please note that notepad.cc is not my site.) Probably because of this redirect feature, when I do "fetch as Google" or "fetch as Bingbot", I get a 302 and no html content. Not even a <html></html> tag. HTTP/1.1 302 Moved Temporarily Server: nginx/1.4.1 Date: Tue, 01 Oct 2013 04:37:37 GMT Content-Type: text/html Transfer-Encoding: chunked Connection: keep-alive X-Powered-By: PHP/5.4.17-1~dotdeb.1 Set-Cookie: PHPSESSID=vp99q5e5t5810e3bnnnvi6sfo2; expires=Thu, 03-Oct-2013 04:37:37 GMT; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Location: /roTr94h4Gd How should I avoid 302 in this case? I suppose I could modify my site to prevent the redirect, but it is a necessary feature of my web app to generate a random URL on each access. I added <meta name="fragment" content="!"> tag into my index page and set it to return a static snapshot of my page when the flag is set. But this still returns a 302. I also added a header to return 200 before redirecting, but this had no effect, either. Could someone tell me a good suggestion to solve this problem?

    Read the article

  • Unity3D : Pause Menu - Android

    - by user3666251
    Im making a 2D game for android.I almost completed the game but now I need a pause game option.I added a pause icon on the top right side of the screen.The icon is a gui texture.Here is what I did so far : I made a script which will bring up some buttons (which is not working) and attached it to the GUITexture.This is the script : #pragma strict function OnMouseDown() { Debug.Log("*Pause Menu Opens*"); Time.timeScale = 0; if (GUI.Button(Rect(10,10,100,50),"Restart")); Application.LoadLevel(Application.loadedLevel); if (GUI.Button(Rect(10,60,100,50),"MainMenu")); Application.LoadLevel("MainMenu"); } Now,the problem stands at the part where the buttons won't show up,the game freezes at the first frame but the buttons won't show up.Please,if you can help I would be realy thankful. Thank you. Edit #1 : I just noticed that when I click "Pause" the game freezes and it takes me to the MainMenu.That's because I added the GUIButton which takes you to the main menu.I think the whole script structure is wrong.I also forgot to mention that Im new in scripting/unity. Thank you.

    Read the article

  • Websocket handshake response not forwarded from TCP to client

    - by Saharsh
    I am trying to create a websocket server. I can see the websocket client's opening handhshake. My response to it is received by the client laptop (I can see this on wireshark). So the TCP connection has been established. But the client (a chrome websocket client extension) does not receive the handshake packet. What could be a possible reason for TCP to not forward the handshake to the client or for the client to not be able to read the TCP message? Client handshake: GET HTTP/1.1 Upgrade: websocket Connection:Upgrade Cache-Control:no-cache Host:192.168.0.101 Origin:http://www.websocket.org Pragma:no-cache Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits, x-webkit-deflate-frame Sec-WebSocket-Key: qrmw/m+BoZije6h9HYKmVw== Sec-WebSocket-Version:13 Upgrade:websocket Server Response: HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: jj1g5Io57m9ks8cme3jkbyo2asc= Access-Control-Allow-Origin: http://www.websocket.org Server: xyz Sec-WebSocket-Extensions: Thanks!

    Read the article

  • htaccess filesMatch exclusion

    - by Hikari
    I have the following directive in my htaccess <filesMatch "\.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml|html?)$"> FileETag None <ifModule mod_headers.c> Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT" </ifModule> </filesMatch> I copied that regex from someplace in Web months ago. It should add those headers to any HTTP Response that does NOT have those extensions. But it's not working, it's adding them to any Response. I also need to create another directive to add Header set Cache-Control "max-age=3600, public" to Responses of files that DOES have them. Could anybody help me make proper fileMatch regexes?

    Read the article

  • How to create a script for moving a 3rd person controller in an iOS device by using Javascript in Unity3D?

    - by user36563
    I've a code but I'm not sure about the steps, so what I should do after the script? pragma strict public var horizontalSpeed : float = 1.0; public var verticalSpeed : float = 1.0; private var h : float = 0.0; private var v : float = 0.0; private var lastPos : Vector3 = Vector3.zero; function Update() { if UNITY_EDITOR if ( Input.GetMouseButtonDown(0) ) { lastPos = Input.mousePosition; } else if ( Input.GetMouseButton(0) ) { var delta = Input.mousePosition - lastPos; h = horizontalSpeed * delta.x ; transform.Rotate( 0, -h, 0, Space.World ); v = verticalSpeed * delta.y ; transform.position += transform.forward * v * Time.deltaTime; lastPos = Input.mousePosition; } else if (Input.touchCount == 1) { var touch : Touch = Input.GetTouch(0); if (touch.phase == TouchPhase.Moved) { h = horizontalSpeed * touch.deltaPosition.x ; transform.Rotate( 0, -h, 0, Space.World ); v = verticalSpeed * touch.deltaPosition.y ; transform.position += transform.forward * v * Time.deltaTime; } } endif }

    Read the article

  • App is getting run in iOS 5.1.1 but crashed in iOS 6.1.3

    - by Jekil Patel
    I have implemented below code but app has been crashed in iPad with iOS version 6.1.3,while running perfectly in iPad with iOS version 5.1.1. when I am scrolling table view continuously it is crashed in ios version 6.1.3. what could be the issue. The implemented delegate and data source methods for the table view are as given below. #pragma mark - Table view data source -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [UserList count]; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 70; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; //cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; cell = nil; if (cell == nil) { // cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } UIImageView *imgViweback; imgViweback = [[UIImageView alloc]initWithFrame:CGRectMake(0,0,0,0)]; imgViweback.image = [UIImage imageNamed:@"1scr-Student List Tab BG.png"]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 10, 32, 32)]; UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(12, 5, 50, 50)]; UILabel *lblName = [[UILabel alloc] initWithFrame:CGRectMake(110, 5, 200, 40)]; //cell.backgroundColor = [UIColor clearColor]; //cell.alpha = 0.5f; CountSelected = 0; flagQuizEnabled = NO; if ([[[checkedImages objectAtIndex:indexPath.row] valueForKey:@"checked"] isEqualToString:@"NO"]) { // cell.imageView.image = [UIImage imageNamed:@"Unchecked.png"]; //imageView.image = [UIImage imageNamed:@"Unchecked.png"]; } else { //imageView.image = [UIImage imageNamed:@"Checked.png"]; } NSString *pathTillApp=[[self getImagePath] stringByDeletingLastPathComponent]; NSLog(@"Path Till App %@",pathTillApp); NSString *makePath=[NSString stringWithFormat:@"%@%@",pathTillApp,[[UserList objectAtIndex:indexPath.row ]valueForKey:@"ImagePath"]]; NSLog(@"makepath=%@",makePath); imageView1.image = [UIImage imageWithContentsOfFile:makePath]; [cell.contentView insertSubview:imgViweback atIndex:0]; [cell.contentView insertSubview:imageView atIndex:0]; [cell.contentView insertSubview:imageView1 atIndex:2]; lblName.text =[NSString stringWithFormat:@"%@ %@",[[UserList objectAtIndex:indexPath.row] valueForKey:@"FirstName"],[[UserList objectAtIndex:indexPath.row] valueForKey:@"LastName"]]; lblName.backgroundColor = [UIColor clearColor]; lblName.font = [UIFont boldSystemFontOfSize:22.0f]; //lblName.font = [UIFont fontWithName:@"HelveticaNeue Heavy" size:22.0f]; lblName.font = [UIFont fontWithName:@"Chalkboard SE" size:22.0f]; [cell.contentView insertSubview:lblName atIndex:3]; [imgViweback release]; [imageView release]; [imageView1 release]; [lblName release]; imgViweback = nil; imageView = nil; imageView1 = nil; lblName = nil; //cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; return cell; } #pragma mark - Table view delegate -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"Values : %@", Val); }

    Read the article

  • I am getting the error Wrong type argument to unary minus and Expected ';' before ':' token

    - by James B.
    I am getting the error Wrong type argument to unary minus and Expected ';' before ':' token The error occurs at the - (NSIndexPath *).... line I am really New at this, so if there is anymore info needed, please ask, if you need to see the entire app, please e-mail me @ james at sevenotwo dot com. the app isn't really complicated. it is based on the sample code on Apple's website for the iphonedatacorerecipes code. #pragma mark - #pragma mark Editing rows - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSIndexPath *rowToSelect = indexPath; NSInteger section = indexPath.section; BOOL isEditing = self.editing; // If editing, don't allow notes to be selected // Not editing: Only allow notes to be selected if ((isEditing && section == NOTES_SECTION) || (!isEditing && section != NOTES_SECTION)) { [tableView deselectRowAtIndexPath:indexPath animated:YES]; rowToSelect = nil; } return rowToSelect; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger section = indexPath.section; UIViewController *nextViewController = nil; /* What to do on selection depends on what section the row is in. For Type, Notes, and Instruments, create and push a new view controller of the type appropriate for the next screen. */ switch (section) { case TYPE_SECTION: nextViewController = [[TypeSelectionViewController alloc] initWithStyle:UITableViewStyleGrouped]; ((TypeSelectionViewController *)nextViewController).doctor = doctor; break; case NOTES_SECTION: nextViewController = [[NotesViewController alloc] initWithNibName:@"NotesView" bundle:nil]; ((NotesViewController *)nextViewController).doctor = doctor; break; case INSTRUMENTS_SECTION: nextViewController = [[InstrumentDetailViewController alloc] initWithStyle:UITableViewStyleGrouped]; ((InstrumentDetailViewController *)nextViewController).doctor = doctor; if (indexPath.row < [doctor.instruments count]) { Instrument *instrument = [instruments objectAtIndex:indexPath.row]; ((InstrumentDetailViewController *)nextViewController).instrument = instrument; } break; default: break; } // If we got a new view controller, push it . if (nextViewController) { [self.navigationController pushViewController:nextViewController animated:YES]; [nextViewController release]; } } - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCellEditingStyle style = UITableViewCellEditingStyleNone; // Only allow editing in the instruments section. // In the instruments section, the last row (row number equal to the count of instruments) is added automatically (see tableView:cellForRowAtIndexPath:) to provide an insertion cell, so configure that cell for insertion; the other cells are configured for deletion. if (indexPath.section == INSTRUMENTS_SECTION) { // If this is the last item, it's the insertion row. if (indexPath.row == [doctor.instruments count]) { style = UITableViewCellEditingStyleInsert; } else { style = UITableViewCellEditingStyleDelete; } } return style; } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { // Only allow deletion, and only in the instruments section if ((editingStyle == UITableViewCellEditingStyleDelete) && (indexPath.section == INSTRUMENTS_SECTION)) { // Remove the corresponding instrument object from the doctor's instrument list and delete the appropriate table view cell. Instrument *instrument = [instruments objectAtIndex:indexPath.row]; [doctor removeInstrumentsObject:instrument]; [instruments removeObject:instrument]; NSManagedObjectContext *context = instrument.managedObjectContext; [context deleteObject:instrument]; [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop]; } }

    Read the article

  • Adding Core Data to existing iPhone project

    - by swalkner
    I'd like to add core data to an existing iPhone project, but I still get a lot of compile errors: NSManagedObjectContext undeclared Expected specifier-qualifier-list before 'NSManagedObjectModel' ... I already added the Core Data Framework to the target (right click on my project under "Targets", "Add" - "Existing Frameworks", "CoreData.framework"). My header-file: NSManagedObjectModel *managedObjectModel; NSManagedObjectContext *managedObjectContext; NSPersistentStoreCoordinator *persistentStoreCoordinator; [...] @property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel; @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; @property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator; What am I missing? Starting a new project is not an option... Thanks a lot! edit sorry, I do have those implementations... but it seems like the Library is missing... the implementation methods are full with compile error like "managedObjectContext undeclared", "NSPersistentStoreCoordinator undeclared", but also with "Expected ')' before NSManagedObjectContext" (although it seems like the parenthesis are correct)... #pragma mark - #pragma mark Core Data stack /** Returns the managed object context for the application. If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application. */ - (NSManagedObjectContext *) managedObjectContext { if (managedObjectContext != nil) { return managedObjectContext; } NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (coordinator != nil) { managedObjectContext = [[NSManagedObjectContext alloc] init]; [managedObjectContext setPersistentStoreCoordinator: coordinator]; } return managedObjectContext; } /** Returns the managed object model for the application. If the model doesn't already exist, it is created by merging all of the models found in application bundle. */ - (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel != nil) { return managedObjectModel; } managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain]; return managedObjectModel; } /** Returns the persistent store coordinator for the application. If the coordinator doesn't already exist, it is created and the application's store added to it. */ - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"Core_Data.sqlite"]]; NSError *error = nil; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]) { /* Replace this implementation with code to handle the error appropriately. abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button. Typical reasons for an error here include: * The persistent store is not accessible * The schema for the persistent store is incompatible with current managed object model Check the error message to determine what the actual problem was. */ NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } return persistentStoreCoordinator; }

    Read the article

  • Core Plot never stops asking for data, hangs device

    - by Ben Collins
    I'm trying to set up a core plot that looks somewhat like the AAPLot example on the core-plot wiki. I have set up my plot like this: - (void)initGraph:(CPXYGraph*)graph forDays:(NSUInteger)numDays { self.cplhView.hostedLayer = graph; graph.paddingLeft = 30.0; graph.paddingTop = 20.0; graph.paddingRight = 30.0; graph.paddingBottom = 20.0; CPXYPlotSpace *plotSpace = (CPXYPlotSpace*)graph.defaultPlotSpace; plotSpace.xRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0) length:CPDecimalFromFloat(numDays)]; plotSpace.yRange = [CPPlotRange plotRangeWithLocation:CPDecimalFromFloat(0) length:CPDecimalFromFloat(1)]; CPLineStyle *lineStyle = [CPLineStyle lineStyle]; lineStyle.lineColor = [CPColor blackColor]; lineStyle.lineWidth = 2.0f; // Axes NSLog(@"Setting up axes"); CPXYAxisSet *xyAxisSet = (id)graph.axisSet; CPXYAxis *xAxis = xyAxisSet.xAxis; // xAxis.majorIntervalLength = CPDecimalFromFloat(7); // xAxis.minorTicksPerInterval = 7; CPXYAxis *yAxis = xyAxisSet.yAxis; // yAxis.majorIntervalLength = CPDecimalFromFloat(0.1); // Line plot with gradient fill NSLog(@"Setting up line plot"); CPScatterPlot *dataSourceLinePlot = [[[CPScatterPlot alloc] initWithFrame:graph.bounds] autorelease]; dataSourceLinePlot.identifier = @"Data Source Plot"; dataSourceLinePlot.dataLineStyle = nil; dataSourceLinePlot.dataSource = self; [graph addPlot:dataSourceLinePlot]; CPColor *areaColor = [CPColor colorWithComponentRed:1.0 green:1.0 blue:1.0 alpha:0.6]; CPGradient *areaGradient = [CPGradient gradientWithBeginningColor:areaColor endingColor:[CPColor clearColor]]; areaGradient.angle = -90.0f; CPFill *areaGradientFill = [CPFill fillWithGradient:areaGradient]; dataSourceLinePlot.areaFill = areaGradientFill; dataSourceLinePlot.areaBaseValue = CPDecimalFromString(@"320.0"); // OHLC plot NSLog(@"OHLC Plot"); CPLineStyle *whiteLineStyle = [CPLineStyle lineStyle]; whiteLineStyle.lineColor = [CPColor whiteColor]; whiteLineStyle.lineWidth = 1.0f; CPTradingRangePlot *ohlcPlot = [[[CPTradingRangePlot alloc] initWithFrame:graph.bounds] autorelease]; ohlcPlot.identifier = @"OHLC"; ohlcPlot.lineStyle = whiteLineStyle; ohlcPlot.stickLength = 2.0f; ohlcPlot.plotStyle = CPTradingRangePlotStyleOHLC; ohlcPlot.dataSource = self; NSLog(@"Data source set, adding plot"); [graph addPlot:ohlcPlot]; } And my delegate methods like this: #pragma mark - #pragma mark CPPlotdataSource Methods - (NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot { NSUInteger maxCount = 0; NSLog(@"Getting number of records."); if (self.data1 && [self.data1 count] > maxCount) { maxCount = [self.data1 count]; } if (self.data2 && [self.data2 count] > maxCount) { maxCount = [self.data2 count]; } if (self.data3 && [self.data3 count] > maxCount) { maxCount = [self.data3 count]; } NSLog(@"%u records", maxCount); return maxCount; } - (NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index { NSLog(@"Getting record @ idx %u", index); return [NSNumber numberWithInt:index]; } All the code above is in the view controller for the view hosting the plot, and when initGraph is called, numDays is 30. I realize of course that this plot, if it even worked, would look nothing like the AAPLot example. The problem I'm having is that the view is never shown. It finished loading because viewDidLoad is the method that calls initGraph above, and the NSLog statements indicate that initGraph finishes. What's strange is that I return a value of 54 from numberOfRecordsForPlot, but the plot asks for more than 54 data points. in fact, it never stops asking. The NSLog statement in numberForPlot:field:recordIndex prints forever, going from 0 to 54 and then looping back around and continuing. What's going on? Why won't the plot stop asking for data and draw itself?

    Read the article

  • NSOperation unable to load data on the TableView

    - by yeohchan
    I have a problem in NSOperation. I tried many ways but it would run behind the screen, but will not make it appear on the my table view. Can anyone help me out with this. I am new to NSOperation. Recents.h #import <UIKit/UIKit.h> #import "FlickrFetcher.h" @interface Recents : UITableViewController { FlickrFetcher *fetcher; NSString *name; NSData *picture; NSString *picName; NSMutableArray *names; NSMutableArray *pics; NSMutableArray *lists; NSArray *namelists; NSOperationQueue *operationQueue; } @property (nonatomic,retain)NSString *name; @property (nonatomic,retain)NSString *picName; @property (nonatomic,retain)NSData *picture; @property (nonatomic,retain)NSMutableArray *names; @property (nonatomic,retain)NSMutableArray *pics; @property(nonatomic,retain)NSMutableArray *lists; @property(nonatomic,retain)NSArray *namelists; @end Recents.m #import "Recents.h" #import "PersonList.h" #import "PhotoDetail.h" @implementation Recents @synthesize picName,picture,name,names,pics,lists,namelists; // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization self.title=@"Recents"; } return self; } - (void)beginLoadingFlickrData{ NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(synchronousLoadFlickrData) object:nil]; [operationQueue addOperation:operation]; [operation release]; } - (void)synchronousLoadFlickrData{ fetcher=[FlickrFetcher sharedInstance]; NSArray *recents=[fetcher recentGeoTaggedPhotos]; [self performSelectorOnMainThread:@selector(didFinishLoadingFlickrDataWithResults:) withObject:recents waitUntilDone:NO]; } - (void)didFinishLoadingFlickrDataWithResults:(NSArray *)recents{ for(NSDictionary *dic in recents){ [names addObject:[fetcher usernameForUserID:[dic objectForKey:@"owner"]]]; if([[dic objectForKey:@"title"]isEqualToString:@""]){ [pics addObject:@"Untitled"]; }else{ [pics addObject:[dic objectForKey:@"title"]]; } NSLog(@"OK!!"); } [self.tableView reloadData]; [self.tableView flashScrollIndicators]; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; operationQueue = [[NSOperationQueue alloc] init]; [operationQueue setMaxConcurrentOperationCount:1]; [self beginLoadingFlickrData]; self.tableView.rowHeight = 95; } /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } #pragma mark - #pragma mark Table View Data Source Methods - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return[names count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleTableIdentifier] autorelease]; } cell.detailTextLabel.text=[names objectAtIndex:indexPath.row]; cell.textLabel.text=[pics objectAtIndex:indexPath.row]; //UIImage *image=[UIImage imageWithData:[self.lists objectAtIndex:indexPath.row]]; //cell.imageView.image=image; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { fetcher=[[FlickrFetcher alloc]init]; PhotoDetail *scroll=[[PhotoDetail alloc]initWithNibName:@"PhotoDetail" bundle:nil]; scroll.titleName=[self.pics objectAtIndex:indexPath.row]; scroll.picture = [UIImage imageWithData:[self.lists objectAtIndex:indexPath.row]]; [self.navigationController pushViewController:scroll animated:YES]; }

    Read the article

  • NSUserDefaults loses 3 rows each time it's called

    - by Jeff Decker
    Hello Everyone! Brand new programmer here, so off-topic help/constructive criticism welcome. I am saving a default state (such as "New York") in a UIPickerView which is in a FlipSideView. It certainly saves for the first and second time I check to make sure it's the same state (I am clicking "done" and then "info" repeatedly), but on the third check the picker has moved up three states (to "New Hampshire") and then every time I check the picker progresses three more states. Here's the .h and .m files of the FlipSideViewController: #import <UIKit/UIKit.h> import "Calculator.h" @protocol FlipsideViewControllerDelegate; @interface FlipsideViewController : UIViewController { id delegate; UIPickerView *myPickerView; NSArray *pickerViewArray; } @property (nonatomic, assign) id delegate; @property (nonatomic, retain) UIPickerView *myPickerView; @property (nonatomic, retain) NSArray *pickerViewArray; (IBAction)done; @end @protocol FlipsideViewControllerDelegate - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller; @end import "FlipsideViewController.h" @implementation FlipsideViewController @synthesize delegate; @synthesize myPickerView, pickerViewArray; -(CGRect)pickerFrameWithSize:(CGSize)size;{ CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; CGRect pickerRect = CGRectMake( 0.0, screenRect.size.height - size.height, size.width, size.height); return pickerRect; } (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor]; [self createPicker]; } -(void)viewWillAppear:(BOOL)animated;{ [super viewWillAppear:NO]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [myPickerView selectRow:[defaults integerForKey:@"pickerRow"] inComponent:0 animated:NO]; } -(void)createPicker;{ pickerViewArray = [[NSArray arrayWithObjects: @"Alabama",@"Alaska", @"Arizona",@"Arkansas",@"California",@"Colorado",@"Connecticut",@"Delaware", @"District of Columbia",@"Florida",@"Georgia",@"Hawaii",@"Idaho",@"Illinois",@"Indiana",@"Iowa", @"Kansas",@"Kentucky",@"Louisiana",@"Maine",@"Maryland",@"Massachusetts",@"Michigan", @"Minnesota",@"Mississippi",@"Missouri",@"Montana",@"Nebraska",@"Nevada",@"New Hampshire",@"New Jersey", @"New Mexico",@"New York",@"North Carolina",@"North Dakota",@"Ohio",@"Oklahoma", @"Oregon",@"Pennsylvania",@"Rhode Island",@"South Carolina",@"South Dakota",@"Tennessee", @"Texas",@"Utah",@"Vermont",@"Virginia",@"Washington",@"West Virginia",@"Wisconsin",@"Wyoming", nil] retain]; myPickerView = [[UIPickerView alloc] initWithFrame:CGRectZero]; CGSize pickerSize = [myPickerView sizeThatFits:CGSizeZero]; myPickerView.frame = [self pickerFrameWithSize:pickerSize]; myPickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth; myPickerView.showsSelectionIndicator = YES; myPickerView.delegate = self; myPickerView.dataSource = self; [self.view addSubview:myPickerView]; } (IBAction)done { [self.delegate flipsideViewControllerDidFinish:self]; } pragma mark - pragma mark UIPickerViewDataSource (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setInteger:row forKey:@"pickerRow"]; [defaults setObject:[pickerViewArray objectAtIndex:row] forKey:@"pickerString"]; return [pickerViewArray objectAtIndex:row]; } (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setInteger:row forKey:@"pickerRow"]; [defaults setObject:[pickerViewArray objectAtIndex:row] forKey:@"pickerString"]; } (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { return 240.0; } (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component { return 40.0; } (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return [pickerViewArray count]; } (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } call me mystified! Thanks for any help. Please let me know if I can make myself more clear...

    Read the article

  • Testing a Non-blocking Queue

    - by jsw
    I've ported the non-blocking queue psuedocode here to C#. The code below is meant as a near verbatim copy of the paper. What approach would you take to test the implementation? Note: I'm running in VS2010 so I don't have CHESS support yet. using System.Threading; #pragma warning disable 0420 namespace ConcurrentCollections { class QueueNodePointer<T> { internal QueueNode<T> ptr; internal QueueNodePointer() : this(null) { } internal QueueNodePointer(QueueNode<T> ptr) { this.ptr = ptr; } } class QueueNode<T> { internal T value; internal QueueNodePointer<T> next; internal QueueNode() : this(default(T)) { } internal QueueNode(T value) { this.value = value; this.next = new QueueNodePointer<T>(); } } public class ConcurrentQueue<T> { private volatile int count = 0; private QueueNodePointer<T> qhead = new QueueNodePointer<T>(); private QueueNodePointer<T> qtail = new QueueNodePointer<T>(); public ConcurrentQueue() { var node = new QueueNode<T>(); node.next.ptr = null; this.qhead.ptr = this.qtail.ptr = node; } public int Count { get { return this.count; } } public void Enqueue(T value) { var node = new QueueNode<T>(value); node.next.ptr = null; QueueNodePointer<T> tail; QueueNodePointer<T> next; while (true) { tail = this.qtail; next = tail.ptr.next; if (tail == this.qtail) { if (next.ptr == null) { var newtail = new QueueNodePointer<T>(node); if (Interlocked.CompareExchange(ref tail.ptr.next, newtail, next) == next) { Interlocked.Increment(ref this.count); break; } else { Interlocked.CompareExchange(ref this.qtail, new QueueNodePointer<T>(next.ptr), tail); } } } } Interlocked.CompareExchange(ref this.qtail, new QueueNodePointer<T>(node), tail); } public T Dequeue() { T value; while (true) { var head = this.qhead; var tail = this.qtail; var next = head.ptr.next; if (head == this.qhead) { if (head.ptr == tail.ptr) { if (next.ptr == null) { return default(T); } Interlocked.CompareExchange(ref this.qtail, new QueueNodePointer<T>(next.ptr), tail); } else { value = next.ptr.value; var newhead = new QueueNodePointer<T>(next.ptr); if (Interlocked.CompareExchange(ref this.qhead, newhead, head) == head) { Interlocked.Decrement(ref this.count); break; } } } } return value; } } } #pragma warning restore 0420

    Read the article

  • Unwanted debug session

    - by b3y4z1d
    Try this code I created,when I use it in Borland C++ and try the remove-function a debug session opens up and it points to a file called "xstring",and it is saying "EAccessViolation". it points to this line in the file: return (compare(0, _Mysize, _Right._Myptr(), _Right.size())); //--------------------------------------------------------------------------- #include<iostream> #include<string> #include<fstream> #include<list> #pragma hdrstop using namespace std; struct Mail{ string name; string ammount; }; //---------------------------Call_Functions----------------------------- void new_mail(list<Mail>& l); void show_mail(list<Mail> l); void remove(list<Mail>& l); //---------------------------------Menu-------------------------------------- #pragma argsused int main(int argc, char* argv[]) { list<Mail> mail; bool contin = true; char answ; do{ cout<<'\n'<<'\t'<<'\t'<<"Menu"<<endl <<'\t'<<'\t'<<"----"<<endl <<"1. New mail"<<endl <<"2. Show mail"<<endl <<"3. Remove mail"<<endl <<"4. Exit"<<endl<<endl; cin>>answ; cin.ignore(1000, '\n'); switch (answ) { case '1': new_mail(mail); break; case '2': show_mail(mail); break; case '3': remove(mail); break; case '4': exit(1); default: cout<<"Choice not recognized"; } } while(contin); return 0; } //------------------------------Functions------------------------------------- //------------------------------New_mail-------------------------------------- void new_mail(list<Mail>& l){ Mail p; cout<<endl<<"Type in the name of the new mail "; getline(cin, p.name); cout<<"Now type in the cost: "; getline(cin, p.ammount); l.push_back(p); } //------------------------------Show_Mail------------------------------------- void show_mail(list<Mail> l){ list<Mail>::iterator it; cout<<"\nAll mail:\n\n"; for (it = l.begin(); it != l.end(); it++) { cout<<(*it).name<<'\t'<<'\t'<<(*it).ammount<<endl; } } //------------------------------Remove---------------------------------------- void remove(list<Mail>& l){ list<Mail>::iterator it; string name; cout<<endl<<"What is the name of the mail you want to remove?: "; getline(cin, name); for (it = l.begin(); it != l.end(); it++) { if ((*it).name == name) { l.erase(it); } } } //------------------------------End----------------------------------------- Why does it show this error,and how can I solve it?

    Read the article

  • There's some html content in a file which is downloaded using PHP scripts on firefox

    - by chqiu
    I use the following to download a file with PHP: ob_start(); $browser = id_browser(); header('Content-Type: '.(($browser=='IE' || $browser=='OPERA')? 'application/octetstream':'application/octet-stream')); header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.filesize(realpath($fullpath))); //header("Content-Encoding: none"); if($browser == 'IE') { header('Content-Disposition: attachment; filename="'.$file.'"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="'.$file.'"'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); } //@set_time_limit( 0 ); ReadFileChunked(utf8_decode($fullpath)); ob_end_flush(); The source code of ReadFileChunked is: function ReadFileChunked($filename,$retbytes=true) { $chunksize = 1*(1024*1024); $remainFileSize = filesize($filename); if($remainFileSize < $chunksize) $chunksize = $remainFileSize; $buffer = ''; $cnt =0; // $handle = fopen($filename, 'rb'); //echo $filename."<br>"; $handle = fopen($filename, 'rb'); if ($handle === false) { //echo 1; return false; } //echo 2; while (!feof($handle)) { //echo "current remain file size $remainFileSize<br>"; //echo "current chunksize $chunksize<br>"; $buffer = fread($handle, $chunksize); echo $buffer; sleep(1); ob_flush(); flush(); if ($retbytes) { $cnt += strlen($buffer); } $remainFileSize -= $chunksize; if($remainFileSize == 0) break; if($remainFileSize < $chunksize) { $chunksize = $remainFileSize; } } $status = fclose($handle); if ($retbytes && $status) { return $cnt; // return num. bytes delivered like readfile() does. } return $status; } The question is : The file downloaded will contiain some html tags which are the content of the html code generated by the php. The error will happened when downloading the txt file with the file size smaller than 4096 bytes. Please help me to slove this problem , thank you very much! Chu

    Read the article

  • SetPixelFormat is not creating an alpha channel for OpenGL

    - by i_photon
    I've been able to do this before, and I don't know what changed between two weeks ago and the last windows update, but for some reason SetPixelFormat isn't creating an alpha channel. gDebugger shows that the window's back buffer only has 3 channels. White+0 alpha renders as white. So there is something inherently wrong with what I was doing, or an update broke it. The code below should be paste-able into an empty VS project. #include <Windows.h> #include <dwmapi.h> #include <gl/GL.h> #pragma comment(lib,"opengl32.lib") #pragma comment(lib,"dwmapi.lib") HWND hWnd = 0; HDC hDC = 0; HGLRC hRC = 0; LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { WNDCLASSEX wcex = {0}; wcex.cbSize = sizeof(WNDCLASSEX); wcex.lpfnWndProc = WndProc; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.lpszClassName = TEXT("why_class"); RegisterClassEx(&wcex); // no errors hWnd = CreateWindowEx( NULL, TEXT("why_class"), TEXT("why_window"), WS_OVERLAPPEDWINDOW, 128,128, 256,256, NULL, NULL, hInstance, NULL ); // no errors PIXELFORMATDESCRIPTOR pfd = {0}; pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW| PFD_SUPPORT_OPENGL| PFD_DOUBLEBUFFER| PFD_SUPPORT_COMPOSITION; pfd.cColorBits = 32; pfd.cAlphaBits = 8; // need an alpha channel pfd.cDepthBits = 24; pfd.cStencilBits = 8; hDC = GetDC(hWnd); int i = ChoosePixelFormat(hDC,&pfd); SetPixelFormat(hDC,i,&pfd); // no errors hRC = wglCreateContext(hDC); // no errors wglMakeCurrent(hDC,hRC); // no errors // EDIT: Turn on alpha testing (which actually won't // fix the clear color problem below) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // EDIT: Regardless of whether or not GL_BLEND is enabled, // a clear color with an alpha of 0 should (or did at one time) // make this window transparent glClearColor( 0,0,0, // if this is (1,1,1), the window renders // solid white regardless of the alpha 0 // changing the alpha here has some effect ); DWM_BLURBEHIND bb = {0}; bb.dwFlags = DWM_BB_ENABLE|DWM_BB_TRANSITIONONMAXIMIZED; bb.fEnable = TRUE; bb.fTransitionOnMaximized = TRUE; DwmEnableBlurBehindWindow(hWnd,&bb); // no errors ShowWindow(hWnd, SW_SHOWNORMAL); UpdateWindow(hWnd); // no errors MSG msg = {0}; while(true){ GetMessage(&msg,NULL,NULL,NULL); if(msg.message == WM_QUIT){ return (int)msg.wParam; } TranslateMessage(&msg); DispatchMessage(&msg); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glBegin(GL_TRIANGLES); // this vertex should be transparent, // as it was when I last built this test // // it renders as white glColor4f(1,1,1,0); glVertex2f(0,0); glColor4f(0,1,1,1); glVertex2f(1,0); glColor4f(1,0,1,1); glVertex2f(0,1); glEnd(); SwapBuffers(hDC); } return (int)msg.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_DESTROY: { PostQuitMessage(0); }return 0; default: break; } return DefWindowProc(hWnd, message, wParam, lParam); }

    Read the article

  • how to obtain the relative path of a resource in a j2ee project

    - by Neeraj
    I have a Dynamic Web Project having a flat file (or say text file). I have created a servlet in which I need to use this file. My code is as following: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // String resource = request.getParameter ("json") ; if ( resource != null && !resource.equals ( "" ) ) { //use getResourceAsStream ( ) to properly get the file. InputStream is = getServletContext ().getResourceAsStream ("rateJSON") ; if ( is != null ) { // the resource exists response.setContentType("application/json"); response.setHeader("Pragma", "No-cache"); response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-cache"); StringWriter sw = new StringWriter ( ) ; for ( int c = is.read ( ) ; c != -1; c = is.read ( ) ) { sw.write ( c ) ; } PrintWriter out = response.getWriter(); out.print (sw.toString ()) ; out.flush(); } } } The problem is that the InputStream is has null value. I'm not sure how to get the correct relative path. I'm using JBOSS as the app server. I have added the resource file in the WebContent directory of a Dynamic Web Project. As a different approch, I tried this: protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub ServletConfig config = getServletConfig(); String contextName = config.getInitParameter("ApplicationName"); System.out.println("context name"+ contextName); String contextPath = config.getServletContext().getRealPath(contextName); System.out.println("context Path"+contextPath); //contextPath = contextPath.substring(0, contextPath.indexOf(contextName)); contextPath += "\\rateJSON.txt"; System.out.println(contextPath); String resource = request.getParameter ("json") ; System.out.println("Hi there1"+resource); if ( resource != null && !resource.equals ( "" ) ) { System.out.println("Hi there"); //use getResourceAsStream ( ) to properly get the file. //InputStream is = getServletContext ().getResourceAsStream (resource) ; InputStream is = getServletConfig().getServletContext().getResourceAsStream(contextPath); if ( is != null ) { // the resource exists System.out.println("Hi there2"); response.setContentType("application/json"); response.setHeader("Pragma", "No-cache"); response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-cache"); StringWriter sw = new StringWriter ( ); for ( int c = is.read ( ) ; c != -1; c = is.read ( ) ) { sw.write ( c ) ; System.out.println(c); } PrintWriter out = response.getWriter(); out.print (sw.toString ()) ; System.out.println(sw.toString()); out.flush(); } } } The value of contextPath is now: C:\JBOSS\jboss-5.0.1.GA\server\default\tmp\4p72206b-uo5r7k-g0vn9pof-1-g0vsh0o9-b7\Nationwide.war\WEB-INF\rateJSON But at this location the rateJSON file is not there? It seems JBOSS is not putting this file in the App.war or doesn't deploy it??? Could someone please help me?

    Read the article

  • UIPageViewController blanking page

    - by CrazyEoin
    I've been trying to use the UIPageViewController to display 3 different nibs for a few days on and off now and have almost got it working. I still have one weird bug that I cant figure out. Basically the app starts, I can scroll between the 3 pages one after another with out any problems, eg: Page1-Page2-Page3 and then back to the start: Page3-Page2-Page1. No Problems. The issue is that if I scroll, for example from Page3-Page2, then BACK to Page3, Page3 Dissappears when it snaps into place. If I scroll to where a forth page would be, then I get Page3. Here is the code relevant to the UIPageViewController, the nibs and the delegate methods for the UIPageViewController: - (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil]; self.pageViewController.delegate = self; [[self.pageViewController view] setFrame:[[self view] bounds]]; indexTest = 0; Page1 *p1 = [[Page1 alloc]initWithNibName:@"Page1" bundle:nil]; p1.view.tag = 1; Page2 *p2 = [[Page2 alloc]initWithNibName:@"Page2" bundle:nil]; p2.view.tag = 2; Page3 *p3 = [[Page3 alloc]initWithNibName:@"Page3" bundle:nil]; p3.view.tag = 3; NSArray *arr = [[NSArray alloc] initWithObjects:p1,nil]; viewControllers = [[NSMutableArray alloc] initWithObjects:p1,p2,p3, nil]; [self.pageViewController setViewControllers:arr direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil]; self.pageViewController.dataSource = self; [self addChildViewController:self.pageViewController]; [[self view] addSubview:[self.pageViewController view]]; [self.pageViewController didMoveToParentViewController:self]; self.view.gestureRecognizers = self.pageViewController.gestureRecognizers; } #pragma mark - page view controller stuff - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController { if (indexTest > 0) { switch (indexTest) { case 1:{ NSLog(@"NO page is BEFORE current page"); break; } case 2:{ NSLog(@"Page BEFORE is Page: %@", [NSString stringWithFormat:@"%@",[viewControllers objectAtIndex:0] ] ); indexTest--; return [viewControllers objectAtIndex:0]; break; } default:{ NSLog(@"PROBLEM in viewBEFORE, indexTest = %d!!!!", indexTest); break; } } } return nil; } - (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController { if (indexTest < NUM_OF_PAGES) { switch (indexTest) { case 0:{ NSLog(@"Page AFTER is Page: %@", [NSString stringWithFormat:@"%@",[viewControllers objectAtIndex:1] ] ); indexTest++; return [viewControllers objectAtIndex:1]; break; } case 1:{ NSLog(@"Page AFTER is Page: %@", [NSString stringWithFormat:@"%@",[viewControllers objectAtIndex:2] ] ); indexTest++; return [viewControllers objectAtIndex:2]; break; } case 2:{ NSLog(@"No pages AFTER this current page %d", indexTest); break; } default:{ NSLog(@"PROBLEM in viewAFTER, indexTest = %d!!!!", indexTest); break; } } } return nil; } Finally the page index dots code #pragma mark - dot controller - (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController { // The number of items reflected in the page indicator. return NUM_OF_PAGES; } - (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController { // The selected item reflected in the page indicator. return 0; } Any and all help is much appreciated, I think I'm just doing something silly that I cant see as I'm so close to it fully working. If anythings not clear or I haven't give enough information please let me know and I'll answer it as best as I can. Thanks

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >