Daily Archives

Articles indexed Thursday December 23 2010

Page 15/28 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • GZipStream in an WebHttpResponse producing no data

    - by Pierre 303
    I want to compress my HTTP Responses for client that supports it. Here is the code used to send a standard response: IHttpClientContext context = (IHttpClientContext)sender; IHttpRequest request = e.Request; string responseBody = "This is some random text"; IHttpResponse response = request.CreateResponse(context); using (StreamWriter writer = new StreamWriter(response.Body)) { writer.WriteLine(responseBody); writer.Flush(); response.Send(); } The code above works fine. Now I added gzip support below. When I test it with a browser that supports gzip or a custom method, it returns an empty string. I'm sure I'm missing something simple, but I just can't find it... IHttpClientContext context = (IHttpClientContext)sender; IHttpRequest request = e.Request; string acceptEncoding = request.Headers["Accept-Encoding"]; string responseBody = "This is some random text"; IHttpResponse response = request.CreateResponse(context); if (acceptEncoding != null && acceptEncoding.Contains("gzip")) { byte[] bytes = ASCIIEncoding.ASCII.GetBytes(responseBody); response.AddHeader("Content-Encoding", "gzip"); using (GZipStream writer = new GZipStream(response.Body, CompressionMode.Compress)) { writer.Write(bytes, 0, bytes.Length); writer.Flush(); response.Send(); } } else { using (StreamWriter writer = new StreamWriter(response.Body)) { writer.WriteLine(responseBody); writer.Flush(); response.Send(); } }

    Read the article

  • AIR for Android, Flash iphone packager, Playbook support for streaming camera and choosing camera

    - by mswallace
    I am wondering if anyone can definitively tell me if Flash / AIR can find all these mobile devices front facing camera and use RTMP to stream the video captured ? I would like to create a video conferencing app for these devices. Of course none of them support testing this in the simulators and I don't have the funds to purchase or access all of them that I would like to test. Wondering if anyone can shed some light on this for me. I have seen some posts where they have done this for android but not sure about support for finding a list of cameras, choosing one and streaming from iphone 4 and playbook. thanks for any help on this.

    Read the article

  • Splitting a file before upload?

    - by Yevgeniy Brikman
    On a webpage, is it possible to split large files into chunks before the file is uploaded to the server? For example, split a 10MB file into 1MB chunks, and upload one chunk at a time while showing a progress bar? It sounds like JavaScript doesn't have any file manipulation abilities, but what about Flash and Java applets? This would need to work in IE6+, Firefox and Chrome. Update: forgot to mention that (a) we are using Grails and (b) this needs to run over https.

    Read the article

  • win32: TextOut not being displayed

    - by KaiserJohaan
    Hello again, I recently having my mainwindow write text by using WM_PAINT, but now I realise it was maybe not the best message to do so in, so I'm trying another version; The mainwindow contains a menu, upon clicing a menu item the ID_FILE_PID msg is sent and it builds the 4 new windows aswell as displays text in the mainwindow (paintEditSigns function). The 4 windows works fine but the text dosn't work at all, unless I do it in the main() function as shown... what on earth is this? O_O BTW: I still have no clue why the code-display on StackOverflow keeps looking so wierd when I post, why is this? switch(message) { case WM_COMMAND: switch (LOWORD(wParam)) { case ID_FILE_PID: { HWND hWndButton; HWND hWndEdit; HWND hWndEdit2; HWND hWndDisplay; // drawing the text in mainwindow paintEditSigns(); -- does not do anything here! // adding new windows in the mainwindow hWndButton = CreateWindowEx(0,TEXT("BUTTON"),"Modify",WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 170,56,80,30,hWnd,(HMENU)ID_BUTTON,hThisInstance,NULL); hWndEdit = CreateWindowEx(0,RICHEDIT_CLASS,TEXT(""),WS_CHILD | WS_VISIBLE | WS_BORDER, 120,30,80,25,hWnd,(HMENU)ID_EDIT,hThisInstance,NULL); hWndEdit2 = CreateWindowEx(0,RICHEDIT_CLASS,TEXT(""),WS_CHILD | WS_VISIBLE | WS_BORDER, 220,30,80,25,hWnd,(HMENU)ID_EDIT2,hThisInstance,NULL); hWndDisplay = CreateWindowEx(0,TEXT("STATIC"),NULL,WS_CHILD | WS_VISIBLE | WS_BORDER, 0,100,450,140,hWnd,(HMENU)ID_DISPLAY,hThisInstance,NULL); break; } ..... // // Main function // int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hWnd; WNDCLASSEX wc; ZeroMemory(&wc, sizeof(WNDCLASSEX)); hThisInstance = hInstance; LoadLibrary("Riched20.dll"); wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = WindowProc; wc.hInstance = hInstance; wc.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU); if(!(wc.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MYICON)))) { HRESULT res = GetLastError(); } wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)COLOR_WINDOW; wc.lpszClassName = TEXT("testcpp"); RegisterClassEx(&wc); hWnd = CreateWindowEx(NULL, wc.lpszClassName, TEXT("test"), WS_OVERLAPPEDWINDOW, 300, 200, 450, 300, NULL, NULL, hInstance, NULL); ShowWindow(hWnd,nCmdShow); //paintEditSigns() -- here it works, but not when in the message part MSG msg; while (GetMessage(&msg, NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } void paintEditSigns() { HFONT hf = createFont(); PAINTSTRUCT ps; HWND hWnd = FindWindow(TEXT("testcpp"),TEXT("test")); HBRUSH hbruzh = CreateSolidBrush(RGB(0,0,0)); HDC hdz = BeginPaint(hWnd,&ps); string s = "Memory Address"; SelectBrush(hdz,hbruzh); SelectFont(hdz,hf); TextOut(hdz,0,100,s.c_str(),s.length()); EndPaint(hWnd,&ps); DeleteObject(hbruzh); UpdateWindow(hWnd); } HFONT createFont() { HDC hdc; long lfHeight; hdc = GetDC(NULL); lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72); ReleaseDC(NULL, hdc); HFONT hf = CreateFont(lfHeight, 0, 0, 0, 0, TRUE, 0, 0, 0, 0, 0, 0, 0, "MS Sans Serif"); return hf; }

    Read the article

  • How to validate data for a Rest Service with symfony

    - by Nicolas V.
    For example imagine I've a rest service, this service takes two parameters : phone number text The goal is to send the message via a sms gateway. I've a class Message which has two properties destinationNumber and textMessage. Before calling the gateway, I want to validate the data received by the rest service. I've two questions relatives to how to validate the data : Where should I put the validation rules ? in the model or in the controller How should I use the sfValidator* classes from Symfony to validate the data (ie. where's the documentation for using sfValidator or where can I find some examples) Any help would be appreciated.

    Read the article

  • .net mvc2 custom HtmlHelper extension unit testing

    - by alex
    My goal is to be able to unit test some custom HtmlHelper extensions - which use RenderPartial internally. http://ox.no/posts/mocking-htmlhelper-in-asp-net-mvc-2-and-3-using-moq I've tried using the method above to mock the HtmlHelper. However, I'm running into Null value exceptions. "Parameter name: view" Anyone have any idea?? Thanks. Below are the ideas of the code: [TestMethod] public void TestMethod1() { var helper = CreateHtmlHelper(new ViewDataDictionary()); helper.RenderPartial("Test"); // supposingly this line is within a method to be tested Assert.AreEqual("test", helper.ViewContext.Writer.ToString()); } public static HtmlHelper CreateHtmlHelper(ViewDataDictionary vd) { Mock<ViewContext> mockViewContext = new Mock<ViewContext>( new ControllerContext( new Mock<HttpContextBase>().Object, new RouteData(), new Mock<ControllerBase>().Object), new Mock<IView>().Object, vd, new TempDataDictionary(), new StringWriter()); var mockViewDataContainer = new Mock<IViewDataContainer>(); mockViewDataContainer.Setup(v => v.ViewData) .Returns(vd); return new HtmlHelper(mockViewContext.Object, mockViewDataContainer.Object); }

    Read the article

  • IDispatchMessageInspector to log plain-text soap messages?

    - by Dan Thomas
    I've written a WCF IDispatchMessageInspector, so I can log incomming and outgoing messages. But I'm not sure how to get a nicely-formatted XML string to log. My code looks something like this: public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) { MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue); request = buffer.CreateMessage(); Log("Received", request.ToString(); return null; } The result of this logging includes things like "ampersand lt;" and some sort of binary-encoded data. How do I get something that looks like a standard soap XML document? I know this should be obvious, but I'm just too dense to figure it out. Thanks. Dan

    Read the article

  • PHP: Star rating system concept?

    - by Prashant
    I am using PHP/MYSQL/JQUERY. I have a site which have news section. On news details page, I want to add star rating system which will allow user to rate the news story. I am using this jquery rating system http://www.fyneworks.com/jquery/star-rating/ Now, I am not getting what will be the database structure and then what I need to code in PHP. I need what logic will be applied for this, like if 1000 people voted for the article, some given rating as 2 or 3 or1 or 5. Then Where I should be storing (db structure) this all and what I'll calculate (in php code). If someone has any article which shows this concept please provide. Please help, to understand the logic and concept of this. Thanks!

    Read the article

  • Reflection: take values from an unknown running alpplication

    - by Dr.Lesh
    I'm writing an application that searchs for Semaphore types in the fields of unknown classes in unknown application (passed by user). I made it using Reflection and it worked. Now I want to fill up these semaphores with values, taking them from a running instance of this unknown application. So i took the class with "main" method of this unknown application, made a newInstance, and passed it when invoking the main method to start the application: Class mainClass = getItSomeWhere(); Object instance = mainClass.newInstance(); Method mainMethod = mainClass.getDeclaredMethod("main", new Class[]{String[].class}); mainMethod.invoke(instance, new Object[]{args}); and it worked fine. Now, how can I get the semaphore values, taking them from the classes of this running application, when I only have an instance of the main class? Many thanks for the answers.

    Read the article

  • Using git submodules in a git-svn project

    - by Matthias
    In our git-svn managed project, we have 3 upstream projects that are all kept in native git repositories on GitHub. Since the source code of those upstream projects is under our control and changes frequently, our current solution, namely re-deploying the build artifacts to the super-project everytime we change something is quite cumbersome. What I'd like to have is this: parent project (git-svn): --> submodule 1 (git) --> submodule 2 (git) --> submodule 3 (git) That way, the source code for submodules 1-3 is compiled along with the sources for the super project, but I can push changes to submodules separately. The question is: what happens when I git svn dcommit on the parent project? Does this even work? UPDATE Hm, I just set up a simple project structure, trying to resemble this scenario, and I receive this error message when trying to dcommit on the superproject: a0301b11f3544a1e71067ff270eded65e4c8afbd doesn't exist in the repository at /opt/local/libexec/git-core/git-svn line 4775 Failed to read object a0301b11f3544a1e71067ff270eded65e4c8afbd at /opt/local/libexec/git-core/git-svn line 574 Any ideas/suggestions?

    Read the article

  • how to get transform a local image to a web accessable image

    - by hguser
    Hi: Generally,if we want to display a image in the web page,we give the uri of the image resource like: http://host:port/image/xxx.jpg. Now,there are some images in my file system,and I save its absolute path in the db. Like this; id name address image 1 xxxx xxxx C:/images/xxx.jpg Now if the entity is retrived,its image should be displayed in the page. How to make it? What I thought is copy the image under the web server dir,then build its url,then the page can render it. But I wonder if this is a good idea? Is there any other way?

    Read the article

  • Retrieving xml value into a string

    - by DelvinK
    Hello, In the following XML structure how do i retrieve the name value and put this into a string? (i am using a XPathNavigator in my method) <testsystem> <test> <name>one</name> </test> </testsystem> I was able to get a attribute with a syntax alike this: (but when changing the xml struture it no longer holds a attribute value) string name = nav.GetAttribute("name", "") But have no luck getting the value with a nav as of yet. The purpose is to be able to use it for the following object so i can put name into it. test t = new test() { Name = name, Questions= new List<Questions>() }; Best regards.

    Read the article

  • Types issue in F#

    - by Andry
    Hello! In my ongoing adventure deep diving into f# I am understanding a lot of this powerful language but there are things that I still do not understand so clearly. One of the most important issues I need to master is types. Well the book I am reading is very straight forward and introduces entities and main functionalities with a direct approach. The first thing I could get start with is types. It introduces the main types as list, option, tuples, and so on... It is clearly underlined that all these types are IMMUTABLE for many reasons regarding functional programming and data consistance in functional programing. Well, no problems until now... But now I am getting started with Concrete Types... Well... I have problems in managing with types like list, option, tuples, types created through new operator and concrete types created using type keyword (for abbreviations, concrete types...). So my question is: how can I efficently catalogue/distinguish all types of data in f#???? I can create a perfect separation among types in C#, VB.NET... FOr example in VB.NET there are value and reference types while in C# there are only references and also int, double are treated as objects (they are objects while in VB.NET a value type is not a object and there is a split in types for this reason). Well in F# I cannot create such differences among types in the language. Can you help me? I hope I was clear.

    Read the article

  • Binding in ContentControl Crash

    - by ImJames
    Can anyone tell me why this crashes my app? There seems to be some endless recursion by I can't figure out why. I get this exception Logical tree depth exceeded while traversing the tree. This could indicate a cycle in the tree <ContentControl Content="{Binding}"> <ContentControl.ContentTemplate> <DataTemplate> <Button Content="{Binding MyString}"/> </DataTemplate> </ContentControl.ContentTemplate> </ContentControl> And this is all I have as Source public MainWindow() { InitializeComponent(); MyString = "Test"; this.DataContext = this; } public string MyString { get; set; }

    Read the article

  • DragDrop-Support of PictureBox-Control

    - by Effdee
    After some searching i figured out how dragdrop is implemented for a picturebox. But there is one thing - the (inherited of course) allowdrop property isn't accessible from code or property window of picturebox class. So to make it work i added following line to my form-load: ((Control)pictureBox1).AllowDrop = true; Why do i have to do that? In msdn it says: "This API supports the .NET Framework infrastructure and is not intended to be used directly from your code." Any explanation appreciated and sorry for my grammar ;)

    Read the article

  • Catching / Redirecting 404's (ASP.NET)

    - by maxp
    Ive noticed that when I request a page in ASP.NET (webforms) that does not exist, the 'StaticFile' handler deals with the error notification. Id like to be a bit more helpful in these situations. What is the correct way for me to intercept this 404, and as a result, run some code to redirect the user? Two ways Ive thought of doing which I currently don't really like are: 1 - Create a module that basically does a if (!file.exists($url){redirect to $correctedurl}) 2 - Modify the error.aspx.cs(or the default error page) to do something similar (yuck!)

    Read the article

  • WPF Binding a textbox to a property of all items in a generic list

    - by muku
    Hello guys, What I want to do is simple. I have a generic list of objects. Let's say the object class contains a property named Height. What I want to do is bind a textbox's text in the UI with this list and when i change the value in the textbox then all objects in the list update their height value. I am new in WPF, I have studied the MVVM pattern, I can do simple data binding but i can't figure out how to do this :'( Thanks!

    Read the article

  • IE8 ignores jQuery UI 'dialog' minHeight and height settings

    - by Kev
    I'm using jQuery 1.4.4 with jQueryUI 1.8.7 to display a modal dialog box. I'm having a problem where IE8 renders a scrollbar and appears to ignore the minHeight and height options in all the many different combinations I've tried them in. In Chrome 8 and Firefox 3.6 my dialogue looks like: In IE 8 it looks like: The markup and script looks like: <a id="create" href="#">Create New Thing</a> <div id="dlg-create-thing" title="Create new thing?"> <form name="create-thing-form" id="dlg-create-thing-form"> <p style="text-align:left"> <span>Name: <input id="thingName" name="thingName" maxlength="12" size="30" /></span> <br /><br /> <b>Thing options:</b><br /><br /> <input type="radio" id="option1" name="theoptions" value="0" checked="checked" />Use this option<br /> <input type="radio" id="option1AndMem" name="theoptions" value="1" />Use this other option </p> </form> </div> <script type="text/javascript"> $(function () { $("#dlg-create-thing").dialog({ autoOpen: false, resizable: false, width: 500, modal: true, minHeight: 280, buttons: { "Create": function () { /* do stuff */ }, "Cancel": function () { /* do other stuff */} } }); $("body").delegate("a[id='create']", "click", function () { $("#dlg-create-thing").dialog('open'); return false; } ); }); </script> How can I fix this (preferably in a nice browser agnostic way, but I'd settle for anything)?

    Read the article

  • Great finds: More TechNet Survival Guides

    - by Enrique Lima
    It has been some time now since Windows Server 2008 R2 arrived, but the features and capabilities in many cases are just now starting to surface with company’s implementing or looking at using. Here is a link to the Survival Guide on TechNet: http://social.technet.microsoft.com/wiki/contents/articles/windows-server-2008-r2-survival-guide.aspx The other item that is coming stronger and stronger is PowerShell.  I mentioned before the need to learn and get into using it as it is a great tool. http://social.technet.microsoft.com/wiki/contents/articles/windows-powershell-survival-guide.aspx

    Read the article

  • In Wireshark's Protocol Hierarchy Statistics screen, is the total byte count of a capture the sum of the Bytes column or just the top line (Frame)?

    - by Howiecamp
    Part 1 - I'm looking at Wireshark's Protocol Hierarchy Statistics screen (sample below), is the total byte count of the capture the sum of the Bytes column or just the top line (Frame)? I'm 99% that it's the latter because of protocol rollup but I wanted to conform. Part 2 - From Wireshark documentation on this screen, "Protocol layers can consist of packets that won't contain any higher layer protocol, so the sum of all higher layer packets may not sum up to the protocols packet count. Example: In the screenshot TCP has 85,83% but the sum of the subprotocols (HTTP, ...) is much less. This may be caused by TCP protocol overhead, e.g. TCP ACK packets won't be counted as packets of the higher layer)." Can you explain this?

    Read the article

  • Trying to mount an NFS directory from a Mac with another user

    - by Yair
    I have a username on an ubuntu server, lets call it user a. I want to mount a directory from that server to my Mac, on which I have another username, lets call it user b. My problem is that, after I mount the directory (using the disk utility app) I can view files on the server but can't modify or create new files on it. I checked, and if I change the permissions of the server directory so that its open to everyone (chmod 777), I can write to it. So what I need to know, is how can I specify the username and password in the NFS client when setting up the mount? That is, I want to specify that I'm trying to log in as user a to the server.

    Read the article

  • Latency in TCP/IP-over-Ethernet networks

    - by aix
    What resources (books, Web pages etc) exist out there that: explain the causes of latency in TCP/IP-over-Ethernet networks; mention tools for looking out for things that cause latency (e.g. certain entries in netstat -s); suggest ways to tweak the Linux TCP stack to reduce TCP latency (Nagle, socket buffers etc). The closest I am aware of is this document, but it's rather brief. Alternatively, you're welcome to answer the above questions directly.

    Read the article

  • Scaling a LAMP website hosted on EC2

    - by Gublooo
    Hello, I'm very new to all this - I've recently managed to launch my website on EC2. As next step, I want to learn how to scale the website. I have a general idea but wanted some input from the experts about how to go about it. My website is based on LAMP but also has Red5 server which allows users to record messages and also used for playing them back. Currently this is the architecture I'm planning to setup for initial scaling. Deploy four small EC2 instances for the following purposes: Instance-1: On this instance I will run the MySql database Instance-2: On this instance I will run the red5 server Instance-3 & Instance-4 These 2 instances will be used to deploy the website and will have Apache running on them. They will communicate with the mysql server on Instance-1 and red5 server on Instance-2 using the internal IP address. As an when required, I will launch another instance of the same EBS - I will have EBS of say 50 GIG where all the mysql data will be stored. Also red5 will use this EBS to store the video messages Load-Balancer - Use the load balancer provided by Amazon to load balance Instance-3 and Instance-4 This is what I have in mind. I could be way off so please bear with me. Also I have not taken into account the case of scaling MySql server as I currently have no idea about how that will be done and whether or not it is necessary initially. I am aware that Amazon provides auto scaling and mysql scaling as well but I dont want to get into that right now. Your feedback is appreciated Thanks

    Read the article

  • Multiple Memcached server /etc/init.d startup script that works ?

    - by p4guru
    I install memcached server via source and can get standard start up script installed for 1 memcached server instance, but trying several scripts via google, can't find one that works to manager auto start up on boot for multiple memcached server instances. I've tried both these scripts and both don't work, service memcached start just returns to command prompt with no memcached server instances started lullabot.com/articles/installing-memcached-redhat-or-centos addmoremem.blogspot.com/2010/09/running-multiple-instances-of-memcached.html However this bash script works but doesn't start up memcached instances at start up though ? #!/bin/sh case "$1" in start) /usr/local/bin/memcached -d -m 16 -p 11211 -u nobody /usr/local/bin/memcached -d -m 16 -p 11212 -u nobody ;; stop) killall memcached ;; esac OS: Centos 5.5 64bit Memcached = v1.4.5 Memcache = v2.2.5 Anyone can point me to a working /etc/init.d/ startup script to manage multiple memcached servers ? Thanks

    Read the article

  • Why dd finishes instantly when pipelining to cat?

    - by agsamek
    I start bash on Cygwin and type: dd if=/dev/zero | cat /dev/null It finishes instantly. When I type: dd if=/dev/zero > /dev/null it runs as expected and I can issue killall -USR1 dd to see the progress. Why does the former invocation finishes instantly? Is it the same on a Linux box? * Explanation why I asked such stupid question and possibly not so stupid question I was compressing hdd images and some were compressed incorrectly. I ended up with the following script showing the problem: while sleep 1 ; do killall -v -USR1 dd ; done & dd if=/dev/zero bs=5000000 count=200 | gzip -c | gzip -cd | wc -c Wc should write 1000000000 at the end. The problem is that it does not on my machine: bash-3.2$ dd if=/dev/zero bs=5000000 count=200 | gzip -c | gzip -cd | wc -c 13+0 records in 12+0 records out 60000000 bytes (60 MB) copied, 0.834 s, 71.9 MB/s 27+0 records in 26+0 records out 130000000 bytes (130 MB) copied, 1.822 s, 71.4 MB/s 200+0 records in 200+0 records out 1000000000 bytes (1.0 GB) copied, 13.231 s, 75.6 MB/s 1005856128 Is it a bug or am I doing something wrong once again?

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >