Search Results

Search found 130 results on 6 pages for 'pound'.

Page 4/6 | < Previous Page | 1 2 3 4 5 6  | Next Page >

  • Why it is called "hash table", or "hash function"? Hash doesn't make any sense to me here

    - by Saeed Neamati
    It's now about 4 years of development that I'm using, hearing, talking about, and implementing hash tables and hash functions. But I really never understand why it's called hash? I remember the first days I started programming, this term was kind'of cumbersome terminology to me. I never figured out what is it, based on its name. I just experimentally understood what it does and why and when should we use it. However, I still sometimes try to figure out why it's called hash. I have no problem with table or function and to be honest, they are pretty deductive, rational terms. However, I think better words could be used instead of hash, like key, or uniqueness. Don't key table or uniqueness table. According to my dictionary, hash means: Fried dish of potato and meats (highly irrelevant) # symbol (AKA number sign, pound sign, etc.) (still irrelevant, maybe just a mis-nomenclature) Apply algorithm to character string (still has nothing to do with uniqueness, which is the most important feature of a hash table) Cut food Another term for hashish Does anyone know why it's called hash?

    Read the article

  • UFW blocking random packets on 443

    - by s2jcpete
    All, I have UFW setup to allow traffic on port 443. It works as expected, though I have a large amount of UFW Block log entries. To Action From -- ------ ---- 80 ALLOW Anywhere 443 ALLOW Anywhere 22222 ALLOW Anywhere 80 ALLOW Anywhere (v6) 443 ALLOW Anywhere (v6) 22222 ALLOW Anywhere (v6) However in my syslog file I see this: [UFW BLOCK] IN=eth0 OUT= MAC=XXX SRC=<foreignip> DST=<serverip> LEN=40 TOS=0x00 PREC=0x00 TTL=116 ID=22025 DF PROTO=TCP SPT=49622 DPT=443 WINDOW=0 RES=0x00 ACK RST URGP=0 About 30 or so seconds later pound (which I'm using for SSL decryption and port redirection) throws a connection timed out messsage. I'm assuming this is because UFW is blocking the packet. I'm at a loss as to an explination. Could the packet be malformed or something, is this normal? Edit - I have since changed the /etc/defaults/ufw and set ipv6=no, so the v6 rules are no longer in the mix. The server is still showing the block / connection timed out behavior though. The new ufw status output is: Status: active Logging: on (low) Default: deny (incoming), allow (outgoing) New profiles: skip To Action From -- ------ ---- 80 ALLOW IN Anywhere 443 ALLOW IN Anywhere 22222 ALLOW IN Anywhere

    Read the article

  • Android: preferences not being stored automatically

    - by Vitaly
    I'm trying to use preference screen. I'm following all steps from online tutorial (once I couldn't get it working, I found other tutorials, and steps seem to be fine). I get to preferences screen, edit values, return to calling activity (via hardware return button). In DDMS perspective FileExplorer shows package_name_preferences.xml file with preferences that should be stored. It contains: <?xml version='1.0' encoding='utf-8' standalone='yes' ?> <map> <string name="false">kg</string> </map> while I expect (data line only shown). <string name="weight">kg</string> Also, if I go change only 1 preference, the same value changes, not a new row is created. I'm just tempted to write my own preference classes that would store data in files or DB, but I know that preferences should work, it just doesn't save properly my stuff. Edit Tutorials used: Main Tutorial - Was using this as a base, simplified, as I needed only 3 listPreferences so far. Another One - Used this one back when first installed android, so referred to this one for its section on preferences Code: (Screen loads, so I'm not showing Manifest) public class MyPrefs extends PreferenceActivity { @Override public void onCreate(Bundle bundle) { super.onCreate(bundle); addPreferencesFromResource(R.xml.my_prefs); } } my_prefs.xml <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceCategory android:title="Value Settings"> <ListPreference android:title="Distance" android:summary="Metric (Kilometer) vs Imperial (Imperial)" android:defaultValue="km" android:key="@+id/distanceMesurement" android:entries="@array/distance" android:entryValues="@array/distance_values"/> <ListPreference android:title="Weight" android:summary="Metric (Kilogram) vs Imperial (Pound)" android:defaultValue="kg" android:key="@+id/weightMesurement" android:entries="@array/weight" android:entryValues="@array/weight_values"/> </PreferenceCategory> </PreferenceScreen> calling MyPrefs from MainScreen Intent i = new Intent(MainScreen.this, MyPrefs.class); startActivity(i); arrays.xml <resources> <string-array name="weight"> <item name="kg">Kilogram (kg)</item> <item name="lb">Pound (lb)</item> </string-array> <string-array name="weight_values"> <item name="kg">kg</item> <item name="lb">lb</item> </string-array> <string-array name="distance"> <item name="km">Kilometer (km)</item> <item name="mi">Mile (mi)</item> </string-array> <string-array name="distance_values"> <item name="km">km</item> <item name="mi">mi</item> </string-array> </resources>

    Read the article

  • Jquery getJSON cross domain problems

    - by Charlie
    I cant seem to get my JSON file to work when pulling it in from another domain using JQuerys getJSON. I have placed the callback part at the end of the url but still have no joy. Firebug tells me its a cross domain issue, which seems to make sense as if I place the json file locally the below code (excluding the ?jsoncallback=? works fine) Heres the Jquery part $.getJSON("http://anotherdomain/js/morearticles.js?jsoncallback=?", function(json){ if (show5More.nextSetCount ' + this.titletext + '' + this.paratext + '').appendTo("#lineupswitch"); } else { $('' + this.titletext + '' + this.paratext + '').appendTo("#lineupswitch"); } }); return false; } }); } }); } And the JSON, which I have validated. { "items": [ [ { "href": "/edinburgh/video/news-090415-s2-squalor-edinburgh/", "thumbimg": "http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_19721015001_asset-1239819553334.jpg?pubId=1486976045", "titletext": "Cannabis plants found in house with neglected children", "paratext": "A court has heard four young children lived in", "cname": "" }, { "href": "/edinburgh/video/news-090414-s2-waverley-station-edinburgh/", "thumbimg": "http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_19537855001_asset-1239732920496.jpg?pubId=1486976045", "titletext": "Multi-million pound revamp for Waverley Station", "paratext": "Edinburgh's Waverley Station is set for a", "cname": "" }, { "href": "/edinburgh/video/news-s2-natal-20090408/", "thumbimg":"http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_18948154001_asset-1239206353135.jpg?pubId=1486976045", "titletext": "Stillbirth charity on the road to raise awareness", "paratext": "SANDS Lothian are hoping to highlight their", "cname": "" }, { "href": "/edinburgh/video/news-090407-l2-rbs/", "thumbimg":"http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_18827378001_asset-1239110600777.jpg?pubId=1486976045", "titletext": "Thousands of jobs to go at Royal Bank of Scotland", "paratext": "Edinburgh-based bank to cut 4,500 positions in the", "cname": "" }, { "href": "/edinburgh/video/news-090415-s2-squalor-edinburgh/", "thumbimg": "http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_19721015001_asset-1239819553334.jpg?pubId=1486976045", "titletext": "1", "paratext": "A court has heard four young children lived in", "cname": "lastlineup" } ], [ { "href": "/edinburgh/video/news-090415-s2-squalor-edinburgh/", "thumbimg": "http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_19721015001_asset-1239819553334.jpg?pubId=1486976045", "titletext": "1", "paratext": "A court has heard four young children lived in", "cname": "" }, { "href": "/edinburgh/video/news-090414-s2-waverley-station-edinburgh/", "thumbimg": "http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_19537855001_asset-1239732920496.jpg?pubId=1486976045", "titletext": "2", "paratext": "Edinburgh's Waverley Station is set for a", "cname": "" }, { "href": "/edinburgh/video/news-s2-natal-20090408/", "thumbimg":"http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_18948154001_asset-1239206353135.jpg?pubId=1486976045", "titletext": "Stillbirth charity on the road to raise awareness", "paratext": "3", "cname": "" }, { "href": "/edinburgh/video/news-090407-l2-rbs/", "thumbimg":"http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_18827378001_asset-1239110600777.jpg?pubId=1486976045", "titletext": "Thousands of jobs to go at Royal Bank of Scotland", "paratext": "4", "cname": "" }, { "href": "/edinburgh/video/news-090407-l2-rbs/", "thumbimg":"http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_18827378001_asset-1239110600777.jpg?pubId=1486976045", "titletext": "Thousands of jobs to go at Royal Bank of Scotland", "paratext": "Edinburgh-based bank to cut 4,500 positions in the", "cname": "lastlineup" } ] ] } { "items": [ [ { "href": "/edinburgh/video/news-090415-s2-squalor-edinburgh/", "thumbimg": "http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_19721015001_asset-1239819553334.jpg?pubId=1486976045", "titletext": "Cannabis plants found in house with neglected children", "paratext": "A court has heard four young children lived in", "cname": "" }, { "href": "/edinburgh/video/news-090414-s2-waverley-station-edinburgh/", "thumbimg": "http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_19537855001_asset-1239732920496.jpg?pubId=1486976045", "titletext": "Multi-million pound revamp for Waverley Station", "paratext": "Edinburgh's Waverley Station is set for a", "cname": "" }, { "href": "/edinburgh/video/news-s2-natal-20090408/", "thumbimg":"http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_18948154001_asset-1239206353135.jpg?pubId=1486976045", "titletext": "Stillbirth charity on the road to raise awareness", "paratext": "SANDS Lothian are hoping to highlight their", "cname": "" }, { "href": "/edinburgh/video/news-090407-l2-rbs/", "thumbimg":"http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_18827378001_asset-1239110600777.jpg?pubId=1486976045", "titletext": "Thousands of jobs to go at Royal Bank of Scotland", "paratext": "Edinburgh-based bank to cut 4,500 positions in the", "cname": "" }, { "href": "/edinburgh/video/news-090415-s2-squalor-edinburgh/", "thumbimg": "http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_19721015001_asset-1239819553334.jpg?pubId=1486976045", "titletext": "1", "paratext": "A court has heard four young children lived in", "cname": "lastlineup" } ], [ { "href": "/edinburgh/video/news-090415-s2-squalor-edinburgh/", "thumbimg": "http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_19721015001_asset-1239819553334.jpg?pubId=1486976045", "titletext": "1", "paratext": "A court has heard four young children lived in", "cname": "" }, { "href": "/edinburgh/video/news-090414-s2-waverley-station-edinburgh/", "thumbimg": "http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_19537855001_asset-1239732920496.jpg?pubId=1486976045", "titletext": "2", "paratext": "Edinburgh's Waverley Station is set for a", "cname": "" }, { "href": "/edinburgh/video/news-s2-natal-20090408/", "thumbimg":"http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_18948154001_asset-1239206353135.jpg?pubId=1486976045", "titletext": "Stillbirth charity on the road to raise awareness", "paratext": "3", "cname": "" }, { "href": "/edinburgh/video/news-090407-l2-rbs/", "thumbimg":"http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_18827378001_asset-1239110600777.jpg?pubId=1486976045", "titletext": "Thousands of jobs to go at Royal Bank of Scotland", "paratext": "4", "cname": "" }, { "href": "/edinburgh/video/news-090407-l2-rbs/", "thumbimg":"http://brightcove.vo.llnwd.net/d7/unsecured/media/1486976045/1486976045_18827378001_asset-1239110600777.jpg?pubId=1486976045", "titletext": "Thousands of jobs to go at Royal Bank of Scotland", "paratext": "Edinburgh-based bank to cut 4,500 positions in the", "cname": "lastlineup" } ] ] }

    Read the article

  • How can I convert RGB hex string into UIColor in objective-c?

    - by dipu
    I have color values coming from the url data is like this, "#ff33cc". How can I convert this value into UIColor? I am attempting with the following lines of code. I am not getting the value for baseColor1 right. Looks like I should take that pound char off. Is there another way to do it? NSScanner *scanner2 = [NSScanner scannerWithString:@"#ff33cc"]; int baseColor1; [scanner2 scanHexInt:&baseColor1]; CGFloat red = (baseColor1 & 0xFF0000); [UIColor colorWithRed:red ...

    Read the article

  • Twitter URL encoding. Getting error when placing UK Currency sign in URL?

    - by bbacarat
    I'm attempting to setup a retweet button with some pre-written post text. However I need to place a pound sign in like so: £50k I've search the web and for the UK currency sign I've been told it is supposed to be replaced with the code: %a3 However when I attempt to click on the link I get the error message: "Invalid Unicode value in one or more parameters" This is the document declaration at the top of the html page I'm using: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    Read the article

  • Change text fields background colour if negative number using Jquery/CSS

    - by Dan C
    Hi, I have the following text input on a budget calculator form which displays the final balance... <tr><td align="right"><b>Balance: &pound;</b></td><td align="left"><input type="text" class="res" name="res" id="res" size="10" readonly="readonly"></td></tr> How do I go about setting the background of the input to red using css and jquery if the value is a negative number? I am sure this is very simple but I have scanned the net looking for a solution for ages. Please can someone help?, my head hurts!

    Read the article

  • Can anyone help me out in writing a xslt-fo for this xml file?

    - by atrueguy
    Currencies By Country Australia Australian Dollar Austria Schilling Belgium Belgium Franc Canada Canadian Dollar England Pound Fiji Fijian Dollar France Franc Germany DMark Hong Kong Hong Kong Dollar Italy Lira Japan Yen Netherlands Guilder Switzerland SFranc USA Dollar I started to write a xsl-fo to format the above xml in to a table, but I am really struggling with the flow of the tags, can any one help me out in writing a xsl-fo for this xml file? Is it possible for anyone to suggest me material for staring with xsl-fo, so that I can code my own xsl-fo., because the tags and syntax are very difficult to understand.

    Read the article

  • Updating Excel Cell with Non-Numeric Data in C#

    - by kbo206
    I have a query that is ExcelQuery = "Update [Sheet1$] set CITIZEN_ID = #" + value + " where CITIZEN_ID = " + value; As you can see, I'm essentially just appending a "#" onto the CITIZEN_ID field. value is a int/numeric value. So if I had "256" in the CITIZEN_ID column it would be converted to "#256" When I execute this I get an OleDbException Syntax error in date in query expression so I surrounded part of the query in single quotes like this, ExcelQuery = "Update [Sheet1$] set CITIZEN_ID = '#" + value + "' where CITIZEN_ID = " + value; With that I get yet another OleDbException this time with, Data type mismatch in criteria expression. I'm guessing for some reason the CITIZEN_ID fields don't want to take anything besides a plain number. Is there any way I can remedy this to get that pound symbol in? Thanks!

    Read the article

  • haml / rails: yield title with german umlauts

    - by Maxem
    Hi, I would like to do something like this in my application layout: %title= "#{yield(:sub_title)} - Page Name" and in a real view - content_for :sub_title do Übersicht # I tried &Uuml;bersicht, != "&Uuml;bersicht" and a bunch of other methods what happens is, I either get the black pound with the question mark in it - wrong encoding or the raw string (&UumI;bersicht). Does anyone know a way how to get this to work? Another requirement is that I'd like to show user generated content in the title and this content may or may not have umlauts in it. Used versions: Haml 3.0.11, Rails 3 beta4 and currently for development JRuby 1.5

    Read the article

  • remove non-UTF-8 characters from xml with declared encoding=utf-8 - Java

    - by St Nietzke
    I have to handle this scenario in Java: I'm getting a request in XML form from a client with declared encoding=utf-8. Unfortunately it may contain not utf-8 characters and there is a requirement to remove these characters from the xml on my side (legacy). Let's consider an example where this invalid XML contains £ (pound). 1) I get xml as java String with £ in it (I don't have access to interface right now, but I probably get xml as a java String). Can I use replaceAll(£, "") to get rid of this character? Any potential issues? 2) I get xml as an array of bytes - how to handle this operation safely in that case?

    Read the article

  • Errors in Decimal Calcs within def clean method?

    - by allanhenderson
    I'm attempting a few simple calculations in a def clean method following validation (basically spitting out a euro conversion of retrieved uk product price on the fly). I keep getting a TypeError. Full error reads: Cannot convert {'product': , 'invoice': , 'order_discount': Decimal("0.00"), 'order_price': {...}, 'order_adjust': None, 'order_value': None, 'DELETE': False, 'id': 92, 'quantity': 8} to Decimal so I guess django is passing through the entire cleaned_data form to Decimal method. Not sure where I'm going wrong - the code I'm working with is: def clean_order_price(self): cleaned_data = self.cleaned_data data = self.data order_price = cleaned_data.get("order_price") if not order_price: try: existing_price = ProductCostPrice.objects.get(supplier=data['supplier'], product_id=cleaned_data['product'], is_latest=True) except ProductCostPrice.DoesNotExist: existing_price = None if not existing_price: raise forms.ValidationError('No match found, please enter new price') else: if data['invoice_type'] == 1: return existing_price.cost_price_gross elif data['invoice_type'] == 2: exchange = EuroExchangeRate.objects.latest('exchange_date') calc = exchange.exchange_rate * float(existing_price.cost_price_gross) calc = Decimal(str(calc)) return calc return cleaned_data If the invoice is of type 2 (a euro invoice) then the system should grab the latest exchange rate and apply that to the matching UK pound price pulled through to get euro result. Should performing a decimal conversion be a problem within def clean method? Thanks

    Read the article

  • How can I provide links to intranet files through ASP.net?

    - by PhoenixWright
    Conditions: The files must be opened outside of the window that the link to them is in. I have tried href, but when I give it an intranet link it only opens correctly if I leave out target="_blank"; if I put that in, the new window that opens doesn't receive the full link if there is a pound sign in the filepath... a direct link to the intranet address \a\b\c#c.txt would be fine with me; there is no concern about security, but I can't seem to get that to happen in a new window. It seems like this is happening when I don't create a new window, but I can't utilize the same window to open the links. Any ideas?

    Read the article

  • How to find and fix performance problems in ORM powered applications

    - by FransBouma
    Once in a while we get requests about how to fix performance problems with our framework. As it comes down to following the same steps and looking into the same things every single time, I decided to write a blogpost about it instead, so more people can learn from this and solve performance problems in their O/R mapper powered applications. In some parts it's focused on LLBLGen Pro but it's also usable for other O/R mapping frameworks, as the vast majority of performance problems in O/R mapper powered applications are not specific for a certain O/R mapper framework. Too often, the developer looks at the wrong part of the application, trying to fix what isn't a problem in that part, and getting frustrated that 'things are so slow with <insert your favorite framework X here>'. I'm in the O/R mapper business for a long time now (almost 10 years, full time) and as it's a small world, we O/R mapper developers know almost all tricks to pull off by now: we all know what to do to make task ABC faster and what compromises (because there are almost always compromises) to deal with if we decide to make ABC faster that way. Some O/R mapper frameworks are faster in X, others in Y, but you can be sure the difference is mainly a result of a compromise some developers are willing to deal with and others aren't. That's why the O/R mapper frameworks on the market today are different in many ways, even though they all fetch and save entities from and to a database. I'm not suggesting there's no room for improvement in today's O/R mapper frameworks, there always is, but it's not a matter of 'the slowness of the application is caused by the O/R mapper' anymore. Perhaps query generation can be optimized a bit here, row materialization can be optimized a bit there, but it's mainly coming down to milliseconds. Still worth it if you're a framework developer, but it's not much compared to the time spend inside databases and in user code: if a complete fetch takes 40ms or 50ms (from call to entity object collection), it won't make a difference for your application as that 10ms difference won't be noticed. That's why it's very important to find the real locations of the problems so developers can fix them properly and don't get frustrated because their quest to get a fast, performing application failed. Performance tuning basics and rules Finding and fixing performance problems in any application is a strict procedure with four prescribed steps: isolate, analyze, interpret and fix, in that order. It's key that you don't skip a step nor make assumptions: these steps help you find the reason of a problem which seems to be there, and how to fix it or leave it as-is. Skipping a step, or when you assume things will be bad/slow without doing analysis will lead to the path of premature optimization and won't actually solve your problems, only create new ones. The most important rule of finding and fixing performance problems in software is that you have to understand what 'performance problem' actually means. Most developers will say "when a piece of software / code is slow, you have a performance problem". But is that actually the case? If I write a Linq query which will aggregate, group and sort 5 million rows from several tables to produce a resultset of 10 rows, it might take more than a couple of milliseconds before that resultset is ready to be consumed by other logic. If I solely look at the Linq query, the code consuming the resultset of the 10 rows and then look at the time it takes to complete the whole procedure, it will appear to me to be slow: all that time taken to produce and consume 10 rows? But if you look closer, if you analyze and interpret the situation, you'll see it does a tremendous amount of work, and in that light it might even be extremely fast. With every performance problem you encounter, always do realize that what you're trying to solve is perhaps not a technical problem at all, but a perception problem. The second most important rule you have to understand is based on the old saying "Penny wise, Pound Foolish": the part which takes e.g. 5% of the total time T for a given task isn't worth optimizing if you have another part which takes a much larger part of the total time T for that same given task. Optimizing parts which are relatively insignificant for the total time taken is not going to bring you better results overall, even if you totally optimize that part away. This is the core reason why analysis of the complete set of application parts which participate in a given task is key to being successful in solving performance problems: No analysis -> no problem -> no solution. One warning up front: hunting for performance will always include making compromises. Fast software can be made maintainable, but if you want to squeeze as much performance out of your software, you will inevitably be faced with the dilemma of compromising one or more from the group {readability, maintainability, features} for the extra performance you think you'll gain. It's then up to you to decide whether it's worth it. In almost all cases it's not. The reason for this is simple: the vast majority of performance problems can be solved by implementing the proper algorithms, the ones with proven Big O-characteristics so you know the performance you'll get plus you know the algorithm will work. The time taken by the algorithm implementing code is inevitable: you already implemented the best algorithm. You might find some optimizations on the technical level but in general these are minor. Let's look at the four steps to see how they guide us through the quest to find and fix performance problems. Isolate The first thing you need to do is to isolate the areas in your application which are assumed to be slow. For example, if your application is a web application and a given page is taking several seconds or even minutes to load, it's a good candidate to check out. It's important to start with the isolate step because it allows you to focus on a single code path per area with a clear begin and end and ignore the rest. The rest of the steps are taken per identified problematic area. Keep in mind that isolation focuses on tasks in an application, not code snippets. A task is something that's started in your application by either another task or the user, or another program, and has a beginning and an end. You can see a task as a piece of functionality offered by your application.  Analyze Once you've determined the problem areas, you have to perform analysis on the code paths of each area, to see where the performance problems occur and which areas are not the problem. This is a multi-layered effort: an application which uses an O/R mapper typically consists of multiple parts: there's likely some kind of interface (web, webservice, windows etc.), a part which controls the interface and business logic, the O/R mapper part and the RDBMS, all connected with either a network or inter-process connections provided by the OS or other means. Each of these parts, including the connectivity plumbing, eat up a part of the total time it takes to complete a task, e.g. load a webpage with all orders of a given customer X. To understand which parts participate in the task / area we're investigating and how much they contribute to the total time taken to complete the task, analysis of each participating task is essential. Start with the code you wrote which starts the task, analyze the code and track the path it follows through your application. What does the code do along the way, verify whether it's correct or not. Analyze whether you have implemented the right algorithms in your code for this particular area. Remember we're looking at one area at a time, which means we're ignoring all other code paths, just the code path of the current problematic area, from begin to end and back. Don't dig in and start optimizing at the code level just yet. We're just analyzing. If your analysis reveals big architectural stupidity, it's perhaps a good idea to rethink the architecture at this point. For the rest, we're analyzing which means we collect data about what could be wrong, for each participating part of the complete application. Reviewing the code you wrote is a good tool to get deeper understanding of what is going on for a given task but ultimately it lacks precision and overview what really happens: humans aren't good code interpreters, computers are. We therefore need to utilize tools to get deeper understanding about which parts contribute how much time to the total task, triggered by which other parts and for example how many times are they called. There are two different kind of tools which are necessary: .NET profilers and O/R mapper / RDBMS profilers. .NET profiling .NET profilers (e.g. dotTrace by JetBrains or Ants by Red Gate software) show exactly which pieces of code are called, how many times they're called, and the time it took to run that piece of code, at the method level and sometimes even at the line level. The .NET profilers are essential tools for understanding whether the time taken to complete a given task / area in your application is consumed by .NET code, where exactly in your code, the path to that code, how many times that code was called by other code and thus reveals where hotspots are located: the areas where a solution can be found. Importantly, they also reveal which areas can be left alone: remember our penny wise pound foolish saying: if a profiler reveals that a group of methods are fast, or don't contribute much to the total time taken for a given task, ignore them. Even if the code in them is perhaps complex and looks like a candidate for optimization: you can work all day on that, it won't matter.  As we're focusing on a single area of the application, it's best to start profiling right before you actually activate the task/area. Most .NET profilers support this by starting the application without starting the profiling procedure just yet. You navigate to the particular part which is slow, start profiling in the profiler, in your application you perform the actions which are considered slow, and afterwards you get a snapshot in the profiler. The snapshot contains the data collected by the profiler during the slow action, so most data is produced by code in the area to investigate. This is important, because it allows you to stay focused on a single area. O/R mapper and RDBMS profiling .NET profilers give you a good insight in the .NET side of things, but not in the RDBMS side of the application. As this article is about O/R mapper powered applications, we're also looking at databases, and the software making it possible to consume the database in your application: the O/R mapper. To understand which parts of the O/R mapper and database participate how much to the total time taken for task T, we need different tools. There are two kind of tools focusing on O/R mappers and database performance profiling: O/R mapper profilers and RDBMS profilers. For O/R mapper profilers, you can look at LLBLGen Prof by hibernating rhinos or the Linq to Sql/LLBLGen Pro profiler by Huagati. Hibernating rhinos also have profilers for other O/R mappers like NHibernate (NHProf) and Entity Framework (EFProf) and work the same as LLBLGen Prof. For RDBMS profilers, you have to look whether the RDBMS vendor has a profiler. For example for SQL Server, the profiler is shipped with SQL Server, for Oracle it's build into the RDBMS, however there are also 3rd party tools. Which tool you're using isn't really important, what's important is that you get insight in which queries are executed during the task / area we're currently focused on and how long they took. Here, the O/R mapper profilers have an advantage as they collect the time it took to execute the query from the application's perspective so they also collect the time it took to transport data across the network. This is important because a query which returns a massive resultset or a resultset with large blob/clob/ntext/image fields takes more time to get transported across the network than a small resultset and a database profiler doesn't take this into account most of the time. Another tool to use in this case, which is more low level and not all O/R mappers support it (though LLBLGen Pro and NHibernate as well do) is tracing: most O/R mappers offer some form of tracing or logging system which you can use to collect the SQL generated and executed and often also other activity behind the scenes. While tracing can produce a tremendous amount of data in some cases, it also gives insight in what's going on. Interpret After we've completed the analysis step it's time to look at the data we've collected. We've done code reviews to see whether we've done anything stupid and which parts actually take place and if the proper algorithms have been implemented. We've done .NET profiling to see which parts are choke points and how much time they contribute to the total time taken to complete the task we're investigating. We've performed O/R mapper profiling and RDBMS profiling to see which queries were executed during the task, how many queries were generated and executed and how long they took to complete, including network transportation. All this data reveals two things: which parts are big contributors to the total time taken and which parts are irrelevant. Both aspects are very important. The parts which are irrelevant (i.e. don't contribute significantly to the total time taken) can be ignored from now on, we won't look at them. The parts which contribute a lot to the total time taken are important to look at. We now have to first look at the .NET profiler results, to see whether the time taken is consumed in our own code, in .NET framework code, in the O/R mapper itself or somewhere else. For example if most of the time is consumed by DbCommand.ExecuteReader, the time it took to complete the task is depending on the time the data is fetched from the database. If there was just 1 query executed, according to tracing or O/R mapper profilers / RDBMS profilers, check whether that query is optimal, uses indexes or has to deal with a lot of data. Interpret means that you follow the path from begin to end through the data collected and determine where, along the path, the most time is contributed. It also means that you have to check whether this was expected or is totally unexpected. My previous example of the 10 row resultset of a query which groups millions of rows will likely reveal that a long time is spend inside the database and almost no time is spend in the .NET code, meaning the RDBMS part contributes the most to the total time taken, the rest is compared to that time, irrelevant. Considering the vastness of the source data set, it's expected this will take some time. However, does it need tweaking? Perhaps all possible tweaks are already in place. In the interpret step you then have to decide that further action in this area is necessary or not, based on what the analysis results show: if the analysis results were unexpected and in the area where the most time is contributed to the total time taken is room for improvement, action should be taken. If not, you can only accept the situation and move on. In all cases, document your decision together with the analysis you've done. If you decide that the perceived performance problem is actually expected due to the nature of the task performed, it's essential that in the future when someone else looks at the application and starts asking questions you can answer them properly and new analysis is only necessary if situations changed. Fix After interpreting the analysis results you've concluded that some areas need adjustment. This is the fix step: you're actively correcting the performance problem with proper action targeted at the real cause. In many cases related to O/R mapper powered applications it means you'll use different features of the O/R mapper to achieve the same goal, or apply optimizations at the RDBMS level. It could also mean you apply caching inside your application (compromise memory consumption over performance) to avoid unnecessary re-querying data and re-consuming the results. After applying a change, it's key you re-do the analysis and interpretation steps: compare the results and expectations with what you had before, to see whether your actions had any effect or whether it moved the problem to a different part of the application. Don't fall into the trap to do partly analysis: do the full analysis again: .NET profiling and O/R mapper / RDBMS profiling. It might very well be that the changes you've made make one part faster but another part significantly slower, in such a way that the overall problem hasn't changed at all. Performance tuning is dealing with compromises and making choices: to use one feature over the other, to accept a higher memory footprint, to go away from the strict-OO path and execute queries directly onto the RDBMS, these are choices and compromises which will cross your path if you want to fix performance problems with respect to O/R mappers or data-access and databases in general. In most cases it's not a big issue: alternatives are often good choices too and the compromises aren't that hard to deal with. What is important is that you document why you made a choice, a compromise: which analysis data, which interpretation led you to the choice made. This is key for good maintainability in the years to come. Most common performance problems with O/R mappers Below is an incomplete list of common performance problems related to data-access / O/R mappers / RDBMS code. It will help you with fixing the hotspots you found in the interpretation step. SELECT N+1: (Lazy-loading specific). Lazy loading triggered performance bottlenecks. Consider a list of Orders bound to a grid. You have a Field mapped onto a related field in Order, Customer.CompanyName. Showing this column in the grid will make the grid fetch (indirectly) for each row the Customer row. This means you'll get for the single list not 1 query (for the orders) but 1+(the number of orders shown) queries. To solve this: use eager loading using a prefetch path to fetch the customers with the orders. SELECT N+1 is easy to spot with an O/R mapper profiler or RDBMS profiler: if you see a lot of identical queries executed at once, you have this problem. Prefetch paths using many path nodes or sorting, or limiting. Eager loading problem. Prefetch paths can help with performance, but as 1 query is fetched per node, it can be the number of data fetched in a child node is bigger than you think. Also consider that data in every node is merged on the client within the parent. This is fast, but it also can take some time if you fetch massive amounts of entities. If you keep fetches small, you can use tuning parameters like the ParameterizedPrefetchPathThreshold setting to get more optimal queries. Deep inheritance hierarchies of type Target Per Entity/Type. If you use inheritance of type Target per Entity / Type (each type in the inheritance hierarchy is mapped onto its own table/view), fetches will join subtype- and supertype tables in many cases, which can lead to a lot of performance problems if the hierarchy has many types. With this problem, keep inheritance to a minimum if possible, or switch to a hierarchy of type Target Per Hierarchy, which means all entities in the inheritance hierarchy are mapped onto the same table/view. Of course this has its own set of drawbacks, but it's a compromise you might want to take. Fetching massive amounts of data by fetching large lists of entities. LLBLGen Pro supports paging (and limiting the # of rows returned), which is often key to process through large sets of data. Use paging on the RDBMS if possible (so a query is executed which returns only the rows in the page requested). When using paging in a web application, be sure that you switch server-side paging on on the datasourcecontrol used. In this case, paging on the grid alone is not enough: this can lead to fetching a lot of data which is then loaded into the grid and paged there. Keep note that analyzing queries for paging could lead to the false assumption that paging doesn't occur, e.g. when the query contains a field of type ntext/image/clob/blob and DISTINCT can't be applied while it should have (e.g. due to a join): the datareader will do DISTINCT filtering on the client. this is a little slower but it does perform paging functionality on the data-reader so it won't fetch all rows even if the query suggests it does. Fetch massive amounts of data because blob/clob/ntext/image fields aren't excluded. LLBLGen Pro supports field exclusion for queries. You can exclude fields (also in prefetch paths) per query to avoid fetching all fields of an entity, e.g. when you don't need them for the logic consuming the resultset. Excluding fields can greatly reduce the amount of time spend on data-transport across the network. Use this optimization if you see that there's a big difference between query execution time on the RDBMS and the time reported by the .NET profiler for the ExecuteReader method call. Doing client-side aggregates/scalar calculations by consuming a lot of data. If possible, try to formulate a scalar query or group by query using the projection system or GetScalar functionality of LLBLGen Pro to do data consumption on the RDBMS server. It's far more efficient to process data on the RDBMS server than to first load it all in memory, then traverse the data in-memory to calculate a value. Using .ToList() constructs inside linq queries. It might be you use .ToList() somewhere in a Linq query which makes the query be run partially in-memory. Example: var q = from c in metaData.Customers.ToList() where c.Country=="Norway" select c; This will actually fetch all customers in-memory and do an in-memory filtering, as the linq query is defined on an IEnumerable<T>, and not on the IQueryable<T>. Linq is nice, but it can often be a bit unclear where some parts of a Linq query might run. Fetching all entities to delete into memory first. To delete a set of entities it's rather inefficient to first fetch them all into memory and then delete them one by one. It's more efficient to execute a DELETE FROM ... WHERE query on the database directly to delete the entities in one go. LLBLGen Pro supports this feature, and so do some other O/R mappers. It's not always possible to do this operation in the context of an O/R mapper however: if an O/R mapper relies on a cache, these kind of operations are likely not supported because they make it impossible to track whether an entity is actually removed from the DB and thus can be removed from the cache. Fetching all entities to update with an expression into memory first. Similar to the previous point: it is more efficient to update a set of entities directly with a single UPDATE query using an expression instead of fetching the entities into memory first and then updating the entities in a loop, and afterwards saving them. It might however be a compromise you don't want to take as it is working around the idea of having an object graph in memory which is manipulated and instead makes the code fully aware there's a RDBMS somewhere. Conclusion Performance tuning is almost always about compromises and making choices. It's also about knowing where to look and how the systems in play behave and should behave. The four steps I provided should help you stay focused on the real problem and lead you towards the solution. Knowing how to optimally use the systems participating in your own code (.NET framework, O/R mapper, RDBMS, network/services) is key for success as well as knowing what's going on inside the application you built. I hope you'll find this guide useful in tracking down performance problems and dealing with them in a useful way.  

    Read the article

  • Roll your own free .NET technical conference

    - by Brian Schroer
    If you can’t get to a conference, let the conference come to you! There are a ton of free recorded conference presentations online… Microsoft TechEd Let’s start with the proverbial 800 pound gorilla. Recent TechEds have recorded the majority of presentations and made them available online the next day. Check out presentations from last month’s TechEd North America 2012 or last week’s TechEd Europe 2012. If you start at http://channel9.msdn.com/Events/TechEd, you can also drill down to presentations from prior years or from other regional TechEds (Australia, New Zealand, etc.) The top presentations from my “View Queue”: Damian Edwards: Microsoft ASP.NET and the Realtime Web (SignalR) Jennifer Smith: Design for Non-Designers Scott Hunter: ASP.NET Roadmap: One ASP.NET – Web Forms, MVC, Web API, and more Daniel Roth: Building HTTP Services with ASP.NET Web API Benjamin Day: Scrum Under a Waterfall NDC The Norwegian Developer Conference site has the most interesting presentations, in my opinion. You can find the videos from the June 2012 conference at that link. The 2011 and 2010 pages have a lot of presentations that are still relevant also. My View Queue Top 5: Shay Friedman: Roslyn... hmmmm... what? Hadi Hariri: Just ‘cause it’s JavaScript, doesn’t give you a license to write rubbish Paul Betts: Introduction to Rx Greg Young: How to get productive in a project in 24 hours Michael Feathers: Deep Design Lessons ØREDEV Travelling on from Norway to Sweden... I don’t know why, but the Scandinavians seem to have this conference thing figured out. ØREDEV happens each November, and you can find videos here and here. My View Queue Top 5: Marc Gravell: Web Performance Triage Robby Ingebretsen: Fonts, Form and Function: A Primer on Digital Typography Jon Skeet: Async 101 Chris Patterson: Hacking Developer Productivity Gary Short: .NET Collections Deep Dive aspConf - The Virtual ASP.NET Conference Formerly known as “mvcConf”, this one’s a little different. It’s a conference that takes place completely on the web. The next one’s happening July 17-18, and it’s not too late to register (It’s free!). Check out the recordings from February 2011 and July 2010. It’s two years old and talks about ASP.NET MVC2, but most of it is still applicable, and Jimmy Bogard’s Put Your Controllers On a Diet presentation is the most useful technical talk I have ever seen. CodeStock Videos from the 2011 edition of this Tennessee conference are available. Presentations from last month’s 2012 conference should be available soon here. I’m looking forward to watching Matt Honeycutt’s Build Your Own Application Framework with ASP.NET MVC 3. UserGroup.tv User Group.tv was founded in January of 2011 by Shawn Weisfeld, with the mission of providing User Group content online for free. You can search by date, group, speaker and category tags. My View Queue Top 5: Sergey Rathon & Ian Henehan: UI Test Automation with Selenium Rob Vettor: The Repository Pattern Latish Seghal: The .NET Ninja’s Toolbelt Amir Rajan: Get Things Done With Dynamic ASP.NET MVC Jeffrey Richter: .NET Nuggets – Houston TechFest Keynote

    Read the article

  • on coding style

    - by user12607414
    I vastly prefer coding to discussing coding style, just as I would prefer to write poetry instead of talking about how it should be written. Sometimes the topic cannot be put off, either because some individual coder is messing up a shared code base and needs to be corrected, or (worse) because some officious soul has decided, "what we really need around here are some strongly enforced style rules!" Neither is the case at the moment, and yet I will venture a post on the subject. The following are not rules, but suggested etiquette. The idea is to allow a coherent style of coding to flourish safely and sanely, as a humane, inductive, social process. Maxim M1: Observe, respect, and imitate the largest-scale precedents available. (Preserve styles of whitespace, capitalization, punctuation, abbreviation, name choice, code block size, factorization, type of comments, class organization, file naming, etc., etc., etc.) Maxim M2: Don't add weight to small-scale variations. (Realize that Maxim M1 has been broken many times, but don't take that as license to create further irregularities.) Maxim M3: Listen to and rely on your reviewers to help you perceive your own coding quirks. (When you review, help the coder do this.) Maxim M4: When you touch some code, try to leave it more readable than you found it. (When you review such changes, thank the coder for the cleanup. When you plan changes, plan for cleanups.) On the Hotspot project, which is almost 1.5 decades old, we have often practiced and benefited from such etiquette. The process is, and should be, inductive, not prescriptive. An ounce of neighborliness is better than a pound of police-work. Reality check: If you actually look at (or live in) the Hotspot code base, you will find we have accumulated many annoying irregularities in our source base. I suppose this is the normal condition of a lived-in space. Unless you want to spend all your time polishing and tidying, you can't live without some smudge and clutter, can you? Final digression: Grammars and dictionaries and other prescriptive rule books are sometimes useful, but we humans learn and maintain our language by example not grammar. The same applies to style rules. Actually, I think the process of maintaining a clean and pleasant working code base is an instance of a community maintaining its common linguistic identity. BTW, I've been reading and listening to John McWhorter lately with great pleasure. (If you end with a digression, is it a tail-digression?)

    Read the article

  • How to bypass vpn talking to VMWare Guest?

    - by marc esher
    Greetings. Network/VPN n00b question here. I'm running VMWare Workstation with a Guest Windows 2003 Server. It has SQL Server 2000 installed. The sole purpose for this Guest is to house SQL Server... it needn't have internet access or access to any other resources on the network other than the host. When launch Check Point VPN software, the host routes through the company network before it connects to the guest ... i.e. it's no longer a direct connection. I assume this is just how things are supposed to work. However, what's happening is that the connection between my host and the SQL Server instance on the guest intermittently drops. It's not consistent, and some databases on the server will be responsive while others aren't. It appears that the databases with the most traffic on the guest (the ones I'm hitting with load tests) are the ones that become intermittently unresponsive. This problem only manifests when VPN is on; when it's off, I can pound away on this database with no troubles. Thanks for any advice!

    Read the article

  • AWS VPC ELB vs. Custom Load Balancing

    - by CP510
    So I'm wondering if this is a good idea. I have a Amazon AWS VPC setup with a public and private subnets. So I all ready get the Internet Gateway and NAT. I was going to setup all my web servers (Apache2 isntances) and DB servers in the private subnet and use a Load Balancer/Reverse Proxy to pick up requests and send them into the private subnets cluster of servers. My question then, is Amazons ELB's a good use for these, or is it better to setup my own custom instance to handle the public requests and run them through the NAT using nginx or pound? I like the second option just for the sake of having a instance I can log into and check. As well as taking advantage of caching and fail2ban ddos prevention, as well as possibly using fail safes to redirect traffic. But I have no experience with their ELB's, so I thought I'd ask your opinions. Also, if you guys have an opinion on this as well, would using the second option allow me to only have 1 public IP address and be able to route SSH connections through port numbers to respective instances? Thanks in advance!

    Read the article

  • How to bypass vpn talking to VMWare Guest?

    - by marc esher
    Greetings. Network/VPN n00b question here. I'm running VMWare Workstation with a Guest Windows 2003 Server. It has SQL Server 2000 installed. The sole purpose for this Guest is to house SQL Server... it needn't have internet access or access to any other resources on the network other than the host. When launch Check Point VPN software, the host routes through the company network before it connects to the guest ... i.e. it's no longer a direct connection. I assume this is just how things are supposed to work. However, what's happening is that the connection between my host and the SQL Server instance on the guest intermittently drops. It's not consistent, and some databases on the server will be responsive while others aren't. It appears that the databases with the most traffic on the guest (the ones I'm hitting with load tests) are the ones that become intermittently unresponsive. This problem only manifests when VPN is on; when it's off, I can pound away on this database with no troubles. Thanks for any advice!

    Read the article

  • Xmonad on windows laptop

    - by Kevin L.
    I'm a Linux developer in the market for a laptop. 90% of my time is spent in Emacs, the terminal, and Google Chrome, and I want to use them within the excellent Xmonad tiling windows manager. Given these constraints, I can only see two options: Run Linux on a laptop Run Windows on the laptop, and spend all of my time working within a Linux VM. Years of experience suggest that the first option will take many frustrating hours and probably be suboptimal w.r.t. battery life, wifi, and fn keys like screen brightness or audio adjustment. For the second option, what would be the ideal setup? I've had a lot of luck with Cooperative Linux on my Samsung NC-10 netbook (Windows XP), but I would have to setup the X11 server myself. What about using VirtualBox (which includes the guest VM's GUI)? Has anyone tried this? Hardware-wise, I'm looking for something in the "Macbook Air killer" category; Samsung Series 9 laptop, Lenovo IdeaPad U300s, &c. (i.e., matte screen, 5h+ battery life, 3ish pound weight). Price is not a consideration; any suggestions?

    Read the article

  • Does Google sometimes ignore "special" characters, possibly depending on your location or font type settings? [closed]

    - by RLH
    TLDR Google tends to ignore special characters in my search strings. Is there anything that I can do about it and is it, possibly, happening because Google makes certain assumptions based off of my default text-encoding settings and my location? I just posted this question over at StackOverflow. I had found a C preprocessor that I'd never seen before. As I should have done, I Googled it and tried to find out further information. I attempted various search terms which were all variations of "C Operator ##" (some times with and some times without the double-quotes.) Google didn't bring back anything of use so I posted my question on SO. As you can see from the comments, someone mentioned a search string (ironically one which I did try to search) and stated that I could have even hit the "I'm feeling lucky" button and have gotten my answer. The problem is I did search that, and the results that I received were far more basic and even after following the top results and searching the resulting pages, I could find nothing referencing the string "##". I'm not posting this question to complain but it does provide an empirical example of something I've seen before that really bugs me-- Google often ignores special characters in my search strings and the results are often useless. As a developer I often need to search for string values containing non-alphanumeric characters. Some characters (like the underscore or hyphen) can be used without trouble. However, other characters (such as the ampersand, carat, tilde and pound sign) are often ignored in my query strings. Is there a way to prevent this from happening so that I can get meaningful results from Google? NOTE I stay logged into Google and I live in the US. I wonder if Google detects some form of text-encoding setting or derives my results based off of certain, localized text-based assumptions. Regardless, I would like to for Google to search for what I give it. Is there anything that I can do to improve my results?

    Read the article

  • Strange issue in header location redirect

    - by hd01
    I have three websites hosted (example1.com, example2.com, example3.com) on a server. There is a page (test.php) on example1.com with just code below inside it: <?php header('Location:http://example2.com/a.php'); ?> When I browse test.php it goes to http://example1.com/a.php . it doesn't understand it is another domain url, it tried to find the page on itself. but when I put http://google.com instead of example2.com/a.php it works correct. I really get confused. What is the problem ? Should I set some configuration on the server? ( I am administrator of the hosting server ). Ps. The server is behind a pound server. Here's the Firebug Net output for example1.com/test.php Response Headers: HTTP/1.1 302 Found Date: Tue, 09 Oct 2012 09:03:34 GMT Server: Apache/2.2.16 (Debian) Location: http://example1.com/a.php Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 21 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Content-Type: text/html; charset=utf-8 Request Headers: Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Encoding gzip, deflate Accept-Language en-us,en;q=0.5 Connection keep-alive Cookie mycookie Host example1.com User-Agent Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20100101 Firefox/14.0.1

    Read the article

  • Im getting fatal errors... can anyone help me edit my program!

    - by user350217
    The errors i am getting are: Error 1 error LNK2019: unresolved external symbol "double __cdecl getDollarAmt(void)" (? getDollarAmt@@YANXZ) referenced in function _main hid.obj Error 2 fatal error LNK1120: 1 unresolved externals this is my program: #include<iostream> #include<cmath> #include<string> using namespace std; double getDollarAmt(); void displayCurrencies(); char getCurrencySelection (float amtExchanged); bool isSelectionValid(char selection); double calcExchangeAmt (float amtExchanged, char selection); void displayResults(double newAmount, float amtExchanged, char selection, char yesNo); const double russianRubles = 31.168; const double northKoreanWon = .385; const double chineseYuan = 6.832; const double canadianDollar = 1.1137; const double cubanPeso = 1.0; const double ethiopianBirr = 9.09; const double egyptianPound = 5.6275; const double tunisianDinar = 1.3585; const double thaiBaht = 34.4; /****** I changed the variables to global variables so you don't have to worry about accidentally setting them to 0 or assigning over a value that you need ********/ float amtEchanged = 0.0; char selection; char yesNo; double newAmount; int main() { float amtExchanged = 0.0; selection = 'a'; yesNo = 'y'; newAmount = 0.0; getDollarAmt (); displayCurrencies(); getCurrencySelection (amtExchanged); isSelectionValid(selection);/**** you only need to use the selection variable ****/ calcExchangeAmt (amtExchanged, selection); displayResults(newAmount, amtExchanged, selection, yesNo); return 0; } double getDollarAmt (float amtExchanged) // promt user for eachange amount and return it to main { float amtExchanged0;//created temporary variable to set amtExchanged to cout<< "Please enter the total dollar amount to exchange: "; cin>> amtExchanged0; amtExchanged = amtExchanged0;//setting amtExchanged to the right value return amtExchanged; } void displayCurrencies() // display list of currencies { cout<<"A Russian Ruble"<<endl <<"B North Korean Won"<<endl <<"C Chinese Yuan"<<endl <<"D Cuban Peso"<<endl <<"E Ethiopian Birr"<<endl <<"F Thai Baht"<<endl <<"G Canadian Dollars"<<endl <<"H Tunisian Dinar"<<endl <<"I Egyptian Pound"<<endl; } char getCurrencySelection (float amtExchanged) // make a selection and return to main { char selection0;//again, created a temporary variable for selection cout<<"Please enter your selection: "; cin>>selection0; selection = selection0;//setting the temporary variable to the actual variable you use /***** we are now going to see if isSelectionValid returns false. if it returns false, that means that their selection was not character A-H. if it is false we keep calling getCurrencySelection *****/ if(isSelectionValid(selection)==false) { cout<<"Sorry, the selection you chose is invalid."<<endl; getCurrencySelection(amtExchanged); } return selection; } bool isSelectionValid(char selection) // this fuction is supposed to be called from getCurrencySelection, the selction // must be sent to isSelectionValid to determine if its valid // if selection is valid send it bac to getCurrencySelection // if it is false then it is returned to getCurrencySelection and prompted to // make another selection until the selection is valid, then it is returned to main. { /**** i'm not sure if this is what you mean, all i am doing is making sure that their selection is A-H *****/ if(selection=='A' || selection=='B' || selection=='C' || selection=='D' || selection=='E' || selection=='F' || selection=='G' || selection=='H' || selection=='I') return true; else return false; } double calcExchangeAmt (float amtExchanged,char selection) // function calculates the amount of money to be exchanged { switch (toupper(selection)) { case 'A': newAmount =(russianRubles) * (amtExchanged); break; case 'B': newAmount = (northKoreanWon) * (amtExchanged); break; case 'C': newAmount = (chineseYuan) * (amtExchanged); break; case 'D': newAmount = (canadianDollar) * (amtExchanged); break; case 'E': newAmount = (cubanPeso) * (amtExchanged); break; case 'F': newAmount = (ethiopianBirr) * (amtExchanged); break; case 'G': newAmount = (egyptianPound) * (amtExchanged); break; case 'H': newAmount = (tunisianDinar) * (amtExchanged); break; case 'I': newAmount = (thaiBaht) * (amtExchanged); break; } return newAmount; } void displayResults(double newAmount, float amtExchanged, char selection, char yesNo) // displays results and asked to repeat. IF they want to repeat it clears the screen and starts over. { switch(toupper(selection)) { case 'A': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Russian Rubles."<<endl<<endl; break; case 'B': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" North Korean Won."<<endl<<endl; break; case 'C': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Chinese Yuan."<<endl<<endl; break; case 'D': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Cuban Pesos."<<endl<<endl; break; case 'E': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Ethiopian Birr."<<endl<<endl; break; case 'F': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Thai Baht."<<endl<<endl; break; case 'G': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Canadian Dollars."<<endl<<endl; break; case 'H': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Tunisian Dinar."<<endl<<endl; break; case 'I': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Egyptian Pound."<<endl<<endl; break; } cout<<"Do you wish to continue? (Y for Yes / N for No)"; cin>>yesNo; if(yesNo=='y' || yesNo=='Y') { getDollarAmt(); } else { system("cls"); } }

    Read the article

  • What makes them click ?

    - by Piet
    The other day (well, actually some weeks ago while relaxing at the beach in Kos) I read ‘Neuro Web Design - What makes them click?’ by Susan Weinschenk. (http://neurowebbook.com) The book is a fast and easy read (no unnecessary filler) and a good introduction on how your site’s visitors can be steered in the direction you want them to go. The Obvious The book handles some of the more known/proven techniques, like for example that ratings/testimonials of other people can help sell your product or service. Another well known technique it talks about is inducing a sense of scarcity/urgency in the visitor. Only 2 seats left! Buy now and get 33% off! It’s not because these are known techniques that they stop working. Luckily 2/3rd of the book handles less obvious techniques, otherwise it wouldn’t be worth buying. The Not So Obvious A less known influencing technique is reciprocity. And then I’m not talking about swapping links with another website, but the fact that someone is more likely to do something for you after you did something for them first. The book cites some studies (I always love the facts and figures) and gives some actual examples of how to implement this in your site’s design, which is less obvious when you think about it. Want to know more ? Buy the book! Other interesting sources For a more general introduction to the same principles, I’d suggest ‘Yes! 50 Secrets from the Science of Persuasion’. ‘Yes!…’ cites some of the same studies (it seems there’s a rather limited pool of studies covering this subject), but of course doesn’t show how to implement these techniques in your site’s design. I read ‘Yes!…’ last year, making ‘Neuro Web Design’ just a little bit less interesting. !!!Always make sure you’re able to measure your changes. If you haven’t yet, check out the advanced segmentation in Google Analytics (don’t be afraid because it says ‘beta’, it works just fine) and Google Website Optimizer. Worth Buying? Can I recommend it ? Sure, why not. I think it can be useful for anyone who ever had to think about the design or content of a site. You don’t have to be a marketing guy to want a site you’re involved with to be successful. The content/filler ratio is excellent too: you don’t need to wade through dozens of pages to filter out the interesting bits. (unlike ‘The Design of Sites’, which contains too much useless info and because it’s in dead-tree format, you can’t google it) If you like it, you might also check out ‘Yes! 50 Secrets from the Science of Persuasion’. Tip for people living in Europe: check Amazon UK for your book buying needs. Because of the low UK Pound exchange rate, it’s usually considerably cheaper and faster to get a book delivered to your doorstep by Amazon UK compared to having to order it at the local book store or web-shop.

    Read the article

  • A debugging experience with "highly compatible" ASP.NET 4.5

    - by Jeff
    I have to admit that I will pretty much upgrade software for no reason other than being on the latest version. I won't do it if it's super expensive (Adobe gets money from me about once every three or four years at best), but particularly with frameworks and stuff generally available as part of my MSDN subscription, I'll be bleeding edge. CoasterBuzz was running on the MVC 4 framework pretty much as soon as they did a "go live" license for it. I didn't really jump in head-first with Windows 8 and Visual Studio 2012, in part because I just wasn't interested in doing the reinstalls for each new version. Turns out there weren't that many revisions anyway. But when the final versions were released a week and a half ago, I jumped in. I saw on one of the Microsoft sites that .Net 4.5 was a "highly compatible in-place update" to the framework. Good enough for me. I was obviously running it by default in Windows 8, and installed it on my production server. I suppose it's "highly compatible," except when it isn't. Three of my sites are running with various flavors of the MVC version of POP Forums. All of them stopped working under ASP.NET 4.5. It was not immediately obvious what the problem might be beyond an exception indicating that there were no repository classes registered with Ninject, which I use for dependency injection in the forums. This was made all the more weird by the fact that it ran fine locally in the dev Web host. My first instinct was to spin up a Windows Server VM on my local box and put the remote debugger on it. (Side note: running multiple VM's on a Retina MacBook Pro with 16 gigs of RAM is pretty much the most awesome thing ever. I can't believe this computer is for real, and not a 50-pound tower under my desk.) What might have been going on in IIS that doesn't happen in Visual Studio? In the debugging process, I realized that I might be looking in the wrong place. POP Forums creates a Ninject container using a method called from a PreApplicationStartMethod attribute, and at that time registers a module (what Ninject uses to map interfaces to implementations) that maps all of the core dependencies. It also creates an instance of an HttpModule that originally hosted the "services" (search indexing, mailer, etc.), but now just records errors. That's all well and good, but the actual repository mapping, where data is actually read or persisted, happens in Application_Start() in global.asax. The idea there is that you can swap out the SqlSingleWebServer repos for something tuned for multiple servers, Oracle or something else. Of course, if I used something like StructureMap, which does convention-based mapping for dependency injection (a class implementing ISettingsRepository called SettingsRepository is automagically mapped), I wouldn't have to worry about it. In any case, the HttpModule, being instantiated before Application_Start() gets to run, would throw because there was no repo mapped where it could get settings from the database. This makes total sense. The fix is sort of a hack, where I don't setup the innards of the HttpModule until a call to its BeginRequest is made. I say it's a hack, because its primary function, logging exceptions, won't work until the app has warmed up. Still, this brings up an interesting question about the race condition, and what changed in 4.5 when it's running in IIS. In ASP.NET 4, it would appear that the code called via the PreApplicationStartMethod was either failing silently, and running again later, or it was getting to that code after Application_Start was called. In any case, weird thing. The real pain point I'm experiencing now is a bug in MVC 4 that is extremely serious because it renders the mobile/alternate view functionality very much broken.

    Read the article

< Previous Page | 1 2 3 4 5 6  | Next Page >