Daily Archives

Articles indexed Wednesday September 5 2012

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

  • What is the response on a REST call where a field is not valid?

    - by MediaSlayer
    There are many questions on StackOverflow about this, but no definitive answer. I have a REST resource where an entity's field, ProductId, is sent. If the ProductId passed is invalid, what kind of response would you do? I want to send the right response code plus information to the requester on what they can do to fix it. Initial thoughts were 422 with the body containing the list of errors in JSON/XML format. Maybe like this (JSON): [ { FieldName : "ProductId", ErrorCode : "M123", Description : "Product Not Found" }, { FieldName : "Quantity", ErrorCode : "Q001", Description : "Quantity cannot be more than 100" } ] Thoughts?

    Read the article

  • Selecting rows distinctively

    - by noway
    Lets assume my database table structure is something like | items | weight | |============|==========| | item_1 | 50 | | item_2 | 90 | | item_2 | 45 | | item_2 | 60 | | item_3 | 40 | In the select statement, I want to show an item only for once with the highest weight also ordered by height. So the result should be : | items | weight | |============|==========| | item_2 | 90 | | item_1 | 50 | | item_3 | 40 | I tried something like SELECT DISTINCT items, weight FROM mytable ORDER BY weight DESC but it didn't work because the results are actually distinct. How can I make that selection?

    Read the article

  • A graph-based tuple merge?

    - by user1644030
    I have paired values in tuples that are related matches (and technically still in CSV files). Neither of the paired values are necessarily unique. tupleAB = (A####, B###), (A###, B###), (A###, B###)... tupleBC = (B####, C###), (B###, C###), (B###, C###)... tupleAC = (A####, C###), (A###, C###), (A###, C###)... My ideal output would be a dictionary with a unique ID and a list of "reinforced" matches. The way I try to think about it is in a graph-based context. For example, if: tupleAB[x] = (A0001, B0012) tupleBC[y] = (B0012, C0230) tupleAC[z] = (A0001, C0230) This would produce: output = {uniquekey0001, [A0001, B0012, C0230]} Ideally, this would also be able to scale up to more than three tuples (for example, adding a "D" match that would result in an additional three tuples - AD, BD, and CD - and lists of four items long; and so forth). In regards to scaling up to more tuples, I am open to having "graphs" that aren't necessarily fully connected, i.e., every node connected to every other node. My hunch is that I could easily filter based on the list lengths. I am open to any suggestions. I think, with a few cups of coffee, I could work out a brute force solution, but I thought I'd ask the community if anyone was aware of a more elegant solution. Thanks for any feedback.

    Read the article

  • Link to specific page on Google Document Viewer on iPad

    - by Debarupa De
    I am thinking of using the Google Document Viewer to show PDF files that are hosted by our company server. The scenario is: A webpage will contain a menu with menu items that are actually different pages of a PDF file. After clicking a menu item, that particular page from the pdf will be displayed on that same web page This project is targeted for mobile devices (iPad, for now) Now, I am using an iFrame like below: But I don't know if linking to a specific page is possible or Google would like that because I tried the solutions posted on how to open specific page on Google's docs viewer and http://googlesystem.blogspot.com/2009/11/link-to-page-in-googles-document-viewer.html but all of them seem to be outdated. Is this even possible? Thanks for any help.

    Read the article

  • Convert Console Output to Array

    - by theundertaker
    Using netsh wlan show networks mode=bssid on Windows CMD yields a listing of available wireless networks. Is it possible to convert the list, which looks something like this: Interface name : Wireless Network Connection There are 11 networks currently visible. SSID 1 : Custom Gifts Memphis Network type : Infrastructure Authentication : Open Encryption : WEP BSSID 1 : 00:24:93:0c:49:e0 Signal : 16% Radio type : 802.11g Channel : 6 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 6 9 12 18 24 36 48 54 SSID 2 : airportthru Network type : Adhoc Authentication : Open Encryption : None BSSID 1 : 62:4c:fe:9c:08:18 Signal : 53% Radio type : 802.11g Channel : 10 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 24 36 48 54 SSID 3 : belkin.ffe Network type : Infrastructure Authentication : WPA2-Personal Encryption : CCMP BSSID 1 : 08:86:3b:9c:8f:fe Signal : 23% Radio type : 802.11n Channel : 1 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 24 36 48 54 SSID 4 : 3333 Network type : Infrastructure Authentication : WPA2-Personal Encryption : CCMP BSSID 1 : 00:0f:cc:6d:ba:ac Signal : 18% Radio type : 802.11g Channel : 6 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 22 24 36 48 54 BSSID 2 : 06:02:6f:c3:06:27 Signal : 20% Radio type : 802.11g Channel : 6 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 24 36 48 54 SSID 5 : linksys Network type : Infrastructure Authentication : Open Encryption : None BSSID 1 : 98:fc:11:69:35:46 Signal : 38% Radio type : 802.11g Channel : 6 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 24 36 48 54 SSID 6 : iHub_0060350392e0 Network type : Infrastructure Authentication : WPA2-Personal Encryption : CCMP BSSID 1 : 00:c0:02:7d:5f:4e Signal : 18% Radio type : 802.11g Channel : 11 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 24 36 48 54 SSID 7 : TopFlight Network type : Infrastructure Authentication : WPA2-Personal Encryption : CCMP BSSID 1 : 00:14:6c:7a:c4:70 Signal : 16% Radio type : 802.11g Channel : 6 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 24 36 48 54 SSID 8 : 2WIRE430 Network type : Infrastructure Authentication : WPA2-Personal Encryption : CCMP BSSID 1 : b8:e6:25:cb:56:a1 Signal : 16% Radio type : 802.11g Channel : 6 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 24 36 48 54 SSID 9 : LUBIN Network type : Infrastructure Authentication : WPA-Personal Encryption : TKIP BSSID 1 : 00:13:10:8d:a7:32 Signal : 65% Radio type : 802.11g Channel : 6 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 24 36 48 54 SSID 10 : TV2 Network Network type : Infrastructure Authentication : WPA2-Personal Encryption : CCMP BSSID 1 : b8:c7:5d:07:6e:cf Signal : 79% Radio type : 802.11n Channel : 11 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 24 36 48 54 SSID 11 : guywork Network type : Infrastructure Authentication : Open Encryption : WEP BSSID 1 : 00:18:e7:cf:02:20 Signal : 15% Radio type : 802.11n Channel : 6 Basic rates (Mbps) : 1 2 5.5 11 Other rates (Mbps) : 6 9 12 18 24 36 48 54 ... into an array using JavaScript or C#? I know it is but it seems like it may be rather difficult. Are there other avenues of obtaining such network information in the requested format? A JavaScript object would be perfect.

    Read the article

  • Programmatic Text Wrapping in TextView

    - by Andrew
    I'm working on a custom widget for my application to replicate the look of a Preference button for layouts. The issue is the 'summary' text wont wrap when it hits the right wall of the view. One of the goals I'm trying to keep is that this widget is completely made from java with no xml attributes. here's what the widget looks like at the moment: http://dl.dropbox.com/u/56017670/Screenshot_2012-09-05-17-22-45.png notice that the middle two don't wrap the text but the text obviously runs right off the edge of the widget below is the code I'm using to create the text view. public void setSummary(String summary) { if (!TextUtils.isEmpty(summary)) { if (mSummaryView == null) { mSummaryView = new TextView(mContext); mSummaryView.setTextSize(14); mSummaryView.setTextColor(mContext.getResources().getColor( android.R.color.tertiary_text_dark)); addView(mSummaryView); } mSummaryView.setText(summary); mSummaryView.setVisibility(View.VISIBLE); } else { if (mSummaryView != null) { mSummaryView.setVisibility(View.GONE); } } mSummaryText = summary; } and here is the code I'm using to layout mSummaryView mSummaryView.layout( mPreferencePadding + mIconWidth, centerVertical + (mCombinedTextHeight / 2) - mSummaryHeight, width - mPreferencePadding, centerVertical + (mCombinedTextHeight / 2)); I've tried to add mSummaryView.setSingleLine(false); along with quite a few other tricks but they all ended in the same way.

    Read the article

  • Threading in java vs C#

    - by ffayyaz
    I need a little confirmation over something i am confused at . I know how threads work in java. new DialList(string a , string b).start(); // where DialList is a class public class DialList extends Thread { public DialList(String a, string b) { FilePath = a; ThreadLogFile = b"; } public void run() { // some code to run in different thread } } Now i want to run same code in C# , Shall i put the code which is in run() into a method and do something like Thread t = new Thread (runcsharp); // Kick off a new thread t.Start(); static void runcsharp() { // code } or is there some other way to do it ?

    Read the article

  • Circular Tally Counter Not Rolling Over

    - by chris ward
    I was practicing my java and was trying to make a simple counter with rollover at max, but for some reason it isn't rolling over. Any advice? public class HandTallyCounter { private int max; private int count; public HandTallyCounter(int max) { this.max = max; count = 0; } public void click() { if (count++ > max) { count = 0; } } public int getCount() { return count; } public void reset() { count = 0; } }

    Read the article

  • 2D vector value replacement using classes; genetic algorithm mutation

    - by gcolumbus
    I have a 2D vector as defined by the classes below. Note that I've used classes because I'm trying to program a genetic algorithm such that many, many 2D vectors will be created and they will all be different. class Quad: public std::vector<int> { public: Quad() : std::vector<int>(4,0) {} }; class QuadVec : public std::vector<Quad> { }; An important part of my algorithm, however, is that I need to be able to "mutate" (randomly change) particular values in a certain number of randomly chosen 2D vectors. This has me stumped. I can easily write code to randomly select the value within the 2D vector that will be selected for "mutation" but how do I actually enact that change using classes? I understand how this would be done with one 2D vector that has already been initialized but how do I do this if it hasn't? Please let me know if I haven't provided enough info or am not clear as I tend to do that. Thanks for your time and help!

    Read the article

  • css not:first-child selector

    - by OTARIKI
    I have div tag and him is several ul tags. If I trying set css properties only for first ul tag, this code works: div ul:first-child { background-color: #900; } But when i want set css properties each ul tags, except first, I trying this: div ul:not:first-child { background-color: #900; } also this div ul:not(:first-child) { background-color: #900; } and this div ul:first-child:after { background-color: #900; } But effect none. Someone tell please, how must write in css: "each element, except first" ?

    Read the article

  • Getting multiple aggregations in Single statement

    - by Harikrishnan R
    The table has data of city and its branchs/atms CITY TYPE NAME ---------------------------------- agra atm X agra branch X1 delhi atm X2 agra atm X3 agra atm X4 delhi branch X5 chennai branch X6 The result set expecting is CITY ATM BRANCH ------------------------------------ agra 3 1 delhi 1 1 chennai 0 1 Whether we can do this in one select statement.

    Read the article

  • Stuggling with webkit-transition in javascript

    - by Mungbeans
    I've tried a few variations of using webkit-transition that I've found from googling but I've not been able to get any to work. I have some audio controls that I make appear on a click event, they appear suddenly and jerky so I want to fade them in. The target browser is iOS so I am trying webkit extensions. This is what I currently have: <div id = "controls"> <audio id = "audio" controls></audio> </div> #controls { position:absolute; top: 35px; left:73px; height: 20px; width: 180px; display:none; } #audio { opacity:0.0; } audio.src = clip; audio.addEventListener('pause', onPauseOrStop, false); audio.addEventListener('ended', onPauseOrStop, false); audio.play(); audioControls.style.display = 'block'; audio.style.setProperty("-webkit-transition", "opacity 0.4s"); audio.style.opacity = 0.7; The documentation for webkit-transition says it takes effect on a change in the property, so I was assuming changing style.opacity in the last line would kick it off. The controls appear with an opacity of 0.7 but I want it to fade in and that animation isn't happening. I also tried this: #audio { opacity:0.0; -webkit-transition-property: opacity; -webkit-transition-duration: 1s; -webkit-timing-function: ease-in; } Also tried audio.style.webkitTransition = "opacity 1.4s"; from this posting How to set CSS3 transition using javascript? I can't get anything to work, I'm testing on iOS, Safari desktop and Chrome. Same non result on all of them.

    Read the article

  • How to use a FolderBrowserDialog from a WPF application with MVVM

    - by David Work
    I'm trying to use the FolderBrowserDialog from my WPF application - nothing fancy. I don't much care that it has the Windows Forms look to it. I found a question with a suitable answer (How to use a FolderBrowserDialog from a WPF application), except I'm using MVVM. This was the answer I "implemented", except I can't get the window object and I'm just calling ShowDialog() without any parameters. The problem is this: var dlg = new FolderBrowserDialog(); System.Windows.Forms.DialogResult result = dlg.ShowDialog(this.GetIWin32Window()); In my ViewModel there the this has no GetIWin32Window() method for me to get the Window context. Any ideas on how to make this work?

    Read the article

  • perl: added hash entry in a subroutine is lost

    - by hansi
    Why is the hash empty on the second call of printHash? my %hash = (); addToHash(\%hash); printHash(\%hash); sub addToHash { my %hash = %{$_[0]}; $hash{"test"} = "test"; printHash(\%hash); } sub printHash { print "printHash: \n"; my %hash = %{$_[0]}; foreach my $key (keys %hash) { print "key: $key, value: $hash{$key}\n"; } } Output: printHash: key: test, value: test printHash:

    Read the article

  • How to implement a multi-threaded asynchronous operation?

    - by drowneath
    Here's how my current approach looks like: // Somewhere in a UI class // Called when a button called "Start" clicked MyWindow::OnStartClicked(Event &sender) { _thread = new boost::thread(boost::bind(&MyWindow::WorkToDo, this)); } MyWindow::WorkToDo() { for(int i = 1; i < 10000000; i++) { int percentage = (int)((float)i / 100000000.f); _progressBar->SetValue(percentage); _statusText->SetText("Working... %d%%", percentage); printf("Pretend to do something useful...\n"); } } // Called on every frame MyWindow::OnUpdate() { if(_thread != 0 && _thread->timed_join(boost::posix_time::seconds(0)) { _progressBar->SetValue(100); _statusText->SetText("Completed!"); delete _thread; _thread = 0; } } But I'm afraid this is far from safe since I keep getting unhandled exception at the end of the program execution. I basically want to separate a heavy task into another thread without blocking the GUI part.

    Read the article

  • testing .mobile mime format with capybara / rspec

    - by Chris Beck
    For detecting and responding to mobile user agents, I'm using Mime::Type.register_alias "text/html", :mobile and the approach I'm wondering what is the best approach to test with capybara. This article suggests setting up an iphone driver with Capybara.register_driver :iphone do |app| http://blog.plataformatec.com.br/2011/03/configuring-user-agents-with-capybara-selenium-webdriver/ but I'd like a more flexible approach where the mime type is set via the url extension localhost/index.mobile and where I can do this visit user_path( format: :mobile) Rails understands the extension and sets the format in the params hash, but how do I get the url helper methods to add that to all urls as a file extension?

    Read the article

  • show tweets inside div from an asynchronous loop

    - by ak_47
    Am trying to laod tweets into a div after looping them from yahoo placemaker. They are loading on the div but the information shown by them is placemaker's last result. This is the code.. function getLocation(user, date, profile_img, text,url) { var templates = []; templates[0] = '<div><div></div><h2 class="firstHeading">'+user+'</h2><div>'+text+'</div><div><p><a href="' + url + '"target="_blank">'+url+'</a></p></div><p>Date Posted- '+date+'</p></div>'; templates[1] = '<table width="320" border="0"><tr><td class="user" colspan="2" rowspan="1">'+user+'</td></tr><tr><td width="45"><a href="'+profile_img+'"><img src="'+profile_img+'" width="55" height="50"/></a></td><td width="186">'+text+'<p><a href="' + url + '"target="_blank">'+url+'</a></p></td></tr></table><hr>'; templates[2] = '<div><div></div><h2 class="firstHeading">'+user+'</h2><div>'+text+'</div><div><p><a href="' + url + '"target="_blank">'+url+'</a></p></div><p>Date Posted- '+date+'</p></div>'; templates[3] = '<table width="320" border="0"><tr><td class="user" colspan="2" rowspan="1">'+user+'</td></tr><tr><td width="45"><a href="'+profile_img+'"><img src="'+profile_img+'" width="55" height="50"/></a></td><td width="186">'+text+'<p><a href="' + url + '"target="_blank">'+url+'</a></p></td></tr></table><hr>'; var geocoder = new google.maps.Geocoder(); Placemaker.getPlaces(text, function (o) { console.log(o); if (!$.isArray(o.match)) { var latitude = o.match.place.centroid.latitude; var longitude = o.match.place.centroid.longitude; var myLatLng = new google.maps.LatLng(latitude, longitude); var marker = new google.maps.Marker({ icon: profile_img, title: user, map: map, position: myLatLng }); var infowindow = new google.maps.InfoWindow({ content: templates[0].replace('user',user).replace('text',text).replace('url',url).replace('date',date) }); var $tweet = $(templates[1].replace('%user',user).replace(/%profile_img/g,profile_img).replace('%text',text).replace('%url',url)); $('#user-banner').css("visibility","visible");$('#news-banner').css("visibility","visible"); $('#news-tweets').css("overflow","scroll").append($tweet); function openInfoWindow() { infowindow.open(map, marker); } google.maps.event.addListener(marker, 'click', openInfoWindow); $tweet.find(".user").on('click', openInfoWindow); bounds.extend(myLatLng); } }); }

    Read the article

  • Storing a set of criteria in another table

    - by bendataclear
    I have a large table with sales data, useful data below: RowID Date Customer Salesperson Product_Type Manufacturer Quantity Value 1 01-06-2004 James Ian Taps Tap Ltd 200 £850 2 02-06-2004 Apple Fran Hats Hats Inc 30 £350 3 04-06-2004 James Lawrence Pencils ABC Ltd 2000 £980 ... Many rows later... ... 185352 03-09-2012 Apple Ian Washers Tap Ltd 600 £80 I need to calculate a large set of targets from table containing values different types, target table is under my control and so far is like: TargetID Year Month Salesperson Target_Type Quantity 1 2012 7 Ian 1 6000 2 2012 8 James 2 2000 3 2012 9 Ian 2 6500 At present I am working out target types using a view of the first table which has a lot of extra columns: SELECT YEAR(Date) , MONTH(Date) , Salesperson , Quantity , CASE WHEN Manufacturer IN ('Tap Ltd','Hats Inc') AND Product_Type = 'Hats' THEN True ELSE False END AS IsType1 , CASE WHEN Manufacturer = 'Hats Inc' AND Product_Type IN ('Hats','Coats') THEN True ELSE False END AS IsType2 ... ... , CASE WHEN Manufacturer IN ('Tap Ltd','Hats Inc') AND Product_Type = 'Hats' THEN True ELSE False END AS IsType24 , CASE WHEN Manufacturer IN ('Tap Ltd','Hats Inc') AND Product_Type = 'Hats' THEN True ELSE False END AS IsType25 FROM SalesTable WHERE [some stuff here] This is horrible to read/debug and I hate it!! I've tried a few different ways of simplifying this but have been unable to get it to work. The closest I have come is to have a third table holding the definition of the types with the values for each field and the type number, this can be joined to the tables to give me the full values but I can't work out a way to cope with multiple values for each field. Finally the question: Is there a standard way this can be done or an easier/neater method other than one column for each type of target? I know this is a complex problem so if anything is unclear please let me know. Edit - What I need to get: At the very end of the process I need to have targets displayed with actual sales: Type Year Month Salesperson TargetQty ActualQty 2 2012 8 James 2000 2809 2 2012 9 Ian 6500 6251 Each row of the sales table could potentially satisfy 8 of the types. Some more points: I have 5 different columns that need to be defined against the targets (or set to NULL to include any value) I have between 30 and 40 different types that need to be defined, several of the columns could contain as many as 10 different values For point 2, if I am using a row for each permutation of values, 2 columns with 10 values each would give me 100 rows for each sales person for each month which is a lot but if this is the only way to define multiple values I will have to do this. Sorry if this makes no sense!

    Read the article

  • GORM column names for simple one to many mapping

    - by Toby Hobson
    I have this setup class User { Date lastLogin // logins is a history of logins static hasMany = [logins : Date] def setLastLogin(Date date) { if (date) { lastLogin = date addToLogins(date) } } } GORM is generating a table MEMBER_LOGINS which currently looks like this: USER_ID, LOGINS Instead I would like USER_ID, DATE I tried adding a mapping in User static mapping = { logins column: 'date'; } But that just changed the foreign key so i now have DATE, LOGINS How can I change the LOGINS column? Thanks!

    Read the article

  • core data saving in textboxes in table view controller

    - by user1489709
    I have created a five column (text boxes) cell (row) in table view controller with an option of add button. When a user clicks on add button, a new row (cell) with five column (text boxe) is added in a table view controller with null values. I want that when user fills the text boxes the data should get saved in database or if he changes any data in previous text boxes also it get saved. this is my save btn coding.. -(void)textFieldDidEndEditing:(UITextField *)textField { row1=textField.tag; NSLog(@"Row is %d",row1); path = [NSIndexPath indexPathForRow:row1 inSection:0]; Input_Details *inputDetailsObject1=[self.fetchedResultsController objectAtIndexPath:path]; /* Update the Input Values from the values in the text fields. */ EditingTableViewCell *cell; cell = (EditingTableViewCell *)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:row1 inSection:0]]; inputDetailsObject1.mh_Up= cell.cell_MH_up.text; inputDetailsObject1.mh_down=cell.cell_MH_dn.text; inputDetailsObject1.sewer_No=[NSNumber numberWithInt:[cell.cell_Sewer_No.text intValue]]; inputDetailsObject1.mhup_gl=[NSNumber numberWithFloat:[cell.cell_gl_MHUP.text floatValue]]; inputDetailsObject1.mhdn_gl=[NSNumber numberWithFloat:[cell.cell_gl_MHDN.text floatValue]]; inputDetailsObject1.pop_Ln=[NSNumber numberWithInt:[cell.cell_Line_pop.text intValue]]; inputDetailsObject1.sew_len=[NSNumber numberWithFloat:[cell.cell_Sewer_len.text floatValue]]; [self saveContext]; NSLog(@"Saving the MH_up value %@ is saved in save at index path %d",inputDetailsObject1.mh_Up,row1); [self.tableView reloadData]; }

    Read the article

  • Xcode puts Default.png in my plist as an Icon file when I assign a Launch Image

    - by xcode_nooob
    When I set a Launch Image, Xcode creates a copy as Default.png and creates an entry in my plist in Icon Files (IOS 5) / Primary Icon / Icon Items -- Item 1 : Default.png Item 0 : MyIcon.png is the app icon which I have already placed through the Target. The reason this is a problem is that the launch image then takes precedence over the actual icon and as a result, it shows as the primary icon instead of my actual icon image. Why is Xcode doing this? Can I safely delete the Default.png entry from my .plist? (this seems to fix the problem) Do I need to copy Default.png somewhere else? Thanks!

    Read the article

  • YouTube Developers Live: Playlist Party Picker

    YouTube Developers Live: Playlist Party Picker Submit your questions here: goo.gl Danny Hermes, Jeff Posnick and JJ Behrens discuss how they built Party Playlist Picker, a Python App Engine application that lets Google+ users collaboratively edit YouTube Playlists. More details are at apiblog.youtube.com Helpful Links: OAuth2 for GData APIs - googleappsdeveloper.blogspot.com Channel API - developers.google.com Memcache - developers.google.com From: GoogleDevelopers Views: 141 18 ratings Time: 40:14 More in Science & Technology

    Read the article

  • Action delegate in C#

    - by Jalpesh P. Vadgama
    In last few posts about I have written lots of things about delegates and this post is also part of that series. In this post we are going to learn about Action delegates in C#.  Following is a list of post related to delegates. Delegates in C#. Multicast Delegates in C#. Func Delegates in C#. Action Delegates in c#: As per MSDN action delegates used to pass a method as parameter without explicitly declaring custom delegates. Action Delegates are used to encapsulate method that does not have return value. C# 4.0 Action delegates have following different variants like following. It can take up to 16 parameters. Action – It will be no parameter and does not return any value. Action(T) Action(T1,T2) Action(T1,T2,T3) Action(T1,T2,T3,T4) Action(T1,T2,T3,T4,T5) Action(T1,T2,T3,T4,T5,T6) Action(T1,T2,T3,T4,T5,T6,T7) Action(T1,T2,T3,T4,T5,T6,T7,T8) Action(T1,T2,T3,T4,T5,T6,T7,T8,T9) Action(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10) Action(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11) Action(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12) Action(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13) Action(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14) Action(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15) Action(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16) So for this Action delegate you can have up to 16 parameters for Action.  Sound interesting!!… Enough theory now. It’s time to implement real code. Following is a code for that. using System; using System.Collections.Generic; namespace DelegateExample { class Program { static void Main(string[] args) { Action<String> Print = p => Console.WriteLine(p); Action<String,String> PrintAnother = (p1,p2)=> Console.WriteLine(string.Format("{0} {1}",p1,p2)); Print("Hello"); PrintAnother("Hello","World"); } } } In the above code you can see that I have created two Action delegate Print and PrintAnother. Print have one string parameter and its printing that. While PrintAnother have two string parameter and printing both the strings via Console.Writeline. Now it’s time to run example and following is the output as expected. That’s it. Hope you liked it. Stay tuned for more updates!!

    Read the article

  • What's the best way to run Drupal and Django sites behind the same Varnish server?

    - by Alexis Bellido
    I have a high traffic website running with Drupal and Apache, five web servers behind a Varnish server load balancing. Let's say this site is example.com. I'm using five backends and a director like this in my default.vcl: director balancer round-robin { { .backend = web1; } { .backend = web2; } { .backend = web3; } { .backend = web4; } { .backend = web5; } } Now I'm working on a new Django project that will be a new section of this site running on example.com/new-section. After checking the documentation I found I can do something like this: sub vcl_recv { if (req.url ~ "^/new-section/") { set req.backend = newbackend; } else { set req.backend = default; } } That is, using a different backend for a subdirectory /new-section under the same domain. My question is, how do I make something like this work with my director and load balancing setup? I'm probably going to run two or more web servers (backends) with my new Django project, each one with a mix of Gunicorn, Nginx, and a few Python packages, and would like to put all of those in their own Varnish director to load balance. Is it possible to do use the above approach to decide which director to use?, like this: sub vcl_recv { if (req.url ~ "^/new-section/") { set req.director = newdirector; } else { set req.director = balancer; } } All suggestions welcome. Thanks!

    Read the article

  • Nginx and low-speed connections: request terminates after 253 seconds

    - by meze
    I'm trying to make nginx to handle static files. All is working fine except that when I throttle my connection speed to 8kbit/s, the loading process of a file just stops after 253-255 seconds (4.2 min according to chrome). No error in the log, the status code is 200 but the response is received partially. If I disable nginx and make apache to send the same file - it loads successfully after 10 minutes. The config I use for debugging is: client_header_buffer_size 16k; large_client_header_buffers 4 8k; client_max_body_size 50m; client_body_buffer_size 16k; client_header_timeout 20m; client_body_timeout 20m; send_timeout 20m; Did i miss some configurations?

    Read the article

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