qid
int64
4
19.1M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
48,397
<p>Is there a redistributable .Net 3.5 installation package that is a silent installer? </p> <p>Or alternatively, is there a switch that can be passed to the main redistributable .Net 3.5 installer to make it silent?</p>
[ { "answer_id": 59395072, "author": "Jean Fiedler", "author_id": 7761893, "author_profile": "https://Stackoverflow.com/users/7761893", "pm_score": -1, "selected": false, "text": "DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:\"Path\\To\\microsoft-windows-netfx3-ondemand-package\"\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
48,426
<p>My gcc build toolchain produces a .map file. How do I display the memory map graphically?</p>
[ { "answer_id": 112078, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 6, "selected": true, "text": "sections symbols with open('t.map') as f:\ncolors = ['9C9F84', 'A97D5D', 'F7DCB4', '5C755E']\ntotal_height = 32.0\n from __future__ import with_statement\nimport re\n\nclass Section:\n def __init__(self, address, size, segment, section):\n self.address = address\n self.size = size\n self.segment = segment\n self.section = section\n def __str__(self):\n return self.section+\"\"\n\nclass Symbol:\n def __init__(self, address, size, file, name):\n self.address = address\n self.size = size\n self.file = file\n self.name = name\n def __str__(self):\n return self.name\n\n#===============================\n# Load the Sections and Symbols\n#\nsections = []\nsymbols = []\n\nwith open('t.map') as f:\n in_sections = True\n for line in f:\n m = re.search('^([0-9A-Fx]+)\\s+([0-9A-Fx]+)\\s+((\\[[ 0-9]+\\])|\\w+)\\s+(.*?)\\s*$', line)\n if m:\n if in_sections:\n sections.append(Section(eval(m.group(1)), eval(m.group(2)), m.group(3), m.group(5)))\n else:\n symbols.append(Symbol(eval(m.group(1)), eval(m.group(2)), m.group(3), m.group(5)))\n else:\n if len(sections) > 0:\n in_sections = False\n\n\n#===============================\n# Gererate the HTML File\n#\n\ncolors = ['9C9F84', 'A97D5D', 'F7DCB4', '5C755E']\ntotal_height = 32.0\n\nsegments = set()\nfor s in sections: segments.add(s.segment)\nsegment_colors = dict()\ni = 0\nfor s in segments:\n segment_colors[s] = colors[i % len(colors)]\n i += 1\n\ntotal_size = 0\nfor s in symbols:\n total_size += s.size\n\nsections.sort(lambda a,b: a.address - b.address)\nsymbols.sort(lambda a,b: a.address - b.address)\n\ndef section_from_address(addr):\n for s in sections:\n if addr >= s.address and addr < (s.address + s.size):\n return s\n return None\n\nprint \"<html><head>\"\nprint \" <style>a { color: black; text-decoration: none; font-family:monospace }</style>\"\nprint \"<body>\"\nprint \"<table cellspacing='1px'>\"\nfor sym in symbols:\n section = section_from_address(sym.address)\n height = (total_height/total_size) * sym.size\n font_size = 1.0 if height > 1.0 else height\n print \"<tr style='background-color:#%s;height:%gem;line-height:%gem;font-size:%gem'><td style='overflow:hidden'>\" % \\\n (segment_colors[section.segment], height, height, font_size)\n print \"<a href='#%s'>%s</a>\" % (sym.name, sym.name)\n print \"</td></tr>\"\nprint \"</table>\"\nprint \"</body></html>\"\n" }, { "answer_id": 35893722, "author": "Sredni", "author_id": 1761205, "author_profile": "https://Stackoverflow.com/users/1761205", "pm_score": 3, "selected": false, "text": "binutils BINUTILS Analyze GCC/LD" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/445087/" ]
48,432
<p>Being relatively new to the .net game, I was wondering, has anyone had any experience of the pros / cons between the use of LINQ and what could be considered more traditional methods working with lists / collections? </p> <p>For a specific example of a project I'm working on : a list of unique id / name pairs are being retrieved from a remote web-service.</p> <ul> <li>this list will change infrequently (once per day), </li> <li>will be read-only from the point of view of the application where it is being used</li> <li>will be stored at the application level for all requests to access</li> </ul> <p>Given those points, I plan to store the returned values at the application level in a singleton class.</p> <p>My initial approach was to iterate through the list returned from the remote service and store it in a NameValueCollection in a singleton class, with methods to retrieve from the collection based on an id:</p> <pre><code>sugarsoap soapService = new sugarsoap(); branch_summary[] branchList = soapService.getBranches(); foreach (branch_summary aBranch in branchList) { branchNameList.Add(aBranch.id, aBranch.name); } </code></pre> <p>The alternative using LINQ is to simply add a method that works on the list directly once it has been retrieved:</p> <pre><code>public string branchName (string branchId) { //branchList populated in the constructor branch_summary bs = from b in branchList where b.id == branchId select b; return branch_summary.name; } </code></pre> <p>Is either better than the other - is there a third way? I'm open to all answers, for both approaches and both in terms of solutions that offer elegance, and those which benefit performance.</p>
[ { "answer_id": 48545, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 3, "selected": true, "text": "public string branchName (string branchId) \n{\n //branchList populated in the constructor\n branch_summary bs = (from b in branchList where b.id == branchId select b).FirstOrDefault();\n return branch_summary == null ? null : branch_summary.name;\n}\n" }, { "answer_id": 12652310, "author": "SimpleVar", "author_id": 1282539, "author_profile": "https://Stackoverflow.com/users/1282539", "pm_score": 0, "selected": false, "text": "public string BranchName(string branchId) \n{\n var bs = branchList.FirstOrDefault(b => b.Id == branchId);\n\n return bs == null ? null : bs.Name;\n}\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48432", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4396/" ]
48,442
<p>Anyone have a good rule of thumb for choosing between different implementations of Java Collection interfaces like List, Map, or Set?</p> <p>For example, generally why or in what cases would I prefer to use a Vector or an ArrayList, a Hashtable or a HashMap?</p>
[ { "answer_id": 48525, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 4, "selected": false, "text": "ArrayList LinkedList" }, { "answer_id": 59806362, "author": "Basil Bourque", "author_id": 642706, "author_profile": "https://Stackoverflow.com/users/642706", "pm_score": 1, "selected": false, "text": "Map Map DayOfWeek Employee Map < DayOfWeek , Employee > weekendWorker = \n Map.of( \n DayOfWeek.SATURDAY , alice ,\n DayOfWeek.SUNDAY , bob\n )\n;\n Map Map" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1294/" ]
48,446
<p>How do you schedule a Windows Mobile application to periodically start up to perform some background processing. For example, assume I'm writing an email client and want to check for email every hour, regardless of whether my app is running at the time.</p> <p>The app is a native C/C++ app on Windows Mobile 5.0 or later.</p>
[ { "answer_id": 48466, "author": "quick_dry", "author_id": 3716, "author_profile": "https://Stackoverflow.com/users/3716", "pm_score": 3, "selected": true, "text": "CeRunAppAtTime( appname, time ) CeRunAppAtEvent RunAppAtTime OpenNETCF.Win32.Notify" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2716/" ]
48,458
<p>I started an application in Google App Engine right when it came out, to play with the technology and work on a pet project that I had been thinking about for a long time but never gotten around to starting. The result is <a href="http://www.bowlsk.com" rel="noreferrer">BowlSK</a>. However, as it has grown, and features have been added, it has gotten really difficult to keep things organized - mainly due to the fact that this is my first python project, and I didn't know anything about it until I started working.</p> <p>What I have:</p> <ul> <li>Main Level contains: <ul> <li>all .py files (didn't know how to make packages work)</li> <li>all .html templates for main level pages</li> </ul></li> <li>Subdirectories: <ul> <li>separate folders for css, images, js, etc.</li> <li>folders that hold .html templates for subdirecty-type urls</li> </ul></li> </ul> <p>Example:<br/> <a href="http://www.bowlsk.com/" rel="noreferrer">http://www.bowlsk.com/</a> maps to HomePage (default package), template at "index.html"<br/> <a href="http://www.bowlsk.com/games/view-series.html?series=7130" rel="noreferrer">http://www.bowlsk.com/games/view-series.html?series=7130</a> maps to ViewSeriesPage (again, default package), template at "games/view-series.html"</p> <p>It's nasty. How do I restructure? I had 2 ideas:</p> <ul> <li><p>Main Folder containing: appdef, indexes, main.py?</p> <ul> <li>Subfolder for code. Does this have to be my first package?</li> <li>Subfolder for templates. Folder heirarchy would match package heirarchy</li> <li>Individual subfolders for css, images, js, etc.</li> </ul></li> <li><p>Main Folder containing appdef, indexes, main.py?</p> <ul> <li>Subfolder for code + templates. This way I have the handler class right next to the template, because in this stage, I'm adding lots of features, so modifications to one mean modifications to the other. Again, do I have to have this folder name be the first package name for my classes? I'd like the folder to be "src", but I don't want my classes to be "src.WhateverPage"</li> </ul></li> </ul> <p>Is there a best practice? With Django 1.0 on the horizon, is there something I can do now to improve my ability to integrate with it when it becomes the official GAE templating engine? I would simply start trying these things, and seeing which seems better, but pyDev's refactoring support doesn't seem to handle package moves very well, so it will likely be a non-trivial task to get all of this working again.</p>
[ { "answer_id": 70271, "author": "fuentesjr", "author_id": 10708, "author_profile": "https://Stackoverflow.com/users/10708", "pm_score": 8, "selected": true, "text": "import wsgiref.handlers\n\nfrom google.appengine.ext import webapp\nfrom myapp.views import *\n\napplication = webapp.WSGIApplication([\n ('/', IndexHandler),\n ('/foo', FooHandler)\n], debug=True)\n\ndef main():\n wsgiref.handlers.CGIHandler().run(application)\n import os\nimport datetime\nimport logging\nimport time\n\nfrom google.appengine.api import urlfetch\nfrom google.appengine.ext.webapp import template\nfrom google.appengine.api import users\nfrom google.appengine.ext import webapp\nfrom models import *\n\nclass IndexHandler(webapp.RequestHandler):\n def get(self):\n date = \"foo\"\n # Do some processing \n template_values = {'data': data }\n path = os.path.join(os.path.dirname(__file__) + '/../templates/', 'main.html')\n self.response.out.write(template.render(path, template_values))\n\nclass FooHandler(webapp.RequestHandler):\n def get(self):\n #logging.debug(\"start of handler\")\n from google.appengine.ext import db\n\nclass SampleModel(db.Model):\n" }, { "answer_id": 153862, "author": "Nick Johnson", "author_id": 12030, "author_profile": "https://Stackoverflow.com/users/12030", "pm_score": 4, "selected": false, "text": "__init__.py" }, { "answer_id": 3105295, "author": "systempuntoout", "author_id": 130929, "author_profile": "https://Stackoverflow.com/users/130929", "pm_score": 2, "selected": false, "text": "app.yaml\napplication.py\nindex.yaml\n/app\n /config\n /controllers\n /db\n /lib\n /models\n /static\n /docs\n /images\n /javascripts\n /stylesheets\n test/\n utility/\n views/\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/96/" ]
48,470
<p>Whenever I use a macro in Visual Studio I get an annoying tip balloon in the system tray and an accompanying "pop" sound. It says:</p> <blockquote> <p>Visual Studio .NET macros</p> <p>To stop the macro from running, double-click the spinning cassette.<br> Click here to not show this balloon again.</p> </blockquote> <p>I have trouble clicking the balloon because my macro runs so quickly.</p> <p>Is this controllable by some dialog box option?</p> <p>(I found someone else asking this question on <a href="http://www.tech-archive.net/Archive/VisualStudio/microsoft.public.vsnet.ide/2005-11/msg00267.html" rel="noreferrer">some other site</a> but it's not answered there. I give credit here because I've copied and pasted some pieces from there.)</p>
[ { "answer_id": 48478, "author": "Owen", "author_id": 4790, "author_profile": "https://Stackoverflow.com/users/4790", "pm_score": 2, "selected": false, "text": "System.Threading.Thread.Sleep(2000)\n" }, { "answer_id": 296494, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "New | DWORD value" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48470", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4790/" ]
48,474
<p>I'm a beginner at rails programming, attempting to show many images on a page. Some images are to lay on top of others. To make it simple, say I want a blue square, with a red square in the upper right corner of the blue square (but not tight in the corner). I am trying to avoid compositing (with ImageMagick and similar) due to performance issues.</p> <p>I just want to position overlapping images relative to one another.</p> <p>As a more difficult example, imagine an odometer placed inside a larger image. For six digits, I would need to composite a million different images, or do it all on the fly, where all that is needed is to place the six images on top of the other one.</p>
[ { "answer_id": 48484, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 6, "selected": false, "text": "img {\n position: absolute;\n top: 25px;\n left: 25px;\n}\n.imgA1 {\n z-index: 1;\n}\n.imgB1 {\n z-index: 3;\n} <img class=\"imgA1\" src=\"https://via.placeholder.com/200/333333\">\n<img class=\"imgB1\" src=\"https://via.placeholder.com/100\">" }, { "answer_id": 48530, "author": "buti-oxa", "author_id": 2515, "author_profile": "https://Stackoverflow.com/users/2515", "pm_score": 5, "selected": false, "text": "<style>\n.containerdiv { float: left; position: relative; } \n.cornerimage { position: absolute; top: 0; right: 0; } \n</style>\n\n<div class=\"containerdiv\">\n <img border=\"0\" src=\"https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png\" alt=\"\"\">\n <img class=\"cornerimage\" border=\"0\" src=\"http://www.gravatar.com/avatar/\" alt=\"\">\n<div>\n" }, { "answer_id": 48531, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": false, "text": "<!-- First, your background image is a DIV with a background \n image style applied, not a IMG tag. -->\n<div style=\"background-image:url(YourBackgroundImage);\">\n <!-- Second, create a placeholder div to assist in positioning \n the other images. This is relative to the background div. -->\n <div style=\"position: relative; left: 0; top: 0;\">\n <!-- Now you can place your IMG tags, and position them relative \n to the container we just made --> \n <img src=\"YourForegroundImage\" style=\"position: relative; top: 0; left: 0;\"/>\n </div>\n</div>\n" }, { "answer_id": 48533, "author": "Sören Kuklau", "author_id": 1600, "author_profile": "https://Stackoverflow.com/users/1600", "pm_score": 0, "selected": false, "text": "width height width: height: text/css <style> <style type=\"text/css\"> \n.containerdiv { float: left; position: relative; } \n.cornerimage { position: absolute; top: 0; right: 0; } \n</style>\n\n<div class=\"containerdiv\">\n <img border=\"0\" src=\"http://www.gravatar.com/avatar/\" alt=\"\" width=\"100\" height=\"100\">\n <img class=\"cornerimage\" border=\"0\" src=\"http://www.gravatar.com/avatar/\" alt=\"\" width=\"40\" height=\"40\">\n<div>\n px; width height" }, { "answer_id": 1997397, "author": "rrichter", "author_id": 5038, "author_profile": "https://Stackoverflow.com/users/5038", "pm_score": 10, "selected": true, "text": ".parent {\n position: relative;\n top: 0;\n left: 0;\n}\n.image1 {\n position: relative;\n top: 0;\n left: 0;\n border: 1px red solid;\n}\n.image2 {\n position: absolute;\n top: 30px;\n left: 30px;\n border: 1px green solid;\n} <div class=\"parent\">\n <img class=\"image1\" src=\"https://via.placeholder.com/50\" />\n <img class=\"image2\" src=\"https://via.placeholder.com/100\" />\n</div>" }, { "answer_id": 8306607, "author": "Wez", "author_id": 1070683, "author_profile": "https://Stackoverflow.com/users/1070683", "pm_score": 4, "selected": false, "text": "<img src=\"b.jpg\" style=\"position: absolute; top: 30; left: 70;\"/>\n <img src=\"b.jpg\" style=\"position: absolute; top: 30px; left: 70px;\"/>\n" }, { "answer_id": 14434582, "author": "Danield", "author_id": 703717, "author_profile": "https://Stackoverflow.com/users/703717", "pm_score": 3, "selected": false, "text": "pseudo elements <div class=\"overlap\"></div>\n .overlap\n{\n width: 100px;\n height: 100px;\n position: relative;\n background-color: blue;\n}\n.overlap:after\n{\n content: '';\n position: absolute;\n width: 20px;\n height: 20px;\n top: 5px;\n left: 5px;\n background-color: red;\n}\n" }, { "answer_id": 51639228, "author": "Elkin Angulo", "author_id": 5618571, "author_profile": "https://Stackoverflow.com/users/5618571", "pm_score": 3, "selected": false, "text": "<!-- html -->\n<div class=\"images-wrapper\">\n <img src=\"images/1\" alt=\"image 1\" />\n <img src=\"images/2\" alt=\"image 2\" />\n <img src=\"images/3\" alt=\"image 3\" />\n <img src=\"images/4\" alt=\"image 4\" />\n</div>\n // In _extra.scss\n$maxImagesNumber: 5;\n\n.images-wrapper {\n img {\n position: absolute;\n padding: 5px;\n border: solid black 1px;\n }\n\n @for $i from $maxImagesNumber through 1 {\n :nth-child(#{ $i }) {\n z-index: #{ $maxImagesNumber - ($i - 1) };\n left: #{ ($i - 1) * 30 }px;\n }\n }\n}\n" }, { "answer_id": 67323791, "author": "Howdy", "author_id": 2246369, "author_profile": "https://Stackoverflow.com/users/2246369", "pm_score": 1, "selected": false, "text": "<div style=\"max-width:100px\">\n <div style=\"background-image:url('/image.png'); background-size: cover; height:100px; width:100px; \"></div>\n</div>\n" }, { "answer_id": 68994219, "author": "Fzum", "author_id": 7449607, "author_profile": "https://Stackoverflow.com/users/7449607", "pm_score": 2, "selected": false, "text": "<div style=\"display: grid; grid-template-columns: [first-col] 100%; grid-template-rows: [first-row] 300px\">\n <img src=\"https://fakeimg.pl/300/\" style=\"grid-column-start: first-col; grid-row-start: first-row\">\n <img src=\"https://fakeimg.pl/300/\" style=\"grid-column-start: first-col; grid-row-start: first-row\">\n <img src=\"https://fakeimg.pl/300/\">\n</div>" }, { "answer_id": 72413713, "author": "John Chidi", "author_id": 13283577, "author_profile": "https://Stackoverflow.com/users/13283577", "pm_score": 1, "selected": false, "text": "img {\n border: 2px solid red;\n}\n\n.img1n2 {\n display: flex; \n justify-content:center;\n}\n\n.img1 {\n z-index: 1;\n}\n\n.img2 {\n position: absolute; \n z-index: 2;\n top: 52.5%;\n} <div class=\"img1n2\">\n <img class=\"img1\" src=\"https://fakeimg.pl/400/\">\n <img class=\"img2\" src=\"https://fakeimg.pl/300/\" width=\"100\">\n <img class=\"img2\" src=\"https://fakeimg.pl/200/\" width=\"50\">\n <img class=\"img2\" src=\"https://fakeimg.pl/50/\" width=\"30\">\n</div>" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48474", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5038/" ]
48,475
<p>How would you design a database to support the following tagging features:</p> <ul> <li>items can have a large number of tags</li> <li>searches for all items that are tagged with a given set of tags must be quick (the items must have ALL tags, so it's an AND-search, not an OR-search)</li> <li>creating/writing items may be slower to enable quick lookup/reading</li> </ul> <p>Ideally, the lookup of all items that are tagged with (at least) a set of n given tags should be done using a single SQL statement. Since the number of tags to search for as well as the number of tags on any item are unknown and may be high, using JOINs is impractical.</p> <p>Any ideas?</p> <hr> <p>Thanks for all the answers so far.</p> <p>If I'm not mistaken, however, the given answers show how to do an OR-search on tags. (Select all items that have one or more of n tags). I am looking for an efficient AND-search. (Select all items that have ALL n tags - and possibly more.)</p>
[ { "answer_id": 48480, "author": "Slartibartfast", "author_id": 4433, "author_profile": "https://Stackoverflow.com/users/4433", "pm_score": 4, "selected": false, "text": "SELECT * FROM items WHERE id IN \n (SELECT DISTINCT item_id FROM item_tag WHERE \n tag_id = tag1 OR tag_id = tag2 OR ...) \n SELECT * FROM items WHERE \n EXISTS (SELECT 1 FROM item_tag WHERE id = item_id AND tag_id = tag1) \n AND EXISTS (SELECT 1 FROM item_tag WHERE id = item_id AND tag_id = tag2) \n AND ...\n" }, { "answer_id": 48481, "author": "Brad Bruce", "author_id": 5008, "author_profile": "https://Stackoverflow.com/users/5008", "pm_score": 3, "selected": false, "text": "Target_Type Target Tag Select distinct target from tags \nwhere tag in ([your list of tags to search for here]) \nand target_type = [the table you're searching]\n select target\nfrom (\n select target, count(*) cnt \n from tags \n where tag in ([your list of tags to search for here])\n and target_type = [the table you're searching]\n)\nwhere cnt = [number of tags being searched]\n" }, { "answer_id": 48485, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 0, "selected": false, "text": " TagId (PK)| TagName (Indexed)\n TagXrefID | ItemID | TagId\n SELECT Tags.TagId,Tags.TagName \n FROM Tags,TagXref \n WHERE TagXref.TagId = Tags.TagId \n AND TagXref.ItemID = @ItemID\n SELECT * FROM Items, TagXref\n WHERE TagXref.TagId IN \n ( SELECT Tags.TagId FROM Tags\n WHERE Tags.TagName = @TagName; )\n AND Items.ItemId = TagXref.ItemId;\n" }, { "answer_id": 48558, "author": "digiguru", "author_id": 5055, "author_profile": "https://Stackoverflow.com/users/5055", "pm_score": 0, "selected": false, "text": "Items (ID pk, Name, <properties>)\nTags (ID pk, Name)\nTagItems (TagID fk, ItemID fk)\n CachedTagItems(ID, Name, <properties>, tag1, tag2, ... tagN)\n 0000\n 1111\n 1100\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48475", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5035/" ]
48,491
<p>I have two machines, speed and mass. speed has a fast Internet connection and is running a crawler which downloads a lot of files to disk. mass has a lot of disk space. I want to move the files from speed to mass after they're done downloading. Ideally, I'd just run:</p> <pre><code>$ rsync --remove-source-files speed:/var/crawldir . </code></pre> <p>but I worry that rsync will unlink a source file that hasn't finished downloading yet. (I looked at the source code and I didn't see anything protecting against this.) Any suggestions?</p>
[ { "answer_id": 48517, "author": "Jason Cohen", "author_id": 4926, "author_profile": "https://Stackoverflow.com/users/4926", "pm_score": 3, "selected": false, "text": "mass speed" }, { "answer_id": 48628, "author": "Grey Panther", "author_id": 1265, "author_profile": "https://Stackoverflow.com/users/1265", "pm_score": 2, "selected": false, "text": "foo.downloading foo" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4300/" ]
48,497
<p>The following XHTML code is not working:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;link rel="stylesheet" type="text/css" href="/dojotoolkit/dijit/themes/tundra/tundra.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="/dojotoolkit/dojo/resources/dojo.css" /&gt; &lt;script type="text/javascript" src="/dojotoolkit/dojo/dojo.js" djConfig="parseOnLoad: true" /&gt; &lt;script type="text/javascript"&gt; dojo.require("dijit.form.ValidationTextBox"); dojo.require("dojo.parser"); &lt;/script&gt; &lt;/head&gt; &lt;body class="nihilo"&gt; &lt;input type="text" dojoType="dijit.form.ValidationTextBox" size="30" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>In Firebug I get the following error message:</p> <blockquote> <p>[Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLElement.innerHTML]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: <a href="http://localhost:21000/dojotoolkit/dojo/dojo.js" rel="nofollow noreferrer">http://localhost:21000/dojotoolkit/dojo/dojo.js</a> :: anonymous :: line 319" data: no] <a href="http://localhost:21000/dojotoolkit/dojo/dojo.js" rel="nofollow noreferrer">http://localhost:21000/dojotoolkit/dojo/dojo.js</a> Line 319</p> </blockquote> <p>Any idea what is wrong?</p>
[ { "answer_id": 48554, "author": "Brian Gianforcaro", "author_id": 3415, "author_profile": "https://Stackoverflow.com/users/3415", "pm_score": 1, "selected": false, "text": "<script type=\"text/javascript\" src=\"/dojotoolkit/dojo/dojo.js\" djConfig=\"parseOnLoad: true\"/>\n <script type=\"text/javascript\" src=\"/dojotoolkit/dojo/dojo.js\" djConfig=\"parseOnLoad:true\"></script>\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48497", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4875/" ]
48,505
<p>Does anyone know of a similar product to Citrix Server that'll run on the Mac OS?</p> <p>Essentially, I'm looking to allow multiple remote users to log in to the same OSX Server at the same time (with full visual desktop, not SSH).</p>
[ { "answer_id": 48729, "author": "ceejayoz", "author_id": 1902010, "author_profile": "https://Stackoverflow.com/users/1902010", "pm_score": 2, "selected": true, "text": "@Soeren Kuklau" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48505", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1902010/" ]
48,521
<p>I would like to use a component that exposes the datasource property, but instead of supplying the datasource with whole list of objects, I would like to use only simple object. Is there any way to do this ?</p> <p>The mentioned component is DevExpress.XtraDataLayout.DataLayoutControl - this is fairly irrelevant to the question though.</p>
[ { "answer_id": 48522, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 4, "selected": true, "text": "DataBindObject.DataSource = new List<YourObject>().Add(YourObjectInstance);\n" }, { "answer_id": 48523, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 1, "selected": false, "text": "List<clsScannedDriverLicense> DriverLicenses = new\nList<clsScannedDriverLicense>();\n//this creates a generic collection for you that you can return from\n//your BLL to the ObjectDataSource\nDriverLicenses.Add(TheOneObjectThatYouHaveofType_c lsDriverLicense);\n <asp:ObjectDataSource ID=\"odsDL\" runat=\"server\"\nSelectMethod=\"OrdersByCustomer\"\nTypeName=\"YourBLL.UtiltiesClassName\"\nDataObjectTypeName=\"clsScannedDriverLicense\">\n</asp:ObjectDataSource>\n" }, { "answer_id": 3326610, "author": "Francisco Aquino", "author_id": 187126, "author_profile": "https://Stackoverflow.com/users/187126", "pm_score": 0, "selected": false, "text": "databoundControl.DataSource = new [] { singleObject };\ndataboundControl.DataBind();\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48521", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4694/" ]
48,526
<p>I've been looking into different web statistics programs for my site, and one promising one is <a href="http://www.hping.org/visitors/" rel="nofollow noreferrer">Visitors</a>. Unfortunately, it's a C program and I don't know how to call it from the web server. I've tried using PHP's <a href="http://us.php.net/manual/en/function.shell-exec.php" rel="nofollow noreferrer">shell_exec</a>, but my web host (<a href="https://www.nearlyfreespeech.net/" rel="nofollow noreferrer">NFSN</a>) has PHP's <a href="http://us2.php.net/features.safe-mode" rel="nofollow noreferrer">safe mode</a> on and it's giving me an error message.</p> <p>Is there a way to execute the program within safe mode? If not, can it work with CGI? If so, how? (I've never used CGI before)</p>
[ { "answer_id": 48721, "author": "Kyle Cronin", "author_id": 658, "author_profile": "https://Stackoverflow.com/users/658", "pm_score": 1, "selected": true, "text": "#!/bin/sh\n\nprintf \"Content-type: text/html\\n\\n\"\nexec visitors -A /home/logs/access_log\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/658/" ]
48,550
<p>I am trying to publish an Asp.net MVC web application locally using the NAnt and MSBuild. This is what I am using for my NAnt target;</p> <pre><code>&lt;target name="publish-artifacts-to-build"&gt; &lt;msbuild project="my-solution.sln" target="Publish"&gt; &lt;property name="Configuration" value="debug" /&gt; &lt;property name="OutDir" value="builds\" /&gt; &lt;arg line="/m:2 /tv:3.5" /&gt; &lt;/msbuild&gt; &lt;/target&gt; </code></pre> <p>and all I get is this as a response;</p> <pre><code>[msbuild] Skipping unpublishable project. </code></pre> <p>Is it possible to publish web applications via the command line in this way?</p>
[ { "answer_id": 6762142, "author": "Alexander Beletsky", "author_id": 386751, "author_profile": "https://Stackoverflow.com/users/386751", "pm_score": 4, "selected": false, "text": "msbuild /t:ResolveReferences;_WPPCopyWebApplication /p:BuildingProject=true;OutDir=C:\\Temp\\buidl\\ Test.csproj\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4642/" ]
48,555
<p>I have a few sites on a shared host that is running Apache 2. I would like to compress the HTML, CSS and Javascript that is delivered to the browser. The host has disabled mod_deflate and mod_gzip, so these options are out. I do have PHP 5 at my disposal, though, so I could use the gzip component of that.</p> <p>I am currently placing the following in my .htaccess file:</p> <blockquote> <p>php_value output_handler ob_gzhandler</p> </blockquote> <p>However, this only compresses the HTML and leaves out the CSS and JS.</p> <p>Is there a reliable way of transparently compressing the output of the CSS and JS without having to change every page? I have searched Google and a number of solutions are presented, but I've yet to get one to work. If anyone could suggest a solution that they know to work, that would be very gratefully received.</p> <p>Note, <strong>Method 2</strong> in <strong><a href="http://www.fiftyfoureleven.com/weblog/web-development/css/the-definitive-css-gzip-method" rel="noreferrer">The Definitive Post on Gzipping your CSS</a></strong> looks like a good solution, but I couldn't get it working. Has anyone else succeeded using this method?</p>
[ { "answer_id": 48583, "author": "macbirdie", "author_id": 5049, "author_profile": "https://Stackoverflow.com/users/5049", "pm_score": 1, "selected": false, "text": "$_SERVER['QUERY_STRING'] mod_rewrite .htaccess XSS" }, { "answer_id": 48592, "author": "Sören Kuklau", "author_id": 1600, "author_profile": "https://Stackoverflow.com/users/1600", "pm_score": 2, "selected": false, "text": "js css <Directory /data/www/path/to/some/site/js/>\n AddHandler application/x-httpd-php .js\n php_value auto_prepend_file gzip-js.php\n php_flag zlib.output_compression On\n</Directory>\n<Directory /data/www/path/to/some/site/css/>\n AddHandler application/x-httpd-php .css\n php_value auto_prepend_file gzip-css.php\n php_flag zlib.output_compression On\n</Directory>\n js <?php\n header(\"Content-type: text/javascript; charset: UTF-8\");\n?>\n css <?php\n header(\"Content-type: text/css; charset: UTF-8\");\n?>\n" }, { "answer_id": 48761, "author": "pilif", "author_id": 5083, "author_profile": "https://Stackoverflow.com/users/5083", "pm_score": 1, "selected": false, "text": "$p = 'path/to/css/file'\n$i = stat($p);\nif ($_SERVER['HTTP_IF_MODIFIED_SINCE']){\n $imd = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);\n if ( ($imd > 0) && ($imd >= $i['mtime'])){\n header('HTTP/1.0 304 Not Modified');\n header('Expires:');\n header('Cache-Control:');\n header('Last-Modified: '.date('r', $i['mtime']));\n exit;\n }\n}\nheader('Last-Modified: '.date('r', $i['mtime']));\nheader('Content-Type: text/css');\nheader('Content-Length: '.filesize($p));\nheader('Cache-Control:');\nheader('Pragma:');\nheader('Expires:');\nreadfile($p);\n" }, { "answer_id": 55092, "author": "macbirdie", "author_id": 5049, "author_profile": "https://Stackoverflow.com/users/5049", "pm_score": 3, "selected": false, "text": ".htaccess compress.php static RewriteEngine on\nRewriteRule ^static/.+\\.(js|ico|gif|jpg|jpeg|png|css|swf)$ compress.php [NC]\n mod_rewrite .htaccess <?php\n\n$basedir = realpath( dirname($_SERVER['SCRIPT_FILENAME']) );\n$file = realpath( $basedir . $_SERVER[\"REQUEST_URI\"] );\n\nif( !file_exists($file) && strpos($file, $basedir) === 0 ) {\n header(\"HTTP/1.0 404 Not Found\");\n print \"File does not exist.\";\n exit();\n}\n\n$components = split('\\.', basename($file));\n$extension = strtolower( array_pop($components) );\n\nswitch($extension)\n{\n case 'css':\n $mime = \"text/css\";\n break;\n default:\n $mime = \"text/plain\";\n}\n\nheader( \"Content-Type: \" . $mime );\nreadfile($file);\n fileinfo $basedir = realpath( dirname($_SERVER['SCRIPT_FILENAME']) );\n$file = realpath( $basedir . $_SERVER[\"REQUEST_URI\"] );\n" }, { "answer_id": 1937300, "author": "Paul D. Waite", "author_id": 20578, "author_profile": "https://Stackoverflow.com/users/20578", "pm_score": 1, "selected": false, "text": "gzip -c styles.css > styles-gzip.css\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48555", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1944/" ]
48,562
<p>I was wondering if anyone here had some experience writing this type of script and if they could give me some pointers.</p> <p>I would like to modify this <a href="http://wordaligned.org/articles/a-subversion-pre-commit-hook" rel="nofollow noreferrer">script</a> to validate that the check-in file does not have a Carriage Return in the EOL formatting. The EOL format is CR LF in Windows and LF in Unix. When a User checks-in code with the Windows format. It does not compile in Unix anymore. I know this can be done on the client side but I need to have this validation done on the server side. To achieve this, I need to do the following:</p> <p>1) Make sure the file I check is not a binary, I dont know how to do this with svnlook, should I check the mime:type of the file? The <a href="http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html" rel="nofollow noreferrer">Red Book</a> does not indicate this clearly or I must have not seen it.</p> <p>2) I would like to run the <a href="http://linux.about.com/od/commands/l/blcmdl1_dos2uni.htm" rel="nofollow noreferrer">dos2unix</a> command to validate that the file has the correct EOL format. I would compare the output of the dos2unix command against the original file. If there is a diff between both, I give an error message to the client and cancel the check-in.</p> <p>I would like your comments/feedback on this approach.</p>
[ { "answer_id": 50507, "author": "Stephen Johnson", "author_id": 5063, "author_profile": "https://Stackoverflow.com/users/5063", "pm_score": 3, "selected": true, "text": "svn:eol-style" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5060/" ]
48,567
<p>I wrote a simple Windows Forms program in C#. I want to be able to input a windows user name and password and when I click a login button to run code run as the user I've entered as input.</p>
[ { "answer_id": 48571, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 3, "selected": true, "text": "// This sample demonstrates the use of the WindowsIdentity class to impersonate a user.\n// IMPORTANT NOTES:\n// This sample can be run only on Windows XP. The default Windows 2000 security policy\n// prevents this sample from executing properly, and changing the policy to allow\n// proper execution presents a security risk.\n// This sample requests the user to enter a password on the console screen.\n// Because the console window does not support methods allowing the password to be masked,\n// it will be visible to anyone viewing the screen.\n// The sample is intended to be executed in a .NET Framework 1.1 environment. To execute\n// this code in a 1.0 environment you will need to use a duplicate token in the call to the\n// WindowsIdentity constructor. See KB article Q319615 for more information.\n\nusing System;\nusing System.Runtime.InteropServices;\nusing System.Security.Principal;\nusing System.Security.Permissions;\nusing System.Windows.Forms;\n\n[assembly:SecurityPermissionAttribute(SecurityAction.RequestMinimum, UnmanagedCode=true)]\n[assembly:PermissionSetAttribute(SecurityAction.RequestMinimum, Name = \"FullTrust\")]\npublic class ImpersonationDemo\n{\n [DllImport(\"advapi32.dll\", SetLastError=true, CharSet = CharSet.Unicode)]\n public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,\n int dwLogonType, int dwLogonProvider, ref IntPtr phToken);\n\n [DllImport(\"kernel32.dll\", CharSet=System.Runtime.InteropServices.CharSet.Auto)]\n private unsafe static extern int FormatMessage(int dwFlags, ref IntPtr lpSource,\n int dwMessageId, int dwLanguageId, ref String lpBuffer, int nSize, IntPtr *Arguments);\n\n [DllImport(\"kernel32.dll\", CharSet=CharSet.Auto)]\n public extern static bool CloseHandle(IntPtr handle);\n\n [DllImport(\"advapi32.dll\", CharSet=CharSet.Auto, SetLastError=true)]\n public extern static bool DuplicateToken(IntPtr ExistingTokenHandle,\n int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);\n\n // Test harness.\n // If you incorporate this code into a DLL, be sure to demand FullTrust.\n [PermissionSetAttribute(SecurityAction.Demand, Name = \"FullTrust\")]\n public static void Main(string[] args)\n {\n IntPtr tokenHandle = new IntPtr(0);\n IntPtr dupeTokenHandle = new IntPtr(0);\n try\n {\n string userName, domainName;\n // Get the user token for the specified user, domain, and password using the\n // unmanaged LogonUser method.\n // The local machine name can be used for the domain name to impersonate a user on this machine.\n Console.Write(\"Enter the name of the domain on which to log on: \");\n domainName = Console.ReadLine();\n\n Console.Write(\"Enter the login of a user on {0} that you wish to impersonate: \", domainName);\n userName = Console.ReadLine();\n\n Console.Write(\"Enter the password for {0}: \", userName);\n\n const int LOGON32_PROVIDER_DEFAULT = 0;\n //This parameter causes LogonUser to create a primary token.\n const int LOGON32_LOGON_INTERACTIVE = 2;\n\n tokenHandle = IntPtr.Zero;\n\n // Call LogonUser to obtain a handle to an access token.\n bool returnValue = LogonUser(userName, domainName, Console.ReadLine(),\n LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,\n ref tokenHandle);\n\n Console.WriteLine(\"LogonUser called.\");\n\n if (false == returnValue)\n {\n int ret = Marshal.GetLastWin32Error();\n Console.WriteLine(\"LogonUser failed with error code : {0}\", ret);\n throw new System.ComponentModel.Win32Exception(ret);\n }\n\n Console.WriteLine(\"Did LogonUser Succeed? \" + (returnValue? \"Yes\" : \"No\"));\n Console.WriteLine(\"Value of Windows NT token: \" + tokenHandle);\n\n // Check the identity.\n Console.WriteLine(\"Before impersonation: \"\n + WindowsIdentity.GetCurrent().Name);\n // Use the token handle returned by LogonUser.\n WindowsIdentity newId = new WindowsIdentity(tokenHandle);\n WindowsImpersonationContext impersonatedUser = newId.Impersonate();\n\n // Check the identity.\n Console.WriteLine(\"After impersonation: \"\n + WindowsIdentity.GetCurrent().Name);\n\n // Stop impersonating the user.\n impersonatedUser.Undo();\n\n // Check the identity.\n Console.WriteLine(\"After Undo: \" + WindowsIdentity.GetCurrent().Name);\n\n // Free the tokens.\n if (tokenHandle != IntPtr.Zero)\n CloseHandle(tokenHandle);\n\n }\n catch(Exception ex)\n {\n Console.WriteLine(\"Exception occurred. \" + ex.Message);\n }\n\n }\n}\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48567", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1360/" ]
48,570
<p>I would like to implement something similar to a c# delegate method in PHP. A quick word to explain what I'm trying to do overall: I am trying to implement some asynchronous functionality. Basically, some resource-intensive calls that get queued, cached and dispatched when the underlying system gets around to it. When the asynchronous call finally receives a response I would like a callback event to be raised.</p> <p>I am having some problems coming up with a mechanism to do callbacks in PHP. I have come up with a method that works for now but I am unhappy with it. Basically, it involves passing a reference to the object and the name of the method on it that will serve as the callback (taking the response as an argument) and then use eval to call the method when need be. This is sub-optimal for a variety of reasons, is there a better way of doing this that anyone knows of? </p>
[ { "answer_id": 48585, "author": "Nick Stinemates", "author_id": 4960, "author_profile": "https://Stackoverflow.com/users/4960", "pm_score": 2, "selected": false, "text": "// This function uses a callback function. \nfunction doIt($callback) \n{ \n $data = \"this is my data\";\n $callback($data); \n} \n\n\n// This is a sample callback function for doIt(). \nfunction myCallback($data) \n{ \n print 'Data is: ' . $data . \"\\n\"; \n} \n\n\n// Call doIt() and pass our sample callback function's name. \ndoIt('myCallback'); \n" }, { "answer_id": 48591, "author": "VolkerK", "author_id": 4833, "author_profile": "https://Stackoverflow.com/users/4833", "pm_score": 5, "selected": true, "text": "call_user_func() call_user_func_array() array(obj, methodname) $obj->methodname() <?php\nclass Foo {\n public function bar($x) {\n echo $x;\n }\n}\n\nfunction xyz($cb) {\n $value = rand(1,100);\n call_user_func($cb, $value);\n}\n\n$foo = new Foo;\nxyz( array($foo, 'bar') );\n?>\n" }, { "answer_id": 3158886, "author": "Benjamin", "author_id": 381220, "author_profile": "https://Stackoverflow.com/users/381220", "pm_score": 2, "selected": false, "text": "interface Callback \n{\n public function __invoke(); \n}\n\nclass MyCallback implements Callback\n{\n private function sayHello () { echo \"Hello\"; }\n public function __invoke () { $this->sayHello(); } \n}\n\nclass MySecondCallback implements Callback\n{\n private function sayThere () { echo \"World\"; }\n public function __invoke () { $this->sayThere(); }\n}\n\nclass WhatToPrint\n{\n protected $callbacks = array();\n public function register (Callback $callback) \n {\n $this->callbacks[] = $callback;\n return $this;\n }\n public function saySomething ()\n {\n foreach ($this->callbacks as $callback) $callback(); \n }\n}\n\n$first_callback = new MyCallback;\n$second_callback = new MySecondCallback;\n$wrapper = new WhatToPrint;\n$wrapper->register($first_callback)->register($second_callback)->saySomething();\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5056/" ]
48,578
<p>Not entirely sure what's going on here; any help would be appreciated.</p> <p>I'm trying to create a new .NET MVC web app. I was pretty sure I had it set up correctly, but I'm getting the following error:</p> <pre><code>The type 'System.Web.Mvc.ViewPage' is ambiguous: it could come from assembly 'C:\MyProject\bin\System.Web.Mvc.DLL' or from assembly 'C:\MyProject\bin\MyProject.DLL'. Please specify the assembly explicitly in the type name. </code></pre> <p>The source error it reports is as follows:</p> <pre><code>Line 1: &lt;%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %&gt; Line 2: Line 3: &lt;asp:Content ID="indexContent" ContentPlaceHolderID="MainContentPlaceHolder" runat="server"&gt; </code></pre> <p>Anything stand out that I'm doing completely wrong?</p>
[ { "answer_id": 48589, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 1, "selected": false, "text": " Inherits=\"System.Web.Mvc.ViewPage\"\n" }, { "answer_id": 48594, "author": "Dale Ragan", "author_id": 1117, "author_profile": "https://Stackoverflow.com/users/1117", "pm_score": 2, "selected": false, "text": "<%@ Page Language=\"C#\" MasterPageFile=\"~/Views/Shared/Site.Master\" AutoEventWireup=\"true\" CodeBehind=\"Index.aspx.cs\" Inherits=\"MvcApplication4.Views.Home.Index\" %>\n" }, { "answer_id": 48597, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 2, "selected": false, "text": "Inherits=\"System.Web.Mvc.ViewPage\"\n Inherits=\"MySite.Views.Pages.Home\"\n" }, { "answer_id": 13310425, "author": "Paul", "author_id": 1423534, "author_profile": "https://Stackoverflow.com/users/1423534", "pm_score": 2, "selected": false, "text": "System.Web.Mvc web.config 2.0.0.0 3.0.0.0" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1540/" ]
48,605
<p>Almost every Java book I read talks about using the interface as a way to share state and behaviour between objects that when first "constructed" did not seem to share a relationship. </p> <p>However, whenever I see architects design an application, the first thing they do is start programming to an interface. How come? How do you know all the relationships between objects that will occur within that interface? If you already know those relationships, then why not just extend an abstract class?</p>
[ { "answer_id": 48611, "author": "Brian Warshaw", "author_id": 1344, "author_profile": "https://Stackoverflow.com/users/1344", "pm_score": 6, "selected": true, "text": "IPoweredByMotor start() MotorizedWheelChair Automobile SmoothieMaker start()" }, { "answer_id": 48624, "author": "Eugene Yokota", "author_id": 3827, "author_profile": "https://Stackoverflow.com/users/3827", "pm_score": 2, "selected": false, "text": "OldButton WinButton OSXButton" }, { "answer_id": 470193, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "interface IRepository<T> { T Get(string key); }\n\nclass TaxRateRepository : IRepository<TaxRate> {\n protected internal TaxRateRepository() {}\n public TaxRate Get(string key) {\n // retrieve an TaxRate (obj) from database\n return obj; }\n}\n public static class RepositoryFactory {\n\n public RepositoryFactory() {\n TaxRateRepository = new TaxRateRepository(); }\n\n public static IRepository TaxRateRepository { get; protected set; }\n public static void SetTaxRateRepository(IRepository rep) {\n TaxRateRepository = rep; }\n}\n class TaxRate {\n public string Region { get; protected set; }\n decimal Rate { get; protected set; }\n}\n\nstatic class Business {\n static decimal GetRate(string region) { \n var taxRate = RepositoryFactory.TaxRateRepository.Get(region);\n return taxRate.Rate; }\n}\n class MockTaxRateRepository : IRepository<TaxRate> {\n public TaxRate ReturnValue { get; set; }\n public bool GetWasCalled { get; protected set; }\n public string KeyParamValue { get; protected set; }\n public TaxRate Get(string key) {\n GetWasCalled = true;\n KeyParamValue = key;\n return ReturnValue; }\n}\n class MyUnitTestFixture { \n var rep = new MockTaxRateRepository();\n\n [FixtureSetup]\n void ConfigureFixture() {\n RepositoryFactory.SetTaxRateRepository(rep); }\n\n [Test]\n void Test() {\n var region = \"NY.NY.Manhattan\";\n var rate = 8.5m;\n rep.ReturnValue = new TaxRate { Rate = rate };\n\n var r = Business.GetRate(region);\n Assert.IsNotNull(r);\n Assert.IsTrue(rep.GetWasCalled);\n Assert.AreEqual(region, rep.KeyParamValue);\n Assert.AreEqual(r.Rate, rate); }\n}\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
48,616
<p>How do I set a property of a user control in <code>ListView</code>'s <code>LayoutTemplate</code> from the code-behind?</p> <pre><code>&lt;asp:ListView ...&gt; &lt;LayoutTemplate&gt; &lt;myprefix:MyControl id="myControl" ... /&gt; &lt;/LayoutTemplate&gt; ... &lt;/asp:ListView&gt; </code></pre> <p>I want to do this:</p> <pre><code>myControl.SomeProperty = somevalue; </code></pre> <p>Please notice that my control is not in <code>ItemTemplate</code>, it is in <code>LayoutTemplate</code>, so it does not exist for all items, it exists only once. So I should be able to access it once, not for every data bound item.</p>
[ { "answer_id": 48636, "author": "chakrit", "author_id": 3055, "author_profile": "https://Stackoverflow.com/users/3055", "pm_score": 1, "selected": false, "text": "var control = (MyControl)Item.FindControl(\"yourControlId\");\n" }, { "answer_id": 1315742, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 5, "selected": true, "text": "var control = (MyControl)myListView.FindControl(\"myControlId\");\n" }, { "answer_id": 3926198, "author": "Ben Rabidou", "author_id": 469285, "author_profile": "https://Stackoverflow.com/users/469285", "pm_score": 4, "selected": false, "text": "var control = (MyControl)myListView.FindControl(\"myControlId\");\n" }, { "answer_id": 52902606, "author": "Jeff", "author_id": 3128942, "author_profile": "https://Stackoverflow.com/users/3128942", "pm_score": 0, "selected": false, "text": "Dim control = CType(myListView.FindControl(\"myControlId\"), MyControl)\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31505/" ]
48,642
<p>I want to write a command that specifies "the word under the cursor" in VIM. For instance, let's say I have the cursor on a word and I make it appear twice. For instance, if the word is "abc" and I want "abcabc" then I could type: </p> <pre><code>:s/\(abc\)/\1\1/ </code></pre> <p>But then I'd like to be able to move the cursor to "def" and use the same command to change it to "defdef": </p> <pre><code>:s/\(def\)/\1\1/ </code></pre> <p>How can I write the command in the commandline so that it does this?</p> <pre><code>:s/\(*whatever is under the commandline*\)/\1\1 </code></pre>
[ { "answer_id": 48657, "author": "hazzen", "author_id": 5066, "author_profile": "https://Stackoverflow.com/users/5066", "pm_score": 7, "selected": true, "text": "<cword> <cword> b #go to beginning of current word\nyw #yank to register\n <control-r>0<enter> :nmap <leader>w :s/\\(<c-r>=expand(\"<cword>\")<cr>\\)/\n :s/\\(<currentword>\\)/\n" }, { "answer_id": 76316, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": ":nmap <leader>w :s/\\\\(<c-r>=expand(\"<cword>\")<cr>\\\\)/\\\\1\\\\1<cr>\n" }, { "answer_id": 80683, "author": "bmb", "author_id": 5298, "author_profile": "https://Stackoverflow.com/users/5298", "pm_score": 1, "selected": false, "text": "ywPx\n ywPxw\n" }, { "answer_id": 82120, "author": "user11211", "author_id": 11211, "author_profile": "https://Stackoverflow.com/users/11211", "pm_score": 5, "selected": false, "text": "yiwP\n yiw P < ALT > - D :nmap < ALT >-D yiwP\n" }, { "answer_id": 82158, "author": "rampion", "author_id": 9859, "author_profile": "https://Stackoverflow.com/users/9859", "pm_score": 4, "selected": false, "text": "* *:s//\\0\\0<Enter>\n * :s// \\0 *@:\n @: q qd*:s//\\0\\0<Enter>q\n @d\n @:" }, { "answer_id": 628865, "author": "César Alforde", "author_id": 75950, "author_profile": "https://Stackoverflow.com/users/75950", "pm_score": 7, "selected": false, "text": "c_CTRL-R :help c_CTRL-R\n" }, { "answer_id": 869112, "author": "SergioAraujo", "author_id": 2571881, "author_profile": "https://Stackoverflow.com/users/2571881", "pm_score": -1, "selected": false, "text": "\" count word (case sensitive)\nnmap <F4> :%s/\\(<c-r>=expand(\"<cword>\")<cr>\\)//gn<cr>\n" }, { "answer_id": 27369655, "author": "BBW Before Windows", "author_id": 3186686, "author_profile": "https://Stackoverflow.com/users/3186686", "pm_score": 0, "selected": false, "text": "yiwP\n yiwPea\n yiw\n yaw\n yawPea\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1084/" ]
48,647
<p>I came across <a href="http://www.ddj.com/cpp/184403758" rel="noreferrer">this article</a> written by Andrei Alexandrescu and Petru Marginean many years ago, which presents and discusses a utility class called ScopeGuard for writing exception-safe code. I'd like to know if coding with these objects truly leads to better code or if it obfuscates error handling, in that perhaps the guard's callback would be better presented in a catch block? Does anyone have any experience using these in actual production code?</p>
[ { "answer_id": 48663, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 7, "selected": true, "text": "catch catch ScopeGuard" }, { "answer_id": 48786, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 2, "selected": false, "text": "DATA_BLOB blobIn, blobOut;\nblobIn.pbData=const_cast<BYTE*>(data);\nblobIn.cbData=length;\n\nCryptUnprotectData(&blobIn, NULL, NULL, NULL, NULL, CRYPTPROTECT_UI_FORBIDDEN, &blobOut);\nGuard guardBlob=guardFn(::LocalFree, blobOut.pbData);\n// do stuff with blobOut.pbData\n" }, { "answer_id": 550945, "author": "j_random_hacker", "author_id": 47984, "author_profile": "https://Stackoverflow.com/users/47984", "pm_score": 5, "selected": false, "text": "CloseHandle() BeginPaint() EndPaint() new" }, { "answer_id": 34716931, "author": "j_kubik", "author_id": 455304, "author_profile": "https://Stackoverflow.com/users/455304", "pm_score": 2, "selected": false, "text": "ScopeGuard ScopeGuard ScopeGuard" }, { "answer_id": 40168672, "author": "timepp", "author_id": 2608744, "author_profile": "https://Stackoverflow.com/users/2608744", "pm_score": 2, "selected": false, "text": "void somefunction() {\n writeln(\"function enter\");\n // c++ has similar constructs but not in syntax level\n scope(exit) writeln(\"function exit\");\n\n // do what ever you do, you never miss the function exit output\n}\n" }, { "answer_id": 64824020, "author": "Grim Fandango", "author_id": 383689, "author_profile": "https://Stackoverflow.com/users/383689", "pm_score": -1, "selected": false, "text": "scoped_guard scoped_guard fclose fopen sorting QListViewItems class scoped_width {\n int m_old_width;\npublic:\n scoped_width(int w) {\n m_old_width = getGLwidth();\n setGLwidth(w);\n }\n ~scoped_width() {\n setGLwidth(m_old_width);\n }\n};\n\nvoid DrawTriangle(Tria *t)\n{\n // GLwidth=1 here\n\n auto guard = scoped_width(2); // sets GLwidth=2\n\n draw_line(t->a, t->b);\n draw_line(t->b, t->c);\n draw_line(t->c, t->a);\n\n setGLwidth(5);\n\n draw_point(t->a);\n draw_point(t->b);\n draw_point(t->c);\n\n} // scoped_width sets GLwidth back to 1 here\n scoped_width scoped_guard scoped_guard [] void DrawTriangle(Tria *t)\n{\n // GLwidth=1 here\n\n auto guard = sg::make_scoped_guard([w=getGLwidth()](){ setGLwidth(w); }); // capture current GLwidth in order to set it back\n setGLwidth(2); // sets GLwidth=2\n\n draw_line(t->a, t->b);\n draw_line(t->b, t->c);\n draw_line(t->c, t->a);\n\n setGLwidth(5);\n\n draw_point(t->a);\n draw_point(t->b);\n draw_point(t->c);\n\n} // scoped_guard sets GLwidth back to 1 here\n scoped_guard void DrawTriangle(Tria *t)\n{\n // GLwidth=1 here\n\n int previous_width = getGLwidth(); // explicitly capture current width \n auto guard = sg::make_scoped_guard([=](){ setGLwidth(previous_width); }); // pass it to lambda in order to set it back\n setGLwidth(2); // sets GLwidth=2\n\n draw_line(t->a, t->b);\n draw_line(t->b, t->c);\n draw_line(t->c, t->a);\n\n setGLwidth(5);\n\n draw_point(t->a);\n draw_point(t->b);\n draw_point(t->c);\n\n} // scoped_guard sets GLwidth back to 1 here\n scoped_guard previous_width guard RAII class guard void some_function() {\n sg::scoped_guard([](){ cout << \"this is printed last\"; }\n\n cout << \"this is printed first\";\n}\n scoped_guard scoped_guard scoped_guard" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4928/" ]
48,668
<p>I've seen lots of descriptions how anonymous types work, but I'm not sure how they're really useful. What are some scenarios that anonymous types can be used to address in a well-designed program?</p>
[ { "answer_id": 48677, "author": "George Mauer", "author_id": 5056, "author_profile": "https://Stackoverflow.com/users/5056", "pm_score": 3, "selected": false, "text": "var pl = new List<Object>();\nforeach(var p in Process.GetProcesses())\n pl.Add(new {p.Id, p.ProcessName, Memory=p.WorkingSet64});\nObjectDumper.Write(pl);\n" }, { "answer_id": 48705, "author": "Omer van Kloeten", "author_id": 4979, "author_profile": "https://Stackoverflow.com/users/4979", "pm_score": 5, "selected": true, "text": "var query = from item in database.Items\n // ...\n select new { Id = item.Id, Name = item.Name };\n\nreturn query.ToDictionary(item => item.Id, item => item.Name);\n" }, { "answer_id": 168109, "author": "Mark Cidade", "author_id": 1659, "author_profile": "https://Stackoverflow.com/users/1659", "pm_score": 2, "selected": false, "text": "from x in db.Table1 select new {x.Column1, Alias2=x.Column2}\n SELECT Column1, Column2 AS Alias2 FROM Table1\n" }, { "answer_id": 168135, "author": "ChaosSpeeder", "author_id": 205962, "author_profile": "https://Stackoverflow.com/users/205962", "pm_score": 0, "selected": false, "text": "var query = from item in database.Items\n// ...\nselect new Person(item.id, item.Name)\n" }, { "answer_id": 887762, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "var query = from item in database.Items\nselect new Person\n{\nID =item.id,\nNAME= item.Name\n};\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
48,669
<p>I receive HTML pages from our creative team, and then use those to build aspx pages. One challenge I frequently face is getting the HTML I spit out to match theirs exactly. I almost always end up screwing up the nesting of <code>&lt;div&gt;</code>s between my page and the master pages.</p> <p>Does anyone know of a tool that will help in this situation -- something that will compare 2 pages and output the structural differences? I can't use a standard diff tool, because IDs change from what I receive from creative, text replaces <i>lorem ipsum</i>, etc.. </p>
[ { "answer_id": 49348, "author": "Peter Hilton", "author_id": 2670, "author_profile": "https://Stackoverflow.com/users/2670", "pm_score": 3, "selected": false, "text": "tidy -asxml index.html\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2757/" ]
48,679
<p>Anybody know of a way to copy a file from path A to path B and suppressing the Windows file system cache?<br> Typical use is copying a large file from a USB drive, or server to your local machine. Windows seems to swap everything out if the file is really big, e.g. 2GiB. Prefer example in C#, but I'm guessing this would be a Win32 call of some sort if possible.</p>
[ { "answer_id": 6198881, "author": "nietras", "author_id": 98692, "author_profile": "https://Stackoverflow.com/users/98692", "pm_score": 3, "selected": false, "text": " public static byte[] ReadAllBytesUnbuffered(string filePath)\n {\n const FileOptions FileFlagNoBuffering = (FileOptions)0x20000000;\n var fileInfo = new FileInfo(filePath);\n long fileLength = fileInfo.Length;\n int bufferSize = (int)Math.Min(fileLength, int.MaxValue / 2);\n bufferSize += ((bufferSize + 1023) & ~1023) - bufferSize;\n using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.None,\n bufferSize, FileFlagNoBuffering | FileOptions.SequentialScan))\n {\n long length = stream.Length;\n if (length > 0x7fffffffL)\n {\n throw new IOException(\"File too long over 2GB\");\n }\n int offset = 0;\n int count = (int)length;\n var buffer = new byte[count];\n while (count > 0)\n {\n int bytesRead = stream.Read(buffer, offset, count);\n if (bytesRead == 0)\n {\n throw new EndOfStreamException(\"Read beyond end of file EOF\");\n }\n offset += bytesRead;\n count -= bytesRead;\n }\n return buffer;\n }\n }\n" }, { "answer_id": 58746922, "author": "Petros Matsakos", "author_id": 4793294, "author_profile": "https://Stackoverflow.com/users/4793294", "pm_score": 0, "selected": false, "text": "/J :: copy using unbuffered I/O (recommended for large files)" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48679", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5080/" ]
48,680
<p>Say I have a <code>Textbox</code> nested within a <code>TabControl</code>. </p> <p>When the form loads, I would like to focus on that <code>Textbox</code> (by default the focus is set to the <code>TabControl</code>).</p> <p>Simply calling <code>textbox1.focus()</code> in the <code>Load</code> event of the form does not appear to work. </p> <p>I have been able to focus it by doing the following:</p> <pre><code> private void frmMainLoad(object sender, EventArgs e) { foreach (TabPage tab in this.tabControl1.TabPages) { this.tabControl1.SelectedTab = tab; } } </code></pre> <p><strong>My question is:</strong></p> <p>Is there a more elegant way to do this?</p>
[ { "answer_id": 48719, "author": "samjudson", "author_id": 1908, "author_profile": "https://Stackoverflow.com/users/1908", "pm_score": 7, "selected": true, "text": "private void frmMainLoad(object sender, EventArgs e)\n{\n ActiveControl = textBox1;\n}\n" }, { "answer_id": 634852, "author": "Korby", "author_id": 76687, "author_profile": "https://Stackoverflow.com/users/76687", "pm_score": 4, "selected": false, "text": "Form_Shown()" }, { "answer_id": 986845, "author": "bdwakefield", "author_id": 55053, "author_profile": "https://Stackoverflow.com/users/55053", "pm_score": 1, "selected": false, "text": "private void ShowControlTab(Control ControlToShow)\n {\n if (!TabSelected)\n {\n if (ControlToShow.Parent != null)\n {\n if (ControlToShow.Parent.GetType() == typeof(TabPage))\n {\n TabPage Tab = (TabPage)ControlToShow.Parent;\n if (WOTabs.TabPages.Contains(Tab))\n {\n WOTabs.SelectedTab = Tab;\n TabSelected = true;\n return;\n }\n }\n\n ShowControlTab(ControlToShow.Parent);\n }\n }\n }\n" }, { "answer_id": 2355348, "author": "Mikhail G", "author_id": 283508, "author_profile": "https://Stackoverflow.com/users/283508", "pm_score": 2, "selected": false, "text": "textbox1.Select() textbox1.Focus()" }, { "answer_id": 23888913, "author": "osama9988", "author_id": 3511799, "author_profile": "https://Stackoverflow.com/users/3511799", "pm_score": 0, "selected": false, "text": " private void ChildForm1_Load(object sender, EventArgs e)\n {\n ActiveControl = txt_fname;\n\n }\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1736/" ]
48,744
<h2>How do you find the phone numbers in 50,000 HTML pages?<br><br></h2> <blockquote> <h3>Jeff Attwood posted 5 Questions for programmers applying for jobs:</h3> <p>In an effort to make life simpler for phone screeners, I've put together this list of Five Essential Questions that you need to ask during an SDE screen. They won't guarantee that your candidate will be great, but they will help eliminate a huge number of candidates who are slipping through our process today.</p> <p><strong>1) Coding</strong> The candidate has to write some simple code, with correct syntax, in C, C++, or Java.</p> <p><strong>2) OO design</strong> The candidate has to define basic OO concepts, and come up with classes to model a simple problem.</p> <p><strong>3) Scripting and regexes</strong> The candidate has to describe how to find the phone numbers in 50,000 HTML pages.</p> <p><strong>4) Data structures</strong> The candidate has to demonstrate basic knowledge of the most common data structures.</p> <p><strong>5) Bits and bytes</strong> The candidate has to answer simple questions about bits, bytes, and binary numbers.</p> <p>Please understand: what I'm looking for here is a total vacuum in one of these areas. It's OK if they struggle a little and then figure it out. It's OK if they need some minor hints or prompting. I don't mind if they're rusty or slow. What you're looking for is candidates who are utterly clueless, or horribly confused, about the area in question.</p> <p><strong><a href="http://www.codinghorror.com/blog/archives/001042.html" rel="noreferrer">>>> The Entirety of Jeff´s Original Post &lt;&lt;&lt;</a></strong></p> </blockquote> <p><br> <strong>Note:</strong> Steve Yegge originally posed the Question.</p>
[ { "answer_id": 48767, "author": "Ande Turner", "author_id": 4857, "author_profile": "https://Stackoverflow.com/users/4857", "pm_score": 1, "selected": false, "text": "#!/usr/bin/perl\nwhile (<*.html>) {\n my $filename = $_;\n my @data = <$filename>;\n\n # Loop once through with simple search\n while (@data) {\n if (/\\(?(\\d\\d\\d)\\)?[ -]?(\\d\\d\\d)-?(\\d\\d\\d\\d)/) {\n push( @files, $filename );\n next;\n }\n }\n\n # None found, strip html\n $text = \"\";\n $text .= $_ while (@data);\n $text =~ s#<[^>]+>##gxs;\n\n # Strip line breaks\n $text =~ s#\\n|\\r##gxs;\n\n # Check for occurrence.\n if ( $text =~ /\\(?(\\d\\d\\d)\\)?[ -]?(\\d\\d\\d)-?(\\d\\d\\d\\d)/ ) {\n push( @files, $filename );\n next;\n }\n}\n\n# Print out result\nprint join( '\\n', @files );\n" }, { "answer_id": 48788, "author": "Marcio Aguiar", "author_id": 4213, "author_profile": "https://Stackoverflow.com/users/4213", "pm_score": 2, "selected": false, "text": " final String regex = \"[\\\\s](\\\\({0,1}\\\\d{3}\\\\){0,1}\" +\n \"[- \\\\.]\\\\d{3}[- \\\\.]\\\\d{4})|\" +\n \"(\\\\+\\\\d{2}-\\\\d{2,4}-\\\\d{3,4}-\\\\d{3,4})\";\n final Pattern phonePattern = Pattern.compile(regex);\n \n /* The result set */\n Set<File> files = new HashSet<File>();\n \n File dir = new File(\"/initDirPath\");\n if (!dir.isDirectory()) return;\n \n for (File file : dir.listFiles()) {\n if (file.isDirectory()) continue;\n \n BufferedReader reader = new BufferedReader(new FileReader(file));\n \n String line;\n boolean found = false;\n while ((line = reader.readLine()) != null \n && !found) {\n \n if (found = phonePattern.matcher(line).find()) {\n files.add(file);\n }\n }\n }\n\n for (File file : files) {\n System.out.println(file.getAbsolutePath());\n }\n" }, { "answer_id": 48812, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverflow.com/users/238", "pm_score": 2, "selected": false, "text": "egrep '\\(?\\d{3}\\)?[-\\s.]?\\d{3}[-.]\\d{4}' *.html\n" }, { "answer_id": 48826, "author": "Jeremy", "author_id": 1114, "author_profile": "https://Stackoverflow.com/users/1114", "pm_score": 6, "selected": true, "text": "egrep \"(([0-9]{1,2}.)?[0-9]{3}.[0-9]{3}.[0-9]{4})\" . -R --include='*.html'\n" }, { "answer_id": 48834, "author": "sieben", "author_id": 1147, "author_profile": "https://Stackoverflow.com/users/1147", "pm_score": 1, "selected": false, "text": "private readonly Regex phoneNumExp = new Regex(@\"(\\({0,1}\\d{3}\\){0,1}[- \\.]\\d{3}[- \\.]\\d{4})|(\\+\\d{2}-\\d{2,4}-\\d{3,4}-\\d{3,4})\");\n\npublic HashSet<string> Search(string dir)\n{\n var numbers = new HashSet<string>();\n\n string[] files = Directory.GetFiles(dir, \"*.html\", SearchOption.AllDirectories);\n\n foreach (string file in files)\n {\n using (var sr = new StreamReader(file))\n {\n string line;\n\n while ((line = sr.ReadLine()) != null)\n {\n var match = phoneNumExp.Match(line);\n\n if (match.Success)\n {\n numbers.Add(match.Value);\n }\n }\n }\n }\n\n return numbers;\n}\n" }, { "answer_id": 716989, "author": "em70", "author_id": 87079, "author_profile": "https://Stackoverflow.com/users/87079", "pm_score": 2, "selected": false, "text": "\nopen System\nopen System.IO\nopen System.Text.RegularExpressions\n\nlet rgx = Regex(@\"(\\({0,1}\\d{3}\\){0,1}[- \\.]\\d{3}[- \\.]\\d{4})|(\\+\\d{2}-\\d{2,4}-\\d{3,4}-\\d{3,4})\", RegexOptions.Compiled)\n\nlet processFile contents = contents |> rgx.Matches |> Seq.cast |> Seq.map(fun m -> m.Value)\n\nlet processDirectory path = Directory.GetFiles(path, \"*.html\", SearchOption.AllDirectories) |> Seq.map(File.ReadAllText >> processFile) |> Seq.concat\n" }, { "answer_id": 15592111, "author": "ruralcoder", "author_id": 324308, "author_profile": "https://Stackoverflow.com/users/324308", "pm_score": 2, "selected": false, "text": "\\(?\\d{3}\\)?[-\\s\\.]?\\d{3}[-\\s\\.]?\\d{4}\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4857/" ]
48,772
<p>I have never "hand-coded" object creation code for SQL Server and foreign key decleration is seemingly different between SQL Server and Postgres. Here is my sql so far:</p> <pre><code>drop table exams; drop table question_bank; drop table anwser_bank; create table exams ( exam_id uniqueidentifier primary key, exam_name varchar(50), ); create table question_bank ( question_id uniqueidentifier primary key, question_exam_id uniqueidentifier not null, question_text varchar(1024) not null, question_point_value decimal, constraint question_exam_id foreign key references exams(exam_id) ); create table anwser_bank ( anwser_id uniqueidentifier primary key, anwser_question_id uniqueidentifier, anwser_text varchar(1024), anwser_is_correct bit ); </code></pre> <p>When I run the query I get this error:</p> <blockquote> <p>Msg 8139, Level 16, State 0, Line 9 Number of referencing columns in foreign key differs from number of referenced columns, table 'question_bank'.</p> </blockquote> <p>Can you spot the error?</p>
[ { "answer_id": 48778, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 9, "selected": true, "text": "create table question_bank\n(\n question_id uniqueidentifier primary key,\n question_exam_id uniqueidentifier not null,\n question_text varchar(1024) not null,\n question_point_value decimal,\n constraint fk_questionbank_exams foreign key (question_exam_id) references exams (exam_id)\n);\n" }, { "answer_id": 48838, "author": "Sara Chipps", "author_id": 4140, "author_profile": "https://Stackoverflow.com/users/4140", "pm_score": 6, "selected": false, "text": "CONSTRAINT your_name_here FOREIGN KEY (question_exam_id) REFERENCES EXAMS (exam_id)\n" }, { "answer_id": 48883, "author": "AlexCuse", "author_id": 794, "author_profile": "https://Stackoverflow.com/users/794", "pm_score": 8, "selected": false, "text": "alter table MyTable\nadd constraint MyTable_MyColumn_FK FOREIGN KEY ( MyColumn ) references MyOtherTable(PKColumn)\n" }, { "answer_id": 6297360, "author": "Bijimon", "author_id": 51038, "author_profile": "https://Stackoverflow.com/users/51038", "pm_score": 4, "selected": false, "text": "create table question_bank\n(\n question_id uniqueidentifier primary key,\n question_exam_id uniqueidentifier not null constraint fk_exam_id foreign key references exams(exam_id),\n question_text varchar(1024) not null,\n question_point_value decimal\n);\n" }, { "answer_id": 24415106, "author": "Shavais", "author_id": 283102, "author_profile": "https://Stackoverflow.com/users/283102", "pm_score": 5, "selected": false, "text": "alter table MyTable\nadd constraint MyTable_MyColumn_FK FOREIGN KEY ( MyColumn ) \nreferences MyOtherTable(PKColumn)\n alter table MyTable\nadd constraint MyTable_MyColumn_FK FOREIGN KEY ( MyColumn ) \nreferences MyOtherTable(PKColumn)\non update cascade \non delete cascade\n create table ProductCategories (\n Id int identity primary key,\n ProductId int references Products(Id)\n on update cascade on delete cascade\n CategoryId int references Categories(Id) \n on update cascade on delete cascade\n)\n" }, { "answer_id": 33299702, "author": "Stefan Steiger", "author_id": 155077, "author_profile": "https://Stackoverflow.com/users/155077", "pm_score": 2, "selected": false, "text": "-- First, chech if the table exists...\nIF 0 < (\n SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES \n WHERE TABLE_TYPE = 'BASE TABLE'\n AND TABLE_SCHEMA = 'dbo'\n AND TABLE_NAME = 'T_SYS_Language_Forms'\n)\nBEGIN\n -- Check for NULL values in the primary-key column\n IF 0 = (SELECT COUNT(*) FROM T_SYS_Language_Forms WHERE LANG_UID IS NULL)\n BEGIN\n ALTER TABLE T_SYS_Language_Forms ALTER COLUMN LANG_UID uniqueidentifier NOT NULL \n\n -- No, don't drop, FK references might already exist...\n -- Drop PK if exists \n -- ALTER TABLE T_SYS_Language_Forms DROP CONSTRAINT pk_constraint_name \n --DECLARE @pkDropCommand nvarchar(1000) \n --SET @pkDropCommand = N'ALTER TABLE T_SYS_Language_Forms DROP CONSTRAINT ' + QUOTENAME((SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS \n --WHERE CONSTRAINT_TYPE = 'PRIMARY KEY' \n --AND TABLE_SCHEMA = 'dbo' \n --AND TABLE_NAME = 'T_SYS_Language_Forms' \n ----AND CONSTRAINT_NAME = 'PK_T_SYS_Language_Forms' \n --))\n ---- PRINT @pkDropCommand \n --EXECUTE(@pkDropCommand) \n\n -- Instead do\n -- EXEC sp_rename 'dbo.T_SYS_Language_Forms.PK_T_SYS_Language_Forms1234565', 'PK_T_SYS_Language_Forms';\n\n\n -- Check if they keys are unique (it is very possible they might not be) \n IF 1 >= (SELECT TOP 1 COUNT(*) AS cnt FROM T_SYS_Language_Forms GROUP BY LANG_UID ORDER BY cnt DESC)\n BEGIN\n\n -- If no Primary key for this table\n IF 0 = \n (\n SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS \n WHERE CONSTRAINT_TYPE = 'PRIMARY KEY' \n AND TABLE_SCHEMA = 'dbo' \n AND TABLE_NAME = 'T_SYS_Language_Forms' \n -- AND CONSTRAINT_NAME = 'PK_T_SYS_Language_Forms' \n )\n ALTER TABLE T_SYS_Language_Forms ADD CONSTRAINT PK_T_SYS_Language_Forms PRIMARY KEY CLUSTERED (LANG_UID ASC)\n ;\n\n -- Adding foreign key\n IF 0 = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME = 'FK_T_ZO_SYS_Language_Forms_T_SYS_Language_Forms') \n ALTER TABLE T_ZO_SYS_Language_Forms WITH NOCHECK ADD CONSTRAINT FK_T_ZO_SYS_Language_Forms_T_SYS_Language_Forms FOREIGN KEY(ZOLANG_LANG_UID) REFERENCES T_SYS_Language_Forms(LANG_UID); \n END -- End uniqueness check\n ELSE\n PRINT 'FSCK, this column has duplicate keys, and can thus not be changed to primary key...' \n END -- End NULL check\n ELSE\n PRINT 'FSCK, need to figure out how to update NULL value(s)...' \nEND \n" }, { "answer_id": 37452116, "author": "Abhishek Jaiswal", "author_id": 5275530, "author_profile": "https://Stackoverflow.com/users/5275530", "pm_score": 3, "selected": false, "text": "ALTER TABLE [SCHEMA].[TABLENAME] ADD FOREIGN KEY (COLUMNNAME) REFERENCES [TABLENAME](COLUMNNAME)\nEXAMPLE\nALTER TABLE [dbo].[UserMaster] ADD FOREIGN KEY (City_Id) REFERENCES [dbo].[CityMaster](City_Id)\n" }, { "answer_id": 44222324, "author": "elkhayari abderrazzak", "author_id": 7840801, "author_profile": "https://Stackoverflow.com/users/7840801", "pm_score": 3, "selected": false, "text": "create table exams\n( \n exam_id int primary key,\n exam_name varchar(50),\n);\n\ncreate table question_bank \n(\n question_id int primary key,\n question_exam_id int not null,\n question_text varchar(1024) not null,\n question_point_value decimal,\n constraint question_exam_id_fk\n foreign key references exams(exam_id)\n ON DELETE CASCADE\n);\n" }, { "answer_id": 45422537, "author": "Md Ashikul Islam", "author_id": 7801470, "author_profile": "https://Stackoverflow.com/users/7801470", "pm_score": 3, "selected": false, "text": "Alter table Foreign_Key_Table_name add constraint \nForeign_Key_Table_name_Columnname_FK\nForeign Key (Column_name) references \nAnother_Table_name(Another_Table_Column_name)\n" }, { "answer_id": 57623016, "author": "Aamir Shaikh", "author_id": 6043224, "author_profile": "https://Stackoverflow.com/users/6043224", "pm_score": 2, "selected": false, "text": "Alter Table ForeignKeyTable\nAdd constraint `ForeignKeyTable_ForeignKeyColumn_FK`\n`Foreign key (ForeignKeyColumn)` references `PrimaryKeyTable (PrimaryKeyColumn)`\n Alter Table tblEmployee\nAdd constraint tblEmployee_DepartmentID_FK\nforeign key (DepartmentID) references tblDepartment (ID)\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1638/" ]
48,773
<p>I've created a custom exception for a very specific problem that can go wrong. I receive data from another system, and I raise the exception if it bombs while trying to parse that data. In my custom exception, I added a field called "ResponseData", so I can track exactly what my code couldn't handle.</p> <p>In custom exceptions such as this one, should that extra response data go into the exception "message"? If it goes there, the message could be huge. I kind of want it there because I'm using Elmah, and that's how I can get at that data.</p> <p>So the question is either: - How can I get Elmah to record extra information from a field in a custom exception OR - Should extra exception details go into the "message" property?</p>
[ { "answer_id": 48792, "author": "Sören Kuklau", "author_id": 1600, "author_profile": "https://Stackoverflow.com/users/1600", "pm_score": 4, "selected": true, "text": ".Message Exception Exception" }, { "answer_id": 155606, "author": "Atif Aziz", "author_id": 6682, "author_profile": "https://Stackoverflow.com/users/6682", "pm_score": 4, "selected": false, "text": "ToString public override String ToString()\n{\n String s = GetType().FullName + \": \" + Message;\n\n if (_fileName != null && _fileName.Length != 0)\n s += Environment.NewLine + String.Format(Environment.GetResourceString(\"IO.FileName_Name\"), _fileName);\n\n if (InnerException != null)\n s = s + \" ---> \" + InnerException.ToString();\n\n if (StackTrace != null)\n s += Environment.NewLine + StackTrace;\n\n try\n {\n if(FusionLog!=null)\n {\n if (s==null)\n s=\" \";\n s+=Environment.NewLine;\n s+=Environment.NewLine;\n s+=\"Fusion log follows: \";\n s+=Environment.NewLine;\n s+=FusionLog;\n }\n }\n catch(SecurityException)\n {\n\n }\n return s;\n}\n ToString ToString" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
48,774
<p>What's the "right" way to do the following as a boolean expression?</p> <pre><code>for i in `ls $1/resources`; do if [ $i != "database.db" ] then if [ $i != "tiles" ] then if [ $i != "map.pdf" ] then if [ $i != "map.png" ] then svn export -q $1/resources/$i ../MyProject/Resources/$i ... </code></pre>
[ { "answer_id": 48787, "author": "frizz", "author_id": 1003, "author_profile": "https://Stackoverflow.com/users/1003", "pm_score": 1, "selected": false, "text": "for i in `ls $1/resources`; do\n if [ $i != \"database.db\" ] && [ $i != \"tiles\" ] && [ $i != \"map.pdf\" ] && [ $i != \"map.png\" ]; then\n svn export -q $1/resources/$i ../MyProject/Resources/$i\n" }, { "answer_id": 48793, "author": "Mo.", "author_id": 1870, "author_profile": "https://Stackoverflow.com/users/1870", "pm_score": 3, "selected": false, "text": "for i in `ls $1/resources`; do\n if [ $i != databse.db -a $i != titles -a $i != map.pdf ]; then\n svn export -q $1/resources/$i ../MyProject/Resources/$i\n fi\ndone;\n -a man test" }, { "answer_id": 64106, "author": "pixelbeat", "author_id": 4421, "author_profile": "https://Stackoverflow.com/users/4421", "pm_score": 5, "selected": true, "text": "for i in $(ls ...) for i in $1/resources*; do ... [ $i != file1 -a $1 != file2 ] $i -a stat stat for i in $1/resources/*; do\n if [ \"$i\" != \"database.db\" ] &&\n [ \"$i\" != \"tiles\" ] &&\n [ \"$i\" != \"map.pdf\" ] &&\n [ \"$i\" != \"map.png\" ]; then\n svn export -q \"$i\" \"../MyProject/Resources/$(basename $i)\"\n fi\ndone\n" }, { "answer_id": 64247, "author": "Fred Yankowski", "author_id": 7887, "author_profile": "https://Stackoverflow.com/users/7887", "pm_score": 2, "selected": false, "text": "for i in $(ls $1/resources); do\n case $i in\n database.db|tiles|map.pdf|map.png)\n ;;\n *)\n svn export -q $1/resources/$i ../MyProject/Resources/$i;;\n esac\ndone\n" }, { "answer_id": 31630150, "author": "Evan Langlois", "author_id": 3847182, "author_profile": "https://Stackoverflow.com/users/3847182", "pm_score": 1, "selected": false, "text": "for i in $1/resources/*; do\n if [[ $i != \"database.db\" && $i != \"tiles\" &&\n $i != \"map.pdf\" && $i != \"map.png\" ]]; then\n svn export -q \"$i\" \"../MyProject/Resources/$(basename $i)\"\n fi\ndone\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79/" ]
48,794
<p>Here is a scenario: Let's say I have site with two controllers responsible for displaying different type of content - Pages and Articles. I need to embed Partial View into my masterpage that will list pages and articles filtered with some criteria, and be displayed on each page. I cannot set Model on my masterpage (am I right?). How do I solve this task using Html.RenderPartial?</p> <p>[EDIT] Yes, I'd probably create separate partial views for listing articles and pages, but still, there is a barrier that I cannot and shouldn't set model on masterpage. I need somehow to say "here are the pages" as an argument to my renderpartial, and also for articles. Entire concept of renderpartial with data from database in masterpages is a bit blurry to me.</p>
[ { "answer_id": 919625, "author": "user113588", "author_id": 113588, "author_profile": "https://Stackoverflow.com/users/113588", "pm_score": 2, "selected": false, "text": " public static void RenderPartialAction<TController>(this HtmlHelper helper, Func<TController, PartialViewResult> actionToRender)\n where TController : Controller, new()\n{\n var arg = new TController {ControllerContext = helper.ViewContext.Controller.ControllerContext};\n actionToRender(arg).ExecuteResult(arg.ControllerContext);\n} \n <% Html.RenderPartialAction((HomeController x) => x.RenderPartial()) %>\n public PartialViewResult RenderPartial()\n{\n\n return PartialView(\"~/Path/or/View\",_homeService.GetModel())\n}\n" }, { "answer_id": 1727633, "author": "Jeremy", "author_id": 52168, "author_profile": "https://Stackoverflow.com/users/52168", "pm_score": 0, "selected": false, "text": "public class BaseViewModel\n{\n public BaseViewModel()\n {\n NavigationItems = RetrieveNavigationItemsFromModel();\n }\n public List<NavItems> NavigationItems {get; set;}\n}\n <ul>\n<% foreach (NavItem ni in (Model as BaseViewModel).NavigationItems) { %>\n <li>\n <a href=\"<%= ni.Url %>\" alt=\"<%= ni.Alt%>\"><%= ni.DisplayText %></a>\n </li>\n<% } %>\n</ul>\n" }, { "answer_id": 2026869, "author": "Ciddan", "author_id": 68891, "author_profile": "https://Stackoverflow.com/users/68891", "pm_score": 0, "selected": false, "text": "<asp:Content ID=\"indexContent\" ContentPlaceHolderID=\"MainContent\" runat=\"server\">\n\n <script type=\"text/javascript\">\n $(document).ready(function() {\n $(\"#applicationForm\").load(\"/Home/ApplicationForm\");\n });\n </script>\n\n <div id=\"applicationForm\" />\n\n</asp:Content>\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/481/" ]
48,805
<p>Some e-Marketing tools claim to choose which web page to display based on where you were before. That is, if you've been browsing truck sites and then go to Ford.com, your first page would be of the Ford Explorer.</p> <p>I know you can get the immediate preceding page with HTTP_REFERRER, but how do you know where they were 6 sites ago? </p>
[ { "answer_id": 5494272, "author": "heymatthew", "author_id": 81271, "author_profile": "https://Stackoverflow.com/users/81271", "pm_score": 3, "selected": false, "text": "document.referrer" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48805", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2757/" ]
48,872
<p>In <a href="https://web.archive.org/web/20141127115939/https://blogs.msmvps.com/kathleen/2008/09/05/in-praise-of-nested-classes/" rel="noreferrer">Kathleen Dollard's 2008 blog post</a>, she presents an interesting reason to use nested classes in .net. However, she also mentions that FxCop doesn't like nested classes. I'm assuming that the people writing FxCop rules aren't stupid, so there must be reasoning behind that position, but I haven't been able to find it.</p>
[ { "answer_id": 48879, "author": "hazzen", "author_id": 5066, "author_profile": "https://Stackoverflow.com/users/5066", "pm_score": 8, "selected": true, "text": "public class SortedMap {\n private class TreeNode {\n TreeNode left;\n TreeNode right;\n }\n}\n public get/set" }, { "answer_id": 1084589, "author": "kay.one", "author_id": 98970, "author_profile": "https://Stackoverflow.com/users/98970", "pm_score": 3, "selected": false, "text": "public sealed class Singleton\n{\n Singleton()\n {\n }\n\n public static Singleton Instance\n {\n get\n {\n return Nested.instance;\n }\n }\n \n class Nested\n {\n // Explicit static constructor to tell C# compiler\n // not to mark type as beforefieldinit\n static Nested()\n {\n }\n\n internal static readonly Singleton instance = new Singleton();\n }\n}\n" }, { "answer_id": 16093091, "author": "nawfal", "author_id": 661933, "author_profile": "https://Stackoverflow.com/users/661933", "pm_score": 1, "selected": false, "text": "abstract public class BankAccount\n{\n private BankAccount() { }\n // Now no one else can extend BankAccount because a derived class\n // must be able to call a constructor, but all the constructors are\n // private!\n private sealed class ChequingAccount : BankAccount { ... }\n public static BankAccount MakeChequingAccount() { return new ChequingAccount(); }\n private sealed class SavingsAccount : BankAccount { ... }\n}\n Equality<Person>.CreateComparer(p => p.Id);\n new EqualityComparer<Person, int>(p => p.Id);\n Equality<Person> EqualityComparer<Person, int> var l = new List<Equality<Person>> \n { \n Equality<Person>.CreateComparer(p => p.Id),\n Equality<Person>.CreateComparer(p => p.Name) \n }\n var l = new List<EqualityComparer<Person, ??>>> \n { \n new EqualityComparer<Person, int>>(p => p.Id),\n new EqualityComparer<Person, string>>(p => p.Name) \n }\n public class Outer \n{\n class Inner //private class\n {\n public int Field; //public field\n }\n\n static inner = new Inner { Field = -1 }; // Field is accessible here, but in no other class\n}\n" }, { "answer_id": 18579666, "author": "supercat", "author_id": 363751, "author_profile": "https://Stackoverflow.com/users/363751", "pm_score": 1, "selected": false, "text": "Action<string, int, double> String<string, int> double Action<string, int, double> Action<string> 7 int 5.3 double MakeDelegate<string,int>.WithParams<double>(theDelegate, 3.5);\nMakeDelegate<string>.WithParams<int,double>(theDelegate, 7, 5.3);\n MakeDelegate<string,int>.WithParams(theDelegate, 3.5);\nMakeDelegate<string>.WithParams(theDelegate, 7, 5.3);\n" }, { "answer_id": 27575449, "author": "Eric Dand", "author_id": 1159805, "author_profile": "https://Stackoverflow.com/users/1159805", "pm_score": 0, "selected": false, "text": "public class MyClass\n{\n void DoStuff()\n {\n if (!someArbitraryCondition)\n {\n // This is the only class from which OhNoException is thrown\n throw new OhNoException(\n \"Oh no! Some arbitrary condition was not satisfied!\");\n }\n // Do other stuff\n }\n\n public class OhNoException : Exception\n {\n // Constructors calling base()\n }\n}\n" }, { "answer_id": 28959647, "author": "tm1", "author_id": 806690, "author_profile": "https://Stackoverflow.com/users/806690", "pm_score": 0, "selected": false, "text": "InternalsVisibleTo" }, { "answer_id": 29379421, "author": "Tyree Jackson", "author_id": 1072184, "author_profile": "https://Stackoverflow.com/users/1072184", "pm_score": 3, "selected": false, "text": "public class BaseDataObject\n <\n tDataObject, \n tDataObjectList, \n tBusiness, \n tDataAccess\n >\n where tDataObject : BaseDataObject<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n where tDataObjectList : BaseDataObjectList<tDataObject, tDataObjectList, tBusiness, tDataAccess>, new()\n where tBusiness : IBaseBusiness<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n where tDataAccess : IBaseDataAccess<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n{\n}\n\npublic class BaseDataObjectList\n <\n tDataObject, \n tDataObjectList, \n tBusiness, \n tDataAccess\n >\n: \n CollectionBase<tDataObject>\n where tDataObject : BaseDataObject<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n where tDataObjectList : BaseDataObjectList<tDataObject, tDataObjectList, tBusiness, tDataAccess>, new()\n where tBusiness : IBaseBusiness<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n where tDataAccess : IBaseDataAccess<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n{\n}\n\npublic interface IBaseBusiness\n <\n tDataObject, \n tDataObjectList, \n tBusiness, \n tDataAccess\n >\n where tDataObject : BaseDataObject<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n where tDataObjectList : BaseDataObjectList<tDataObject, tDataObjectList, tBusiness, tDataAccess>, new()\n where tBusiness : IBaseBusiness<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n where tDataAccess : IBaseDataAccess<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n{\n}\n\npublic interface IBaseDataAccess\n <\n tDataObject, \n tDataObjectList, \n tBusiness, \n tDataAccess\n >\n where tDataObject : BaseDataObject<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n where tDataObjectList : BaseDataObjectList<tDataObject, tDataObjectList, tBusiness, tDataAccess>, new()\n where tBusiness : IBaseBusiness<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n where tDataAccess : IBaseDataAccess<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n{\n}\n public\npartial class Entity\n <\n tDataObject, \n tDataObjectList, \n tBusiness, \n tDataAccess\n >\n where tDataObject : Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>.BaseDataObject\n where tDataObjectList : Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>.BaseDataObjectList, new()\n where tBusiness : Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>.IBaseBusiness\n where tDataAccess : Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>.IBaseDataAccess\n{\n\n public class BaseDataObject {}\n\n public class BaseDataObjectList : CollectionBase<tDataObject> {}\n\n public interface IBaseBusiness {}\n\n public interface IBaseDataAccess {}\n\n}\n public\npartial class Entity\n <\n tDataObject, \n tDataObjectList, \n tBusiness, \n tDataAccess\n >\n where tDataObject : Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>.BaseDataObject\n where tDataObjectList : Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>.BaseDataObjectList, new()\n where tBusiness : Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>.IBaseBusiness\n where tDataAccess : Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>.IBaseDataAccess\n{\n}\n partial class Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n{\n\n public class BaseDataObject\n {\n\n public DataTimeOffset CreatedDateTime { get; set; }\n public Guid CreatedById { get; set; }\n public Guid Id { get; set; }\n public DataTimeOffset LastUpdateDateTime { get; set; }\n public Guid LastUpdatedById { get; set; }\n\n public\n static\n implicit operator tDataObjectList(DataObject dataObject)\n {\n var returnList = new tDataObjectList();\n returnList.Add((tDataObject) this);\n return returnList;\n }\n\n }\n\n}\n partial class Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n{\n\n public class BaseDataObjectList : CollectionBase<tDataObject>\n {\n\n public tDataObjectList ShallowClone() \n {\n var returnList = new tDataObjectList();\n returnList.AddRange(this);\n return returnList;\n }\n\n }\n\n}\n partial class Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n{\n\n public interface IBaseBusiness\n {\n tDataObjectList Load();\n void Delete();\n void Save(tDataObjectList data);\n }\n\n}\n partial class Entity<tDataObject, tDataObjectList, tBusiness, tDataAccess>\n{\n\n public interface IBaseDataAccess\n {\n tDataObjectList Load();\n void Delete();\n void Save(tDataObjectList data);\n }\n\n}\n Entity.cs\n+ Entity.BaseDataObject.cs\n+ Entity.BaseDataObjectList.cs\n+ Entity.IBaseBusiness.cs\n+ Entity.IBaseDataAccess.cs\n public\npartial class User\n:\n Entity\n <\n User.DataObject, \n User.DataObjectList, \n User.IBusiness, \n User.IDataAccess\n >\n{\n}\n partial class User\n{\n\n public class DataObject : BaseDataObject \n {\n public string UserName { get; set; }\n public byte[] PasswordHash { get; set; }\n public bool AccountIsEnabled { get; set; }\n }\n\n}\n partial class User\n{\n\n public class DataObjectList : BaseDataObjectList {}\n\n}\n partial class User\n{\n\n public interface IBusiness : IBaseBusiness {}\n\n}\n partial class User\n{\n\n public interface IDataAccess : IBaseDataAccess {}\n\n}\n User.cs\n+ User.DataObject.cs\n+ User.DataObjectList.cs\n+ User.IBusiness.cs\n+ User.IDataAccess.cs\n" }, { "answer_id": 50997412, "author": "Alex Martinez", "author_id": 4698151, "author_profile": "https://Stackoverflow.com/users/4698151", "pm_score": 0, "selected": false, "text": "class Join_Operator\n{\n\n class Departamento\n {\n public int idDepto { get; set; }\n public string nombreDepto { get; set; }\n }\n\n class Empleado\n {\n public int idDepto { get; set; }\n public string nombreEmpleado { get; set; }\n }\n\n public void JoinTables()\n {\n List<Departamento> departamentos = new List<Departamento>();\n departamentos.Add(new Departamento { idDepto = 1, nombreDepto = \"Arquitectura\" });\n departamentos.Add(new Departamento { idDepto = 2, nombreDepto = \"Programación\" });\n\n List<Empleado> empleados = new List<Empleado>();\n empleados.Add(new Empleado { idDepto = 1, nombreEmpleado = \"John Doe.\" });\n empleados.Add(new Empleado { idDepto = 2, nombreEmpleado = \"Jim Bell\" });\n\n var joinList = (from e in empleados\n join d in departamentos on\n e.idDepto equals d.idDepto\n select new\n {\n nombreEmpleado = e.nombreEmpleado,\n nombreDepto = d.nombreDepto\n });\n foreach (var dato in joinList)\n {\n Console.WriteLine(\"{0} es empleado del departamento de {1}\", dato.nombreEmpleado, dato.nombreDepto);\n }\n }\n}\n" }, { "answer_id": 63224333, "author": "Hamid", "author_id": 9523274, "author_profile": "https://Stackoverflow.com/users/9523274", "pm_score": 0, "selected": false, "text": " class Order\n {\n private List<OrderItem> _orderItems = new List<OrderItem>();\n\n public void AddOrderItem(OrderItem line)\n {\n _orderItems.Add(line);\n }\n\n public double OrderTotal()\n {\n double total = 0;\n foreach (OrderItem item in _orderItems)\n {\n total += item.TotalPrice();\n }\n\n return total;\n }\n\n // Nested class\n public class OrderItem\n {\n public int ProductId { get; set; }\n public int Quantity { get; set; }\n public double Price { get; set; }\n public double TotalPrice() => Price * Quantity;\n }\n }\n\n class Program\n {\n\n static void Main(string[] args)\n {\n Order order = new Order();\n\n Order.OrderItem orderItem1 = new Order.OrderItem();\n orderItem1.ProductId = 1;\n orderItem1.Quantity = 5;\n orderItem1.Price = 1.99;\n order.AddOrderItem(orderItem1);\n\n Order.OrderItem orderItem2 = new Order.OrderItem();\n orderItem2.ProductId = 2;\n orderItem2.Quantity = 12;\n orderItem2.Price = 0.35;\n order.AddOrderItem(orderItem2);\n\n Console.WriteLine(order.OrderTotal());\n ReadLine();\n }\n\n\n }\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/100/" ]
48,884
<p>What Python libraries do folks use for querying Amazon product data? (Amazon Associates Web Service - used to be called E-Commerce API, or something along those lines).</p> <p>Based on my research, <a href="http://pyaws.sourceforge.net/" rel="noreferrer">PyAWS</a> seems okay, but still pretty raw (and hasn't been updated in a while). Wondering if there's an obvious canonical library that I'm just missing.</p>
[ { "answer_id": 4251893, "author": "tobych", "author_id": 76452, "author_profile": "https://Stackoverflow.com/users/76452", "pm_score": 5, "selected": false, "text": "ACCESS_KEY_ID = \"...\"\nSECRET_KEY = \"...\"\nASSOC_TAG = \"...\"\n\nimport bottlenose\namazon = bottlenose.Amazon(ACCESS_KEY_ID, SECRET_KEY, ASSOC_TAG)\nresponse=amazon.ItemLookup(ItemId=\"B0018AFK38\", ResponseGroup=\"OfferSummary\")\n\nfrom lxml import objectify\nroot = objectify.fromstring(response)\nroot.Items.Item.OfferSummary.LowestNewPrice.FormattedPrice\n" } ]
2008/09/07
[ "https://Stackoverflow.com/questions/48884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2678/" ]
48,908
<p>I am a bit confused about socket programming in C.</p> <p>You create a socket, bind it to an interface and an IP address and get it to listen. I found a couple of web resources on that, and understood it fine. In particular, I found an article <s><a href="http://users.actcom.co.il/~choo/lupg/tutorials/internetworking/internet-theory.html" rel="nofollow noreferrer">Network programming under Unix systems</a></s> to be very informative.</p> <p>What confuses me is the timing of data arriving on the socket.</p> <p>How can you tell when packets arrive, and how big the packet is, do you have to do all the heavy lifting yourself? </p> <p>My basic assumption here is that packets can be of variable length, so once binary data starts appearing down the socket, how do you begin to construct packets from that?</p>
[ { "answer_id": 48929, "author": "dfjacobs", "author_id": 4848, "author_profile": "https://Stackoverflow.com/users/4848", "pm_score": 5, "selected": true, "text": "/* buffer points to memory block that is bigger than the number of bytes to be read */\n/* socket is open socket that is connected to a sender */\n/* bytesToRead is the number of bytes expected from the sender */\n/* bytesRead is a pointer to a integer variable that will hold the number of bytes */\n/* actually received from the sender. */\n/* The function returns either the number of bytes read, */\n/* 0 if the socket was closed by the sender, and */\n/* -1 if an error occurred while reading from the socket */\nint readBytes(int socket, char *buffer, int bytesToRead, int *bytesRead)\n{\n *bytesRead = 0;\n while(*bytesRead < bytesToRead)\n {\n int ret = read(socket, buffer + *bytesRead, bytesToRead - *bytesRead);\n if(ret <= 0)\n {\n /* either connection was closed or an error occurred */\n return ret;\n }\n else\n {\n *bytesRead += ret;\n }\n }\n return *bytesRead;\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/277/" ]
48,916
<p>I want a splash screen to show while the application is loading. I have a form with a system tray control tied to it. I want the splash screen to display while this form loads, which takes a bit of time since it's accessing a web service API to populate some drop-downs. I also want to do some basic testing for dependencies before loading (that is, the web service is available, the configuration file is readable). As each phase of the startup goes, I want to update the splash screen with progress.</p> <p>I have been reading a lot on threading, but I am getting lost on where this should be controlled from (the <code>main()</code> method?). I am also missing how <code>Application.Run()</code> works, is this where the threads for this should be created from? Now, if the form with the system tray control is the "living" form, should the splash come from there? Wouldn't it not load until the form is completed anyway?</p> <p>I'm not looking for a code handout, more of an algorithm/approach so I can figure this out once and for all :) </p>
[ { "answer_id": 48944, "author": "McKenzieG1", "author_id": 3776, "author_profile": "https://Stackoverflow.com/users/3776", "pm_score": 3, "selected": false, "text": "<STAThread()> Public Shared Sub Main()\n\n splash = New frmSplash\n splash.Show()\n\n ' Your startup code goes here...\n\n UpdateSplashAndLogMessage(\"Startup part 1 done...\")\n\n ' ... and more as needed...\n\n splash.Hide()\n Application.Run(myMainForm)\nEnd Sub\n" }, { "answer_id": 48946, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 6, "selected": false, "text": "private void Form1_Load(object sender, EventArgs e)\n{\n Hide();\n bool done = false;\n ThreadPool.QueueUserWorkItem((x) =>\n {\n using (var splashForm = new SplashForm())\n {\n splashForm.Show();\n while (!done)\n Application.DoEvents();\n splashForm.Close();\n }\n });\n\n Thread.Sleep(3000); // Emulate hardwork\n done = true;\n Show();\n}\n" }, { "answer_id": 48971, "author": "Guy Starbuck", "author_id": 2194, "author_profile": "https://Stackoverflow.com/users/2194", "pm_score": 7, "selected": true, "text": "Microsoft.VisualBasic Microsoft.VisualBasic Microsoft.VisualBasic.WindowsFormsApplicationBase protected override void OnCreateSplashScreen()\n{\n this.SplashScreen = new SplashForm();\n this.SplashScreen.TopMost = true;\n}\n VisualBasic.WindowsFormsApplicationBase bytecode" }, { "answer_id": 2117094, "author": "DelftRed", "author_id": 256697, "author_profile": "https://Stackoverflow.com/users/256697", "pm_score": 3, "selected": false, "text": "Activate(); Show();" }, { "answer_id": 3296362, "author": "Jay", "author_id": 114994, "author_profile": "https://Stackoverflow.com/users/114994", "pm_score": 3, "selected": false, "text": "<Application Startup=\"ApplicationStart\" …\n void ApplicationStart(object sender, StartupEventArgs e)\n{\n var thread = new Thread(() =>\n {\n Dispatcher.CurrentDispatcher.BeginInvoke ((Action)(() => new MySplashForm().Show()));\n Dispatcher.Run();\n });\n thread.SetApartmentState(ApartmentState.STA);\n thread.IsBackground = true;\n thread.Start();\n\n // call synchronous configuration process\n // and declare/get reference to \"main form\"\n\n thread.Abort();\n\n mainForm.Show();\n mainForm.Activate();\n }\n" }, { "answer_id": 4994912, "author": "Adam Nofsinger", "author_id": 18524, "author_profile": "https://Stackoverflow.com/users/18524", "pm_score": 4, "selected": false, "text": "public partial class FormSplash : Form\n{\n private static Thread _splashThread;\n private static FormSplash _splashForm;\n\n public FormSplash() {\n InitializeComponent();\n }\n\n /// <summary>\n /// Show the Splash Screen (Loading...)\n /// </summary>\n public static void ShowSplash()\n {\n if (_splashThread == null)\n {\n // show the form in a new thread\n _splashThread = new Thread(new ThreadStart(DoShowSplash));\n _splashThread.IsBackground = true;\n _splashThread.Start();\n }\n }\n\n // called by the thread\n private static void DoShowSplash()\n {\n if (_splashForm == null)\n _splashForm = new FormSplash();\n\n // create a new message pump on this thread (started from ShowSplash)\n Application.Run(_splashForm);\n }\n\n /// <summary>\n /// Close the splash (Loading...) screen\n /// </summary>\n public static void CloseSplash()\n {\n // need to call on the thread that launched this splash\n if (_splashForm.InvokeRequired)\n _splashForm.Invoke(new MethodInvoker(CloseSplash));\n\n else\n Application.ExitThread();\n }\n}\n static class Program\n{\n /// <summary>\n /// The main entry point for the application.\n /// </summary>\n [STAThread]\n static void Main(string[] args)\n {\n // splash screen, which is terminated in FormMain\n FormSplash.ShowSplash();\n\n Application.EnableVisualStyles();\n Application.SetCompatibleTextRenderingDefault(false);\n // this is probably where your heavy lifting is:\n Application.Run(new FormMain());\n }\n}\n ...\n\n public FormMain()\n {\n InitializeComponent(); \n\n // bunch of database access, form loading, etc\n // this is where you could do the heavy lifting of \"loading\" the app\n PullDataFromDatabase();\n DoLoadingWork(); \n\n // ready to go, now close the splash\n FormSplash.CloseSplash();\n }\n Microsoft.VisualBasic" }, { "answer_id": 6744070, "author": "Reabetswe Molefe", "author_id": 851539, "author_profile": "https://Stackoverflow.com/users/851539", "pm_score": 2, "selected": false, "text": "private void MainForm_Load(object sender, EventArgs e)\n{\n FormSplash splash = new FormSplash();\n splash.Show();\n splash.Update();\n System.Threading.Thread.Sleep(3000);\n splash.Hide();\n}\n" }, { "answer_id": 8234046, "author": "Patratacus", "author_id": 179037, "author_profile": "https://Stackoverflow.com/users/179037", "pm_score": 2, "selected": false, "text": "formSplash FormBorderStyle = None TopMost = True StartPosition=CenterScreen TrasparencyKey private void formMain_Load(object sender, EventArgs e)\n {\n\n Hide();\n bool done = false;\n ThreadPool.QueueUserWorkItem(delegate\n {\n using (formSplash splashForm = new formSplash())\n {\n splashForm.Show();\n while (!done)\n Application.DoEvents();\n splashForm.Close();\n }\n }, null);\n\n Thread.Sleep(2000);\n done = true;\n Show();\n }\n" }, { "answer_id": 18376592, "author": "Colonel Panic", "author_id": 284795, "author_profile": "https://Stackoverflow.com/users/284795", "pm_score": 2, "selected": false, "text": "WindowsFormsApplicationBase WindowsFormsApplicationBase MinimumSplashScreenDisplayTime class App : WindowsFormsApplicationBase\n{\n protected override void OnCreateSplashScreen()\n {\n this.MinimumSplashScreenDisplayTime = 3000; // milliseconds\n this.SplashScreen = new Splash();\n }\n\n protected override void OnCreateMainForm()\n {\n this.MainForm = new Form1();\n }\n}\n public Form1()\n{\n InitializeComponent();\n Shown += Form1_Shown;\n Thread.Sleep(TimeSpan.FromSeconds(1));\n}\n\nvoid Form1_Shown(object sender, EventArgs e)\n{\n Thread.Sleep(TimeSpan.FromSeconds(2));\n Program.watch.Stop();\n this.textBox1.Text = Program.watch.ElapsedMilliseconds.ToString();\n}\n WindowsFormsApplicationBase" }, { "answer_id": 46033441, "author": "Do-do-new", "author_id": 3535036, "author_profile": "https://Stackoverflow.com/users/3535036", "pm_score": 0, "selected": false, "text": "private void SomethingChanged(object sender, MyEventArgs e)\n{\n formSplash.Update(e);\n Application.DoEvents(); //this will update any animation\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4246/" ]
48,919
<p>What is the JavaScript to scroll to the top when a button/link/etc. is clicked?</p>
[ { "answer_id": 48925, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 4, "selected": true, "text": "<a href=\"javascript:scroll(0, 0)\">Top</a>\n" }, { "answer_id": 48939, "author": "Rob Rolnick", "author_id": 4798, "author_profile": "https://Stackoverflow.com/users/4798", "pm_score": 2, "selected": false, "text": "<a name=\"top\"></a>\n<a href='#top\">top</a>\n" }, { "answer_id": 68626, "author": "scunliffe", "author_id": 6144, "author_profile": "https://Stackoverflow.com/users/6144", "pm_score": 0, "selected": false, "text": "<a href=\"#top\">top</a>\n <a href=\"/\">reload</a>\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469/" ]
48,931
<p>I used jQuery to set hover callbacks for elements on my page. I'm now writing a module which needs to temporarily set new hover behaviour for some elements. The new module has no access to the original code for the hover functions.</p> <p>I want to store the old hover functions before I set new ones so I can restore them when finished with the temporary hover behaviour.</p> <p>I think these can be stored using the <code>jQuery.data()</code> function:</p> <pre><code>//save old hover behavior (somehow) $('#foo').data('oldhoverin',???) $('#foo').data('oldhoverout',???); //set new hover behavior $('#foo').hover(newhoverin,newhoverout); </code></pre> <p>Do stuff with new hover behaviour...</p> <pre><code>//restore old hover behaviour $('#foo').hover($('#foo').data('oldhoverin'),$('#foo').data('oldhoverout')); </code></pre> <p>But how do I get the currently registered hover functions from jQuery?</p> <p>Shadow2531, I am trying to do this without modifying the code which originally registered the callbacks. Your suggestion would work fine otherwise. Thanks for the suggestion, and for helping clarify what I'm searching for. Maybe I have to go into the source of jquery and figure out how these callbacks are stored internally. Maybe I should change the question to "Is it possible to do this without modifying jquery?"</p>
[ { "answer_id": 49126, "author": "Shadow2531", "author_id": 1697, "author_profile": "https://Stackoverflow.com/users/1697", "pm_score": 1, "selected": false, "text": "\n<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <title>Jquery - Get, change and restore hover handlers</title>\n <script src=\"jquery.js\"></script>\n <script>\n function setHover(obj, mouseenter, mouseleave) {\n obj.data(\"_mouseenter\", mouseenter);\n obj.data(\"_mouseleave\", mouseleave);\n obj.hover(obj.data(\"_mouseenter\"), obj.data(\"_mouseleave\"));\n }\n function removeHover(obj) {\n obj.unbind(\"mouseenter\", obj.data(\"_mouseenter\"));\n obj.unbind(\"mouseleave\", obj.data(\"_mouseleave\"));\n obj.data(\"_mouseenter\", undefined);\n obj.data(\"_mouseleave\", undefined);\n }\n $(document).ready(function() {\n var test = $(\"#test\");\n setHover(test, function(e) {\n alert(\"original \" + e.type);\n }, function(e) {\n alert(\"original \" + e.type);\n });\n var saved_mouseenter = test.data(\"_mouseenter\");\n var saved_mouseleave = test.data(\"_mouseleave\");\n removeHover(test);\n setHover(test, function() {\n alert(\"zip\");\n }, function() {\n alert('zam');\n });\n removeHover(test);\n setHover(test, saved_mouseenter, saved_mouseleave);\n });\n </script>\n </head>\n <body>\n <p><a id=\"test\" href=\"\">test</a></p>\n </body>\n</html>\n" }, { "answer_id": 49434, "author": "samjudson", "author_id": 1908, "author_profile": "https://Stackoverflow.com/users/1908", "pm_score": 3, "selected": true, "text": "bind hover" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48931", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5114/" ]
48,933
<p>Does anybody know of a way to list up the "loaded plugins" in <strong>Vim</strong>? I know I should be keeping track of this kind of stuff myself but it would always be nice to be able to check the current status.</p>
[ { "answer_id": 48952, "author": "Rob Rolnick", "author_id": 4798, "author_profile": "https://Stackoverflow.com/users/4798", "pm_score": 10, "selected": true, "text": "\" where was an option set \n:scriptnames : list all plugins, _vimrcs loaded (super) \n:verbose set history? : reveals value of history and where set \n:function : list functions \n:func SearchCompl : List particular function\n" }, { "answer_id": 6706782, "author": "Mohammed", "author_id": 846425, "author_profile": "https://Stackoverflow.com/users/846425", "pm_score": 6, "selected": false, "text": ":scriptnames :commands :functions" }, { "answer_id": 33961194, "author": "Matt Florence", "author_id": 76289, "author_profile": "https://Stackoverflow.com/users/76289", "pm_score": 5, "selected": false, "text": ":PluginList" }, { "answer_id": 39443529, "author": "akashbw", "author_id": 5123544, "author_profile": "https://Stackoverflow.com/users/5123544", "pm_score": 5, "selected": false, "text": ":set runtimepath?\n" }, { "answer_id": 64393657, "author": "aris", "author_id": 2628879, "author_profile": "https://Stackoverflow.com/users/2628879", "pm_score": 3, "selected": false, "text": ":PlugStatus\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4037/" ]
48,934
<p>I copied some Delphi code from one project to another, and found that it doesn't compile in the new project, though it did in the old one. The code looks something like this:</p> <pre><code>procedure TForm1.CalculateGP(..) const Price : money = 0; begin ... Price := 1.0; ... end; </code></pre> <p>So in the new project, Delphi complains that "left side cannot be assigned to" - understandable! But this code compiles in the old project. So my question is, <strong>why</strong>? Is there a compiler switch to allow consts to be reassigned? How does that even work? I thought consts were replaced by their values at compile time?</p>
[ { "answer_id": 48938, "author": "Ray", "author_id": 233, "author_profile": "https://Stackoverflow.com/users/233", "pm_score": 6, "selected": true, "text": "{$J+} {$WRITEABLECONST ON}" }, { "answer_id": 100061, "author": "PatrickvL", "author_id": 12170, "author_profile": "https://Stackoverflow.com/users/12170", "pm_score": 2, "selected": false, "text": " // Example implementation of the Singleton pattern.\n TSingleton = class(TObject)\n protected\n constructor CreateInstance; virtual;\n class function AccessInstance(Request: Integer): TSingleton;\n public\n constructor Create; virtual;\n destructor Destroy; override;\n class function Instance: TSingleton;\n class procedure ReleaseInstance;\n end;\n\nconstructor TSingleton.Create;\nbegin\n inherited Create;\n\n raise Exception.CreateFmt('Access class %s through Instance only', [ClassName]);\nend;\n\nconstructor TSingleton.CreateInstance;\nbegin\n inherited Create;\n\n // Do whatever you would normally place in Create, here.\nend;\n\ndestructor TSingleton.Destroy;\nbegin\n // Do normal destruction here\n\n if AccessInstance(0) = Self then\n AccessInstance(2);\n\n inherited Destroy;\nend;\n\n{$WRITEABLECONST ON}\nclass function TSingleton.AccessInstance(Request: Integer): TSingleton;\nconst\n FInstance: TSingleton = nil;\nbegin\n case Request of\n 0 : ;\n 1 : if not Assigned(FInstance) then\n FInstance := CreateInstance;\n 2 : FInstance := nil;\n else\n raise Exception.CreateFmt('Illegal request %d in AccessInstance', [Request]);\n end;\n Result := FInstance;\nend;\n{$IFNDEF WRITEABLECONST_ON}\n {$WRITEABLECONST OFF}\n{$ENDIF}\n\nclass function TSingleton.Instance: TSingleton;\nbegin\n Result := AccessInstance(1);\nend;\n\nclass procedure TSingleton.ReleaseInstance;\nbegin\n AccessInstance(0).Free;\nend;\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48934", "https://Stackoverflow.com", "https://Stackoverflow.com/users/369/" ]
48,935
<p>I'm building an application in C# using WPF. How can I bind to some keys?</p> <p>Also, how can I bind to the <a href="http://en.wikipedia.org/wiki/Windows_key" rel="noreferrer">Windows key</a>?</p>
[ { "answer_id": 49102, "author": "Andy", "author_id": 3857, "author_profile": "https://Stackoverflow.com/users/3857", "pm_score": 0, "selected": false, "text": "RegisterHotKey() PresentationSource.FromVisual() WM_HOTKEY" }, { "answer_id": 49171, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 6, "selected": true, "text": "UIElement InputBinding SaveAll CommandBinding Key.LWin Key.RWin public WindowMain()\n{\n InitializeComponent();\n\n // Bind Key\n var ib = new InputBinding(\n MyAppCommands.SaveAll,\n new KeyGesture(Key.S, ModifierKeys.Shift | ModifierKeys.Control));\n this.InputBindings.Add(ib);\n\n // Bind handler\n var cb = new CommandBinding( MyAppCommands.SaveAll);\n cb.Executed += new ExecutedRoutedEventHandler( HandlerThatSavesEverthing );\n\n this.CommandBindings.Add (cb );\n}\n\nprivate void HandlerThatSavesEverthing (object obSender, ExecutedRoutedEventArgs e)\n{\n // Do the Save All thing here.\n}\n" }, { "answer_id": 1960122, "author": "jgraves", "author_id": 204961, "author_profile": "https://Stackoverflow.com/users/204961", "pm_score": 4, "selected": false, "text": "using System;\nusing System.Runtime.InteropServices;\nusing System.Windows.Interop;\nusing System.Windows.Media;\nusing System.Threading;\nusing System.Windows;\nusing System.Windows.Input;\n\nnamespace GlobalKeyboardHook\n{\n public class KeyboardHandler : IDisposable\n {\n\n public const int WM_HOTKEY = 0x0312;\n public const int VIRTUALKEYCODE_FOR_CAPS_LOCK = 0x14;\n\n [DllImport(\"user32.dll\")]\n [return: MarshalAs(UnmanagedType.Bool)]\n public static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);\n\n [DllImport(\"user32.dll\")]\n [return: MarshalAs(UnmanagedType.Bool)]\n public static extern bool UnregisterHotKey(IntPtr hWnd, int id);\n\n private readonly Window _mainWindow;\n WindowInteropHelper _host;\n\n public KeyboardHandler(Window mainWindow)\n {\n _mainWindow = mainWindow;\n _host = new WindowInteropHelper(_mainWindow);\n\n SetupHotKey(_host.Handle);\n ComponentDispatcher.ThreadPreprocessMessage += ComponentDispatcher_ThreadPreprocessMessage;\n }\n\n void ComponentDispatcher_ThreadPreprocessMessage(ref MSG msg, ref bool handled)\n {\n if (msg.message == WM_HOTKEY)\n {\n //Handle hot key kere\n }\n }\n\n private void SetupHotKey(IntPtr handle)\n {\n RegisterHotKey(handle, GetType().GetHashCode(), 0, VIRTUALKEYCODE_FOR_CAPS_LOCK);\n }\n\n public void Dispose()\n {\n UnregisterHotKey(_host.Handle, GetType().GetHashCode());\n }\n }\n}\n" }, { "answer_id": 2643355, "author": "Mattias Wikström", "author_id": 317213, "author_profile": "https://Stackoverflow.com/users/317213", "pm_score": 1, "selected": false, "text": "using System.Windows;\nusing System.Windows.Interop;\n\nnamespace WpfApp\n{\n public partial class MainWindow : Window\n {\n const int WM_KEYUP = 0x0101;\n\n const int VK_RETURN = 0x0D;\n const int VK_LEFT = 0x25; \n \n public MainWindow()\n {\n this.InitializeComponent();\n\n ComponentDispatcher.ThreadPreprocessMessage += \n ComponentDispatcher_ThreadPreprocessMessage;\n }\n\n void ComponentDispatcher_ThreadPreprocessMessage(\n ref MSG msg, ref bool handled)\n {\n if (msg.message == WM_KEYUP)\n {\n if ((int)msg.wParam == VK_RETURN)\n MessageBox.Show(\"RETURN was pressed\");\n \n if ((int)msg.wParam == VK_LEFT)\n MessageBox.Show(\"LEFT was pressed\");\n }\n }\n }\n}\n" }, { "answer_id": 9330358, "author": "Eric Ouellet", "author_id": 452845, "author_profile": "https://Stackoverflow.com/users/452845", "pm_score": 6, "selected": false, "text": "_hotKey = new HotKey(Key.F9, KeyModifier.Shift | KeyModifier.Win, OnHotKeyHandler);\n private void OnHotKeyHandler(HotKey hotKey)\n{\n SystemHelper.SetScreenSaverRunning();\n}\n using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing System.Linq;\nusing System.Net.Mime;\nusing System.Runtime.InteropServices;\nusing System.Text;\nusing System.Windows;\nusing System.Windows.Input;\nusing System.Windows.Interop;\n\nnamespace UnManaged\n{\n public class HotKey : IDisposable\n {\n private static Dictionary<int, HotKey> _dictHotKeyToCalBackProc;\n\n [DllImport(\"user32.dll\")]\n private static extern bool RegisterHotKey(IntPtr hWnd, int id, UInt32 fsModifiers, UInt32 vlc);\n\n [DllImport(\"user32.dll\")]\n private static extern bool UnregisterHotKey(IntPtr hWnd, int id);\n\n public const int WmHotKey = 0x0312;\n\n private bool _disposed = false;\n\n public Key Key { get; private set; }\n public KeyModifier KeyModifiers { get; private set; }\n public Action<HotKey> Action { get; private set; }\n public int Id { get; set; }\n\n // ******************************************************************\n public HotKey(Key k, KeyModifier keyModifiers, Action<HotKey> action, bool register = true)\n {\n Key = k;\n KeyModifiers = keyModifiers;\n Action = action;\n if (register)\n {\n Register();\n }\n }\n\n // ******************************************************************\n public bool Register()\n {\n int virtualKeyCode = KeyInterop.VirtualKeyFromKey(Key);\n Id = virtualKeyCode + ((int)KeyModifiers * 0x10000);\n bool result = RegisterHotKey(IntPtr.Zero, Id, (UInt32)KeyModifiers, (UInt32)virtualKeyCode);\n\n if (_dictHotKeyToCalBackProc == null)\n {\n _dictHotKeyToCalBackProc = new Dictionary<int, HotKey>();\n ComponentDispatcher.ThreadFilterMessage += new ThreadMessageEventHandler(ComponentDispatcherThreadFilterMessage);\n }\n\n _dictHotKeyToCalBackProc.Add(Id, this);\n\n Debug.Print(result.ToString() + \", \" + Id + \", \" + virtualKeyCode);\n return result;\n }\n\n // ******************************************************************\n public void Unregister()\n {\n HotKey hotKey;\n if (_dictHotKeyToCalBackProc.TryGetValue(Id, out hotKey))\n {\n UnregisterHotKey(IntPtr.Zero, Id);\n }\n }\n\n // ******************************************************************\n private static void ComponentDispatcherThreadFilterMessage(ref MSG msg, ref bool handled)\n {\n if (!handled)\n {\n if (msg.message == WmHotKey)\n {\n HotKey hotKey;\n\n if (_dictHotKeyToCalBackProc.TryGetValue((int)msg.wParam, out hotKey))\n {\n if (hotKey.Action != null)\n {\n hotKey.Action.Invoke(hotKey);\n }\n handled = true;\n }\n }\n }\n }\n\n // ******************************************************************\n // Implement IDisposable.\n // Do not make this method virtual.\n // A derived class should not be able to override this method.\n public void Dispose()\n {\n Dispose(true);\n // This object will be cleaned up by the Dispose method.\n // Therefore, you should call GC.SupressFinalize to\n // take this object off the finalization queue\n // and prevent finalization code for this object\n // from executing a second time.\n GC.SuppressFinalize(this);\n }\n\n // ******************************************************************\n // Dispose(bool disposing) executes in two distinct scenarios.\n // If disposing equals true, the method has been called directly\n // or indirectly by a user's code. Managed and unmanaged resources\n // can be _disposed.\n // If disposing equals false, the method has been called by the\n // runtime from inside the finalizer and you should not reference\n // other objects. Only unmanaged resources can be _disposed.\n protected virtual void Dispose(bool disposing)\n {\n // Check to see if Dispose has already been called.\n if (!this._disposed)\n {\n // If disposing equals true, dispose all managed\n // and unmanaged resources.\n if (disposing)\n {\n // Dispose managed resources.\n Unregister();\n }\n\n // Note disposing has been done.\n _disposed = true;\n }\n }\n }\n\n // ******************************************************************\n [Flags]\n public enum KeyModifier\n {\n None = 0x0000,\n Alt = 0x0001,\n Ctrl = 0x0002,\n NoRepeat = 0x4000,\n Shift = 0x0004,\n Win = 0x0008\n }\n\n // ******************************************************************\n}\n" }, { "answer_id": 12676910, "author": "Louis Kottmann", "author_id": 677014, "author_profile": "https://Stackoverflow.com/users/677014", "pm_score": 4, "selected": false, "text": "protected override void OnStartup(StartupEventArgs e)\n{\n EventManager.RegisterClassHandler(typeof(Window), Window.PreviewKeyUpEvent, new KeyEventHandler(OnWindowKeyUp));\n}\n\nprivate void OnWindowKeyUp(object source, KeyEventArgs e))\n{\n //Do whatever you like with e.Key and Keyboard.Modifiers\n}\n" }, { "answer_id": 33797344, "author": "BornToCode", "author_id": 1057791, "author_profile": "https://Stackoverflow.com/users/1057791", "pm_score": 2, "selected": false, "text": "using System;\nusing System.Windows.Forms;\n\nnamespace GlobalHotkeyExampleForm\n{\n public partial class ExampleForm : Form\n {\n [System.Runtime.InteropServices.DllImport(\"user32.dll\")]\n private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);\n [System.Runtime.InteropServices.DllImport(\"user32.dll\")]\n private static extern bool UnregisterHotKey(IntPtr hWnd, int id);\n\n enum KeyModifier\n {\n None = 0,\n Alt = 1,\n Control = 2,\n Shift = 4,\n WinKey = 8\n }\n\n public ExampleForm()\n {\n InitializeComponent();\n\n int id = 0; // The id of the hotkey. \n RegisterHotKey(this.Handle, id, (int)KeyModifier.Shift, Keys.A.GetHashCode()); // Register Shift + A as global hotkey. \n }\n\n protected override void WndProc(ref Message m)\n {\n base.WndProc(ref m);\n\n if (m.Msg == 0x0312)\n {\n /* Note that the three lines below are not needed if you only want to register one hotkey.\n * The below lines are useful in case you want to register multiple keys, which you can use a switch with the id as argument, or if you want to know which key/modifier was pressed for some particular reason. */\n\n Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF); // The key of the hotkey that was pressed.\n KeyModifier modifier = (KeyModifier)((int)m.LParam & 0xFFFF); // The modifier of the hotkey that was pressed.\n int id = m.WParam.ToInt32(); // The id of the hotkey that was pressed.\n\n\n MessageBox.Show(\"Hotkey has been pressed!\");\n // do something\n }\n }\n\n private void ExampleForm_FormClosing(object sender, FormClosingEventArgs e)\n {\n UnregisterHotKey(this.Handle, 0); // Unregister hotkey with id 0 before closing the form. You might want to call this more than once with different id values if you are planning to register more than one hotkey.\n }\n }\n}\n" }, { "answer_id": 63843177, "author": "Anthony Nguyen", "author_id": 12848112, "author_profile": "https://Stackoverflow.com/users/12848112", "pm_score": 2, "selected": false, "text": "<KeyBinding Gesture=\"Ctrl+Alt+Add\" Command=\"{Binding IncrementCommand}\" />\n <KeyBinding Gesture=\"Ctrl+Alt+Add\" Command=\"{Binding IncrementCommand}\"\n HotkeyManager.RegisterGlobalHotkey=\"True\" />\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/146637/" ]
48,947
<p>How are callbacks written in PHP?</p>
[ { "answer_id": 48948, "author": "Nick Stinemates", "author_id": 4960, "author_profile": "https://Stackoverflow.com/users/4960", "pm_score": 5, "selected": false, "text": "// This function uses a callback function. \nfunction doIt($callback) \n{ \n $data = \"this is my data\";\n $callback($data); \n} \n\n\n// This is a sample callback function for doIt(). \nfunction myCallback($data) \n{ \n print 'Data is: ' . $data . \"\\n\"; \n} \n\n\n// Call doIt() and pass our sample callback function's name. \ndoIt('myCallback');\n" }, { "answer_id": 49034, "author": "yukondude", "author_id": 726, "author_profile": "https://Stackoverflow.com/users/726", "pm_score": 3, "selected": false, "text": "create_function() array_map() preg_replace_callback() usort() eval()" }, { "answer_id": 49570, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverflow.com/users/238", "pm_score": 2, "selected": false, "text": "create_function()" }, { "answer_id": 50515, "author": "SeanDowney", "author_id": 5261, "author_profile": "https://Stackoverflow.com/users/5261", "pm_score": 3, "selected": false, "text": "function doIt($callback) {\n if(function_exists($callback)) {\n $callback();\n } else {\n // some error handling\n }\n}\n" }, { "answer_id": 50596, "author": "Steve Clay", "author_id": 3779, "author_profile": "https://Stackoverflow.com/users/3779", "pm_score": 8, "selected": true, "text": "$cb1 = 'someGlobalFunction';\n$cb2 = ['ClassName', 'someStaticMethod'];\n$cb3 = [$object, 'somePublicMethod'];\n\n// this syntax is callable since PHP 5.2.3 but a string containing it\n// cannot be called directly\n$cb2 = 'ClassName::someStaticMethod';\n$cb2(); // fatal error\n\n// legacy syntax for PHP 4\n$cb3 = array(&$object, 'somePublicMethod');\n if (is_callable($cb2)) {\n // Autoloading will be invoked to load the class \"ClassName\" if it's not\n // yet defined, and PHP will check that the class has a method\n // \"someStaticMethod\". Note that is_callable() will NOT verify that the\n // method can safely be executed in static context.\n\n $returnValue = call_user_func($cb2, $arg1, $arg2);\n}\n $cb() call_user_func call_user_func_array ['Vendor\\Package\\Foo', 'method'] call_user_func call_user_func_array $cb() __invoke() create_function() eval()" }, { "answer_id": 1272403, "author": "goliatone", "author_id": 125083, "author_profile": "https://Stackoverflow.com/users/125083", "pm_score": 3, "selected": false, "text": "create_function call_user_func <?php\n\nclass Dispatcher {\n //Added explicit callback declaration.\n var $callback;\n\n public function Dispatcher( $callback ){\n $this->callback = $callback;\n }\n\n public function asynchronous_method(){\n //do asynch stuff, like fwrite...then, fire callback.\n if ( isset( $this->callback ) ) {\n if (function_exists( $this->callback )) call_user_func( $this->callback, \"File done!\" );\n }\n }\n\n}\n <?php \ninclude_once('Dispatcher.php');\n$d = new Dispatcher( 'do_callback' );\n$d->asynchronous_method();\n\nfunction do_callback( $data ){\n print 'Data is: ' . $data . \"\\n\";\n}\n?>\n" }, { "answer_id": 2523807, "author": "Bart van Heukelom", "author_id": 85821, "author_profile": "https://Stackoverflow.com/users/85821", "pm_score": 6, "selected": false, "text": "function doIt($callback) { $callback(); }\n\ndoIt(function() {\n // this will be done\n});\n" }, { "answer_id": 11657728, "author": "Kendall Hopkins", "author_id": 188044, "author_profile": "https://Stackoverflow.com/users/188044", "pm_score": 2, "selected": false, "text": "< 5.4 function call_with_hello_and_append_world( callable $callback )\n{\n // No need to check $closure because of the type hint\n return $callback( \"hello\" ).\"world\";\n}\n\nfunction append_space( $string )\n{\n return $string.\" \";\n}\n\n$output1 = call_with_hello_and_append_world( function( $string ) { return $string.\" \"; } );\nvar_dump( $output1 ); // string(11) \"hello world\"\n\n$output2 = call_with_hello_and_append_world( \"append_space\" );\nvar_dump( $output2 ); // string(11) \"hello world\"\n\n$old_lambda = create_function( '$string', 'return $string.\" \";' );\n$output3 = call_with_hello_and_append_world( $old_lambda );\nvar_dump( $output3 ); // string(11) \"hello world\"\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4960/" ]
48,984
<p>We're using WatiN for testing our UI, but one page (which is unfortunately not under our teams control) takes forever to finish loading. Is there a way to get WatiN to click a link on the page before the page finishes rendering completely?</p>
[ { "answer_id": 49136, "author": "Glenn Slaven", "author_id": 2975, "author_profile": "https://Stackoverflow.com/users/2975", "pm_score": 5, "selected": true, "text": "IE browser = new IE(....);\nbrowser.Button(\"SlowPageLoadingButton\").ClickNoWait();\nLink continueLink = browser.Link(Find.ByText(\"linktext\"));\ncontinueLink.WaitUntilExists();\ncontinueLink.Click();\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975/" ]
48,993
<p>I am wondering if anyone has any experience using a JQuery plugin that converts a html </p> <pre><code>&lt;select&gt; &lt;option&gt; Blah &lt;/option&gt; &lt;/select&gt; </code></pre> <p>combo box into something (probably a div) where selecting an item acts the same as clicking a link.</p> <p>I guess you could probably use javascript to handle a selection event (my javascript knowledge is a little in disrepair at the moment) and 'switch' on the value of the combo box but this seems like more of a hack.</p> <p>Your advice, experience and recommendations are appreciated.</p>
[ { "answer_id": 49027, "author": "Matt Mitchell", "author_id": 364, "author_profile": "https://Stackoverflow.com/users/364", "pm_score": 0, "selected": false, "text": "onchange=\"if(this.options[this.selectedIndex].value!=''){this.form.submit()}\"\n" }, { "answer_id": 49419, "author": "samjudson", "author_id": 1908, "author_profile": "https://Stackoverflow.com/users/1908", "pm_score": 2, "selected": false, "text": "<select id=\"mySelect\">\n <option value=\"1\">Option 1</option>\n <option value=\"2\">Option 2</options>\n</select>\n<div id=\"myDiv\"/>\n <div> $(\"#mySelect option\").each(function() {\n $(\"<div>\" + $(this).text() + \"</div>\").appendTo($(\"#myDiv\")).bind(\"click\", $(this).val(), function(event) {\n location.href = \"goto.php?id=\" + event.data;\n });\n});\n$(\"#mySelect\").remove();\n" }, { "answer_id": 49454, "author": "Erlend Halvorsen", "author_id": 1920, "author_profile": "https://Stackoverflow.com/users/1920", "pm_score": 4, "selected": true, "text": "$(\"#mySelect\").change(function() {\n document.location = this.value;\n});\n" }, { "answer_id": 431268, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "$(\"[id*='COMMON_NAME']\").change(function() {\n document.location = this.value;\n});\n <select id=\"COMMON_NAME_001\">...</select>\n<select id=\"COMMON_NAME_002\">...</select>\n <option>" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48993", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
48,999
<p>The problem I'm trying to solve is "What's at this position?"</p> <p>It's fairly trivial to get the x/y position (offset) of a DIV, but what about the reverse? How do I get the id of a DIV (or any element) given an x/y position?</p>
[ { "answer_id": 49936, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 2, "selected": false, "text": "function getDivByXY(x,y) {\n var alldivs = document.getElementsByTagName('div');\n\n for(var d = 0; d < alldivs.length; d++) {\n if((alldivs[d].offsetLeft == x) && (alldivs[d].offsetTop == y)) {\n return alldivs[d];\n }\n }\n\n return false;\n}\n" }, { "answer_id": 54595, "author": "rdworth", "author_id": 5643, "author_profile": "https://Stackoverflow.com/users/5643", "pm_score": 2, "selected": false, "text": "var el = document.elementFromPoint(x, y);\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/48999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5123/" ]
49,002
<p>Why prefer composition over inheritance? What trade-offs are there for each approach? When should you choose inheritance over composition?</p>
[ { "answer_id": 891820, "author": "aleemb", "author_id": 50475, "author_profile": "https://Stackoverflow.com/users/50475", "pm_score": 8, "selected": false, "text": "class Person {\n String Title;\n String Name;\n Int Age\n}\n\nclass Employee : Person {\n Int Salary;\n String Title;\n}\n Employee Person Person Employee Title Person Employee.Title Title Employee Person class Person {\n String Title;\n String Name;\n Int Age;\n\n public Person(String title, String name, String age) {\n this.Title = title;\n this.Name = name;\n this.Age = age;\n }\n\n}\n\nclass Employee {\n Int Salary;\n private Person person;\n\n public Employee(Person p, Int salary) {\n this.person = p;\n this.Salary = salary;\n }\n}\n\nPerson johnny = new Person (\"Mr.\", \"John\", 25);\nEmployee john = new Employee (johnny, 50000);\n Employee Person Person Person Manager class Manager : Person, Employee {\n ...\n}\n Person Employee Title Manager.Title Class Manager {\n public string Title;\n public Manager(Person p, Employee e)\n {\n this.Title = e.Title;\n }\n}\n Manager Employee Person Title Employee" }, { "answer_id": 1020959, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 0, "selected": false, "text": "Is-a Has-a" }, { "answer_id": 4303034, "author": "simplfuzz", "author_id": 49560, "author_profile": "https://Stackoverflow.com/users/49560", "pm_score": 4, "selected": false, "text": "Class Aircraft extends Engine{\n var wings;\n}\n Engine Aircraft Class Aircraft {\n var wings;\n var engine;\n}\n" }, { "answer_id": 18548784, "author": "Enrique Molinari", "author_id": 842533, "author_profile": "https://Stackoverflow.com/users/842533", "pm_score": 2, "selected": false, "text": "class List {\n data = new Array();\n\n Integer size() {\n return data.length;\n }\n\n add(Integer anInteger) {\n data[data.length] = anInteger;\n }\n}\n class Set, inheriting from: List {\n add(Integer anInteger) {\n if (data.notContains(anInteger)) {\n super.add(anInteger);\n }\n }\n}\n" }, { "answer_id": 32557773, "author": "lcn", "author_id": 2073130, "author_profile": "https://Stackoverflow.com/users/2073130", "pm_score": 6, "selected": false, "text": "this" }, { "answer_id": 37218825, "author": "Scott Hannen", "author_id": 5101046, "author_profile": "https://Stackoverflow.com/users/5101046", "pm_score": 3, "selected": false, "text": "ObjectBaseThatContainsVariousFunctionsNeededByDifferentClasses" }, { "answer_id": 37624298, "author": "Boris Dalstein", "author_id": 1951907, "author_profile": "https://Stackoverflow.com/users/1951907", "pm_score": 6, "selected": false, "text": "Bar Foo Foo Bar Foo Bar Dog Animal Circle Ellipse Widget Node" }, { "answer_id": 39635299, "author": "Ravindra babu", "author_id": 4999394, "author_profile": "https://Stackoverflow.com/users/4999394", "pm_score": 2, "selected": false, "text": "class Vehicle{\n protected double getPrice(){\n // return price\n }\n} \n\nclass Car{\n Vehicle vehicle;\n protected double getPrice(){\n return vehicle.getPrice();\n }\n} \n" }, { "answer_id": 71568176, "author": "Scotty Jamison", "author_id": 7696223, "author_profile": "https://Stackoverflow.com/users/7696223", "pm_score": 4, "selected": false, "text": "setWidth() setHeight() Square Rectangle" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4883/" ]
49,035
<p>Given a declaration like this:</p> <pre><code>class A { public: void Foo() const; }; </code></pre> <p>What does it mean?</p> <p>Google turns up this:</p> <blockquote> <p>Member functions should be declared with the const keyword after them if they can operate on a const (this) object. If the function is not declared const, in can not be applied to a const object, and the compiler will give an error message.</p> </blockquote> <p>But I find that somewhat confusing; can anyone out there put it in better terms?</p> <p>Thanks. </p>
[ { "answer_id": 49039, "author": "1800 INFORMATION", "author_id": 3146, "author_profile": "https://Stackoverflow.com/users/3146", "pm_score": 2, "selected": false, "text": "const class A\n{\n int x;\n mutable int y;\n\n void f() const\n {\n x = 1; // error\n y = 1; // ok because y is mutable\n }\n};\n" }, { "answer_id": 49044, "author": "dfjacobs", "author_id": 4848, "author_profile": "https://Stackoverflow.com/users/4848", "pm_score": 2, "selected": false, "text": "const A obj = new A();\n" }, { "answer_id": 49056, "author": "Henk", "author_id": 4613, "author_profile": "https://Stackoverflow.com/users/4613", "pm_score": 5, "selected": true, "text": "A class A {\npublic:\n void Foo() const;\n void Moo();\n\nprivate:\n int m_nState; // Could add mutable keyword if desired\n int GetState() const { return m_nState; }\n void SetState(int val) { m_nState = val; }\n};\n\nconst A *A1 = new A();\nA *A2 = new A();\n\nA1->Foo(); // OK\nA2->Foo(); // OK\n\nA1->Moo(); // Error - Not allowed to call non-const function on const object instance\nA2->Moo(); // OK\n const A const A::Foo A::SetState const A::GetState const m_nState mutable const mutable" }, { "answer_id": 49076, "author": "Pat Notz", "author_id": 825, "author_profile": "https://Stackoverflow.com/users/825", "pm_score": 3, "selected": false, "text": "const const const const" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61/" ]
49,046
<p>Why does <code>n</code> not equal to <code>8</code> in the following function?</p> <pre><code>void foo(char cvalue[8]) { int n = sizeof (cvalue); } </code></pre> <p>But <code>n</code> <em>does</em> equal to <code>8</code> in this version of the function:</p> <pre><code>void bar() { char cvalue[8]; int n = sizeof (cvalue); } </code></pre>
[ { "answer_id": 49055, "author": "Nick Retallack", "author_id": 2653, "author_profile": "https://Stackoverflow.com/users/2653", "pm_score": 7, "selected": true, "text": "// These all do the same thing\nvoid foo(char cvalue[8])\nvoid foo(char cvalue[])\nvoid foo(char *cvalue)\n" }, { "answer_id": 49061, "author": "dagorym", "author_id": 171, "author_profile": "https://Stackoverflow.com/users/171", "pm_score": 1, "selected": false, "text": "sizeof()" }, { "answer_id": 49656, "author": "DrPizza", "author_id": 2131, "author_profile": "https://Stackoverflow.com/users/2131", "pm_score": 4, "selected": false, "text": "template<typename T, size_t N>\nvoid foo(const T(&arr)[N])\n{\n int n = sizeof(arr);\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5065/" ]
49,066
<p>I have a vs.net project, and after some refactoring, have modified the name of the project. How can I easily rename the underlying windows folder name to match this new project name under a TFS controlled project and solution?<br> Note, I used to be able to do by fiddling with things in the background using SourceSafe ... </p>
[ { "answer_id": 10853509, "author": "Scott Munro", "author_id": 81595, "author_profile": "https://Stackoverflow.com/users/81595", "pm_score": 7, "selected": false, "text": "No ... AssemblyProductAttribute AssemblyDescriptionAttribute AssemblyTitleAttribute" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5110/" ]
49,092
<p>Where can I find an online interactive console for programming language or api?</p> <ul> <li><a href="http://tryruby.org/" rel="nofollow noreferrer">Ruby</a></li> <li><a href="http://shell.appspot.com/" rel="nofollow noreferrer">Python</a></li> <li><a href="http://groovyconsole.appspot.com/" rel="nofollow noreferrer">Groovy</a></li> <li>PHP?</li> <li>Perl?</li> <li><a href="http://eval.ironscheme.net/" rel="nofollow noreferrer">Scheme</a></li> <li><a href="http://www.javarepl.com/" rel="nofollow noreferrer">Java</a></li> <li>C?</li> </ul>
[ { "answer_id": 6141374, "author": "OnesimusUnbound", "author_id": 24755, "author_profile": "https://Stackoverflow.com/users/24755", "pm_score": 1, "selected": false, "text": "# Script text here\nimport itertools\n\ng = itertools.chain(\"AB\", range(2))\n\nprint g.next()\nprint g.next()\nprint g.next()\nprint g.next()\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2653/" ]
49,098
<p>So I have a function that looks something like this:</p> <pre><code>float function(){ float x = SomeValue; return x / SomeOtherValue; } </code></pre> <p>At some point, this function overflows and returns a really large negative value. To try and track down exactly where this was happening, I added a cout statement so that the function looked like this:</p> <pre><code>float function(){ float x = SomeValue; cout &lt;&lt; x; return x / SomeOtherValue; } </code></pre> <p>and it worked! Of course, I solved the problem altogether by using a double. But I'm curious as to why the function worked properly when I couted it. Is this typical, or could there be a bug somewhere else that I'm missing?</p> <p>(If it's any help, the value stored in the float is just an integer value, and not a particularly big one. I just put it in a float to avoid casting.)</p>
[ { "answer_id": 50068, "author": "David Joyner", "author_id": 1146, "author_profile": "https://Stackoverflow.com/users/1146", "pm_score": 2, "selected": false, "text": "const float function(){\n const float x = SomeValue;\n cout << x;\n return x / SomeOtherValue;\n}\n const" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
49,107
<p>Actionscript 3.0 (and I assume Javascript and ECMAScript in general) lacks pass-by-reference for native types like ints. As a result I'm finding getting values back from a function really clunky. What's the normal pattern to work around this? </p> <p>For example, is there a clean way to implement <em>swap( intA, intB )</em> in Actionscript?</p>
[ { "answer_id": 49109, "author": "Nick Retallack", "author_id": 2653, "author_profile": "https://Stackoverflow.com/users/2653", "pm_score": -1, "selected": false, "text": "[a,b] = [b,a]\n" }, { "answer_id": 50755, "author": "hasseg", "author_id": 4111, "author_profile": "https://Stackoverflow.com/users/4111", "pm_score": 4, "selected": true, "text": "function swapAB(aValuesContainer:Object):void\n{\n if (!(aValuesContainer.hasOwnProperty(\"a\") && aValuesContainer.hasOwnProperty(\"b\")))\n throw new ArgumentError(\"aValuesContainer must have properties a and b\");\n\n var tempValue:int = aValuesContainer[\"a\"];\n aValuesContainer[\"a\"] = aValuesContainer[\"b\"];\n aValuesContainer[\"b\"] = tempValue;\n}\nvar ints:Object = {a:13, b:25};\nswapAB(ints);\n" }, { "answer_id": 50990, "author": "imaginaryboy", "author_id": 2508, "author_profile": "https://Stackoverflow.com/users/2508", "pm_score": 2, "selected": false, "text": "public class Reference {\n public var value:*;\n}\n function swap(Reference a, Reference b) {\n var tmp:* = a.value;\n a.value = b.value;\n b.value = tmp;\n}\n" }, { "answer_id": 50992, "author": "Andres", "author_id": 1815, "author_profile": "https://Stackoverflow.com/users/1815", "pm_score": 2, "selected": false, "text": "public class Integer\n{\n public var value:int;\n\n public function Integer(value:int)\n {\n this.value = value;\n }\n}\n" }, { "answer_id": 51315, "author": "Theo", "author_id": 1109, "author_profile": "https://Stackoverflow.com/users/1109", "pm_score": 2, "selected": false, "text": "int String Number" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4969/" ]
49,110
<p>I'm looking for the basic loop like:</p> <pre><code>for(int i = 0; i &lt; MAX; i++) { doSomething(i); } </code></pre> <p>but for Bash.</p>
[ { "answer_id": 49111, "author": "Rob Rolnick", "author_id": 4798, "author_profile": "https://Stackoverflow.com/users/4798", "pm_score": 8, "selected": true, "text": "for i in $(seq 1 10);\ndo\n echo $i\ndone\n" }, { "answer_id": 49114, "author": "Nick Stinemates", "author_id": 4960, "author_profile": "https://Stackoverflow.com/users/4960", "pm_score": 6, "selected": false, "text": "for ((i = 0 ; i < max ; i++ )); do echo \"$i\"; done\n" }, { "answer_id": 49115, "author": "Pat Notz", "author_id": 825, "author_profile": "https://Stackoverflow.com/users/825", "pm_score": 4, "selected": false, "text": "help for\n for: for NAME [in WORDS ... ;] do COMMANDS; done\n The `for' loop executes a sequence of commands for each member in a\n list of items. If `in WORDS ...;' is not present, then `in \"$@\"' is\n assumed. For each element in WORDS, NAME is set to that element, and\n the COMMANDS are executed.\n\nfor ((: for (( exp1; exp2; exp3 )); do COMMANDS; done\n Equivalent to\n (( EXP1 ))\n while (( EXP2 )); do\n COMMANDS\n (( EXP3 ))\n done\n EXP1, EXP2, and EXP3 are arithmetic expressions. If any expression is\n omitted, it behaves as if it evaluates to 1.\n" }, { "answer_id": 49125, "author": "Fernando Barrocal", "author_id": 2274, "author_profile": "https://Stackoverflow.com/users/2274", "pm_score": 5, "selected": false, "text": "for for w in word1 word2 word3\ndo\n doSomething($w)\ndone\n seq seq 1 100\n for n in $(seq 1 100)\ndo\n doSomething($n)\ndone\n $(...) seq for for d in $(find $somepath -type d)\ndo\n doSomething($d)\ndone\n" }, { "answer_id": 143376, "author": "terson", "author_id": 22974, "author_profile": "https://Stackoverflow.com/users/22974", "pm_score": 2, "selected": false, "text": "% for host in {frontend{1..5},backend{1..3}}.mycompany.com\n do ssh $host \"echo -n $host; uptime\"\n done\n" }, { "answer_id": 3307917, "author": "David Gardner", "author_id": 86080, "author_profile": "https://Stackoverflow.com/users/86080", "pm_score": 5, "selected": false, "text": "for i in {1..10} ; do ... ; done\n seq 1 10 for(())" }, { "answer_id": 14098446, "author": "Brent Bradburn", "author_id": 86967, "author_profile": "https://Stackoverflow.com/users/86967", "pm_score": 3, "selected": false, "text": "#! /bin/bash\n\nfunction do_something {\n echo value=${1}\n}\n\nMAX=4\nfor (( i=0; i<MAX; i++ )) ; {\n do_something ${i}\n}\n Z=$(date) awk 'BEGIN { for ( i=0; i<4; i++ ) { print i,\"hello\",ENVIRON[\"Z\"]; } }'\n awk" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49110", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3535/" ]
49,137
<p>I would like to call python script files from my c++ program.</p> <p>I am not sure that the people I will distribute to will have python installed.</p>
[ { "answer_id": 53325201, "author": "ingomueller.net", "author_id": 651937, "author_profile": "https://Stackoverflow.com/users/651937", "pm_score": 5, "selected": false, "text": "#include <pybind11/embed.h> // everything needed for embedding\nnamespace py = pybind11;\n\nint main() {\n py::scoped_interpreter guard{}; // start the interpreter and keep it alive\n py::print(\"Hello, World!\"); // use the Python API\n}\n" }, { "answer_id": 54383046, "author": "RiteshC", "author_id": 7864743, "author_profile": "https://Stackoverflow.com/users/7864743", "pm_score": 3, "selected": false, "text": "#include<iostream>\n#include <cstdlib>\nusing namespace std;\nint main ()\n{\nint result = system(\"/usr/bin/python3 testGen1.py 1\");\ncout << result; \n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49137", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3153/" ]
49,147
<p>I have just installed C# for the first time, and at first glance it appears to be very similar to VB6. I decided to start off by trying to make a 'Hello, World!' UI Edition.</p> <p>I started in the Form Designer and made a button named "Click Me!" proceeded to double-click it and typed in</p> <pre><code>MessageBox("Hello, World!"); </code></pre> <p>I received the following error:</p> <p>MessageBox is a 'type' but used as a 'variable'</p> <p>Fair enough, it seems in C# MessageBox is an Object. I tried the following</p> <pre><code>MessageBox a = new MessageBox("Hello, World!"); </code></pre> <p>I received the following error: MessageBox does not contain a constructor that takes '1' arguments</p> <p>Now I am stumped. Please help.</p>
[ { "answer_id": 49151, "author": "moobaa", "author_id": 3569, "author_profile": "https://Stackoverflow.com/users/3569", "pm_score": 5, "selected": false, "text": "using System.Windows.Forms;\n\n...\n\nMessageBox.Show( \"hello world\" );\n System.Windows.Forms" }, { "answer_id": 49152, "author": "George Mauer", "author_id": 5056, "author_profile": "https://Stackoverflow.com/users/5056", "pm_score": 3, "selected": false, "text": "MessageBox.Show(\"my message\");\n" }, { "answer_id": 49153, "author": "Merus", "author_id": 5133, "author_profile": "https://Stackoverflow.com/users/5133", "pm_score": 7, "selected": true, "text": "if (MessageBox.Show(\"Do you want to continue?\", \"Question\", MessageBoxButtons.YesNo) == MessageBoxResult.Yes) {\n //some interesting behaviour here\n}\n" }, { "answer_id": 10829863, "author": "William Fitzmaurice", "author_id": 1427875, "author_profile": "https://Stackoverflow.com/users/1427875", "pm_score": 0, "selected": false, "text": "System.Windows.Forms alert(\"my message\"); confirm(\"my question\");" }, { "answer_id": 18951433, "author": "user2680314", "author_id": 2680314, "author_profile": "https://Stackoverflow.com/users/2680314", "pm_score": 0, "selected": false, "text": "MessageBox.Show(\"Enter the text for the message box\",\n \"Enter the name of the message box\",\n (Enter the button names e.g. MessageBoxButtons.YesNo),\n (Enter the icon e.g. MessageBoxIcon.Question),\n (Enter the default button e.g. MessageBoxDefaultButton.Button1)" }, { "answer_id": 21935165, "author": "Sagar Dev Timilsina", "author_id": 3335710, "author_profile": "https://Stackoverflow.com/users/3335710", "pm_score": 3, "selected": false, "text": "MessageBox.Show(\"Test Information Message\", \"Caption\", MessageBoxButtons.OK, MessageBoxIcon.Information);\n" }, { "answer_id": 28933652, "author": "KeithJ", "author_id": 3470547, "author_profile": "https://Stackoverflow.com/users/3470547", "pm_score": 0, "selected": false, "text": "MessageBox.Show(\"Hello, World!\");\n MessageBox.Show (\"Hello, World!\");\n MessageBox.Show(\"Hello, World!\");\n" }, { "answer_id": 50077660, "author": "MicroDOS", "author_id": 9714192, "author_profile": "https://Stackoverflow.com/users/9714192", "pm_score": 1, "selected": false, "text": "MessageBox OKCancel if OK else Cancel if (MessageBox.Show(\"Are you sure you want to do this?\", \"Question\", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)\n{\n MessageBox.Show(\"You pressed OK!\");\n}\nelse\n{\n MessageBox.Show(\"You pressed Cancel!\");\n}\n MessageBox YesNo if (MessageBox.Show(\"Are you sure want to doing this?\", \"Question\", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)\n{\n MessageBox.Show(\"You are pressed Yes!\");\n}\nelse\n{\n MessageBox.Show(\"You are pressed No!\");\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4960/" ]
49,158
<p>I've got quite a few GreaseMonkey scripts that I wrote at my work which automatically log me into the internal sites we have here. I've managed to write a script for nearly each one of these sites except for our time sheet application, which uses HTTP authentication. </p> <p>Is there a way I can use GreaseMonkey to log me into this site automatically?</p> <p>Edit: I am aware of the store password functionality in browsers, but my scripts go a step further by checking if I'm logged into the site when it loads (by traversing HTML) and then submitting a post to the login page. This removes the step of having to load up the site, entering the login page, entering my credentials, then hitting submit</p>
[ { "answer_id": 49736, "author": "pkaeding", "author_id": 4257, "author_profile": "https://Stackoverflow.com/users/4257", "pm_score": 2, "selected": false, "text": "http://username:password@host/\n" }, { "answer_id": 55744, "author": "jklp", "author_id": 3847, "author_profile": "https://Stackoverflow.com/users/3847", "pm_score": 4, "selected": true, "text": "var loggedInText = document.getElementById('metanav').firstChild.firstChild.innerHTML;\nif (loggedInText != \"logged in as jklp\") {\n var username = 'jklp';\n var password = 'jklpPass';\n var base64string = Base64.encode(username + \":\" + password);\n\n GM_xmlhttpRequest({\n method: 'GET',\n url: 'http://foo.com/trac/login',\n headers: {\n 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey/0.3',\n 'Accept': 'application/atom+xml,application/xml,text/xml',\n 'Authorization':'Basic ' + base64string,\n }\n });\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3847/" ]
49,164
<p>How do I turn a python program into an .egg file?</p>
[ { "answer_id": 49169, "author": "dF.", "author_id": 3002, "author_profile": "https://Stackoverflow.com/users/3002", "pm_score": 5, "selected": true, "text": "distutils setup.py python setup.py bdist_egg" }, { "answer_id": 61389995, "author": "Manthan Trivedi", "author_id": 12557421, "author_profile": "https://Stackoverflow.com/users/12557421", "pm_score": 0, "selected": false, "text": "c:\\Python34\\python.exe setup.py bdist_egg\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49164", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4491/" ]
49,194
<p>I have an action like this:</p> <pre><code>public class News : System.Web.Mvc.Controller { public ActionResult Archive(int year) { / *** / } } </code></pre> <p>With a route like this:</p> <pre><code>routes.MapRoute( "News-Archive", "News.mvc/Archive/{year}", new { controller = "News", action = "Archive" } ); </code></pre> <p>The URL that I am on is:</p> <pre><code>News.mvc/Archive/2008 </code></pre> <p>I have a form on this page like this:</p> <pre><code>&lt;form&gt; &lt;select name="year"&gt; &lt;option value="2007"&gt;2007&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> <p>Submitting the form should go to News.mvc/Archive/2007 if '2007' is selected in the form.</p> <p>This requires the form 'action' attribute to be "News.mvc/Archive".</p> <p>However, if I declare a form like this:</p> <pre><code>&lt;form method="get" action="&lt;%=Url.RouteUrl("News-Archive")%&gt;"&gt; </code></pre> <p>it renders as:</p> <pre><code>&lt;form method="get" action="/News.mvc/Archive/2008"&gt; </code></pre> <p>Can someone please let me know what I'm missing?</p>
[ { "answer_id": 49223, "author": "Matt Mitchell", "author_id": 364, "author_profile": "https://Stackoverflow.com/users/364", "pm_score": 0, "selected": false, "text": "routes.MapRoute(\n \"News-Archive\", \n \"News.mvc/Archive/{year}\", \n new { controller = \"News\", action = \"Archive\", year = 0 }\n );\n public ActionResult Archive(int year)\n{\n if (!String.IsNullOrEmpty(Request[\"year\"]))\n {\n return RedirectToAction(\"Archive\", new { year = Request[\"year\"] });\n }\n}\n public ActionResult Archive(int year)\n{\n if (!String.IsNullOrEmpty(Request[\"year\"]))\n {\n return RedirectToAction(\"Archive\", new { year = Request[\"year\"] });\n }\n if (year == 0)\n {\n /* ... */\n }\n /* ... */\n}\n Url.RouteUrl(\"News-Archive\", new { year = 0 })\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/364/" ]
49,211
<p>I have an existing application that is written in C++ for Windows. This application uses the Win32 CryptoAPI to generate a TripleDES session key for encrypting/decrypting data. We're using the <a href="http://www.phdcc.com/cryptorc4.htm" rel="nofollow noreferrer">exponent of one trick</a> to export the session key out as a blob, which allows the blob to be stored somewhere in a decrypted format.</p> <p>The question is how can we use this in our .NET application (C#). The framework encapsulates/wraps much of what the CryptoAPI is doing. Part of the problem is the CryptAPI states that the TripleDES algorithm for the <a href="http://msdn.microsoft.com/en-us/library/aa386986(VS.85).aspx" rel="nofollow noreferrer">Microsoft Enhanced Cryptographic Provider</a> is 168 bits (3 keys of 56 bits). However, the .NET framework states their keys are 192 bits (3 keys of 64 bits). Apparently, the 3 extra bytes in the .NET framework is for parity?</p> <p>Anyway, we need to read the key portion out of the blob and somehow be able to use that in our .NET application. Currently we are not getting the expected results when attempting to use the key in .NET. The decryption is failing miserably. Any help would be greatly appreciated. </p> <h2>Update:</h2> <p>I've been working on ways to resolve this and have come up with a solution that I will post in time. However, still would appreciate any feedback from others.</p>
[ { "answer_id": 345696, "author": "Scott Saad", "author_id": 4916, "author_profile": "https://Stackoverflow.com/users/4916", "pm_score": 4, "selected": true, "text": "Array.Reverse( keyByteArray );\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49211", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4916/" ]
49,214
<p>I need a list of integers from 1 to x where x is set by the user. I could build it with a for loop eg assuming x is an integer set previously:</p> <pre><code>List&lt;int&gt; iList = new List&lt;int&gt;(); for (int i = 1; i &lt;= x; i++) { iList.Add(i); } </code></pre> <p>This seems dumb, surely there's a more elegant way to do this, something like the <a href="http://au2.php.net/manual/en/function.range.php" rel="noreferrer">PHP range method</a></p>
[ { "answer_id": 49216, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 6, "selected": false, "text": "// Adding value to existing list\nvar list = new List<int>();\nlist.AddRange(Enumerable.Range(1, x));\n\n// Creating new list\nvar list = Enumerable.Range(1, x).ToList();\n" }, { "answer_id": 49342, "author": "Samuel Jack", "author_id": 1727, "author_profile": "https://Stackoverflow.com/users/1727", "pm_score": 4, "selected": false, "text": "\npublic static class IntegerExtensions\n{\n public static IEnumerable<int> To(this int first, int last)\n {\n for (int i = first; i <= last; i++)\n { \n yield return i;\n } \n }\n}\n List<int> = first.To(last).ToList(); List<int> = 1.To(x).ToList();" }, { "answer_id": 36462316, "author": "Gaspare Bonventre", "author_id": 3976189, "author_profile": "https://Stackoverflow.com/users/3976189", "pm_score": 1, "selected": false, "text": " public static List<int> MakeSequence(int startingValue, int sequenceLength)\n {\n return Enumerable.Range(startingValue, sequenceLength).ToList<int>();\n }\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2975/" ]
49,251
<p>Following this question:<br> <a href="https://stackoverflow.com/questions/49224/good-crash-reporting-library-in-c">Good crash reporting library in c#</a></p> <p>Is there any library like CrashRpt.dll that does the same on Linux? That is, generate a failure report including a core dump and any necessary environment and notify the developer about it?</p> <p>Edit: This seems to be a duplicate of <a href="https://stackoverflow.com/questions/18265/getting-stack-traces-on-unix-systems-automatically">this question</a></p>
[ { "answer_id": 54243, "author": "Martin Del Vecchio", "author_id": 5397, "author_profile": "https://Stackoverflow.com/users/5397", "pm_score": 0, "selected": false, "text": "x86 0x00000000 0x00000000 int j = *i\n int j = i[2];\n 0x00000008" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1084/" ]
49,252
<p>For a project I am working on in ruby I am overriding the method_missing method so that I can set variables using a method call like this, similar to setting variables in an ActiveRecord object:</p> <p><code>Object.variable_name= 'new value'</code> </p> <p>However, after implementing this I found out that many of the variable names have periods (.) in them. I have found this workaround:</p> <p><code>Object.send('variable.name=', 'new value')</code></p> <p>However, I am wondering is there a way to escape the period so that I can use</p> <p><code>Object.variable.name= 'new value'</code></p>
[ { "answer_id": 49255, "author": "Nick Retallack", "author_id": 2653, "author_profile": "https://Stackoverflow.com/users/2653", "pm_score": 4, "selected": true, "text": "attr_writer :bar\nattr_reader :baz\nattr_accessor :foo\n class SillySetter\n def initialize path=nil\n @path = path\n end\n\n def method_missing name,value=nil\n new_path = @path ? \"#{@path}.#{name}\" : name\n if name.to_s[-1] == ?=\n puts \"setting #{new_path} #{value}\"\n else\n return self.class.new(path=new_path)\n end\n end\nend\n\ns = SillySetter.new\ns.foo = 5 # -> setting foo= 5\ns.foo.bar.baz = 4 # -> setting foo.bar.baz= 4\n" }, { "answer_id": 49575, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 0, "selected": false, "text": "def variable_name\n send 'variable.name'\nend\n\ndef variable_name=(value)\n send 'variable.name=', value\nend\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5004/" ]
49,258
<p>I am writing my first serious wxWidgets program. I'd like to use the wxConfig facility to make the program's user options persistent. However I <em>don't</em> want wxConfigBase to automatically use the Windows registry. Even though I'm initially targeting Windows, I'd prefer to use a configuration (eg .ini) file. Does anyone know a clean and simple way of doing this ? Thanks.</p>
[ { "answer_id": 49255, "author": "Nick Retallack", "author_id": 2653, "author_profile": "https://Stackoverflow.com/users/2653", "pm_score": 4, "selected": true, "text": "attr_writer :bar\nattr_reader :baz\nattr_accessor :foo\n class SillySetter\n def initialize path=nil\n @path = path\n end\n\n def method_missing name,value=nil\n new_path = @path ? \"#{@path}.#{name}\" : name\n if name.to_s[-1] == ?=\n puts \"setting #{new_path} #{value}\"\n else\n return self.class.new(path=new_path)\n end\n end\nend\n\ns = SillySetter.new\ns.foo = 5 # -> setting foo= 5\ns.foo.bar.baz = 4 # -> setting foo.bar.baz= 4\n" }, { "answer_id": 49575, "author": "James A. Rosen", "author_id": 1190, "author_profile": "https://Stackoverflow.com/users/1190", "pm_score": 0, "selected": false, "text": "def variable_name\n send 'variable.name'\nend\n\ndef variable_name=(value)\n send 'variable.name=', value\nend\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3955/" ]
49,267
<p>Embedded custom-tag in dynamic content (nested tag) not rendering.</p> <p>I have a page that pulls dynamic content from a javabean and passes the list of objects to a custom tag for processing into html. Within each object is a bunch of html to be output that contains a second custom tag that I would like to also be rendered. The problem is that the tag invocation is rendered as plaintext.</p> <p>An example might serve me better.</p> <p>1 Pull information from a database and return it to the page via a javabean. Send this info to a custom tag for outputting.</p> <pre><code>&lt;jsp:useBean id="ImportantNoticeBean" scope="page" class="com.mysite.beans.ImportantNoticeProcessBean"/&gt; &lt;%-- Declare the bean --%&gt; &lt;c:forEach var="noticeBean" items="${ImportantNoticeBean.importantNotices}"&gt; &lt;%-- Get the info --%&gt; &lt;mysite:notice importantNotice="${noticeBean}"/&gt; &lt;%-- give it to the tag for processing --%&gt; &lt;/c:forEach&gt; </code></pre> <p>this tag should output a box div like so</p> <pre><code>*SNIP* class for custom tag def and method setup etc out.println("&lt;div class=\"importantNotice\"&gt;"); out.println(" " + importantNotice.getMessage()); out.println(" &lt;div class=\"importantnoticedates\"&gt;Posted: " + importantNotice.getDateFrom() + " End: " + importantNotice.getDateTo()&lt;/div&gt;"); out.println(" &lt;div class=\"noticeAuthor\"&gt;- " + importantNotice.getAuthor() + "&lt;/div&gt;"); out.println("&lt;/div&gt;"); *SNIP* </code></pre> <p>This renders fine and as expected</p> <pre><code>&lt;div class="importantNotice"&gt; &lt;p&gt;This is a very important message. Everyone should pay attenton to it.&lt;/p&gt; &lt;div class="importantnoticedates"&gt;Posted: 2008-09-08 End: 2008-09-08&lt;/div&gt; &lt;div class="noticeAuthor"&gt;- The author&lt;/div&gt; &lt;/div&gt; </code></pre> <p>2 If, in the above example, for instance, I were to have a custom tag in the importantNotice.getMessage() String:</p> <pre><code>*SNIP* "This is a very important message. Everyone should pay attenton to it. &lt;mysite:quote author="Some Guy"&gt;Quote this&lt;/mysite:quote&gt;" *SNIP* </code></pre> <p>The important notice renders fine but the quote tag will not be processed and simply inserted into the string and put as plain text/html tag.</p> <pre><code>&lt;div class="importantNotice"&gt; &lt;p&gt;This is a very important message. Everyone should pay attenton to it. &lt;mysite:quote author="Some Guy"&gt;Quote this&lt;/mysite:quote&gt;&lt;/p&gt; &lt;div class="importantnoticedates"&gt;Posted: 2008-09-08 End: 2008-09-08&lt;/div&gt; &lt;div class="noticeAuthor"&gt;- The author&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Rather than </p> <pre><code>&lt;div class="importantNotice"&gt; &lt;p&gt;This is a very important message. Everyone should pay attenton to it. &lt;div class="quote"&gt;Quote this &lt;span class="authorofquote"&gt;Some Guy&lt;/span&gt;&lt;/div&gt;&lt;/p&gt; // or wahtever I choose as the output &lt;div class="importantnoticedates"&gt;Posted: 2008-09-08 End: 2008-09-08&lt;/div&gt; &lt;div class="noticeAuthor"&gt;- The author&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I know this has to do with processors and pre-processors but I am not to sure about how to make this work.</p>
[ { "answer_id": 49410, "author": "Georgy Bolyuba", "author_id": 4052, "author_profile": "https://Stackoverflow.com/users/4052", "pm_score": 2, "selected": true, "text": "<bodycontent>JSP</bodycontent>\n JspFragment body = getJspBody(); \nStringWriter stringWriter = new StringWriter(); \nStringBuffer buff = stringWriter.getBuffer(); \nbuff.append(\"<h1>\"); \nbody.invoke(stringWriter); \nbuff.append(\"</h1>\"); \nout.println(stringWriter);\n <jsp:useBean id=\"ImportantNoticeBean\" scope=\"page class=\"com.mysite.beans.ImportantNoticeProcessBean\"/>\n<c:forEach var=\"noticeBean\" items=\"${ImportantNoticeBean.importantNotices}\">\n <mysite:notice importantNotice=\"${noticeBean}\">\n <mysite:quote author=\"Some Guy\">Quote this</mysite:quote>\n <mysite:messagebody author=\"Some Guy\" />\n </mysite:notice>\n</c:forEach>\n" }, { "answer_id": 6538030, "author": "Samuel Marchant", "author_id": 823341, "author_profile": "https://Stackoverflow.com/users/823341", "pm_score": 0, "selected": false, "text": "BodyTagSupport EVAL_BODY_BUFFERED" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3431280/" ]
49,269
<p>I have a number of application settings (in user scope) for my custom grid control. Most of them are color settings. I have a form where the user can customize these colors and I want to add a button for reverting to default color settings. How can I read the default settings?</p> <p>For example:</p> <ol> <li>I have a user setting named <code>CellBackgroundColor</code> in <code>Properties.Settings</code>.</li> <li>At design time I set the value of <code>CellBackgroundColor</code> to <code>Color.White</code> using the IDE.</li> <li>User sets <code>CellBackgroundColor</code> to <code>Color.Black</code> in my program.</li> <li>I save the settings with <code>Properties.Settings.Default.Save()</code>.</li> <li>User clicks on the <code>Restore Default Colors</code> button.</li> </ol> <p>Now, <code>Properties.Settings.Default.CellBackgroundColor</code> returns <code>Color.Black</code>. How do I go back to <code>Color.White</code>?</p>
[ { "answer_id": 49289, "author": "aku", "author_id": 1196, "author_profile": "https://Stackoverflow.com/users/1196", "pm_score": 6, "selected": true, "text": "Settings.Default.Properties[\"property\"].DefaultValue // initial value from config file\n string foo = Settings.Default.Foo; // Foo = \"Foo\" by default\nSettings.Default.Foo = \"Boo\";\nSettings.Default.Save();\nstring modifiedValue = Settings.Default.Foo; // modifiedValue = \"Boo\"\nstring originalValue = Settings.Default.Properties[\"Foo\"].DefaultValue as string; // originalValue = \"Foo\"\n" }, { "answer_id": 49336, "author": "Matt Warren", "author_id": 4500, "author_profile": "https://Stackoverflow.com/users/4500", "pm_score": 2, "selected": false, "text": "Properties.Settings.Default Properties.DefaultSettings.Default Properties.DefaultSettings.Default" }, { "answer_id": 2117359, "author": "Ohad Schneider", "author_id": 67824, "author_profile": "https://Stackoverflow.com/users/67824", "pm_score": 4, "selected": false, "text": "Properties.Settings.Default.Reset()\nProperties.Settings.Default.Reload()\n" }, { "answer_id": 2165493, "author": "Domagoj Peharda", "author_id": 103055, "author_profile": "https://Stackoverflow.com/users/103055", "pm_score": 2, "selected": false, "text": "Properties.Settings.Default.Reset()" }, { "answer_id": 8231413, "author": "expelledboy", "author_id": 644945, "author_profile": "https://Stackoverflow.com/users/644945", "pm_score": 3, "selected": false, "text": "public static class SettingsPropertyCollectionExtensions\n{\n public static T GetDefault<T>(this SettingsPropertyCollection me, string property)\n {\n string val_string = (string)Settings.Default.Properties[property].DefaultValue;\n\n return (T)Convert.ChangeType(val_string, typeof(T));\n }\n}\n var setting = Settings.Default.Properties.GetDefault<double>(\"MySetting\");\n" }, { "answer_id": 14310533, "author": "ta.speot.is", "author_id": 242520, "author_profile": "https://Stackoverflow.com/users/242520", "pm_score": 1, "selected": false, "text": "ApplicationSettingsBase.Reset using System;\nusing System.Configuration;\n\nnamespace YourApplication.Extensions\n{\n public static class ExtensionsApplicationSettingsBase\n {\n public static void LoadDefaults(this ApplicationSettingsBase that)\n {\n foreach (SettingsProperty settingsProperty in that.Properties)\n {\n that[settingsProperty.Name] =\n Convert.ChangeType(settingsProperty.DefaultValue,\n settingsProperty.PropertyType);\n }\n }\n }\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/976/" ]
49,274
<p>I have a string, say <code>'123'</code>, and I want to convert it to the integer <code>123</code>.</p> <p>I know you can simply do <code>some_string.to_i</code>, but that converts <code>'lolipops'</code> to <code>0</code>, which is not the effect I have in mind. I want it to blow up in my face when I try to convert something invalid, with a nice and painful <code>Exception</code>. Otherwise, I can't distinguish between a valid <code>0</code> and something that just isn't a number at all.</p> <p><strong>EDIT:</strong> I was looking for the standard way of doing it, without regex trickery.</p>
[ { "answer_id": 49282, "author": "Slartibartfast", "author_id": 4433, "author_profile": "https://Stackoverflow.com/users/4433", "pm_score": 9, "selected": true, "text": "Integer('1001') # => 1001 \nInteger('1001 nights') \n# ArgumentError: invalid value for Integer: \"1001 nights\" \n 0x 0b Integer('23') # => 23\nInteger('0x23') # => 35\nInteger('023') # => 19\nInteger('0x23', 10)\n# => #<ArgumentError: invalid value for Integer: \"0x23\">\nInteger('023', 10) # => 23\n" }, { "answer_id": 49283, "author": "Purfideas", "author_id": 4615, "author_profile": "https://Stackoverflow.com/users/4615", "pm_score": 5, "selected": false, "text": "i.to_i if i.match(/^\\d+$/)\n" }, { "answer_id": 49287, "author": "Paul Wicks", "author_id": 85, "author_profile": "https://Stackoverflow.com/users/85", "pm_score": 2, "selected": false, "text": "someString = \"asdfasd123\"\nnumber = someString.to_i\nif someString != number.to_s\n puts \"oops, this isn't a number\"\nend\n" }, { "answer_id": 53359, "author": "Joseph Pecoraro", "author_id": 792, "author_profile": "https://Stackoverflow.com/users/792", "pm_score": 5, "selected": false, "text": ">> Integer('0x15')\n# => 21 \n>> Integer('0b10')\n# => 2 \n>> Integer('077')\n# => 63\n 0x 0X 0b 0B 0 /\\d+/" }, { "answer_id": 53840, "author": "metavida", "author_id": 5539, "author_profile": "https://Stackoverflow.com/users/5539", "pm_score": 1, "selected": false, "text": "def safeParse2(strToParse)\n if strToParse =~ /\\A\\d+\\Z/\n strToParse.to_i\n else\n raise Exception\n end\nend\n\n[\"100\", \"1a\", \"b2\", \"t\"].each do |number|\n begin\n puts safeParse2(number)\n rescue Exception\n puts \"#{number} is invalid\"\n end\nend\n 100\n1a is invalid\nb2 is invalid\nt is invalid\n" }, { "answer_id": 131714, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 3, "selected": false, "text": "class NotAnIntError < StandardError \nend\n\nclass String\n def is_int? \n self =~ /^-?[0-9]+$/\n end\n\n def safe_to_i\n return self.to_i if is_int?\n raise NotAnIntError, \"The string '#{self}' is not a valid integer.\", caller\n end\nend\n\nclass Integer\n def safe_to_i\n return self\n end \nend\n\nclass StringExtensions < Test::Unit::TestCase\n\n def test_is_int\n assert \"98234\".is_int?\n assert \"-2342\".is_int?\n assert \"02342\".is_int?\n assert !\"+342\".is_int?\n assert !\"3-42\".is_int?\n assert !\"342.234\".is_int?\n assert !\"a342\".is_int?\n assert !\"342a\".is_int?\n end\n\n def test_safe_to_i\n assert 234234 == 234234.safe_to_i\n assert 237 == \"237\".safe_to_i\n begin\n \"a word\".safe_to_i\n fail 'safe_to_i did not raise the expected error.'\n rescue NotAnIntError \n # this is what we expect..\n end\n end\n\nend\n" }, { "answer_id": 2551994, "author": "Jaime Cham", "author_id": 304734, "author_profile": "https://Stackoverflow.com/users/304734", "pm_score": 4, "selected": false, "text": ">> Integer(:foobar)\n=> 26017\n>> Integer(:yikes)\n=> 26025\n .to_s" }, { "answer_id": 16526935, "author": "ian", "author_id": 335847, "author_profile": "https://Stackoverflow.com/users/335847", "pm_score": 3, "selected": false, "text": "class IntegerInString < String\n\n def initialize( s )\n fail ArgumentError, \"The string '#{s}' is not an integer in a string, it's just a string.\" unless s =~ /^\\-?[0-9]+$/\n super\n end\nend\n n = IntegerInString.new \"2\"\nn.to_i\n# => 2\n\nIntegerInString.new \"blob\"\nArgumentError: The string 'blob' is not an integer in a string, it's just a string.\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2018/" ]
49,284
<p>I've come across a rather interesing (and frustrating) problem with IE6. We are serving up some server generated pdfs and then simply setting headers in PHP to force a browser download of the file. Works fine and all, except in IE6 but <strong>only</strong> if the windows user account is set to standard user (ie. not administrator).</p> <p>Since this is for a corporate environment, of course all their accounts are setup this way. Weird thing is, that in the download dialog, the Content-Type is not recognized:</p> <pre><code>header( 'Pragma: public' ); header( 'Expires: 0' ); header( 'Cache-Control: must-revalidate, pre-check=0, post-check=0' ); header( 'Cache-Control: public' ); header( 'Content-Description: File Transfer' ); header( 'Content-Type: application/pdf' ); header( 'Content-Disposition: attachment; filename="xxx.pdf"' ); header( 'Content-Transfer-Encoding: binary' ); echo $content; exit; </code></pre> <p>I also tried writing the file content to a temporary file first so I could also set the <code>Content-Length</code> in the header but that didn't help.</p>
[ { "answer_id": 49306, "author": "Stu Thompson", "author_id": 2961, "author_profile": "https://Stackoverflow.com/users/2961", "pm_score": 1, "selected": false, "text": " response.setHeader(\"Content-Type\", \"application/pdf \"; name=\" + file.getName());\n response.setContentType(\"application/pdf\");\n response.setHeader(\"Last-Modified\", getHeaderDate(file.getFile());\n response.setHeader(\"Content-Length\", file.getLength());\n" }, { "answer_id": 49325, "author": "pilif", "author_id": 5083, "author_profile": "https://Stackoverflow.com/users/5083", "pm_score": 2, "selected": false, "text": "header( 'Expires: 0' );\nheader( 'Cache-Control: must-revalidate, pre-check=0, post-check=0' );\n" }, { "answer_id": 72399, "author": "Twan", "author_id": 6702, "author_profile": "https://Stackoverflow.com/users/6702", "pm_score": 0, "selected": false, "text": "ini_set(\"zlib.output_compression\",0);\n" }, { "answer_id": 134693, "author": "Tom De Leu", "author_id": 22263, "author_profile": "https://Stackoverflow.com/users/22263", "pm_score": 0, "selected": false, "text": "response.setHeader(\"Content-Disposition\", \"attachment; filename=\\\"\" + file.getName() + \"\\\"\");\nresponse.setContentType(getServletContext().getMimeType(file.getName()));\nresponse.setContentLength(file.length());\n" }, { "answer_id": 731183, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 2, "selected": false, "text": "Content-Transfer-Encoding: binary\n X-Bits-Per-Byte: 8 Cache-control: pre-check=0, post-check=0\n 0 0 Expires:0 must-revalidate Content-Description: File Transfer\n X-Hi-Mom: I'm sending you a file! header( 'Cache-Control: must-revalidate, pre-check=0, post-check=0' );\nheader( 'Cache-Control: public' );\n Content-Disposition: attachment\n mod_rewrite index.php/fakefilename.doc Content-Disposition Cache-control:no-cache session.cache_limiter none ini_set('session.cache_limiter','none'); // tell PHP to stop screwing up HTTP\n" }, { "answer_id": 3758994, "author": "Andreas Linden", "author_id": 412395, "author_profile": "https://Stackoverflow.com/users/412395", "pm_score": 0, "selected": false, "text": "header( 'Content-type: application/octet-stream'); # force download, no matter what mimetype\nheader( 'Content-Transfer-Encoding: binary' ); # is always ok, also for plain text\n" }, { "answer_id": 5732601, "author": "vmaior", "author_id": 717391, "author_profile": "https://Stackoverflow.com/users/717391", "pm_score": 1, "selected": false, "text": "public function download(sfResponse $response) {\n\n $response->clearHttpHeaders();\n $response->setHttpHeader('Pragma: public', true);\n $response->addCacheControlHttpHeader(\"Cache-control\",\"private\"); \n $response->setContentType('application/octet-stream', true);\n $response->setHttpHeader('Content-Length', filesize(sfConfig::get('sf_web_dir') . sfConfig::get('app_paths_docPdf') . $this->getFilename()), true);\n $response->setHttpHeader(\"Content-Disposition\", \"attachment; filename=\\\"\". $this->getFilename() .\"\\\"\");\n $response->setHttpHeader('Content-Transfer-Encoding', 'binary', true);\n $response->setHttpHeader(\"Content-Description\",\"File Transfer\");\n $response->sendHttpHeaders();\n $response->setContent(readfile(sfConfig::get('sf_web_dir') . sfConfig::get('app_paths_docPdf') . $this->getFilename()));\n\n return sfView::NONE;\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49284", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3196/" ]
49,299
<p>I am considering building a application using PRISM (Composite WPF Guidance/Library). The application modules will be vertically partitioned (i.e. Customers, Suppliers, Sales Orders, etc). This is still all relatively easy... I also have a Shell with a main region were all the work will happen but now I need the following behavior: I need a menu on my main Shell and when each one of the options gets clicked (like customers, suppliers, etc) I need to find the module and load it into the region (Only 1 view at a time)? </p> <p>Does anybody know of any sample applications with this type of behavior? All the samples are more focused on having all the modules loaded on the main shell? And should my menu bar also be a module?</p> <p>[<strong>UPDATE</strong>] How do I inject a module into a region based on it being selected from a menu? All the examples show that the module injects the view into the region on initialize? I need to only inject the view if the module is selected on a menu?</p>
[ { "answer_id": 881213, "author": "Scott Barnes", "author_id": 94167, "author_profile": "https://Stackoverflow.com/users/94167", "pm_score": 2, "selected": false, "text": "MyConstructor(IRegionManager regionManager, IUnityContainer container) \n IMyViewInstance myViewInstance = this.container.Resolve<IMyViewInstance>();\nIRegion myRegion = this.regionManager.Regions[\"YourRegion\"];\nmyRegion.add(myViewInstance);\nmyRegion.Active(myViewInstance);\n" }, { "answer_id": 3321851, "author": "renlesterdg", "author_id": 400607, "author_profile": "https://Stackoverflow.com/users/400607", "pm_score": -1, "selected": false, "text": "Screen Conductor" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5147/" ]
49,302
<p>We have some legacy code that needs to identify in the Page_Load which event caused the postback. At the moment this is implemented by checking the Request data like this...</p> <p>if (Request.Form["__EVENTTARGET"] != null<br> &amp;&amp; (Request.Form["__EVENTTARGET"].IndexOf("BaseGrid") > -1 // BaseGrid event ( e.g. sort)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|| Request.Form["btnSave"] != null // Save button </p> <p>This is pretty ugly and breaks if someone renames a control. Is there a better way of doing this?</p> <p>Rewriting each page so that it does not need to check this in Page_Load is not an option at the moment.</p>
[ { "answer_id": 49311, "author": "Espo", "author_id": 2257, "author_profile": "https://Stackoverflow.com/users/2257", "pm_score": 4, "selected": true, "text": "public static Control GetPostBackControl(Page page)\n{\n Control control = null;\n\n string ctrlname = page.Request.Params.Get(\"__EVENTTARGET\");\n if (ctrlname != null && ctrlname != string.Empty)\n {\n control = page.FindControl(ctrlname);\n }\n else\n {\n foreach (string ctl in page.Request.Form)\n {\n Control c = page.FindControl(ctl);\n if (c is System.Web.UI.WebControls.Button)\n {\n control = c;\n break;\n }\n }\n }\n return control;\n}\n" }, { "answer_id": 15296527, "author": "AProgrammer", "author_id": 1684424, "author_profile": "https://Stackoverflow.com/users/1684424", "pm_score": 0, "selected": false, "text": "if (control == null) \n{ for (int i = 0; i < page.Request.Form.Count; i++) \n { \n if ((page.Request.Form.Keys[i].EndsWith(\".x\")) || (page.Request.Form.Keys[i].EndsWith(\".y\"))) \n { control = page.FindControl(page.Request.Form.Keys[i].Substring(0, page.Request.Form.Keys[i].Length - 2)); break; \n }\n }\n } \n" }, { "answer_id": 15296614, "author": "AProgrammer", "author_id": 1684424, "author_profile": "https://Stackoverflow.com/users/1684424", "pm_score": 0, "selected": false, "text": "public Control GetPostBackControl(Page page)\n{ \n Control control = null; \n string ctrlname = page.Request.Params.Get(\"__EVENTTARGET\"); \n if ((ctrlname != null) & ctrlname != string.Empty)\n { \n control = page.FindControl(ctrlname); \n }\n else \n {\n foreach (string ctl in page.Request.Form) \n { \n Control c = page.FindControl(ctl); \n if (c is System.Web.UI.WebControls.Button) \n { control = c; break; }\n }\n }\n// handle the ImageButton postbacks \nif (control == null) \n{ for (int i = 0; i < page.Request.Form.Count; i++) \n { \n if ((page.Request.Form.Keys[i].EndsWith(\".x\")) || (page.Request.Form.Keys[i].EndsWith(\".y\"))) \n { control = page.FindControl(page.Request.Form.Keys[i].Substring(0, page.Request.Form.Keys[i].Length - 2)); break; \n }\n }\n } \nreturn control; \n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49302", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1127460/" ]
49,307
<p>Using the <code>zip</code> function, Python allows for loops to traverse multiple sequences in parallel. </p> <p><code>for (x,y) in zip(List1, List2):</code></p> <p>Does MATLAB have an equivalent syntax? If not, what is the best way to iterate over two parallel arrays at the same time using MATLAB?</p>
[ { "answer_id": 49514, "author": "sven", "author_id": 46, "author_profile": "https://Stackoverflow.com/users/46", "pm_score": 3, "selected": false, "text": "for i=1:length(a)\n c(i) = a(i) + b(i);\nend\n" }, { "answer_id": 51137, "author": "DMC", "author_id": 3148, "author_profile": "https://Stackoverflow.com/users/3148", "pm_score": 3, "selected": false, "text": "dostuff = @(my_ten, my_one) my_ten + my_one;\n\ntens = [ 10 20 30 ];\nones = [ 1 2 3];\n\nx = arrayfun(dostuff, tens, ones);\n\nx\n x =\n\n 11 22 33\n" }, { "answer_id": 65903, "author": "mattiast", "author_id": 8272, "author_profile": "https://Stackoverflow.com/users/8272", "pm_score": 4, "selected": false, "text": "for i=[x';y']\n# do stuff with i(1) and i(2)\nend\n x y >> x=[1 ; 2; 3;]\n\nx =\n\n 1\n 2\n 3\n\n>> y=[10 ; 20; 30;]\n\ny =\n\n 10\n 20\n 30\n\n>> for i=[x';y']\ndisp(['size of i = ' num2str(size(i)) ', i(1) = ' num2str(i(1)) ', i(2) = ' num2str(i(2))])\nend\nsize of i = 2 1, i(1) = 1, i(2) = 10\nsize of i = 2 1, i(1) = 2, i(2) = 20\nsize of i = 2 1, i(1) = 3, i(2) = 30\n>> \n" }, { "answer_id": 138886, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": "for tic toc" }, { "answer_id": 218618, "author": "bastibe", "author_id": 1034, "author_profile": "https://Stackoverflow.com/users/1034", "pm_score": 2, "selected": false, "text": "% assuming you have column vectors a and b\nx = [a b];\n\nfor i = 1:length(a)\n % do stuff with one row...\n x(i,:);\nend\n" }, { "answer_id": 54482864, "author": "Sean", "author_id": 2194422, "author_profile": "https://Stackoverflow.com/users/2194422", "pm_score": 0, "selected": false, "text": "for (x,y) in zip(List1, List2):\n >> for row = {'string' 10\n>> 'property' 100 }'\n>> fprintf([row{1,:} '%d\\n'], row{2, :});\n>> end\nstring10\nproperty100\n >> cStr = cell(1,10);cStr(:)={'string'};\n>> cNum=cell(1,10);for cnt=1:10, cNum(cnt)={cnt};\n>> for row = {cStr{:}; cNum{:}}\n>> fprintf([row{1,:} '%d\\n'], row{2,:});\n>> end\nstring1\nstring2\nstring3\nstring4\nstring5\nstring6\nstring7\nstring8\nstring9\nstring10\n" }, { "answer_id": 64389879, "author": "Alex", "author_id": 11554957, "author_profile": "https://Stackoverflow.com/users/11554957", "pm_score": 0, "selected": false, "text": "al(i)*bl(:,i) al = 1:9;\nbl = [11:19; 21:29];\n\nfor data = [num2cell(al); num2cell(bl,1)]\n\n    [a, b] = data{:};\n    disp(a*b)\n\nend\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5148/" ]
49,334
<p>In my database, I have an entity table (let's call it Entity). Each entity can have a number of entity types, and the set of entity types is static. Therefore, there is a connecting table that contains rows of the entity id and the name of the entity type. In my code, EntityType is an enum, and Entity is a Hibernate-mapped class.<br> in the Entity code, the mapping looks like this:</p> <pre><code>@CollectionOfElements @JoinTable( name = "ENTITY-ENTITY-TYPE", joinColumns = @JoinColumn(name = "ENTITY-ID") ) @Column(name="ENTITY-TYPE") public Set&lt;EntityType&gt; getEntityTypes() { return entityTypes; } </code></pre> <p>Oh, did I mention I'm using annotations?<br> Now, what I'd like to do is create an HQL query or search using a Criteria for all Entity objects of a specific entity type.<p> <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-869?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel" rel="nofollow noreferrer">This</a> page in the Hibernate forum says this is impossible, but then this page is 18 months old. Can anyone tell me if this feature has been implemented in one of the latest releases of Hibernate, or planned for the coming release?</p>
[ { "answer_id": 50402, "author": "Hank Gay", "author_id": 4203, "author_profile": "https://Stackoverflow.com/users/4203", "pm_score": 0, "selected": false, "text": "EntityType Entity entity.Name from EntityType where name = ?" }, { "answer_id": 53405, "author": "marcospereira", "author_id": 4600, "author_profile": "https://Stackoverflow.com/users/4600", "pm_score": 2, "selected": true, "text": "select entity from Entity entity where :type = some elements(entity.types)\n select entity from Entity entity where :type in(entity.types)\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2819/" ]
49,346
<p>Is it possible to prevent an asp.net Hyperlink control from linking, i.e. so that it appears as a label, without actually having to replace the control with a label? Maybe using CSS or setting an attribute?</p> <p>I know that marking it as disabled works but then it gets displayed differently (greyed out).</p> <p>To clarify my point, I have a list of user names at the top of my page which are built dynamically using a user control. Most of the time these names are linkable to an email page. However if the user has been disabled the name is displayed in grey but currently still links to the email page. I want these disabled users to not link.</p> <p>I know that really I should be replacing them with a label but this does not seem quite as elegant as just removing the linking ability usings CSS say (if thats possible). They are already displayed in a different colour so its obvious that they are disabled users. I just need to switch off the link.</p>
[ { "answer_id": 49358, "author": "Jon Limjap", "author_id": 372, "author_profile": "https://Stackoverflow.com/users/372", "pm_score": 2, "selected": false, "text": "a: link, visited, hover, active {\n text-decoration: none;\n}\n" }, { "answer_id": 49362, "author": "Slartibartfast", "author_id": 4433, "author_profile": "https://Stackoverflow.com/users/4433", "pm_score": 2, "selected": false, "text": "onclick=\"return false;\" \n a.dummy { \n cursor:default; \n} \n" }, { "answer_id": 49380, "author": "Radu094", "author_id": 3263, "author_profile": "https://Stackoverflow.com/users/3263", "pm_score": 2, "selected": false, "text": "protected override void Render(HtmlTextWriter writer)\n {\n if (Enabled)\n base.Render(writer);\n else\n {\n writer.RenderBeginTag(HtmlTextWriterTag.Span);\n writer.Write(Text);\n writer.RenderEndTag(HtmlTextWriterTag.Span);\n }\n }\n\n }\n" }, { "answer_id": 49381, "author": "NakedBrunch", "author_id": 3742, "author_profile": "https://Stackoverflow.com/users/3742", "pm_score": 4, "selected": true, "text": "$(document).ready(function() {\n $('a.NoLink').removeAttr('href')\n});\n" }, { "answer_id": 47924576, "author": "Hasan Ali", "author_id": 8744304, "author_profile": "https://Stackoverflow.com/users/8744304", "pm_score": 0, "selected": false, "text": ".avoid-clicks {\n pointer-events: none;\n}\n" }, { "answer_id": 70901572, "author": "Jay Irvine", "author_id": 4756306, "author_profile": "https://Stackoverflow.com/users/4756306", "pm_score": 0, "selected": false, "text": "a:not([href]), a:not([href]):hover, a:not([href]):active, a:not([href]):visited {\n text-decoration: inherit !important;\n color: inherit !important;\n cursor: inherit !important;\n}\n pointer-events:none a:disabled" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1127460/" ]
49,350
<p>What can be a practical solution to center vertically and horizontally content in HTML that works in Firefox, IE6 and IE7?</p> <p>Some details:</p> <ul> <li><p>I am looking for solution for the entire page.</p></li> <li><p>You need to specify only width of the element to be centered. Height of the element is not known in design time.</p></li> <li><p>When minimizing window, scrolling should appear only when all white space is gone. In other words, width of screen should be represented as: </p></li> </ul> <p>"leftSpace width=(screenWidth-widthOfCenteredElement)/2"+<br> "centeredElement width=widthOfCenteredElement"+<br> "rightSpace width=(screenWidth-widthOfCenteredElement)/2" </p> <p>And the same for the height:</p> <p>"topSpace height=(screenHeight-heightOfCenteredElement)/2"+<br> "centeredElement height=heightOfCenteredElement"+<br> "bottomSpace height=(screenWidth-heightOfCenteredElement)/2"</p> <ul> <li>By practical I mean that use of tables is OK. I intend to use this layout mostly for special pages like login. So CSS purity is not so important here, while following standards is desirable for future compatibility.</li> </ul>
[ { "answer_id": 49353, "author": "Oleksandr Yanovets", "author_id": 5139, "author_profile": "https://Stackoverflow.com/users/5139", "pm_score": 2, "selected": false, "text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <title>Centering</title>\n <style type=\"text/css\" media=\"screen\">\n body, html {height: 100%; padding: 0px; margin: 0px;}\n #outer {width: 100%; height: 100%; overflow: visible; padding: 0px; margin: 0px;}\n #middle {vertical-align: middle}\n #centered {width: 280px; margin-left: auto; margin-right: auto; text-align:center;}\n </style> \n</head>\n<body>\n <table id=\"outer\" cellpadding=\"0\" cellspacing=\"0\">\n <tr><td id=\"middle\">\n <div id=\"centered\" style=\"border: 1px solid green;\">\n Centered content\n </div>\n </td></tr>\n </table>\n</body>\n</html>\n" }, { "answer_id": 49759, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 1, "selected": false, "text": "<style>\nbody\n{\n text-align:left;\n}\n.MainBlockElement\n{\n text-align:center;\n margin: 0 auto;\n}\n</style>\n" }, { "answer_id": 288881, "author": "keikkeik", "author_id": 15193, "author_profile": "https://Stackoverflow.com/users/15193", "pm_score": 2, "selected": false, "text": "#horizon \n {\n text-align: center;\n position: absolute;\n top: 50%;\n left: 0px;\n width: 100%;\n height: 1px;\n overflow: visible;\n display: block\n }\n\n#content \n {\n width: 250px;\n height: 70px;\n margin-left: -125px;\n position: absolute;\n top: -35px;\n left: 50%;\n visibility: visible\n }\n\n<div id=\"horizon\">\n <div id=\"content\">\n <p>This text is<br><emphasis>DEAD CENTRE</emphasis ><br>and stays there!</p>\n </div><!-- closes content-->\n</div><!-- closes horizon-->\n" }, { "answer_id": 13010260, "author": "Saeed", "author_id": 1726377, "author_profile": "https://Stackoverflow.com/users/1726377", "pm_score": 1, "selected": false, "text": "#yourElement {\n margin:0 auto;\n min-width:500px;\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5139/" ]
49,356
<p>We have the standard Subversion trunk/branches/tags layout. We have several branches for medium- and long-term projects, but none so far for a release. This is approaching fast.</p> <p>Should we:</p> <ol> <li>Mix release branches and project branches together?</li> <li>Create a releases folder? If so, is there a better name than releases?</li> <li>Create a projects folder and move the current branches there? If so, is there a better name than projects? I've seen "sandbox" and "spike" in other repositories.</li> <li>Something else altogether?</li> </ol>
[ { "answer_id": 49366, "author": "Polsonby", "author_id": 137, "author_profile": "https://Stackoverflow.com/users/137", "pm_score": -1, "selected": false, "text": "trunk\n fooapp\n stuff...\n barapp\n stuff...\ntags\n fooapp\n 1.0.0\n 1.0.1\n barapp \n 1.0.0\n" }, { "answer_id": 49376, "author": "mpdaly", "author_id": 3984, "author_profile": "https://Stackoverflow.com/users/3984", "pm_score": 0, "selected": false, "text": "branches\n this-project\n that-project\n the-other-project\n 1.0\n 1.1\n 1.2\ntags\n 1.0.0\n 1.0.1\n 1.1.0\n 1.2.0\n 1.2.1\n" }, { "answer_id": 49390, "author": "Troels Arvin", "author_id": 4462, "author_profile": "https://Stackoverflow.com/users/4462", "pm_score": 3, "selected": false, "text": "project1\n trunk\n branches\n 1.0\n 1.1\n joes-experimental-feature-branch\n tags\n 1.0.0\n 1.0.1\n 1.0.2\nproject2\n trunk\n branches\n 1.0\n 1.1\n tags\n 1.0.0\n 1.0.1\n 1.0.2\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3984/" ]
49,368
<p><a href="http://www.w3.org/TR/REC-CSS2/selector.html#attribute-selectors" rel="noreferrer">CSS Attribute selectors</a> allow the selection of elements based on attribute values. Unfortunately, I've not used them in years (mainly because they're not supported by all modern browsers). However, I remember distinctly that I was able to use them to adorn all external links with an icon, by using a code similar to the following:</p> <pre><code>a[href=http] { background: url(external-uri); padding-left: 12px; } </code></pre> <p>The above code doesn't work. My question is: <strong>How does it work?</strong> How do I select all <code>&lt;a&gt;</code> tags whose <code>href</code> attribute starts with <code>"http"</code>? The official CSS spec (linked above) doesn't even mention that this is possible. But I do remember doing this.</p> <p>(<em>Note</em>: The obvious solution would be to use <code>class</code> attributes for distinction. I want to avoid this because I have little influence of the way the HTML code is built. All I can edit is the CSS code.)</p>
[ { "answer_id": 49373, "author": "Antti Kissaniemi", "author_id": 2948, "author_profile": "https://Stackoverflow.com/users/2948", "pm_score": 6, "selected": true, "text": "a[href^=http]\n{\n background: url(external-uri);\n padding-left: 12px;\n}\n" }, { "answer_id": 49462, "author": "Bobby Jack", "author_id": 5058, "author_profile": "https://Stackoverflow.com/users/5058", "pm_score": 2, "selected": false, "text": "a[href^=\"http://your.domain.com\"]\n{\n background: none;\n padding: 0;\n}\n a[href^=\"http://\"]\n{\n background: url(external-uri);\n padding-left: 12px;\n}\n" }, { "answer_id": 20713770, "author": "dcarps14", "author_id": 3006805, "author_profile": "https://Stackoverflow.com/users/3006805", "pm_score": 3, "selected": false, "text": "Attribute selectors may match in four ways:\n\n[att]\nMatch when the element sets the \"att\" attribute, whatever the value of the attribute.\n[att=val]\nMatch when the element's \"att\" attribute value is exactly \"val\".\n[att~=val]\nMatch when the element's \"att\" attribute value is a space-separated list of\n\"words\", one of which is exactly \"val\". If this selector is used, the words in the \nvalue must not contain spaces (since they are separated by spaces).\n[att|=val]\nMatch when the element's \"att\" attribute value is a hyphen-separated list of\n\"words\", beginning with \"val\". The match always starts at the beginning of the\nattribute value. This is primarily intended to allow language subcode matches\n(e.g., the \"lang\" attribute in HTML) as described in RFC 3066 ([RFC3066]).\n a[href^=http]:not([href*=\"yourdomain.com\"])\n{\n background: url(external-uri);\n padding-left: 12px;\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1968/" ]
49,379
<p>How do I lock compiled Java classes to prevent decompilation?</p> <p>I know this must be very well discussed topic on the Internet, but I could not come to any conclusion after referring them.</p> <p>Many people do suggest obfuscator, but they just do renaming of classes, methods, and fields with tough-to-remember character sequences but what about sensitive constant values?</p> <p>For example, you have developed the encryption and decryption component based on a password based encryption technique. Now in this case, any average Java person can use <a href="http://www.kpdus.com/jad.html" rel="noreferrer">JAD</a> to decompile the class file and easily retrieve the password value (defined as constant) as well as <a href="http://en.wikipedia.org/wiki/Salt_%28cryptography%29" rel="noreferrer">salt</a> and in turn can decrypt the data by writing small independent program!</p> <p>Or should such sensitive components be built in native code (for example, VC++) and call them via <a href="http://en.wikipedia.org/wiki/Java_Native_Interface" rel="noreferrer">JNI</a>?</p>
[ { "answer_id": 9598442, "author": "Yury Bendersky", "author_id": 1239661, "author_profile": "https://Stackoverflow.com/users/1239661", "pm_score": 2, "selected": false, "text": "ClassLoader.defineClass(...) ClassLoader defineClass(...) ClassLoader" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/959/" ]
49,382
<p>Are the naming conventions similar in different languages? If not, what are the differences?</p>
[ { "answer_id": 49530, "author": "Anders Sandvig", "author_id": 1709, "author_profile": "https://Stackoverflow.com/users/1709", "pm_score": 3, "selected": true, "text": "lowercase, lowercase_with_underscores UPPERCASE, UPPERCASE_WITH_UNDERSCORES: CamelCase, javaCamelCase: prefix_CamelCase, prefix_lowercase, prefix_lowercase_with_underscores:" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/184/" ]
49,402
<p>Imagine a DOS style .cmd file which is used to launch interdependent windowed applications in the right order.</p> <p>Example:<br> 1) Launch a server application by calling an exe with parameters.<br> 2) Wait for the server to become initialized (or a fixed amount of time).<br> 3) Launch client application by calling an exe with parameters.</p> <p>What is the simplest way of accomplishing this kind of batch job in PowerShell?</p>
[ { "answer_id": 49520, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 0, "selected": false, "text": "launch-server-application serverparam1 serverparam2 ...\nStart-Sleep -s 10\nlaunch-client-application clientparam1 clientparam2 clientparam3 ...\n launch-server-application $args[0] $args[1]\nStart-Sleep -s 10\nlaunch-client-application $args[2] $args[3] $args[4]\n 10" }, { "answer_id": 49540, "author": "Lars Truijens", "author_id": 1242, "author_profile": "https://Stackoverflow.com/users/1242", "pm_score": 4, "selected": true, "text": "$sp = get-process server-application\n$sp.WaitForInputIdle()\n $sp = [diagnostics.process]::start(\"server-application\", \"params\")\n$sp.WaitForInputIdle()\n$cp = [diagnostics.process]::start(\"client-application\", \"params\")\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49402", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5085/" ]
49,403
<p>I have a filename in a format like:</p> <blockquote> <p><code>system-source-yyyymmdd.dat</code></p> </blockquote> <p>I'd like to be able to parse out the different bits of the filename using the "-" as a delimiter.</p>
[ { "answer_id": 49406, "author": "David", "author_id": 381, "author_profile": "https://Stackoverflow.com/users/381", "pm_score": 3, "selected": false, "text": "cut echo \"system-source-yyyymmdd.dat\" | cut -f1 -d'-'\n -f" }, { "answer_id": 49409, "author": "Bobby Jack", "author_id": 5058, "author_profile": "https://Stackoverflow.com/users/5058", "pm_score": 6, "selected": true, "text": "$ echo \"system-source-yyyymmdd.dat\" | cut -d'-' -f2\nsource\n" }, { "answer_id": 49482, "author": "flight", "author_id": 3377, "author_profile": "https://Stackoverflow.com/users/3377", "pm_score": 3, "selected": false, "text": "# echo \"system-source-yyyymmdd.dat\" \\\n |awk -F- '{printf \"System: %s\\nSource: %s\\nYear: %s\\nMonth: %s\\nDay: %s\\n\",\n $1,$2,substr($3,1,4),substr($3,5,2),substr($3,7,2)}'\nSystem: system\nSource: source\nYear: yyyy\nMonth: mm\nDay: dd\n" }, { "answer_id": 481899, "author": "Colas Nahaboo", "author_id": 58468, "author_profile": "https://Stackoverflow.com/users/58468", "pm_score": 3, "selected": false, "text": "var='system-source-yyyymmdd.dat'\nparts=(${var//-/ })\n echo ${parts[0]} ==> system\necho ${parts[1]} ==> source\necho ${parts[2]} ==> yyyymmdd.dat\n" }, { "answer_id": 51213978, "author": "William Pursell", "author_id": 140750, "author_profile": "https://Stackoverflow.com/users/140750", "pm_score": 0, "selected": false, "text": "read $ IFS=-. read system source date ext << EOF\n> foo-bar-yyyymmdd.dat\n> EOF\n$ echo $system\nfoo\n$ echo $source $date $ext\nbar yyyymmdd dat\n bash$ IFS=-. read system source date ext <<< foo-bar-yyyymmdd.dat echo \"$name\" | { IFS=-. read system source date ext\n echo In all shells, the variables are set here...; }\necho but only in some shells do they retain their value here\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4003/" ]
49,404
<p>I have a table containing prices for a lot of different "things" in a MS SQL 2005 table. There are hundreds of records per thing per day and the different things gets price updates at different times.</p> <pre><code>ID uniqueidentifier not null, ThingID int NOT NULL, PriceDateTime datetime NOT NULL, Price decimal(18,4) NOT NULL </code></pre> <p>I need to get today's latest prices for a group of things. The below query works but I'm getting hundreds of rows back and I have to loop trough them and only extract the latest one per ThingID. How can I (e.g. via a GROUP BY) say that I want the latest one per ThingID? Or will I have to use subqueries?</p> <pre><code>SELECT * FROM Thing WHERE ThingID IN (1,2,3,4,5,6) AND PriceDate &gt; cast( convert(varchar(20), getdate(), 106) as DateTime) </code></pre> <p><strong>UPDATE:</strong> In an attempt to hide complexity I put the ID column in a an int. In real life it is GUID (and not the sequential kind). I have updated the table def above to use uniqueidentifier.</p>
[ { "answer_id": 49414, "author": "BlaM", "author_id": 999, "author_profile": "https://Stackoverflow.com/users/999", "pm_score": 5, "selected": true, "text": "SELECT *\n FROM Thing\n WHERE ID IN (SELECT max(ID) FROM Thing \n WHERE ThingID IN (1,2,3,4)\n GROUP BY ThingID)\n SELECT *\n FROM Thing\n WHERE ThingID IN (1,2,3,4)\n AND IsCurrent = 1\n SELECT T.* \n FROM Thing T\n JOIN (SELECT ThingID, max(PriceDateTime)\n WHERE ThingID IN (1,2,3,4)\n GROUP BY ThingID) X ON X.ThingID = T.ThingID \n AND X.PriceDateTime = T.PriceDateTime\n WHERE ThingID IN (1,2,3,4)\n" }, { "answer_id": 49424, "author": "Mark Nold", "author_id": 4134, "author_profile": "https://Stackoverflow.com/users/4134", "pm_score": 2, "selected": false, "text": "SELECT\n *\nFROM\n Thing\nWHERE \n (ThingID, PriceDateTime) IN \n (SELECT \n ThingID, \n max(PriceDateTime ) \n FROM \n Thing \n WHERE \n ThingID IN (1,2,3,4)\n GROUP BY \n ThingID\n )\n SELECT\n p.*\nFROM\n Thing p,\n (SELECT ThingID, max(PriceDateTime ) FROM Thing WHERE ThingID IN (1,2,3,4) GROUP BY ThingID) m\nWHERE \n p.ThingId = m.ThingId\n and p.PriceDateTime = m.PriceDateTime\n" }, { "answer_id": 49427, "author": "Nick Pierpoint", "author_id": 4003, "author_profile": "https://Stackoverflow.com/users/4003", "pm_score": 2, "selected": false, "text": "ThingID int not null,\nUpdateID int not null,\nPriceDateTime datetime not null,\nPrice decimal(18,4) not null\n" }, { "answer_id": 49446, "author": "BirgerH", "author_id": 5164, "author_profile": "https://Stackoverflow.com/users/5164", "pm_score": 1, "selected": false, "text": "SELECT * FROM Thing WHERE CONVERT(BINARY(16),Thing.ID) IN\n(\n SELECT MAX(CONVERT(BINARY(16),Thing.ID))\n FROM Thing\n INNER JOIN\n (SELECT ThingID, MAX(PriceDateTime) LatestPriceDateTime FROM Thing\n WHERE PriceDateTime >= CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)\n GROUP BY ThingID) LatestPrices\n ON Thing.ThingID = LatestPrices.ThingID\n AND Thing.PriceDateTime = LatestPrices.LatestPriceDateTime\n GROUP BY Thing.ThingID, Thing.PriceDateTime\n) AND Thing.ThingID IN (1,2,3,4,5,6)\n" }, { "answer_id": 49527, "author": "Peter", "author_id": 5189, "author_profile": "https://Stackoverflow.com/users/5189", "pm_score": 1, "selected": false, "text": "SELECT * \nFROM Thing thi\nWHERE thi.ThingID IN (1,2,3,4,5,6)\n AND thi.PriceDateTime =\n (SELECT MAX(maxThi.PriceDateTime)\n FROM Thing maxThi\n WHERE maxThi.PriceDateTime >= CAST( CONVERT(varchar(20), GETDATE(), 106) AS DateTime)\n AND maxThi.ThingID = thi.ThingID)\n" }, { "answer_id": 49528, "author": "Pop Catalin", "author_id": 4685, "author_profile": "https://Stackoverflow.com/users/4685", "pm_score": 2, "selected": false, "text": "CREATE FUNCTION dbo.fn_GetTopThings(@ThingID AS GUID, @n AS INT)\n RETURNS TABLE\nAS\nRETURN\n SELECT TOP(@n) *\n FROM Things\n WHERE ThingID= @ThingID\n ORDER BY PriceDateTime DESC\nGO\n SELECT *\n FROM Thing t\nCROSS APPLY dbo.fn_GetTopThings(t.ThingID, 1)\nWHERE t.ThingID IN (1,2,3,4,5,6)\n" }, { "answer_id": 49543, "author": "MobyDX", "author_id": 3923, "author_profile": "https://Stackoverflow.com/users/3923", "pm_score": 0, "selected": false, "text": "SELECT ThingID, (SELECT TOP 1 Price FROM Thing WHERE ThingID = T.ThingID ORDER BY PriceDateTime DESC) Price\nFROM Thing T\nWHERE ThingID IN (1,2,3,4) AND DATEDIFF(D, PriceDateTime, GETDATE()) = 0\nGROUP BY ThingID\n" }, { "answer_id": 17063932, "author": "Novalis", "author_id": 2478038, "author_profile": "https://Stackoverflow.com/users/2478038", "pm_score": -1, "selected": false, "text": "SELECT ID, ThingID, max(PriceDateTime), Price \n FROM Thing GROUP BY ThingID" }, { "answer_id": 17277562, "author": "30thh", "author_id": 608164, "author_profile": "https://Stackoverflow.com/users/608164", "pm_score": 1, "selected": false, "text": "SELECT t1.*, t2.PriceDateTime AS bigger FROM Prices t1 \nLEFT JOIN Prices t2 ON t1.ThingID = t2.ThingID AND t1.PriceDateTime < t2.PriceDateTime \nHAVING t2.PriceDateTime IS NULL\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1008/" ]
49,426
<p>Take a .Net Winforms App.. mix in a flakey wireless network connection, stir with a few users who like to simply pull the blue plug out occasionally and for good measure, add a Systems Admin that decides to reboot the SQL server box without warning now and again just to keep everyone on their toes.</p> <p>What are the suggestions and strategies for handling this sort of scenario in respect to :</p> <ul> <li><p>Error Handling - for example, do you wrap every call to the server with a Try/Catch or do you rely on some form of Generic Error Handling to manage this? If so what does it look like?</p></li> <li><p>Application Management - for example, do you disable the app and not allow users to interact with it until a connection is detected again? What would you do?</p></li> </ul>
[ { "answer_id": 49433, "author": "Simon Keep", "author_id": 1127460, "author_profile": "https://Stackoverflow.com/users/1127460", "pm_score": 1, "selected": false, "text": "Main() Application.ThreadException += new \nSystem.Threading.ThreadExceptionEventHandler(UnhandledExceptionCatcher);\n\nThread.GetDomain().UnhandledException += new \nUnhandledExceptionEventHandler(Application_UnhandledException);\n Application_UnhandledException UnhandledExceptionCatcher" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49426", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3849/" ]
49,430
<p>I have just started working with the <code>AnimationExtender</code>. I am using it to show a new div with a list gathered from a database when a button is pressed. The problem is the button needs to do a postback to get this list as I don't want to make the call to the database unless it's needed. The postback however stops the animation mid flow and resets it. The button is within an update panel.</p> <p>Ideally I would want the animation to start once the postback is complete and the list has been gathered. I have looked into using the <code>ScriptManager</code> to detect when the postback is complete and have made some progress. I have added two javascript methods to the page.</p> <pre><code>function linkPostback() { var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_endRequest(playAnimation) } function playAnimation() { var onclkBehavior = $find("ctl00_btnOpenList").get_OnClickBehavior().get_animation(); onclkBehavior.play(); } </code></pre> <p>And I’ve changed the <code>btnOpenList.OnClientClick=”linkPostback();”</code></p> <p>This almost solves the problem. I’m still get some animation stutter. The animation starts to play before the postback and then plays properly after postback. Using the <code>onclkBehavior.pause()</code> has no effect. I can get around this by setting the <code>AnimationExtender.Enabled = false</code> and setting it to true in the buttons postback event. This however works only once as now the AnimationExtender is enabled again. I have also tried disabling the <code>AnimationExtender</code> via javascript but this has no effect.</p> <p>Is there a way of playing the animations only via javascript calls? I need to decouple the automatic link to the buttons click event so I can control when the animation is fired.</p> <p>Hope that makes sense.</p> <p>Thanks</p> <p>DG</p>
[ { "answer_id": 57774, "author": "Andrew Johnson", "author_id": 5109, "author_profile": "https://Stackoverflow.com/users/5109", "pm_score": 2, "selected": true, "text": "function linkPostback() {\n\n var prm = Sys.WebForms.PageRequestManager.getInstance();\n prm.add_endRequest(playAnimation)\n}\n\nfunction playAnimation() {\n\n AnimationExtender.Enabled = true;\n var onclkBehavior = $find(\"ctl00_btnOpenList\").get_OnClickBehavior().get_animation();\n onclkBehavior.play();\n AnimationExtender.Enabled = false;\n}\n" }, { "answer_id": 84844, "author": "Magpie", "author_id": 5170, "author_profile": "https://Stackoverflow.com/users/5170", "pm_score": 0, "selected": false, "text": "<input id=\"btnHdn\" runat=\"server\" type=\"button\" value=\"button\" style=\"display:none;\" />\n <cc1:AnimationExtender ID=\"aniExt\" runat=\"server\" TargetControlID=\"btnHdn\">\n <asp:ImageButton ID=\"btnShowList\" runat=\"server\" OnClick=\"btnShowList_Click\" OnClientClick=\"linkPostback();\" />\n function linkPostback() {\n var prm = Sys.WebForms.PageRequestManager.getInstance();\n prm.add_endRequest(playOpenAnimation)\n}\n\nfunction playOpenAnimation() {\n var onclkBehavior = ind(\"ctl00_aniExt\").get_OnClickBehavior().get_animation();\n onclkBehavior.play(); \n\n var prm = Sys.WebForms.PageRequestManager.getInstance();\n prm.remove_endRequest(playOpenAnimation) \n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5170/" ]
49,442
<p>When do you recommend integrating a custom view into Interface Builder with a plug-in? When skimming through Apple's <a href="http://developer.apple.com/documentation/DeveloperTools/Conceptual/IBPlugInGuide/CreatingPluginBundle/chapter_2_section_3.html#//apple_ref/doc/uid/TP40004323-CH4-DontLinkElementID_15" rel="noreferrer" title="Interface Builder Plug-In Programming Guide">Interface Builder Plug-In Programming Guide</a> I found:</p> <blockquote> <ul> <li>Are your custom objects going to be used by only one application?</li> <li>Do your custom objects rely on state information found only in your application?</li> <li>Would it be problematic to encapsulate your custom views in a standalone library or framework?</li> </ul> <p>If you answered yes to any of the preceding questions, your objects may not be good candidates for a plug-in.</p> </blockquote> <p>That answers some of my questions, but I would still like your thoughts on when it's a good idea. What are the benefits and how big of a time investment is it?</p>
[ { "answer_id": 89185, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 4, "selected": true, "text": "-awakeFromNib" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49442", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5156/" ]
49,445
<p>I have a WCF service which includes UI components, which forces me to be in STA mode.</p> <p>How do I set the service behaviour to STA-mode?</p> <hr> <p>The service uses a reference to a WPF DLL file which opens a UI window (used as view port) for picture analysis. When the service is trying to create an instance of that item (inherits from window) it throws an exception:</p> <blockquote> <p>The calling thread must be an STA</p> </blockquote>
[ { "answer_id": 49448, "author": "John Sibly", "author_id": 1078, "author_profile": "https://Stackoverflow.com/users/1078", "pm_score": 0, "selected": false, "text": "[STAThread]\nstatic void Main()\n{\n ServiceBase[] ServicesToRun;\n ServicesToRun = new ServiceBase[] { new Host() };\n ServiceBase.Run(ServicesToRun);\n}\n" }, { "answer_id": 37119709, "author": "Matas Vaitkevicius", "author_id": 1509764, "author_profile": "https://Stackoverflow.com/users/1509764", "pm_score": 0, "selected": false, "text": "[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.PerCall)]\npublic class Service : IService\n{\n}\n InstanceContextMode app.config <behavior name=\"wsSingleThreadServiceBehavior\">\n <serviceThrottling maxConcurrentCalls=\"1\"/>\n </behavior>\n app.config <service behaviorConfiguration=\"wsSingleThreadServiceBehavior\" name=\"IService\">\n <endpoint address=\"\" binding=\"wsHttpBinding\" bindingConfiguration=\"wsEndpointBinding\" name=\"ConveyancingEndpoint\" contract=\"IService\" />\n </service>\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
49,450
<p>I'm just about wrapped up on a project where I was using a commercial SVN provider to store the source code. The web host the customer ultimately picked includes a repository as part of the hosting package, so, now that the project is over, I'd like to relocate the repository to their web host and discontinue the commercial account.</p> <p>How would I go about doing this?</p>
[ { "answer_id": 49468, "author": "pilif", "author_id": 5083, "author_profile": "https://Stackoverflow.com/users/5083", "pm_score": 3, "selected": false, "text": "svnadmin dump\n" }, { "answer_id": 49483, "author": "Tadmas", "author_id": 3750, "author_profile": "https://Stackoverflow.com/users/3750", "pm_score": 7, "selected": true, "text": "svnadmin dump svnadmin load svnadmin load --force-uuid" }, { "answer_id": 49493, "author": "pirho", "author_id": 3911, "author_profile": "https://Stackoverflow.com/users/3911", "pm_score": 2, "selected": false, "text": "svnadmin hotcopy svnadmin hotcopy OLD_REPOS_PATH NEW_REPOS_PATH\n" }, { "answer_id": 49501, "author": "Gishu", "author_id": 1695, "author_profile": "https://Stackoverflow.com/users/1695", "pm_score": 3, "selected": false, "text": "svnadmin dump /path/to/your/old/repo > backup.dump\nsvnadmin load /path/to/your/new/repo < backup.dump.dmp\n svnadmin dump C:\\path\\to\\your\\old\\repo > backup.dump\nsvnadmin load C:\\path\\to\\your\\old\\repo < backup.dump\n" }, { "answer_id": 5346380, "author": "tkdave", "author_id": 311432, "author_profile": "https://Stackoverflow.com/users/311432", "pm_score": 5, "selected": false, "text": "rsvndump sudo apt-get install apache2-threaded-dev\nsudo apt-get install libsvn-dev\n wget http://prdownloads.sourceforge.net/rsvndump/rsvndump-0.5.5.tar.gz\ntar xvfz rsvndump-0.5.5.tar.gz\ncd rsvndump-0.5.5\n./configure\nmake\nsudo make install\n rsvndump http://my.svnrepository.com/svn/old_repo > old_repo_dump\n sudo svnadmin create /opt/subversion/my_new_rep\nsudo svnadmin load --force-uuid /opt/subversion/my_new_repo < old_repo_dump\n" }, { "answer_id": 18648699, "author": "Braiam", "author_id": 792066, "author_profile": "https://Stackoverflow.com/users/792066", "pm_score": 2, "selected": false, "text": "mkdir ~/repo\nMYREPO=/home/me/someplace ## you should use full path here\n svnadmin create $MYREPO echo '#!/bin/sh' > $MYREPO/hooks/pre-revprop-change\nchmod +x $MYREPO/hooks/pre-revprop-change\n svnsync svnsync init file://$MYREPO http://your.svn.repo.here/\n svnsync sync file://$MYREPO\n ~/repo" }, { "answer_id": 20395184, "author": "bahrep", "author_id": 761095, "author_profile": "https://Stackoverflow.com/users/761095", "pm_score": 2, "selected": false, "text": "svnadmin dump svnadmin load svnadmin create svnrdump svnadmin dump svnadmin load svnadmin hotcopy" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1344/" ]
49,458
<p>We have an application that has to be flexible in how it displays it's main form to the user - depending on the user, the form should be slightly different, maybe an extra button here or there, or some other nuance. In order to stop writing code to explicitly remove or add controls etc, I turned to visual inheritance to solve the problem - in what I thought was a neat, clean and logical OO style - turns out that half the time inherited forms have a hard time rendering themeselves in VS for no good reason etc - and I get the feeling that developers and to some extent Microsoft have shunned the practice of Visual Inheritance - can you confirm this, am I missing something here?</p> <p>Regards.</p>
[ { "answer_id": 49554, "author": "Mendelt", "author_id": 3320, "author_profile": "https://Stackoverflow.com/users/3320", "pm_score": 2, "selected": false, "text": "public class MyForm<MyObject> : Form\n" }, { "answer_id": 258868, "author": "Tigraine", "author_id": 21699, "author_profile": "https://Stackoverflow.com/users/21699", "pm_score": 1, "selected": false, "text": "public ProductDetail()\n{\n InitializeComponent();\n}\n\npublic ProductDetail(ISupplierController supplierController) : base()\n{\n InitializeComponent();\n this.supplierController = supplierController;\n}\n public NewProduct(ISupplierController supplierController)\n : base(supplierController)\n{\n InitializeComponent();\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5175/" ]
49,461
<p>Is there a C# equivalent for the VB.NET <code>FormatNumber</code> function? </p> <p>I.e.:</p> <pre><code>JSArrayString += "^" + (String)FormatNumber(inv.RRP * oCountry.ExchangeRate, 2); </code></pre>
[ { "answer_id": 49476, "author": "d91-jal", "author_id": 5085, "author_profile": "https://Stackoverflow.com/users/5085", "pm_score": 1, "selected": false, "text": "double MyNumber = inv.RRP * oCountry.ExchangeRate;\nJSArrayString += \"^\" + MyNumber.ToString(\"#0.00\");\n" }, { "answer_id": 49479, "author": "John", "author_id": 33, "author_profile": "https://Stackoverflow.com/users/33", "pm_score": 4, "selected": true, "text": "JSArrayString += \"^\" + (inv.RRP * oCountry.ExchangeRate).ToString(\"#0.00\")\n JSArrayString = String.Format(\"{0}^{1:#0.00}\",JSArrayString,(inv.RRP * oCountry.ExchangeRate))\n" }, { "answer_id": 49486, "author": "DonkeyMaster", "author_id": 5178, "author_profile": "https://Stackoverflow.com/users/5178", "pm_score": 2, "selected": false, "text": "int number = 32;\nstring formatted = number.ToString(\"D4\");\nConsole.WriteLine(formatted);\n// Shows 0032\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1583/" ]
49,473
<p>Is <a href="http://bouncycastle.org/java.html" rel="nofollow noreferrer">Bouncy Castle API</a> Thread Safe ? Especially,</p> <pre><code>org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher org.bouncycastle.crypto.paddings.PKCS7Padding org.bouncycastle.crypto.engines.AESFastEngine org.bouncycastle.crypto.modes.CBCBlockCipher </code></pre> <p>I am planning to write a singleton Spring bean for basic level cryptography support in my app. Since it is a web application, there are greater chances of multiple threads accessing this component at a time. So tread safety is essential here.</p> <p>Please let me know if you have come across such situations using Bouncy Castle.</p>
[ { "answer_id": 49498, "author": "Tnilsson", "author_id": 4165, "author_profile": "https://Stackoverflow.com/users/4165", "pm_score": 5, "selected": true, "text": "E(X) = Enctrypt message X\nD(X) = Dectrypt X. (Note that D(E(X)) = X)\nIV = Initialization vector. A random sequence to bootstrap the CBC algorithm\nCBC = Cipher block chaining.\n 1. Generate an IV, just random bits.\n2. Calculate E( P1 xor IV) call this C1\n3. Calculate E( P2 xor C1) call this C2\n4. Calculate E( P3 xor C2) call this C3.\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/959/" ]
49,478
<p>Which files should I include in <code>.gitignore</code> when using <em>Git</em> in conjunction with <em>Xcode</em>?</p>
[ { "answer_id": 49488, "author": "Hagelin", "author_id": 5156, "author_profile": "https://Stackoverflow.com/users/5156", "pm_score": 8, "selected": false, "text": ".DS_Store\n*.swp\n*~.nib\n\nbuild/\n\n*.pbxuser\n*.perspective\n*.perspectivev3\n *.mode1v3\n*.mode2v3\n xcuserdata\n" }, { "answer_id": 50283, "author": "Dave Verwer", "author_id": 4496, "author_profile": "https://Stackoverflow.com/users/4496", "pm_score": 3, "selected": false, "text": ".DS_Store\n*.mode1v3\n*.pbxuser\n*.perspectivev3\n*.tm_build_errors\n" }, { "answer_id": 349129, "author": "Abizern", "author_id": 41116, "author_profile": "https://Stackoverflow.com/users/41116", "pm_score": 6, "selected": false, "text": "# Mac OS X\n*.DS_Store\n\n# Xcode\n*.pbxuser\n*.mode1v3\n*.mode2v3\n*.perspectivev3\n*.xcuserstate\nproject.xcworkspace/\nxcuserdata/\n\n# Generated files\n*.o\n*.pyc\n\n\n#Python modules\nMANIFEST\ndist/\nbuild/\n\n# Backup files\n*~.nib\n" }, { "answer_id": 3924579, "author": "Vladimir Mitrovic", "author_id": 281119, "author_profile": "https://Stackoverflow.com/users/281119", "pm_score": 6, "selected": false, "text": "YourProjectName.xcodeproj/xcuserdata/*\nYourProjectName.xcodeproj/project.xcworkspace/xcuserdata/*\n" }, { "answer_id": 12021580, "author": "Adam", "author_id": 153422, "author_profile": "https://Stackoverflow.com/users/153422", "pm_score": 10, "selected": true, "text": "#########################\n# .gitignore file for Xcode4 and Xcode5 Source projects\n#\n# Apple bugs, waiting for Apple to fix/respond:\n#\n# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?\n#\n# Version 2.6\n# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects\n#\n# 2015 updates:\n# - Fixed typo in \"xccheckout\" line - thanks to @lyck for pointing it out!\n# - Fixed the .idea optional ignore. Thanks to @hashier for pointing this out\n# - Finally added \"xccheckout\" to the ignore. Apple still refuses to answer support requests about this, but in practice it seems you should ignore it.\n# - minor tweaks from Jona and Coeur (slightly more precise xc* filtering/names)\n# 2014 updates:\n# - appended non-standard items DISABLED by default (uncomment if you use those tools)\n# - removed the edit that an SO.com moderator made without bothering to ask me\n# - researched CocoaPods .lock more carefully, thanks to Gokhan Celiker\n# 2013 updates:\n# - fixed the broken \"save personal Schemes\"\n# - added line-by-line explanations for EVERYTHING (some were missing)\n#\n# NB: if you are storing \"built\" products, this WILL NOT WORK,\n# and you should use a different .gitignore (or none at all)\n# This file is for SOURCE projects, where there are many extra\n# files that we want to exclude\n#\n#########################\n\n#####\n# OS X temporary files that should never be committed\n#\n# c.f. http://www.westwind.com/reference/os-x/invisibles.html\n\n.DS_Store\n\n# c.f. http://www.westwind.com/reference/os-x/invisibles.html\n\n.Trashes\n\n# c.f. http://www.westwind.com/reference/os-x/invisibles.html\n\n*.swp\n\n#\n# *.lock - this is used and abused by many editors for many different things.\n# For the main ones I use (e.g. Eclipse), it should be excluded\n# from source-control, but YMMV.\n# (lock files are usually local-only file-synchronization on the local FS that should NOT go in git)\n# c.f. the \"OPTIONAL\" section at bottom though, for tool-specific variations!\n#\n# In particular, if you're using CocoaPods, you'll want to comment-out this line:\n*.lock\n\n\n#\n# profile - REMOVED temporarily (on double-checking, I can't find it in OS X docs?)\n#profile\n\n\n####\n# Xcode temporary files that should never be committed\n# \n# NB: NIB/XIB files still exist even on Storyboard projects, so we want this...\n\n*~.nib\n\n\n####\n# Xcode build files -\n#\n# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named \"DerivedData\"\n\nDerivedData/\n\n# NB: slash on the end, so we only remove the FOLDER, not any files that were badly named \"build\"\n\nbuild/\n\n\n#####\n# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups)\n#\n# This is complicated:\n#\n# SOMETIMES you need to put this file in version control.\n# Apple designed it poorly - if you use \"custom executables\", they are\n# saved in this file.\n# 99% of projects do NOT use those, so they do NOT want to version control this file.\n# ..but if you're in the 1%, comment out the line \"*.pbxuser\"\n\n# .pbxuser: http://lists.apple.com/archives/xcode-users/2004/Jan/msg00193.html\n\n*.pbxuser\n\n# .mode1v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html\n\n*.mode1v3\n\n# .mode2v3: http://lists.apple.com/archives/xcode-users/2007/Oct/msg00465.html\n\n*.mode2v3\n\n# .perspectivev3: http://stackoverflow.com/questions/5223297/xcode-projects-what-is-a-perspectivev3-file\n\n*.perspectivev3\n\n# NB: also, whitelist the default ones, some projects need to use these\n!default.pbxuser\n!default.mode1v3\n!default.mode2v3\n!default.perspectivev3\n\n\n####\n# Xcode 4 - semi-personal settings\n#\n# Apple Shared data that Apple put in the wrong folder\n# c.f. http://stackoverflow.com/a/19260712/153422\n# FROM ANSWER: Apple says \"don't ignore it\"\n# FROM COMMENTS: Apple is wrong; Apple code is too buggy to trust; there are no known negative side-effects to ignoring Apple's unofficial advice and instead doing the thing that actively fixes bugs in Xcode\n# Up to you, but ... current advice: ignore it.\n*.xccheckout\n\n#\n#\n# OPTION 1: ---------------------------------\n# throw away ALL personal settings (including custom schemes!\n# - unless they are \"shared\")\n# As per build/ and DerivedData/, this ought to have a trailing slash\n#\n# NB: this is exclusive with OPTION 2 below\nxcuserdata/\n\n# OPTION 2: ---------------------------------\n# get rid of ALL personal settings, but KEEP SOME OF THEM\n# - NB: you must manually uncomment the bits you want to keep\n#\n# NB: this *requires* git v1.8.2 or above; you may need to upgrade to latest OS X,\n# or manually install git over the top of the OS X version\n# NB: this is exclusive with OPTION 1 above\n#\n#xcuserdata/**/*\n\n# (requires option 2 above): Personal Schemes\n#\n#!xcuserdata/**/xcschemes/*\n\n####\n# Xcode 4 workspaces - more detailed\n#\n# Workspaces are important! They are a core feature of Xcode - don't exclude them :)\n#\n# Workspace layout is quite spammy. For reference:\n#\n# /(root)/\n# /(project-name).xcodeproj/\n# project.pbxproj\n# /project.xcworkspace/\n# contents.xcworkspacedata\n# /xcuserdata/\n# /(your name)/xcuserdatad/\n# UserInterfaceState.xcuserstate\n# /xcshareddata/\n# /xcschemes/\n# (shared scheme name).xcscheme\n# /xcuserdata/\n# /(your name)/xcuserdatad/\n# (private scheme).xcscheme\n# xcschememanagement.plist\n#\n#\n\n####\n# Xcode 4 - Deprecated classes\n#\n# Allegedly, if you manually \"deprecate\" your classes, they get moved here.\n#\n# We're using source-control, so this is a \"feature\" that we do not want!\n\n*.moved-aside\n\n####\n# OPTIONAL: Some well-known tools that people use side-by-side with Xcode / iOS development\n#\n# NB: I'd rather not include these here, but gitignore's design is weak and doesn't allow\n# modular gitignore: you have to put EVERYTHING in one file.\n#\n# COCOAPODS:\n#\n# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#what-is-a-podfilelock\n# c.f. http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control\n#\n#!Podfile.lock\n#\n# RUBY:\n#\n# c.f. http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/\n#\n#!Gemfile.lock\n#\n# IDEA:\n#\n# c.f. https://www.jetbrains.com/objc/help/managing-projects-under-version-control.html?search=workspace.xml\n# \n#.idea/workspace.xml\n#\n# TEXTMATE:\n#\n# -- UNVERIFIED: c.f. http://stackoverflow.com/a/50283/153422\n#\n#tm_build_errors\n\n####\n# UNKNOWN: recommended by others, but I can't discover what these files are\n#\n" }, { "answer_id": 12591443, "author": "user1524957", "author_id": 1524957, "author_profile": "https://Stackoverflow.com/users/1524957", "pm_score": 2, "selected": false, "text": "xcuserstate\nxcsettings\n git rm --cached UserInterfaceState.xcuserstate WorkspaceSettings.xcsettings\n <my_project_name>/<my_project_name>.xcodeproj/project.xcworkspace/xcuserdata/<my_user_name>.xcuserdatad/\n" }, { "answer_id": 16062099, "author": "Wanbok Choi", "author_id": 1602311, "author_profile": "https://Stackoverflow.com/users/1602311", "pm_score": 4, "selected": false, "text": ".idea/ .gitignore ####\n# AppCode\n.idea/\n" }, { "answer_id": 19397066, "author": "Wanbok Choi", "author_id": 1602311, "author_profile": "https://Stackoverflow.com/users/1602311", "pm_score": 3, "selected": false, "text": "####\n# Xcode 5 - VCS metadata\n#\n*.xccheckout\n" }, { "answer_id": 26034755, "author": "onmyway133", "author_id": 1418457, "author_profile": "https://Stackoverflow.com/users/1418457", "pm_score": 4, "selected": false, "text": ".gitignore # Xcode\n.DS_Store\n*/build/*\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata\nprofile\n*.moved-aside\nDerivedData\n.idea/\n*.hmap\n*.xccheckout\n*.xcworkspace\n!default.xcworkspace\n\n#CocoaPods\nPods\n" }, { "answer_id": 26615020, "author": "funroll", "author_id": 878969, "author_profile": "https://Stackoverflow.com/users/878969", "pm_score": 2, "selected": false, "text": ".gitignore" }, { "answer_id": 31962296, "author": "joserock85", "author_id": 2315658, "author_profile": "https://Stackoverflow.com/users/2315658", "pm_score": 2, "selected": false, "text": "### Xcode ###\nbuild/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata\n*.xccheckout\n*.moved-aside\nDerivedData\n*.xcuserstate\n\n\n### Objective-C ###\n# Xcode\n#\nbuild/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata\n*.xccheckout\n*.moved-aside\nDerivedData\n*.hmap\n*.ipa\n*.xcuserstate\n\n# CocoaPods\n#\n# We recommend against adding the Pods directory to your .gitignore. However\n# you should judge for yourself, the pros and cons are mentioned at:\n# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control\n#\nPods/\n" }, { "answer_id": 33688681, "author": "swiftBoy", "author_id": 1371853, "author_profile": "https://Stackoverflow.com/users/1371853", "pm_score": 4, "selected": false, "text": "# file\n\n#########################################################################\n# #\n# Title - .gitignore file #\n# For - Mac OS X, Xcode 7 and Swift Source projects #\n# Updated by - Ramdhan Choudhary #\n# Updated on - 13 - November - 2015 #\n# #\n#########################################################################\n\n########### Xcode ###########\n# Xcode temporary files that should never be committed\n\n## Build generated\nbuild/\nDerivedData\n\n# NB: NIB/XIB files still exist even on Storyboard projects, so we want this\n*~.nib\n*.swp\n\n## Various settings\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata\n\n## Other\n*.xccheckout\n*.moved-aside\n*.xcuserstate\n*.xcscmblueprint\n*.xcscheme\n\n########### Mac OS X ###########\n# Mac OS X temporary files that should never be committed\n\n.DS_Store\n.AppleDouble\n.LSOverride\n\n# Icon must end with two \\r\nIcon\n\n\n# Thumbnails\n._*\n\n# Files that might appear in the root of a volume\n.DocumentRevisions-V100\n.fseventsd\n.Spotlight-V100\n.TemporaryItems\n.Trashes\n.VolumeIcon.icns\n\n# Directories potentially created on remote AFP share\n.AppleDB\n.AppleDesktop\nNetwork Trash Folder\nTemporary Items\n.apdisk\n\n########## Objective-C/Swift specific ##########\n*.hmap\n*.ipa\n\n# CocoaPods\n#\n# We recommend against adding the Pods directory to your .gitignore. However\n# you should judge for yourself, the pros and cons are mentioned at:\n# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control\n#\n# Pods/\n\n# Carthage\n#\n# Add this line if you want to avoid checking in source code from Carthage dependencies.\n# Carthage/Checkouts\n\nCarthage/Build\n\n# fastlane\n#\n# It is recommended to not store the screenshots in the Git repository. Instead, use fastlane to re-generate the\n\nfastlane/report.xml\nfastlane/screenshots\n" }, { "answer_id": 48268216, "author": "damianesteban", "author_id": 2945764, "author_profile": "https://Stackoverflow.com/users/2945764", "pm_score": 0, "selected": false, "text": ".gitignore $ joe g osx,xcode > .gitignore .gitignore .DS_Store\n.AppleDouble\n.LSOverride\n\nIcon\n._*\n\n.DocumentRevisions-V100\n.fseventsd\n.Spotlight-V100\n.TemporaryItems\n.Trashes\n.VolumeIcon.icns\n\n.AppleDB\n.AppleDesktop\nNetwork Trash Folder\nTemporary Items\n.apdisk\n\nbuild/\nDerivedData\n\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata\n\n*.xccheckout\n*.moved-aside\n*.xcuserstate\n" }, { "answer_id": 51133984, "author": "Rahul Singha Roy", "author_id": 9557153, "author_profile": "https://Stackoverflow.com/users/9557153", "pm_score": -1, "selected": false, "text": ".DS_Store\n.DS_Store?\n._*\n.Spotlight-V100\n.Trashes\nIcon?\nehthumbs.db\nThumbs.db\nbuild/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\n!default.xcworkspace\nxcuserdata\nprofile\n*.moved-aside\nDerivedData\n.idea/\n" }, { "answer_id": 53515016, "author": "BB9z", "author_id": 945906, "author_profile": "https://Stackoverflow.com/users/945906", "pm_score": 3, "selected": false, "text": "# Xcode Project\n**/*.xcodeproj/xcuserdata/\n**/*.xcworkspace/xcuserdata/\n**/.swiftpm/xcode/xcuserdata/\n**/*.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist\n**/*.xcworkspace/xcshareddata/*.xccheckout\n**/*.xcworkspace/xcshareddata/*.xcscmblueprint\n**/*.playground/**/timeline.xctimeline\n.idea/\n\n# Build\nScripts/build/\nbuild/\nDerivedData/\n*.ipa\n\n# Carthage\nCarthage/\n\n# CocoaPods\nPods/\n\n# fastlane\nfastlane/report.xml\nfastlane/Preview.html\nfastlane/screenshots\nfastlane/test_output\nfastlane/sign&cert\n\n# CSV\n*.orig\n.svn\n\n# Other\n*~\n.DS_Store\n*.swp\n*.save\n._*\n*.bak\n" }, { "answer_id": 65613459, "author": "jqgsninimo", "author_id": 1260976, "author_profile": "https://Stackoverflow.com/users/1260976", "pm_score": 2, "selected": false, "text": "macOS Objective-C Swift SwiftPackageManager Carthage git config --global alias.ignore '!gi() { curl -L -s https://www.gitignore.io/api/$@ ;}; gi'\n cd <the project directory>\n git ignore macOS,Objective-C,Swift,SwiftPackageManager,Carthage >.gitignore\n git add .gitignore\ngit commit -m \"Add .gitignore file\"\n" }, { "answer_id": 70019630, "author": "Alwin Jose", "author_id": 11844048, "author_profile": "https://Stackoverflow.com/users/11844048", "pm_score": 0, "selected": false, "text": "npx gitignore Objective-C\n" }, { "answer_id": 74349469, "author": "Ozgur Sahin", "author_id": 4156490, "author_profile": "https://Stackoverflow.com/users/4156490", "pm_score": 0, "selected": false, "text": "git ignore swift,ios >.gitignore\n git ignore swift,macos >.gitignore\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5156/" ]
49,500
<p>I'm trying to redirect requests for a wildcard domain to a sub-directory.<br /> ie. <code>something.blah.example.com</code> --&gt; <code>blah.example.com/something</code></p> <p>I don't know how to get the subdomain name to use in the rewrite rule.</p> <p><strong>Final Solution:</strong></p> <pre><code>RewriteCond %{HTTP_HOST} !^blah\.example\.com RewriteCond %{HTTP_HOST} ^([^.]+) RewriteRule ^(.*) /%1/$1 [L] </code></pre> <p>Or as pointed out by pilif</p> <pre><code>RewriteCond %{HTTP_HOST} ^([^.]+)\.blah\.example\.com$ </code></pre>
[ { "answer_id": 49504, "author": "pilif", "author_id": 5083, "author_profile": "https://Stackoverflow.com/users/5083", "pm_score": 6, "selected": true, "text": "RewriteCond %{HTTP_HOST} ^([^.]+)\\.blah\\.domain\\.com$\nRewriteRule ^/(.*)$ http://blah.domain.com/%1/$1 [L,R] \n" }, { "answer_id": 49505, "author": "BlaM", "author_id": 999, "author_profile": "https://Stackoverflow.com/users/999", "pm_score": 2, "selected": false, "text": "RewriteCond %{HTTP_HOST} (.+)\\.blah\\.domain\\.com\nRewriteRule ^(.+)$ /%1/$1 [L]\n" }, { "answer_id": 49838, "author": "pilif", "author_id": 5083, "author_profile": "https://Stackoverflow.com/users/5083", "pm_score": 1, "selected": false, "text": "RewriteCond %{HTTP_HOST} ^([^\\.]+)\\.media\\.xnet\\.tk$\n ^\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428/" ]
49,507
<p>The system I'm currently working on consists of a controller PC running XP with .Net 2 connected to a set of embedded systems. All these components communicate with each other over an ethernet network. I'm currently using TcpClient.Connect on the XP computer to open a connection to the embedded systems to send TCP/IP messages. </p> <p>I now have to connect the XP computer to an external network to send processing data to, so there are now two network cards on the XP computer. However, the messages sent to the external network mustn't appear on the network connecting the embedded systems together (don't want to consume the bandwidth) and the messages to the embedded systems mustn't appear on the external network.</p> <p>So, the assertion I'm making is that messages sent to a defined IP address are sent out on both network cards when using the TcpClient.Connect method.</p> <p>How do I specify which physical network card messages are sent via, ideally using the .Net networking API. If no such method exists in .Net, then I can always P/Invoke the Win32 API.</p> <p>Skizz</p>
[ { "answer_id": 49545, "author": "Hath", "author_id": 5186, "author_profile": "https://Stackoverflow.com/users/5186", "pm_score": 3, "selected": false, "text": " int port = 1234;\n\n IPHostEntry entry = Dns.GetHostEntry(Dns.GetHostName());\n\n //find ip address for your adapter here\n IPAddress localAddress = entry.AddressList.FirstOrDefault();\n\n IPEndPoint localEndPoint = new IPEndPoint(localAddress, port);\n\n //use socket instead of a TcpClient\n Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);\n\n //binds client to the local end point\n client.Bind(localEndPoint);\n" }, { "answer_id": 60922, "author": "Murali Suriar", "author_id": 6306, "author_profile": "https://Stackoverflow.com/users/6306", "pm_score": 2, "selected": false, "text": "NIC A (Public): 192.168.1.10 mask 255.255.255.0\nNIC B (Private): 192.168.5.10 mask 255.255.255.0\n IPv4 Route Table\n===========================================================================\nActive Routes:\nNetwork Destination Netmask Gateway Interface Metric\n 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.10 266 <<--\n 127.0.0.0 255.0.0.0 On-link 127.0.0.1 306\n 127.0.0.1 255.255.255.255 On-link 127.0.0.1 306\n 127.255.255.255 255.255.255.255 On-link 127.0.0.1 306\n 169.254.0.0 255.255.0.0 On-link 192.168.1.10 286\n 169.254.255.255 255.255.255.255 On-link 192.168.1.10 266\n 192.168.1.0 255.255.255.0 On-link 192.168.1.10 266\n 192.168.1.10 255.255.255.255 On-link 192.168.1.10 266\n 192.168.1.255 255.255.255.255 On-link 192.168.1.10 266\n 192.168.5.0 255.255.255.0 On-link 192.168.5.10 266\n 192.168.5.10 255.255.255.255 On-link 192.168.5.10 266\n 192.168.5.255 255.255.255.255 On-link 192.168.5.10 266\n 255.255.255.255 255.255.255.255 On-link 192.168.1.10 276\n 255.255.255.255 255.255.255.255 On-link 192.168.5.10 276\n===========================================================================\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1898/" ]
49,510
<p>How do you set your Cocoa application as the default web browser?</p> <p>I want to create an application that is launched by default when the user clicks on an HTTP or HTTPS link in other applications (Mail, iChat etc.).</p>
[ { "answer_id": 49512, "author": "georgebrock", "author_id": 5168, "author_profile": "https://Stackoverflow.com/users/5168", "pm_score": 7, "selected": true, "text": "http:// https:// <key>CFBundleURLTypes</key>\n<array>\n <dict>\n <key>CFBundleURLName</key>\n <string>http URL</string>\n <key>CFBundleURLSchemes</key>\n <array>\n <string>http</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleURLName</key>\n <string>Secure http URL</string>\n <key>CFBundleURLSchemes</key>\n <array>\n <string>https</string>\n </array>\n </dict>\n</array>\n - (void)getUrl:(NSAppleEventDescriptor *)event \n withReplyEvent:(NSAppleEventDescriptor *)replyEvent\n{\n // Get the URL\n NSString *urlStr = [[event paramDescriptorForKeyword:keyDirectObject] \n stringValue];\n\n //TODO: Your custom URL handling code here\n}\n self setEventHandler getUrl:withReplyEvent: NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];\n[em \n setEventHandler:self \n andSelector:@selector(getUrl:withReplyEvent:) \n forEventClass:kInternetEventClass \n andEventID:kAEGetURL];\n [em\n setEventHandler:self \n andSelector:@selector(getUrl:withReplyEvent:) \n forEventClass:'WWW!' \n andEventID:'OURL'];\n CFStringRef bundleID = (CFStringRef)[[NSBundle mainBundle] bundleIdentifier];\nOSStatus httpResult = LSSetDefaultHandlerForURLScheme(CFSTR(\"http\"), bundleID);\nOSStatus httpsResult = LSSetDefaultHandlerForURLScheme(CFSTR(\"https\"), bundleID);\n//TODO: Check httpResult and httpsResult for errors\n com.example.MyApp x-com-example-myapp://" }, { "answer_id": 65479328, "author": "vauxhall", "author_id": 4691224, "author_profile": "https://Stackoverflow.com/users/4691224", "pm_score": 0, "selected": false, "text": "System Preferences > General > Default web browser <key>CFBundleDocumentTypes</key>\n<array>\n <dict>\n <key>CFBundleTypeName</key>\n <string>HTML document</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>public.html</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeName</key>\n <string>XHTML document</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>public.xhtml</string>\n </array>\n </dict>\n</array>\n" }, { "answer_id": 66104677, "author": "Donald Timberlake", "author_id": 15168824, "author_profile": "https://Stackoverflow.com/users/15168824", "pm_score": 2, "selected": false, "text": "<key>CFBundleURLTypes</key>\n <array>\n <dict>\n <key>CFBundleURLName</key>\n <string>Web site URL</string>\n <key>CFBundleURLSchemes</key>\n <array>\n <string>http</string>\n <string>https</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleURLName</key>\n <string>http URL</string>\n <key>CFBundleURLSchemes</key>\n <array>\n <string>http</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleURLName</key>\n <string>Secure http URL</string>\n <key>CFBundleURLSchemes</key>\n <array>\n <string>https</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeName</key>\n <string>HTML document</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>public.html</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeName</key>\n <string>XHTML document</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>public.xhtml</string>\n </array>\n </dict>\n </array>\n <key>CFBundleDocumentTypes</key>\n <array>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>GIF image</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>com.compuserve.gif</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>HTML document</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>public.html</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>XHTML document</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>public.xhtml</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>JavaScript script</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>com.netscape.javascript-​source</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>JPEG image</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>public.jpeg</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>MHTML document</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>org.ietf.mhtml</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>HTML5 Audio (Ogg)</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>org.xiph.ogg-audio</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>HTML5 Video (Ogg)</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>org.xiph.ogv</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>PNG image</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>public.png</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>SVG document</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>public.svg-image</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>Plain text document</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>public.text</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>HTML5 Video (WebM)</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>org.webmproject.webm</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>WebP image</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>org.webmproject.webp</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>org.chromium.extension</string>\n </array>\n </dict>\n <dict>\n <key>CFBundleTypeIconFile</key>\n <string>document.icns</string>\n <key>CFBundleTypeName</key>\n <string>PDF Document</string>\n <key>CFBundleTypeRole</key>\n <string>Viewer</string>\n <key>LSItemContentTypes</key>\n <array>\n <string>com.adobe.pdf</string>\n </array>\n </dict>\n </array>\n func application(_ application: NSApplication, open urls: [URL]) {\n// do a for loop, I recommend it\n}\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5168/" ]
49,511
<p>I have played with the idea of using a wiki (MediaWiki) to centralize all project information for a development project. This was done using extensions that pull information from SVN (using <a href="http://svnkit.com/" rel="nofollow noreferrer">SVNKit</a>) and by linking to Bugzilla to extract work assigned to a developer or work remaining for a release.</p> <p>Examples:</p> <pre><code>&lt;bugzilla type="summary" user="richard.tasker@gmail.com" /&gt; </code></pre> <p>would return a summary</p> <p><img src="https://i.stack.imgur.com/rfJjy.png" alt="Bugzilla Summary"></p> <pre><code>&lt;bugzilla type="status" status="ASSIGNED" product="SCM BEPPI" /&gt; </code></pre> <p>would return</p> <p><img src="https://i.stack.imgur.com/YSV0t.png" alt="Bugzilla Status"></p> <p>Do you think that this would be useful? If so then what other integrations would you think would be valuable?</p>
[ { "answer_id": 49541, "author": "Richard Tasker", "author_id": 2939, "author_profile": "https://Stackoverflow.com/users/2939", "pm_score": 0, "selected": false, "text": "<project file=\"AOZA_BEPPI_Billing_Project_Plan_v0.2.mpp\" type=\"list\" user=\"Martin\" />\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49511", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2939/" ]
49,536
<p>You find plenty of tutorials on menu bars in HTML, but for this specific (though IMHO generic) case, I haven't found any decent solution:</p> <pre><code># THE MENU ITEMS SHOULD BE JUSTIFIED JUST AS PLAIN TEXT WOULD BE # # ^ ^ # </code></pre> <ul> <li>There's an varying number of text-only menu items and the page layout is fluid.</li> <li>The first menu item should be left-aligned, the last menu item should be right-aligned.</li> <li>The remaining items should be spread optimally on the menu bar.</li> <li>The number is varying,so there's no chance to pre-calculate the optimal widths.</li> </ul> <p>Note that a TABLE won't work here as well:</p> <ul> <li>If you center all TDs, the first and the last item aren’t aligned correctly.</li> <li>If you left-align and right-align the first resp. the last items, the spacing will be sub-optimal.</li> </ul> <p>Isn’t it strange that there is no obvious way to implement this in a clean way by using HTML and CSS?</p>
[ { "answer_id": 49538, "author": "Jordi Bunster", "author_id": 4272, "author_profile": "https://Stackoverflow.com/users/4272", "pm_score": 2, "selected": false, "text": "<p> text-align: justify text-align-last" }, { "answer_id": 49558, "author": "flight", "author_id": 3377, "author_profile": "https://Stackoverflow.com/users/3377", "pm_score": 1, "selected": false, "text": "<div style=\"width:500px; background:#eee;\">\n <p style=\"text-align:justify\">\n <a href=\"#\">THE&nbsp;MENU&nbsp;ITEMS</a>\n <a href=\"#\">SHOULD&nbsp;BE</a>\n <a href=\"#\">JUSTIFIED</a>\n <a href=\"#\">JUST&nbsp;AS</a>\n <a href=\"#\">PLAIN&nbsp;TEXT</a>\n <a href=\"#\">WOULD&nbsp;BE</a>\n <img src=\"/Content/Img/stackoverflow-logo-250.png\" width=\"400\" height=\"0\"/>\n </p>\n <p>There's an varying number of text-only menu items and the page layout is fluid.</p>\n <p>The first menu item should be left-aligned, the last menu item should be right-aligned. The remaining items should be spread optimal on the menu bar.</p>\n <p>The number is varying,so there's no chance to pre-calculate the optimal widths.</p>\n <p>Note that a TABLE won't work here as well:</p>\n <ul>\n <li>If you center all TDs, the first and the last item aren't aligned correctly.</li>\n <li>If you left-align and right-align the first resp. the last items, the spacing will be sub-optimal.</li>\n </ul>\n</div>\n" }, { "answer_id": 49659, "author": "David Heggie", "author_id": 4309, "author_profile": "https://Stackoverflow.com/users/4309", "pm_score": -1, "selected": false, "text": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n\n<html>\n\n <head>\n <title>Kind-of-justified horizontal menu</title>\n\n <style type=\"text/css\">\n ul {\n list-style: none;\n margin: 0;\n padding: 0;\n width: 100%;\n }\n\n ul li {\n display: block;\n float: left;\n text-align: center;\n }\n </style>\n\n <script type=\"text/javascript\">\n setMenu = function() {\n var items = document.getElementById(\"nav\").getElementsByTagName(\"li\");\n var newwidth = 100 / items.length;\n\n for(var i = 0; i < items.length; i++) {\n items[i].style.width = newwidth + \"%\";\n }\n }\n </script>\n\n </head>\n\n <body>\n\n <ul id=\"nav\">\n <li><a href=\"#\">first item</a></li>\n <li><a href=\"#\">item</a></li>\n <li><a href=\"#\">item</a></li>\n <li><a href=\"#\">item</a></li>\n <li><a href=\"#\">item</a></li>\n <li><a href=\"#\">last item</a></li>\n </ul>\n\n <script type=\"text/javascript\">\n setMenu();\n </script>\n\n </body>\n\n</html>\n" }, { "answer_id": 2444135, "author": "Asbjørn Ulsberg", "author_id": 61818, "author_profile": "https://Stackoverflow.com/users/61818", "pm_score": 6, "selected": false, "text": "span #menu {\n text-align: justify;\n}\n\n#menu * {\n display: inline;\n}\n\n#menu li {\n display: inline-block;\n}\n\n#menu span {\n display: inline-block;\n position: relative;\n width: 100%;\n height: 0;\n} <div id=\"menu\">\n <ul>\n <li><a href=\"#\">Menu item 1</a></li>\n <li><a href=\"#\">Menu item 3</a></li>\n <li><a href=\"#\">Menu item 2</a></li>\n </ul>\n <span></span>\n</div> #menu span span display: inline-block inline-block span width span" }, { "answer_id": 2459113, "author": "mikelikespie", "author_id": 64941, "author_profile": "https://Stackoverflow.com/users/64941", "pm_score": 3, "selected": false, "text": "span.inner .outer .outer {\n text-align: justify;\n}\n.outer span.finish {\n display: inline-block;\n width: 100%;\n}\n.outer span.inner {\n display: inline-block;\n white-space: nowrap;\n} <div class=\"outer\">\n <span class=\"inner\">THE MENU ITEMS</span>\n <span class=\"inner\">SHOULD BE</span>\n <span class=\"inner\">JUSTIFIED</span>\n <span class=\"inner\">JUST AS</span>\n <span class=\"inner\">PLAIN TEXT</span>\n <span class=\"inner\">WOULD BE</span>\n <span class=\"finish\"></span>\n</div>" }, { "answer_id": 3581939, "author": "Raksmey", "author_id": 432634, "author_profile": "https://Stackoverflow.com/users/432634", "pm_score": 0, "selected": false, "text": "<script type=\"text/javascript\">//<![CDATA[\n window.addEvent('load', function(){\n var mncontainer = $('main-menu');\n var mncw = mncontainer.getSize().size.x;\n var mnul = mncontainer.getFirst();//UL\n var mnuw = mnul.getSize().size.x;\n var wdif = mncw - mnuw;\n var list = mnul.getChildren(); //get all list items\n //get the remained width (which can be positive or negative)\n //and devided by number of list item and also take out the precision\n var liwd = Math.floor(wdif/list.length);\n var selw, mwd=mncw, tliw=0;\n list.each(function(el){\n var elw = el.getSize().size.x;\n if(elw < mwd){ mwd = elw; selw = el;}\n el.setStyle('width', elw+liwd);\n tliw += el.getSize().size.x;\n });\n var rwidth = mncw-tliw;//get the remain width and set it to item which has smallest width\n if(rwidth>0){\n elw = selw.getSize().size.x;\n selw.setStyle('width', elw+rwidth);\n }\n });\n //]]>\n</script>\n <style type=\"text/css\">\n #main-menu{\n padding-top:41px;\n width:100%;\n overflow:hidden;\n position:relative;\n }\n ul.menu_tab{\n padding-top:1px;\n height:38px;\n clear:left;\n float:left;\n list-style:none;\n margin:0;\n padding:0;\n position:relative;\n left:50%;\n text-align:center;\n }\n ul.menu_tab li{\n display:block;\n float:left;\n list-style:none;\n margin:0;\n padding:0;\n position:relative;\n right:50%;\n }\n ul.menu_tab li.item7{\n margin-right:0;\n }\n ul.menu_tab li a, ul.menu_tab li a:visited{\n display:block;\n color:#006A71;\n font-weight:700;\n text-decoration:none;\n padding:0 0 0 10px;\n }\n ul.menu_tab li a span{\n display:block;\n padding:12px 10px 8px 0;\n }\n ul.menu_tab li.active a, ul.menu_tab li a:hover{\n background:url(\"../images/bg-menutab.gif\") repeat-x left top;\n color:#999999;\n }\n ul.menu_tab li.active a span,ul.menu_tab li.active a.visited span, ul.menu_tab li a:hover span{\n background:url(\"../images/bg-menutab.gif\") repeat-x right top;\n color:#999999;\n }\n</style>\n <div id=\"main-menu\">\n <ul class=\"menu_tab\">\n <li class=\"item1\"><a href=\"#\"><span>Home</span></a></li>\n <li class=\"item2\"><a href=\"#\"><span>The Project</span></a></li>\n <li class=\"item3\"><a href=\"#\"><span>About Grants</span></a></li>\n <li class=\"item4\"><a href=\"#\"><span>Partners</span></a></li>\n <li class=\"item5\"><a href=\"#\"><span>Resources</span></a></li>\n <li class=\"item6\"><a href=\"#\"><span>News</span></a></li>\n <li class=\"item7\"><a href=\"#\"><span>Contact</span></a></li>\n </ul>\n</div>\n" }, { "answer_id": 6789387, "author": "Diaren W", "author_id": 437887, "author_profile": "https://Stackoverflow.com/users/437887", "pm_score": 1, "selected": false, "text": "ul {\n text-align: justify;\n width: 400px;\n margin: 0;\n padding: 0;\n height: 1.2em;\n /* forces the height of the ul to one line */\n overflow: hidden;\n /* enforces the single line height */\n list-style-type: none;\n background-color: yellow;\n}\n\nul li {\n display: inline;\n}\n\nul li.break {\n margin-left: 100%;\n /* use e.g. 1000px if your ul has no width */\n}\n <ul>\n <li><a href=\"/\">The</a></li>\n <li><a href=\"/\">quick</a></li>\n <li><a href=\"/\">brown</a></li>\n <li><a href=\"/\">fox</a></li>\n <li class=\"break\">&nbsp;</li>\n</ul>\n" }, { "answer_id": 7117171, "author": "Jason Paul", "author_id": 788575, "author_profile": "https://Stackoverflow.com/users/788575", "pm_score": -1, "selected": false, "text": "ul li {\nmargin-right:20px;\n}\nul li:last-child {\nmargin-right:0;\n}\n" }, { "answer_id": 9559900, "author": "remitbri", "author_id": 1183664, "author_profile": "https://Stackoverflow.com/users/1183664", "pm_score": 4, "selected": false, "text": ":before :after ul {\n text-align: justify;\n list-style: none;\n list-style-image: none;\n margin: 0;\n padding: 0;\n}\nul:after {\n content: \"\";\n margin-left: 100%;\n}\nli {\n display: inline;\n}\na {\n display: inline-block;\n} <div id=\"menu\">\n <ul>\n <li><a href=\"#\">Menu item 1</a></li>\n <li><a href=\"#\">Menu item 2</a></li>\n <li><a href=\"#\">Menu item 3</a></li>\n <li><a href=\"#\">Menu item 4</a></li>\n <li><a href=\"#\">Menu item 5</a></li>\n </ul>\n</div> inline-block" }, { "answer_id": 10651987, "author": "Litek", "author_id": 650157, "author_profile": "https://Stackoverflow.com/users/650157", "pm_score": 0, "selected": false, "text": "<div class=\"nav\">\n <a href=\"#\" class=\"nav_item\">nav item1</a>\n <a href=\"#\" class=\"nav_item\">nav item2</a>\n <a href=\"#\" class=\"nav_item\">nav item3</a>\n <a href=\"#\" class=\"nav_item\">nav item4</a>\n <a href=\"#\" class=\"nav_item\">nav item5</a>\n <a href=\"#\" class=\"nav_item\">nav item6</a>\n <span class=\"empty\"></span>\n</div>\n .nav {\n width: 500px;\n height: 1em;\n line-height: 1em;\n text-align: justify;\n overflow: hidden;\n border: 1px dotted gray;\n}\n.nav_item {\n display: inline-block;\n}\n.empty {\n display: inline-block;\n width: 100%;\n height: 0;\n}\n" }, { "answer_id": 11687443, "author": "Rafał Rowiński", "author_id": 809351, "author_profile": "https://Stackoverflow.com/users/809351", "pm_score": 2, "selected": false, "text": "ul {\n display: table;\n margin: 1em auto 0;\n padding: 0;\n text-align: center;\n width: 90%;\n}\n\nli {\n display: table-cell;\n border: 1px solid black;\n padding: 0 5px;\n}\n" }, { "answer_id": 19469993, "author": "bash2day", "author_id": 2633611, "author_profile": "https://Stackoverflow.com/users/2633611", "pm_score": 2, "selected": false, "text": "ul {\n margin: 0; \n padding: 0; \n list-style: none; \n width: 200px; \n text-align: justify; \n list-style-type: none;\n}\nul > li {\n display: inline; \n text-align: justify; \n}\n\n/* declaration below will add a whitespace after every li. This is for one line codes where no whitespace (of breaks) are present and the browser wouldn't know where to make a break. */\nul > li:after {\n content: ' '; \n display: inline;\n}\n\n/* notice the 'inline-block'! Otherwise won't work for webkit which puts after pseudo el inside of it's parent instead of after thus shifting also the parent on next line! */\nul > li:last-child:after {\n display: inline-block;\n margin-left: 100%; \n content: ' ';\n} <ul>\n <li><a href=\"#\">home</a></li>\n <li><a href=\"#\">exposities</a></li>\n <li><a href=\"#\">werk</a></li>\n <li><a href=\"#\">statement</a></li>\n <li><a href=\"#\">contact</a></li>\n</ul>" }, { "answer_id": 29188477, "author": "Josh Crozier", "author_id": 2680216, "author_profile": "https://Stackoverflow.com/users/2680216", "pm_score": 6, "selected": true, "text": "display flex justify-content space-between space-around justify-content: space-between ul {\n list-style: none;\n padding: 0;\n margin: 0;\n}\n.menu {\n display: flex;\n justify-content: space-between;\n} <ul class=\"menu\">\n <li>Item One</li>\n <li>Item Two</li>\n <li>Item Three Longer</li>\n <li>Item Four</li>\n</ul> justify-content: space-around ul {\n list-style: none;\n padding: 0;\n margin: 0;\n}\n.menu {\n display: flex;\n justify-content: space-around;\n} <ul class=\"menu\">\n <li>Item One</li>\n <li>Item Two</li>\n <li>Item Three Longer</li>\n <li>Item Four</li>\n</ul>" }, { "answer_id": 72763328, "author": "Amir ", "author_id": 19136274, "author_profile": "https://Stackoverflow.com/users/19136274", "pm_score": 0, "selected": false, "text": "*{\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n }\n ul {\n list-style: none;\n display: flex;\n align-items: center;\n justify-content: space-evenly;\n } <ul>\n <li>List item One</li>\n <li>List item Two</li>\n <li>List item Three </li>\n <li>List item Four</li>\n </ul>" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3377/" ]
49,547
<p>Our investigations have shown us that not all browsers respect the HTTP cache directives in a uniform manner.</p> <p>For security reasons we do not want certain pages in our application to be cached, <strong>ever,</strong> by the web browser. This must work for at least the following browsers:</p> <ul> <li>Internet Explorer 6+</li> <li>Firefox 1.5+</li> <li>Safari 3+</li> <li>Opera 9+</li> <li>Chrome</li> </ul> <p>Our requirement came from a security test. After logging out from our website you could press the back button and view cached pages.</p>
[ { "answer_id": 49549, "author": "Edward Wilde", "author_id": 5182, "author_profile": "https://Stackoverflow.com/users/5182", "pm_score": 5, "selected": false, "text": "Response.ClearHeaders(); \nResponse.AppendHeader(\"Cache-Control\", \"no-cache\"); //HTTP 1.1\nResponse.AppendHeader(\"Cache-Control\", \"private\"); // HTTP 1.1\nResponse.AppendHeader(\"Cache-Control\", \"no-store\"); // HTTP 1.1\nResponse.AppendHeader(\"Cache-Control\", \"must-revalidate\"); // HTTP 1.1\nResponse.AppendHeader(\"Cache-Control\", \"max-stale=0\"); // HTTP 1.1 \nResponse.AppendHeader(\"Cache-Control\", \"post-check=0\"); // HTTP 1.1 \nResponse.AppendHeader(\"Cache-Control\", \"pre-check=0\"); // HTTP 1.1 \nResponse.AppendHeader(\"Pragma\", \"no-cache\"); // HTTP 1.0 \nResponse.AppendHeader(\"Expires\", \"Sat, 26 Jul 1997 05:00:00 GMT\"); // HTTP 1.0 \n" }, { "answer_id": 49557, "author": "Grey Panther", "author_id": 1265, "author_profile": "https://Stackoverflow.com/users/1265", "pm_score": 3, "selected": false, "text": " header('Pragma: public');\n header(\"Expires: Sat, 26 Jul 1997 05:00:00 GMT\"); // Date in the past \n header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');\n header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1\n header('Cache-Control: pre-check=0, post-check=0, max-age=0', false); // HTTP/1.1\n header (\"Pragma: no-cache\");\n header(\"Expires: 0\", false);\n" }, { "answer_id": 91512, "author": "Steven Oxley", "author_id": 3831, "author_profile": "https://Stackoverflow.com/users/3831", "pm_score": 3, "selected": false, "text": "header('Cache-Control: no-store, private, no-cache, must-revalidate'); // HTTP/1.1\nheader('Cache-Control: pre-check=0, post-check=0, max-age=0, max-stale = 0', false); // HTTP/1.1\nheader('Pragma: public');\nheader('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past \nheader('Expires: 0', false); \nheader('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');\nheader ('Pragma: no-cache');\n false header() Cache-Control header() header('Cache-Control: this');\nheader('Cache-Control: and, this', false);\n" }, { "answer_id": 2068407, "author": "BalusC", "author_id": 157882, "author_profile": "https://Stackoverflow.com/users/157882", "pm_score": 13, "selected": true, "text": "Cache-Control: no-cache, no-store, must-revalidate\nPragma: no-cache\nExpires: 0\n Cache-Control Expires Pragma Expires Cache-Control Expires no-store Cache-Control: no-cache Cache-Control: no-store, must-revalidate\nPragma: no-cache\nExpires: 0\n Pragma Cache-Control: no-store, must-revalidate\nExpires: 0\n Expires Cache-Control: no-store, must-revalidate\n Date Cache-Control Expires Date: Wed, 24 Aug 2016 18:32:02 GMT\nExpires: 0\n Cache-Control max-age Cache-Control Last-Modified header(\"Cache-Control: no-cache, no-store, must-revalidate\"); // HTTP 1.1.\nheader(\"Pragma: no-cache\"); // HTTP 1.0.\nheader(\"Expires: 0\"); // Proxies.\n response.setHeader(\"Cache-Control\", \"no-cache, no-store, must-revalidate\"); // HTTP 1.1.\nresponse.setHeader(\"Pragma\", \"no-cache\"); // HTTP 1.0.\nresponse.setHeader(\"Expires\", \"0\"); // Proxies.\n Response.Cache.SetCacheability(HttpCacheability.NoCache); // HTTP 1.1.\nResponse.Cache.AppendCacheExtension(\"no-store, must-revalidate\");\nResponse.AppendHeader(\"Pragma\", \"no-cache\"); // HTTP 1.0.\nResponse.AppendHeader(\"Expires\", \"0\"); // Proxies.\n // `response` is an instance of System.Net.Http.HttpResponseMessage\nresponse.Headers.CacheControl = new CacheControlHeaderValue\n{\n NoCache = true,\n NoStore = true,\n MustRevalidate = true\n};\nresponse.Headers.Pragma.ParseAdd(\"no-cache\");\n// We can't use `response.Content.Headers.Expires` directly\n// since it allows only `DateTimeOffset?` values.\nresponse.Content?.Headers.TryAddWithoutValidation(\"Expires\", 0.ToString()); \n Response.AppendHeader(\"Cache-Control\", \"no-cache, no-store, must-revalidate\"); // HTTP 1.1.\nResponse.AppendHeader(\"Pragma\", \"no-cache\"); // HTTP 1.0.\nResponse.AppendHeader(\"Expires\", \"0\"); // Proxies.\n // using Microsoft.Net.Http.Headers\nResponse.Headers[HeaderNames.CacheControl] = \"no-cache, no-store, must-revalidate\";\nResponse.Headers[HeaderNames.Expires] = \"0\";\nResponse.Headers[HeaderNames.Pragma] = \"no-cache\";\n Response.addHeader \"Cache-Control\", \"no-cache, no-store, must-revalidate\" ' HTTP 1.1.\nResponse.addHeader \"Pragma\", \"no-cache\" ' HTTP 1.0.\nResponse.addHeader \"Expires\", \"0\" ' Proxies.\n headers[\"Cache-Control\"] = \"no-cache, no-store, must-revalidate\" # HTTP 1.1.\nheaders[\"Pragma\"] = \"no-cache\" # HTTP 1.0.\nheaders[\"Expires\"] = \"0\" # Proxies.\n response = make_response(render_template(...))\nresponse.headers[\"Cache-Control\"] = \"no-cache, no-store, must-revalidate\" # HTTP 1.1.\nresponse.headers[\"Pragma\"] = \"no-cache\" # HTTP 1.0.\nresponse.headers[\"Expires\"] = \"0\" # Proxies.\n response[\"Cache-Control\"] = \"no-cache, no-store, must-revalidate\" # HTTP 1.1.\nresponse[\"Pragma\"] = \"no-cache\" # HTTP 1.0.\nresponse[\"Expires\"] = \"0\" # Proxies.\n request.response.headerlist.extend(\n (\n ('Cache-Control', 'no-cache, no-store, must-revalidate'),\n ('Pragma', 'no-cache'),\n ('Expires', '0')\n )\n)\n responseWriter.Header().Set(\"Cache-Control\", \"no-cache, no-store, must-revalidate\") // HTTP 1.1.\nresponseWriter.Header().Set(\"Pragma\", \"no-cache\") // HTTP 1.0.\nresponseWriter.Header().Set(\"Expires\", \"0\") // Proxies.\n (require '[ring.util.response :as r])\n(-> response\n (r/header \"Cache-Control\" \"no-cache, no-store, must-revalidate\")\n (r/header \"Pragma\" \"no-cache\")\n (r/header \"Expires\" 0))\n .htaccess <IfModule mod_headers.c>\n Header set Cache-Control \"no-cache, no-store, must-revalidate\"\n Header set Pragma \"no-cache\"\n Header set Expires 0\n</IfModule>\n <meta http-equiv=\"Cache-Control\" content=\"no-cache, no-store, must-revalidate\">\n<meta http-equiv=\"Pragma\" content=\"no-cache\">\n<meta http-equiv=\"Expires\" content=\"0\">\n <meta http-equiv> file:// <meta http-equiv> http-equiv" }, { "answer_id": 5493543, "author": "Kornel", "author_id": 27009, "author_profile": "https://Stackoverflow.com/users/27009", "pm_score": 8, "selected": false, "text": "Cache-Control: no-store, must-revalidate no-store must-revalidate <meta> post-check pre-check no-cache max-age=0 no-store Expires" }, { "answer_id": 5767046, "author": "Tobias", "author_id": 591025, "author_profile": "https://Stackoverflow.com/users/591025", "pm_score": 2, "selected": false, "text": "<body onunload=\"\"> \n" }, { "answer_id": 11043978, "author": "Joseph Connolly", "author_id": 1409310, "author_profile": "https://Stackoverflow.com/users/1409310", "pm_score": 6, "selected": false, "text": "<configuration>\n<system.webServer>\n <httpProtocol>\n <customHeaders>\n <add name=\"Cache-Control\" value=\"no-cache, no-store, must-revalidate\" />\n <!-- HTTP 1.1. -->\n <add name=\"Pragma\" value=\"no-cache\" />\n <!-- HTTP 1.0. -->\n <add name=\"Expires\" value=\"0\" />\n <!-- Proxies. -->\n </customHeaders>\n </httpProtocol>\n</system.webServer>\n app.use(function(req, res, next) {\n res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');\n res.setHeader('Pragma', 'no-cache');\n res.setHeader('Expires', '0');\n next();\n});\n" }, { "answer_id": 14724964, "author": "yongfa365", "author_id": 1879111, "author_profile": "https://Stackoverflow.com/users/1879111", "pm_score": 2, "selected": false, "text": "//In .net MVC\n[OutputCache(NoStore = true, Duration = 0, VaryByParam = \"*\")]\npublic ActionResult FareListInfo(long id)\n{\n}\n\n// In .net webform\n<%@ OutputCache NoStore=\"true\" Duration=\"0\" VaryByParam=\"*\" %>\n" }, { "answer_id": 17197577, "author": "user2321638", "author_id": 2321638, "author_profile": "https://Stackoverflow.com/users/2321638", "pm_score": 3, "selected": false, "text": "<form id=\"form1\" runat=\"server\" autocomplete=\"off\">\n" }, { "answer_id": 18516720, "author": "Pacerier", "author_id": 632951, "author_profile": "https://Stackoverflow.com/users/632951", "pm_score": 7, "selected": false, "text": "Cache-Control: no-store Cache-Control: no-store Cache-Control: no-cache Pragma: no-cache Vary: * Cache-Control: must-revalidate Cache-Control: no-store <body onunload=\"\"> Cache-Control: no-store Cache-Control: must-revalidate, max-age=0 Cache-Control: no-cache Cache-Control: no-store Cache-Control: must-revalidate Expires: 0 Cache-Control: must-revalidate Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * Cache-Control: no-store, must-revalidate Cache-Control: no-store\n<body onunload=\"\">\n Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: 0 Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: 0 Pragma: no-cache Vary: * Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * Cache-Control: private, no-cache, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: 0 Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: private, no-cache, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: private, no-cache, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: 0 Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: private, no-cache, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: no-store Cache-Control: no-store <body onunload=\"\"> Cache-Control: no-cache Vary: * Pragma: no-cache Cache-Control: private, no-cache, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: private, no-cache, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: 0 Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: must-revalidate, max-age=0 Cache-Control: must-revalidate Expires: 0 Cache-Control: must-revalidate Expires: Sat, 12 Oct 1991 05:00:00 GMT Cache-Control: private, must-revalidate, proxy-revalidate, s-maxage=0 Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: private, max-age=0, proxy-revalidate, s-maxage=0 Expires: 0 <body onunload=\"\"> Cache-Control: private, max-age=0, proxy-revalidate, s-maxage=0 Expires: Sat, 12 Oct 1991 05:00:00 GMT <body onunload=\"\"> Vary: * Pragma: no-cache Cache-Control: no-cache Cache-Control: private, no-cache, max-age=0, proxy-revalidate, s-maxage=0 Cache-Control: private, no-cache, max-age=0, proxy-revalidate, s-maxage=0 Expires: 0 Pragma: no-cache Vary: * Cache-Control: private, no-cache, max-age=0, proxy-revalidate, s-maxage=0 Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * Cache-Control: must-revalidate Cache-Control: private, must-revalidate, proxy-revalidate, s-maxage=0 <body onunload=\"\"> Cache-Control: must-revalidate, max-age=0 Cache-Control: private, no-cache, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: private, no-cache, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: 0 Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: no-store Cache-Control: private, no-cache, no-store, max-age=0, proxy-revalidate, s-maxage=0 Expires: 0 Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: private, no-cache, no-store, max-age=0, proxy-revalidate, s-maxage=0 Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * <body onunload=\"\"> Cache-Control: private, no-cache Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * Cache-Control: must-revalidate Expires: 0 Cache-Control: must-revalidate Expires: Sat, 12 Oct 1991 05:00:00 GMT Cache-Control: private, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: 0 <body onunload=\"\"> Cache-Control: private, must-revalidate, max-age=0, proxy-revalidate, s-maxage=0 Expires: Sat, 12 Oct 1991 05:00:00 GMT <body onunload=\"\"> Cache-Control: private, must-revalidate Expires: Sat, 12 Oct 1991 05:00:00 GMT Pragma: no-cache Vary: * Cache-Control: no-store, must-revalidate" }, { "answer_id": 21753925, "author": "Carlos Escalera Alonso", "author_id": 3197362, "author_profile": "https://Stackoverflow.com/users/3197362", "pm_score": 1, "selected": false, "text": "Use CGI; \nsub set_new_query() {\n binmode STDOUT, \":utf8\";\n die if defined $query;\n $query = CGI->new();\n print $query->header(\n -expires => 'Sat, 26 Jul 1997 05:00:00 GMT',\n -Pragma => 'no-cache',\n -Cache_Control => join(', ', qw(\n private\n no-cache\n no-store\n must-revalidate\n max-age=0\n pre-check=0\n post-check=0 \n ))\n );\n }\n <FilesMatch \"\\.(html|htm|js|css|pl)$\">\nFileETag None\n<ifModule mod_headers.c>\nHeader unset ETag\nHeader set Cache-Control \"max-age=0, no-cache, no-store, must-revalidate\"\nHeader set Pragma \"no-cache\"\nHeader set Expires \"Wed, 11 Jan 1984 05:00:00 GMT\"\n</ifModule>\n" }, { "answer_id": 22468342, "author": "JK.", "author_id": 325727, "author_profile": "https://Stackoverflow.com/users/325727", "pm_score": 3, "selected": false, "text": "Response.Cache.SetCacheability(HttpCacheability.NoCache);\nResponse.Cache.AppendCacheExtension(\"no-store, must-revalidate\");\nResponse.AppendHeader(\"Pragma\", \"no-cache\");\nResponse.AppendHeader(\"Expires\", \"-1\");\n Cache-control no-cache no-store, must-revalidate" }, { "answer_id": 23760017, "author": "user3253726", "author_id": 3253726, "author_profile": "https://Stackoverflow.com/users/3253726", "pm_score": 0, "selected": false, "text": "filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);\nfilterContext.HttpContext.Response.Cache.AppendCacheExtension(\"no-store, must-revalidate\");\n" }, { "answer_id": 24556984, "author": "Paul", "author_id": 3802165, "author_profile": "https://Stackoverflow.com/users/3802165", "pm_score": 0, "selected": false, "text": "Cache-Control: no-store" }, { "answer_id": 37332851, "author": "kspearrin", "author_id": 1090359, "author_profile": "https://Stackoverflow.com/users/1090359", "pm_score": 3, "selected": false, "text": "public class NoCacheMiddleware\n{\n private readonly RequestDelegate m_next;\n\n public NoCacheMiddleware( RequestDelegate next )\n {\n m_next = next;\n }\n\n public async Task Invoke( HttpContext httpContext )\n {\n httpContext.Response.OnStarting( ( state ) =>\n {\n // ref: http://stackoverflow.com/questions/49547/making-sure-a-web-page-is-not-cached-across-all-browsers\n httpContext.Response.Headers.Append( \"Cache-Control\", \"no-cache, no-store, must-revalidate\" );\n httpContext.Response.Headers.Append( \"Pragma\", \"no-cache\" );\n httpContext.Response.Headers.Append( \"Expires\", \"0\" );\n return Task.FromResult( 0 );\n }, null );\n\n await m_next.Invoke( httpContext );\n }\n}\n Startup.cs app.UseMiddleware<NoCacheMiddleware>();\n app.UseStaticFiles();\n" }, { "answer_id": 38884396, "author": "Richard Elkins", "author_id": 6169583, "author_profile": "https://Stackoverflow.com/users/6169583", "pm_score": 0, "selected": false, "text": "<head><meta> web.header" }, { "answer_id": 39047433, "author": "ObiHill", "author_id": 310139, "author_profile": "https://Stackoverflow.com/users/310139", "pm_score": 2, "selected": false, "text": "ExpiresDefault .htaccess ExpiresDefault \"access plus 0 seconds\"\n ExpiresByType ExpiresByType image/x-icon \"access plus 3 month\"\n ExpiresDefault" }, { "answer_id": 61744446, "author": "CodeMind", "author_id": 2408266, "author_profile": "https://Stackoverflow.com/users/2408266", "pm_score": -1, "selected": false, "text": " <location path=\"index.html\">\n <system.webServer>\n <httpProtocol>\n <customHeaders>\n <add name=\"Cache-Control\" value=\"no-cache\" />\n </customHeaders>\n </httpProtocol>\n </system.webServer>\n </location>\n" }, { "answer_id": 62086019, "author": "Antonio Ooi", "author_id": 2200913, "author_profile": "https://Stackoverflow.com/users/2200913", "pm_score": -1, "selected": false, "text": "window.location.replace(\"https://www.example.com/page-not-to-be-viewed-in-browser-history-back-button.html\");" }, { "answer_id": 62340815, "author": "elle0087", "author_id": 3061212, "author_profile": "https://Stackoverflow.com/users/3061212", "pm_score": 0, "selected": false, "text": "function setCookie(name, value, days)\n{\n var expires = \"\";\n if (days)\n {\n var date = new Date();\n date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));\n expires = \"; expires=\" + date.toUTCString();\n }\n document.cookie = name + \"=\" + (value || \"\") + expires + \"; path=/\";\n}\n\nfunction getCookie(name)\n{\n var nameEQ = name + \"=\";\n var ca = document.cookie.split(';');\n\n for (var i = ca.length - 1; i >= 0; i--)\n {\n var c = ca[i];\n while (c.charAt(0) == ' ')\n {\n c = c.substring(1, c.length);\n }\n\n if (c.indexOf(nameEQ) == 0)\n {\n return c.substring(nameEQ.length, c.length);\n }\n }\n return null;\n}\n protected void Page_Load(object sender, EventArgs e)\n {\n Page.RegisterClientScriptBlock(\"\", \"<script>setCookie('\" + Session.SessionID + \"', '\" + Login + \"', '100');</script>\");\n }\n <script type=\"text/javascript\">\nif (getCookie('<%= Session.SessionID %>') < 0)\n {\n if (history.length > 0)\n {\n history.go(+1);\n }\n }\n\n</script>\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5182/" ]
49,562
<p>I think this is a fun engineering-level question.</p> <p>I need to design a control which displays a line chart. What I want to be able to do is use a designer to add multiple <code>Pens</code> which actually describe the data and presentation so that it ends up with Xaml something along these lines:</p> <pre><code>&lt;Chart&gt; &lt;Pen Name="SalesData" Color="Green" Data="..."/&gt; &lt;Pen Name="CostData" Color="Red" Data="..." /&gt; ... &lt;/chart&gt; </code></pre> <p>My first thought is to extend <code>ItemsControl</code> for the <code>Chart</code> class. Will that get me where I want to go or should I be looking at it from a different direction such as extending <code>Panel</code>?</p> <p>The major requirement is to be able to use it in a designer without adding any C# code. In order for that to even be feasible, it needs to retain its structure in the tree-view model. In other words, if I were working with this in Expression Blend or Mobiform Aurora, I would be able to select the chart from the logical tree or select any of the individual pens to edit their properties.</p>
[ { "answer_id": 334399, "author": "Rhys", "author_id": 22169, "author_profile": "https://Stackoverflow.com/users/22169", "pm_score": 1, "selected": false, "text": "<Chart>\n <Chart.Pens>\n <Pen Name=\"SalesData\" Data=\"{Binding Name=SalesData}\" /> \n <Pen Name=\"CostData\">\n <Pen.Data>\n <PenData Y=\"12\" X=\"Jan\" />\n <PenData Y=\"34\" X=\"Feb\" />\n </Pen.Data>\n </Pen>\n </Chart.Pens>\n</Chart>\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49562", "https://Stackoverflow.com", "https://Stackoverflow.com/users/93/" ]
49,564
<p>I would like display something more meaningful that animated gif while users upload file to my web application. What possibilities do I have? </p> <p><em>Edit: I am using .Net but I don't mind if somebody shows me platform agnostic version.</em></p>
[ { "answer_id": 51641, "author": "georgebrock", "author_id": 5168, "author_profile": "https://Stackoverflow.com/users/5168", "pm_score": 2, "selected": false, "text": "uploadStarted uploadProgress uploadError" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2361/" ]
49,582
<p>In our current database development evironment we have automated build procceses check all the sql code out of svn create database scripts and apply them to the various development/qa databases.</p> <p>This is all well and good, and is a tremdous improvement over what we did in the past, but we have a problem with rerunning scripts. Obviously this isn't a problem with some scripts like altering procedures, because you can run them over and over without adversly affecting the system. Right now to add metadata and run statements like create/alter table statements we add code to check and see if the objects exists, and if they do, don't run them.</p> <p>Our problem is that we really only get one shot to run the script, because once the script has been run, the objects are in the environment and system won't run the script again. If something needs to change once it's been deployed, we have a difficult process of running update scripts agaist the update scripts and hoping that everything falls in the correct order and all of the PKs line up between the environments (the databases are, shall we say, "special").</p> <p>Short of dropping the database and starting the process from scratch (the last most current release), does anyone have a more elegant solution to this? </p>
[ { "answer_id": 49597, "author": "Ryan Lanciaux", "author_id": 1385358, "author_profile": "https://Stackoverflow.com/users/1385358", "pm_score": 1, "selected": false, "text": "http://www.rikware.com/RikMigrations.html\n" }, { "answer_id": 49845, "author": "Ben Scheirman", "author_id": 3381, "author_profile": "https://Stackoverflow.com/users/3381", "pm_score": 0, "selected": false, "text": "create table Customers (\n id int identity(1,1) primary key,\n first_name varchar(255) not null,\n last_name varchar(255) not null\n)\n alter table Customers\nadd column status varchar(50) null\n\nupdate Customers set status = 'Silver' where status is null\n\nalter table Customers\nalter column status varchar(50) not null\n" } ]
2008/09/08
[ "https://Stackoverflow.com/questions/49582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1942/" ]