qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
278,571
|
<p>I'm wondering if there is a quick and easy function to clean get variables in my url, before I work with them.( or $_POST come to think of it... )</p>
<p>I suppose I could use a regex to replace non-permitted characters, but I'm interested to hear what people use for this sort of thing?</p>
|
[
{
"answer_id": 278664,
"author": "troelskn",
"author_id": 18180,
"author_profile": "https://Stackoverflow.com/users/18180",
"pm_score": 3,
"selected": false,
"text": "urlencode htmlspecialchars"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278571",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26107/"
] |
278,588
|
<p>I'm using the XML data source feature in Reporting Services 2005 but having some issues with missing data. When there is no value for the first column in a row, it appears that the entire column is ignored by SSRS!</p>
<p>The web method request is very simple:</p>
<pre><code><Query>
<Method Name="GetIssues"
Namespace="http://www.mycompany.com/App/">
</Method>
<SoapAction>http://www.mycompany.com/App/GetIssues</SoapAction>
<ElementPath IgnoreNamespaces="true">*</ElementPath>
</Query>
</code></pre>
<p>Equally, the response is very simple:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetIssuesResponse xmlns="http://www.mycompany.com/App/">
<GetIssuesResult>
<Issue>
<Title>ABC</Title>
<RaisedBy />
<Action>Do something</Action>
</Issue>
<Issue>
<Title>ABC</Title>
<RaisedBy>Jeff Smith</RaisedBy>
<Action>Do something</Action>
</Issue>
</GetIssuesResult>
</GetIssuesResponse>
</soap:Body>
</soap:Envelope>
</code></pre>
<p>In this example the RaisedBy column will be completely empty. If the 'Issues' are reversed so RaisedBy first has a value, there is no problem. Any ideas?</p>
|
[
{
"answer_id": 278638,
"author": "Gene",
"author_id": 35630,
"author_profile": "https://Stackoverflow.com/users/35630",
"pm_score": 4,
"selected": true,
"text": "<ElementPath IgnoreNamespaces=\"true\">*</ElementPath>\n <ElementPath IgnoreNamespaces=\"true\">GetIssues/GetIssuesItemsResult/listitems/data/row{@Title,@RaisedBy,@Action}</ElementPath>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6651/"
] |
278,596
|
<p>Using Maven 2, is there a way I can list out the jar dependencies as just the file names?</p>
<pre><code>mvn dependency:build-classpath
</code></pre>
<p>can list the jar files, but that will include the full path to their location in my local repository. What I need is essentially just a list of the file names (or the file names that the copy-dependencies goal copied).</p>
<p>So the list I need would be something like</p>
<pre><code>activation-1.1.jar,antlr-2.7.6.jar,aopalliance-1.0.jar etc...
</code></pre>
<p>ideally as a maven property, but I guess, a file such as build-classpath can generate will do.</p>
<p>What I am trying to achieve is writing a <code>Bundle-ClassPath</code> to an otherwise manually maintained MANIFEST.MF file for a OSGi bundle. (You shouldn't need to understand this bit to answer the question.)</p>
<p>To clarify: The question is <strong>not</strong> about how to write manifest headers into the MANIFEST.MF file in a jar (that is easily googleble). I am asking about how to get the data I want to write, namely the list shown above.</p>
|
[
{
"answer_id": 278623,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 2,
"selected": false,
"text": "<addClasspath> <manifestFile> <plugin>\n <groupId>org.apache.maven.plugins</groupId>\n <artifactId>maven-jar-plugin</artifactId>\n ...\n <configuration>\n <archive>\n <addClasspath>true</addClasspath>\n <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>\n </archive>\n </configuration>\n ...\n</plugin>\n"
},
{
"answer_id": 708473,
"author": "Gabe Mc",
"author_id": 86010,
"author_profile": "https://Stackoverflow.com/users/86010",
"pm_score": 5,
"selected": false,
"text": "pathSeparator fileSeparator '::' ',' generate-resources process-resources"
},
{
"answer_id": 2834352,
"author": "Anis",
"author_id": 341247,
"author_profile": "https://Stackoverflow.com/users/341247",
"pm_score": 7,
"selected": false,
"text": "$ mvn dependency:tree\n"
},
{
"answer_id": 18263982,
"author": "Andrew",
"author_id": 379428,
"author_profile": "https://Stackoverflow.com/users/379428",
"pm_score": 1,
"selected": false,
"text": "outputProperty"
},
{
"answer_id": 47474708,
"author": "naXa stands with Ukraine",
"author_id": 1429387,
"author_profile": "https://Stackoverflow.com/users/1429387",
"pm_score": 4,
"selected": false,
"text": "$ mvn dependency:tree\n $ mvn dependency:tree | findstr javax.persistence\n $ mvn dependency:tree | grep javax.persistence\n $ mvn dependency:tree -Dincludes=javax.persistence:*\n $ mvn dependency:tree '-Dincludes=javax.persistence:*'\n"
},
{
"answer_id": 49579828,
"author": "kisna",
"author_id": 469718,
"author_profile": "https://Stackoverflow.com/users/469718",
"pm_score": 5,
"selected": false,
"text": "mvn dependency:list\n"
},
{
"answer_id": 57755874,
"author": "Matthieu",
"author_id": 1098603,
"author_profile": "https://Stackoverflow.com/users/1098603",
"pm_score": 1,
"selected": false,
"text": "mvn dependency:list mvn dependency:list | awk -f mvnfmt.awk\n | sort | tr '\\n' ':' mvnfmt.awk BEGIN {\n found = 0\n}\n\n/The following files have been resolved/ {\n found = 1\n next\n}\n\n/^\\[INFO\\] \\$/ {\n print \"Empty \" found\n if (found != 0) found = 0\n}\n\n{\n if (!found) next\n n = split($0, a, \" \")\n if (n != 2) {\n found = 0\n next\n }\n split(a[2], a, \":\")\n print a[2] \"-\" a[4] \".\" a[3]\n} \n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1113/"
] |
278,604
|
<p>I need to implement the classic Factory Method pattern in ASP.NET to create server controls dynamically.</p>
<p>The only way I've found to create .ascx controls is to use the LoadControl method of the Page/UserControl classes. I find it messy however to link my factory with a page or to pass a page parameter to the factory.</p>
<p>Does anybody know of another method to create such controls (such as a static method somewhere i'd have overlooked) ?</p>
<p>Thanks.</p>
|
[
{
"answer_id": 278878,
"author": "Mathieu Garstecki",
"author_id": 22078,
"author_profile": "https://Stackoverflow.com/users/22078",
"pm_score": 2,
"selected": true,
"text": "public ControlsFactory\n{\n private Page _containingPage;\n\n public ControlsFactory(Page containingPage)\n {\n _containingPage = containingPage;\n }\n\n public CustomControlClass GetControl(string type)\n {\n ... snip ...\n CustomControlClass result = (CustomControlClass)_containingPage.LoadControl(controlLocation);\n\n return result;\n }\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22078/"
] |
278,622
|
<p>I'm looking for a method to reliably extract the host name from a URL string in Ruby.</p>
<p>e.g.
<a href="http://www.mglenn.com/directory" rel="noreferrer">http://www.mglenn.com/directory</a> = www.mglenn.com
OR
<a href="http://www.mglenn.com?param=x" rel="noreferrer">http://www.mglenn.com?param=x</a> = www.mglenn.com</p>
|
[
{
"answer_id": 278673,
"author": "glenatron",
"author_id": 15394,
"author_profile": "https://Stackoverflow.com/users/15394",
"pm_score": 7,
"selected": true,
"text": "require 'uri'\n\nmyUri = URI.parse( 'http://www.mglenn.com/directory' )\nprint myUri.host\n# => www.mglenn.com\n"
},
{
"answer_id": 11872519,
"author": "Kumar",
"author_id": 540852,
"author_profile": "https://Stackoverflow.com/users/540852",
"pm_score": 5,
"selected": false,
"text": "URI(\"http://www.mglenn.com/directory\").host\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9424/"
] |
278,627
|
<p>We've converted our solution from .NET 2.0 to .NET 3.5. All projects converted just fine except for the Website Project, which still doesn't understand what I mean when using 'var' and the like.</p>
<p>I've looked in the property pages for the web project, and the Target Framework is set to '.NET Framework 3.5'.</p>
<p>Any other ideas?</p>
|
[
{
"answer_id": 278650,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 2,
"selected": false,
"text": " <assemblies>\n <add assembly=\"System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\"/>\n <add assembly=\"System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\"/>\n <add assembly=\"System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>\n <add assembly=\"System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\"/>\n </assemblies>\n <runtime>\n <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n <dependentAssembly>\n <assemblyIdentity name=\"System.Web.Extensions\" publicKeyToken=\"31bf3856ad364e35\"/>\n <bindingRedirect oldVersion=\"1.0.0.0-1.1.0.0\" newVersion=\"3.5.0.0\"/>\n </dependentAssembly>\n <dependentAssembly>\n <assemblyIdentity name=\"System.Web.Extensions.Design\" publicKeyToken=\"31bf3856ad364e35\"/>\n <bindingRedirect oldVersion=\"1.0.0.0-1.1.0.0\" newVersion=\"3.5.0.0\"/>\n </dependentAssembly>\n </assemblyBinding>\n </runtime>\n"
},
{
"answer_id": 280667,
"author": "Peter Evjan",
"author_id": 3397,
"author_profile": "https://Stackoverflow.com/users/3397",
"pm_score": 3,
"selected": true,
"text": " <system.codedom>\n <compilers>\n <compiler language=\"c#;cs;csharp\" extension=\".cs\" warningLevel=\"4\"\n type=\"Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\">\n <providerOption name=\"CompilerVersion\" value=\"v3.5\"/>\n <providerOption name=\"WarnAsError\" value=\"false\"/>\n </compiler>\n </compilers>\n </system.codedom>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3397/"
] |
278,633
|
<p>I must be overlooking something simple. I'm setting a variable from a query result in a MySQL stored procedure like this:</p>
<pre><code>SELECT @myName := username FROM User WHERE ID=1;
</code></pre>
<p>So, @myName is storing the username of userid 1, which is 'Paul'. Great.</p>
<p>But later in the stored procedure I run an update on this record:</p>
<pre><code>UPDATE User SET username = 'Fred' WHERE ID=1;
</code></pre>
<p>Now, for some reason, @myName = 'Fred' when it should still equal 'Paul', right? It appears MySQL is just creating a pointer to the record rather than storing a static value in the @myName variable. </p>
<p>So in short, I want to be able to store a value in a variable from a query result and assure the value of my variable doesn't change, even when the data in the table it was set from changes.</p>
<p>What am I missing? Thanks in advance!</p>
|
[
{
"answer_id": 278681,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 3,
"selected": true,
"text": "SELECT username INTO myName FROM User WHERE ID=1;\n drop table if exists user;\ncreate table user (\n id serial primary key,\n username varchar(10)\n);\ninsert into user (username) values ('Paul');\n\ndrop procedure if exists doit;\ndelimiter !!\ncreate procedure doit()\nbegin\n declare name varchar(10);\n select @name:=username from user where id=1;\n select @name; -- shows 'Paul' as expected\n update user set username = 'Fred' where id=1;\n select @name; -- still shows 'Paul'\nend!!\ndelimiter ;\n\ncall doit();\n"
},
{
"answer_id": 3406850,
"author": "user410927",
"author_id": 410927,
"author_profile": "https://Stackoverflow.com/users/410927",
"pm_score": 0,
"selected": false,
"text": "@name drop procedure if exists doit;\ndelimiter !!\ncreate procedure doit()\nbegin\n declare name varchar(10);\n select @name:=username from user where id=1;\n select @name; -- shows 'Paul' as expected\n update user set username = 'Fred' where id=1;\n select @name:=username from user where id=1; -- this will update the @name value\n select @name; -- shows 'Fred'\nend!!\ndelimiter ;\n\ncall doit();\n"
},
{
"answer_id": 17745790,
"author": "Jitendra Pasi",
"author_id": 2599406,
"author_profile": "https://Stackoverflow.com/users/2599406",
"pm_score": 0,
"selected": false,
"text": "drop table if exists user;\ncreate table user (\nid serial primary key,\nusername varchar(10)\n);\ninsert into user (username) values ('Paul');\n\ndrop procedure if exists doit;\ndelimiter !!\ncreate procedure doit()\nbegin\ndeclare name varchar(10);\nselect @name:=username from user where id=1;\nselect @name; -- shows 'Paul' as expected\n\nset @name = '' /*Initialize @name with '' and then get the result as you expected*/\n\nupdate user set username = 'Fred' where id=1;\nselect @name; -- now you will get exepected results\nend!!\ndelimiter ;\n\ncall doit();\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26180/"
] |
278,644
|
<p>A "static" query is one that remains the same at all times. For example, the "Tags" button on Stackoverflow, or the "7 days" button on Digg. In short, they always map to a specific database query, so you can create them at design time. </p>
<p>But I am trying to figure out how to do "dynamic" queries where the user basically dictates how the database query will be created at runtime. For example, on Stackoverflow, you can combine tags and filter the posts in ways you choose. That's a dynamic query albeit a very simple one since what you can combine is within the world of tags. A more complicated example is if you could combine tags and users. </p>
<p>First of all, when you have a dynamic query, it sounds like you can no longer use the substitution api to avoid sql injection since the query elements will depend on what the user decided to include in the query. I can't see how else to build this query other than using string append.</p>
<p>Secondly, the query could potentially span multiple tables. For example, if SO allows users to filter based on Users and Tags, and these probably live in two different tables, building the query gets a bit more complicated than just appending columns and WHERE clauses.</p>
<p>How do I go about implementing something like this?</p>
|
[
{
"answer_id": 278661,
"author": "Mladen Prajdic",
"author_id": 31345,
"author_profile": "https://Stackoverflow.com/users/31345",
"pm_score": 0,
"selected": false,
"text": "CONCAT"
},
{
"answer_id": 278672,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": false,
"text": "Zend_Db_Select"
},
{
"answer_id": 279006,
"author": "Tom Leys",
"author_id": 11440,
"author_profile": "https://Stackoverflow.com/users/11440",
"pm_score": 0,
"selected": false,
"text": "#Model definition\nclass Blog(models.Model):\n name = models.CharField(max_length=100)\n tagline = models.TextField()\n\n def __unicode__(self):\n return self.name\n from mysite.blog.models import Blog\nb = Blog(name='Beatles Blog', tagline='All the latest Beatles news.')\nb.save()\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30581/"
] |
278,655
|
<p>When should I put ... at the end of a menu item? I seem to remember reading some rules but can't for the life of me find them.</p>
<p>For context - I'm adding a properties option to a right click menu and am wondering if it is appropriate to add them.</p>
|
[
{
"answer_id": 1405784,
"author": "Kyle Rosendo",
"author_id": 103385,
"author_profile": "https://Stackoverflow.com/users/103385",
"pm_score": 1,
"selected": false,
"text": "Dialog"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/770/"
] |
278,668
|
<p>Is it possible to have an ASP.NET MVC route that uses subdomain information to determine its route? For example:</p>
<ul>
<li><em><strong>user1</strong>.domain.example</em> goes to one place</li>
<li><em><strong>user2</strong>.domain.example</em> goes to another?</li>
</ul>
<p>Or, can I make it so both of these go to the same controller/action with a <code>username</code> parameter?</p>
|
[
{
"answer_id": 541495,
"author": "Jon Cahill",
"author_id": 10830,
"author_profile": "https://Stackoverflow.com/users/10830",
"pm_score": 8,
"selected": true,
"text": "public class ExampleRoute : RouteBase\n{\n\n public override RouteData GetRouteData(HttpContextBase httpContext)\n {\n var url = httpContext.Request.Headers[\"HOST\"];\n var index = url.IndexOf(\".\");\n\n if (index < 0)\n return null;\n\n var subDomain = url.Substring(0, index);\n\n if (subDomain == \"user1\")\n {\n var routeData = new RouteData(this, new MvcRouteHandler());\n routeData.Values.Add(\"controller\", \"User1\"); //Goes to the User1Controller class\n routeData.Values.Add(\"action\", \"Index\"); //Goes to the Index action on the User1Controller\n\n return routeData;\n }\n\n if (subDomain == \"user2\")\n {\n var routeData = new RouteData(this, new MvcRouteHandler());\n routeData.Values.Add(\"controller\", \"User2\"); //Goes to the User2Controller class\n routeData.Values.Add(\"action\", \"Index\"); //Goes to the Index action on the User2Controller\n\n return routeData;\n }\n\n return null;\n }\n\n public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)\n {\n //Implement your formating Url formating here\n return null;\n }\n}\n"
},
{
"answer_id": 2723863,
"author": "Jim Blake",
"author_id": 3457,
"author_profile": "https://Stackoverflow.com/users/3457",
"pm_score": 5,
"selected": false,
"text": "routes.Add(\"DomainRoute\", new DomainRoute( \n \"{customer}.example.com\", // Domain with parameters \n \"{action}/{id}\", // URL with parameters \n new { controller = \"Home\", action = \"Index\", id = \"\" } // Parameter defaults \n))\n"
},
{
"answer_id": 15287579,
"author": "Edward Brey",
"author_id": 145173,
"author_profile": "https://Stackoverflow.com/users/145173",
"pm_score": 6,
"selected": false,
"text": "SubdomainRoute Route SubdomainRoute sub.example.com/foo/bar example.com/foo/bar?subdomain=sub Url.Action class SubdomainRoute : Route\n{\n public SubdomainRoute(string url) : base(url, new MvcRouteHandler()) {}\n\n public override RouteData GetRouteData(HttpContextBase httpContext)\n {\n var routeData = base.GetRouteData(httpContext);\n if (routeData == null) return null; // Only look at the subdomain if this route matches in the first place.\n string subdomain = httpContext.Request.Params[\"subdomain\"]; // A subdomain specified as a query parameter takes precedence over the hostname.\n if (subdomain == null) {\n string host = httpContext.Request.Headers[\"Host\"];\n int index = host.IndexOf('.');\n if (index >= 0)\n subdomain = host.Substring(0, index);\n }\n if (subdomain != null)\n routeData.Values[\"subdomain\"] = subdomain;\n return routeData;\n }\n\n public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)\n {\n object subdomainParam = requestContext.HttpContext.Request.Params[\"subdomain\"];\n if (subdomainParam != null)\n values[\"subdomain\"] = subdomainParam;\n return base.GetVirtualPath(requestContext, values);\n }\n}\n MapSubdomainRoute RegisterRoutes MapRoute static void MapSubdomainRoute(this RouteCollection routes, string name, string url, object defaults = null, object constraints = null)\n{\n routes.Add(name, new SubdomainRoute(url) {\n Defaults = new RouteValueDictionary(defaults),\n Constraints = new RouteValueDictionary(constraints),\n DataTokens = new RouteValueDictionary()\n });\n}\n Subdomain protected string Subdomain\n{\n get { return (string)Request.RequestContext.RouteData.Values[\"subdomain\"]; }\n}\n"
},
{
"answer_id": 18727372,
"author": "Edward Brey",
"author_id": 145173,
"author_profile": "https://Stackoverflow.com/users/145173",
"pm_score": 2,
"selected": false,
"text": "subdomain public string Get(string id, string subdomain)\n class SubdomainActionSelector : IHttpActionSelector\n{\n private readonly IHttpActionSelector defaultSelector;\n\n public SubdomainActionSelector(IHttpActionSelector defaultSelector)\n {\n this.defaultSelector = defaultSelector;\n }\n\n public ILookup<string, HttpActionDescriptor> GetActionMapping(HttpControllerDescriptor controllerDescriptor)\n {\n return defaultSelector.GetActionMapping(controllerDescriptor);\n }\n\n public HttpActionDescriptor SelectAction(HttpControllerContext controllerContext)\n {\n var routeValues = controllerContext.Request.GetRouteData().Values;\n if (!routeValues.ContainsKey(\"subdomain\")) {\n string host = controllerContext.Request.Headers.Host;\n int index = host.IndexOf('.');\n if (index >= 0)\n controllerContext.Request.GetRouteData().Values.Add(\"subdomain\", host.Substring(0, index));\n }\n return defaultSelector.SelectAction(controllerContext);\n }\n}\n WebApiConfig.Register config.Services.Replace(typeof(IHttpActionSelector), new SubdomainActionSelector(config.Services.GetActionSelector()));\n"
},
{
"answer_id": 30933162,
"author": "Amirhossein Mehrvarzi",
"author_id": 1743997,
"author_profile": "https://Stackoverflow.com/users/1743997",
"pm_score": 1,
"selected": false,
"text": "public abstract class SiteController : Controller {\n ISiteProvider _siteProvider;\n\n public SiteController() {\n _siteProvider = new SiteProvider();\n }\n\n public SiteController(ISiteProvider siteProvider) {\n _siteProvider = siteProvider;\n }\n\n protected override void Initialize(RequestContext requestContext) {\n string[] host = requestContext.HttpContext.Request.Headers[\"Host\"].Split(':');\n\n _siteProvider.Initialise(host[0]);\n\n base.Initialize(requestContext);\n }\n\n protected override void OnActionExecuting(ActionExecutingContext filterContext) {\n ViewData[\"Site\"] = Site;\n\n base.OnActionExecuting(filterContext);\n }\n\n public Site Site {\n get {\n return _siteProvider.GetCurrentSite();\n }\n }\n\n}\n ISiteProvider public interface ISiteProvider {\n void Initialise(string host);\n Site GetCurrentSite();\n}\n"
},
{
"answer_id": 39996443,
"author": "Edward Brey",
"author_id": 145173,
"author_profile": "https://Stackoverflow.com/users/145173",
"pm_score": 2,
"selected": false,
"text": "Request.Host.Host Request.Query app.UseMvc routes.Routes.Add(new HostPropagationRouter(routes.DefaultHandler));\n HostPropagationRouter /// <summary>\n/// A router that propagates the request's \"host\" query parameter to the response.\n/// </summary>\nclass HostPropagationRouter : IRouter\n{\n readonly IRouter router;\n\n public HostPropagationRouter(IRouter router)\n {\n this.router = router;\n }\n\n public VirtualPathData GetVirtualPath(VirtualPathContext context)\n {\n if (context.HttpContext.Request.Query.TryGetValue(\"host\", out var host))\n context.Values[\"host\"] = host;\n return router.GetVirtualPath(context);\n }\n\n public Task RouteAsync(RouteContext context) => router.RouteAsync(context);\n}\n"
},
{
"answer_id": 46795547,
"author": "Mariusz",
"author_id": 746962,
"author_profile": "https://Stackoverflow.com/users/746962",
"pm_score": 2,
"selected": false,
"text": "public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)\n{\n var hostnames = new[] { \"localhost:54575\" };\n\n app.UseMvc(routes =>\n {\n routes.MapSubdomainRoute(\n hostnames,\n \"SubdomainRoute\",\n \"{username}\",\n \"{controller}/{action}\",\n new { controller = \"Home\", action = \"Index\" });\n )};\n public IActionResult Index(string username)\n{\n //code\n}\n @Html.ActionLink(\"User home\", \"Index\", \"Home\" new { username = \"user1\" }, null)\n <a href=\"http://user1.localhost:54575/Home/Index\">User home</a> BeginForm UrlHelper FormTagHelper AnchorTagHelper"
},
{
"answer_id": 54312956,
"author": "Jean",
"author_id": 4881677,
"author_profile": "https://Stackoverflow.com/users/4881677",
"pm_score": 0,
"selected": false,
"text": "[IsDomain(\"localhost\",\"example.com\",\"www.example.com\",\"*.t1.example.com\")]\n[HttpGet(\"RestrictedByHost\")]\npublic IActionResult Test(){}\n public class IsDomainAttribute : Attribute, Microsoft.AspNetCore.Mvc.Filters.IAuthorizationFilter\n{\n\n public IsDomainAttribute(params string[] domains)\n {\n Domains = domains;\n }\n\n public string[] Domains { get; }\n\n public void OnAuthorization(AuthorizationFilterContext context)\n {\n var host = context.HttpContext.Request.Host.Host;\n if (Domains.Contains(host))\n return;\n if (Domains.Any(d => d.EndsWith(\"*\"))\n && Domains.Any(d => host.StartsWith(d.Substring(0, d.Length - 1))))\n return;\n if (Domains.Any(d => d.StartsWith(\"*\"))\n && Domains.Any(d => host.EndsWith(d.Substring(1))))\n return;\n\n context.Result = new Microsoft.AspNetCore.Mvc.NotFoundResult();//.ChallengeResult\n }\n}\n [IsDomain(\"test1.example.com\")]\n[HttpGet(\"/Test\")]\npublic IActionResult Test1(){}\n\n[IsDomain(\"test2.example.com\")]\n[HttpGet(\"/Test\")]\npublic IActionResult Test2(){}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19020/"
] |
278,674
|
<p>I've been tasked with the awesome job of generating a look-up table for our application culture information. The columns I need to generate data for are:</p>
<ul>
<li>Dot Net Code</li>
<li>Version</li>
<li>Culture Name</li>
<li>Country Name</li>
<li>Language Name</li>
<li>Java Country Code</li>
<li>Java Language Code</li>
<li>Iso Country Code</li>
<li>Iso Language Code</li>
</ul>
<p>I have found the globalization name space, but I'm sure someone out there has asked the same question, or there is a table already available.</p>
<p>Thanks for any help</p>
|
[
{
"answer_id": 278875,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 3,
"selected": true,
"text": "Locale l = Locale.ITALY;\nSystem.out.println(l.getDisplayCountry() + \": \" + l.getDisplayLanguage());\nSystem.out.println(l.getDisplayCountry(l) + \": \" + l.getDisplayLanguage(l));\n Italy: Italian \nItalia: italiano\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36269/"
] |
278,676
|
<p>I'm working the the image upload piece of the <a href="http://www.fckeditor.net/" rel="nofollow noreferrer">FCKEditor</a> and I've got the uploading working properly but am stuck with the server file browser.</p>
<p><img src="https://farm4.static.flickr.com/3184/3019956718_f7ab198c16.jpg?v=0" alt="FCKEditor Image Properties dialog"/></p>
<p>You can see in the dialog above has a <strong>Browse Server</strong> button which pops up the following dialog</p>
<p><img src="https://farm4.static.flickr.com/3054/3019956722_712ae75d24.jpg?v=0" alt="FCKEditor Resources Browser" /></p>
<p>The problem is that I have no idea which folder the file browser is pointing at.</p>
<p>I've set the <strong>UserFilePath</strong> and <strong>USerFilesAbsolutePath</strong> in the PHP connector config.php to control where my image uploads go.</p>
<h3>How can I configure the file browser so that it starts off pointing at the same folder where my uploads are going?</h3>
<hr>
<p><strong>Edit</strong></p>
<p>The <strong>ImageBrowserURL</strong> property is <em>NOT</em> what I'm looking for. That property is used for having the <em>Browser Server</em> button point somewhere other than the default file browser.</p>
<p>My problem is figuring out how to point the default file browser to a specific directory.</p>
|
[
{
"answer_id": 281821,
"author": "Steve Massing",
"author_id": 34889,
"author_profile": "https://Stackoverflow.com/users/34889",
"pm_score": 1,
"selected": false,
"text": "FCKConfig.ImageBrowserURL = '/myfilebrowserpath/browser.php' ;\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] |
278,684
|
<p>I am just getting started with expression trees so I hope this makes sense. I am trying to create an expression tree to represent:</p>
<pre><code>t => t.SomeProperty.Contains("stringValue");
</code></pre>
<p>So far I have got:</p>
<pre><code> private static Expression.Lambda<Func<string, bool>> GetContainsExpression<T>(string propertyName, string propertyValue)
{
var parameterExp = Expression.Parameter(typeof(T), "type");
var propertyExp = Expression.Property(parameter, propertyName);
var containsMethodExp = Expression.*SomeMemberReferenceFunction*("Contains", propertyExp) //this is where I got lost, obviously :)
...
return Expression.Lambda<Func<string, bool>>(containsMethodExp, parameterExp); //then something like this
}
</code></pre>
<p>I just don't know how to reference the String.Contains() method.</p>
<p>Help appreciated. </p>
|
[
{
"answer_id": 278702,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 8,
"selected": true,
"text": "class Foo\n{\n public string Bar { get; set; }\n}\nstatic void Main()\n{\n var lambda = GetExpression<Foo>(\"Bar\", \"abc\");\n Foo foo = new Foo { Bar = \"aabca\" };\n bool test = lambda.Compile()(foo);\n}\nstatic Expression<Func<T, bool>> GetExpression<T>(string propertyName, string propertyValue)\n{\n var parameterExp = Expression.Parameter(typeof(T), \"type\");\n var propertyExp = Expression.Property(parameterExp, propertyName);\n MethodInfo method = typeof(string).GetMethod(\"Contains\", new[] { typeof(string) });\n var someValue = Expression.Constant(propertyValue, typeof(string));\n var containsMethodExp = Expression.Call(propertyExp, method, someValue);\n\n return Expression.Lambda<Func<T, bool>>(containsMethodExp, parameterExp);\n}\n"
},
{
"answer_id": 1129741,
"author": "Abhijeet Patel",
"author_id": 84074,
"author_profile": "https://Stackoverflow.com/users/84074",
"pm_score": 3,
"selected": false,
"text": "Expression<Func<string, string, bool>> expFunc = (name, value) => name.Contains(value);\n bool result = expFunc.Compile()(\"FooBar\", \"Foo\"); //result true\n result = expFunc.Compile()(\"FooBar\", \"Boo\"); //result false\n"
},
{
"answer_id": 9678266,
"author": "Leng Weh Seng",
"author_id": 1265602,
"author_profile": "https://Stackoverflow.com/users/1265602",
"pm_score": 3,
"selected": false,
"text": "ef.Entities.Where(entity => arr.Contains(entity.Name)).ToArray();\n SELECT .... From Entities ... Where Name In (\"abc\", \"def\", \"qaz\")\n ef.Entities.Where(ContainsPredicate<Entity, string>(arr, \"Name\")).ToArray();\n\npublic Expression<Func<TEntity, bool>> ContainsPredicate<TEntity, T>(T[] arr, string fieldname) where TEntity : class {\n ParameterExpression entity = Expression.Parameter(typeof(TEntity), \"entity\");\n MemberExpression member = Expression.Property(entity, fieldname);\n\n var containsMethods = typeof(Enumerable).GetMethods(BindingFlags.Static | BindingFlags.Public)\n .Where(m => m.Name == \"Contains\");\n MethodInfo method = null;\n foreach (var m in containsMethods) {\n if (m.GetParameters().Count() == 2) {\n method = m;\n break;\n }\n }\n method = method.MakeGenericMethod(member.Type);\n var exprContains = Expression.Call(method, new Expression[] { Expression.Constant(arr), member });\n return Expression.Lambda<Func<TEntity, bool>>(exprContains, entity);\n}\n"
},
{
"answer_id": 47688937,
"author": "Xavier John",
"author_id": 1394827,
"author_profile": "https://Stackoverflow.com/users/1394827",
"pm_score": 1,
"selected": false,
"text": "var method = typeof(Enumerable)\n .GetRuntimeMethods()\n .Single(m => m.Name == nameof(Enumerable.Contains) && m.GetParameters().Length == 2);\nvar containsMethod = method.MakeGenericMethod(typeof(string));\nvar doesContain = Expression\n.Call(containsMethod, Expression.Constant(criteria.ToArray()),\n Expression.Property(p, \"MyParam\"));\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27805/"
] |
278,692
|
<p>If I have a comma separated file like the following:</p>
<pre>
foo,bar,n
,a,bc,d
one,two,three
,a,bc,d
</pre>
<p>And I want to join the <code>\n,</code> to produce this:</p>
<pre>
foo,bar,n,a,bc,d
one,two,three,a,bc,d
</pre>
<p>What is the regex trick? I thought that an <code>if (/\n,/)</code> would catch this.</p>
<p>Also, will I need to do anything special for a UTF-8 encoded file?</p>
<p>Finally, a solution in Groovy would also be helpful.</p>
|
[
{
"answer_id": 278723,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 0,
"selected": false,
"text": "open(F, \"test.txt\") or die;\nundef $/;\n$s = <F>;\nclose(F);\n$s =~ s/\\n,/,/g;\nprint $s;\n\n$ cat test.txt\nfoo,bar,n\n,a,bc,d\none,two,three\n,a,bc,d\n$ perl test.pl \nfoo,bar,n,a,bc,d\none,two,three,a,bc,d\n"
},
{
"answer_id": 280096,
"author": "Ted Naleid",
"author_id": 8912,
"author_profile": "https://Stackoverflow.com/users/8912",
"pm_score": 0,
"selected": false,
"text": "def input = \"\"\"foo,bar,n\n,a,bc,d\none,two,three\n,a,bc,d\"\"\"\n\ndef answer = (input =~ /(.*\\n?,){5}.*(\\n|$)/).inject (\"\") { ans, match ->\n ans << match.replaceAll(\"\\n\",\"\") << \"\\n\"\n}\n\nassert answer.toString() == \n\"\"\"foo,bar,n,a,bc,d\none,two,three,a,bc,d\n\"\"\"\n"
},
{
"answer_id": 282927,
"author": "Bob Herrmann",
"author_id": 6580,
"author_profile": "https://Stackoverflow.com/users/6580",
"pm_score": 0,
"selected": false,
"text": "def input = \"\"\"foo,bar,n\n,a,bc,d\none,two,three\n,a,bc,d\"\"\"\n\ndef last\ninput.eachLine {\n if(it.startsWith(',')) {\n last += it;\n return;\n }\n if(last)\n println last;\n last = it\n}\nprintln last\n foo,bar,n,a,bc,d\none,two,three,a,bc,d\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
278,703
|
<p>I know the standard way of using the <a href="https://en.wikipedia.org/wiki/Null_coalescing_operator" rel="noreferrer">null coalescing operator</a> in C# is to set default values.</p>
<pre><code>string nobody = null;
string somebody = "Bob Saget";
string anybody = "";
anybody = nobody ?? "Mr. T"; // Returns Mr. T
anybody = somebody ?? "Mr. T"; // Returns "Bob Saget"
</code></pre>
<p>But what else can <code>??</code> be used for? It doesn't seem as useful as the <a href="https://en.wikipedia.org/wiki/%3F:" rel="noreferrer">ternary operator</a>, apart from being more concise and easier to read than:</p>
<pre><code>nobody = null;
anybody = nobody == null ? "Bob Saget" : nobody; // Returns Bob Saget
</code></pre>
<p>So given that fewer even know about null coalescing operator...</p>
<ul>
<li><p>Have you used <code>??</code> for something else?</p>
</li>
<li><p>Is <code>??</code> necessary, or should you just use the ternary operator (that
most are familiar with)</p>
</li>
</ul>
|
[
{
"answer_id": 278713,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "||"
},
{
"answer_id": 278716,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 9,
"selected": true,
"text": "string anybody = parm1 ?? localDefault ?? globalDefault;\n string anyboby = (parm1 != null) ? parm1\n : ((localDefault != null) ? localDefault\n : globalDefault);\n string anybody = Parameters[\"Name\"]\n ?? Settings[\"Name\"]\n ?? GlobalSetting[\"Name\"];\n string anybody = (Parameters[\"Name\"] != null ? Parameters[\"Name\"]\n : (Settings[\"Name\"] != null) ? Settings[\"Name\"]\n : GlobalSetting[\"Name\"];\n"
},
{
"answer_id": 278718,
"author": "Cristian Libardo",
"author_id": 16526,
"author_profile": "https://Stackoverflow.com/users/16526",
"pm_score": 7,
"selected": false,
"text": "public MyClass LazyProp\n{\n get { return lazyField ?? (lazyField = new MyClass()); }\n}\n"
},
{
"answer_id": 278734,
"author": "HanClinto",
"author_id": 26933,
"author_profile": "https://Stackoverflow.com/users/26933",
"pm_score": 2,
"selected": false,
"text": "public void someMethod(object parm2, ArrayList parm3)\n{\n someMethod(null, parm2, parm3);\n}\n\npublic void someMethod(string parm1, ArrayList parm3)\n{\n someMethod(parm1, null, parm3);\n}\n\npublic void someMethod(string parm1, object parm2)\n{\n someMethod(parm1, parm2, null);\n}\n\npublic void someMethod(string parm1)\n{\n someMethod(parm1, null, null);\n}\n\npublic void someMethod(object parm2)\n{\n someMethod(null, parm2, null);\n}\n\npublic void someMethod(ArrayList parm3)\n{\n someMethod(null, null, parm3);\n}\n\npublic void someMethod(string parm1, object parm2, ArrayList parm3)\n{\n // Set your default parameters here rather than scattered \n // through the above function overloads\n parm1 = parm1 ?? \"Default User Name\";\n parm2 = parm2 ?? GetCurrentUserObj();\n parm3 = parm3 ?? DefaultCustomerList;\n\n // Do the rest of the stuff here\n}\n"
},
{
"answer_id": 278897,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 6,
"selected": false,
"text": "out TryParse public int Compare(Person p1, Person p2)\n{\n return PartialComparer.Compare(p1.Age, p2.Age)\n ?? PartialComparer.Compare(p1.Name, p2.Name)\n ?? PartialComparer.Compare(p1.Salary, p2.Salary)\n ?? 0;\n}\n"
},
{
"answer_id": 280476,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 3,
"selected": false,
"text": "?? public string Error\n{\n get\n {\n return this[\"Name\"] ?? this[\"Address\"] ?? this[\"Phone\"];\n }\n}\n\npublic string this[string columnName]\n{\n get { ... }\n}\n"
},
{
"answer_id": 382269,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": false,
"text": "string result = MyMethod() ?? \"default value\";\n string result = (MyMethod () != null ? MyMethod () : \"default value\");\n string methodResult = MyMethod ();\nstring result = (methodResult != null ? methodResult : \"default value\");\n"
},
{
"answer_id": 630945,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "string result1 = string.empty ?? \"dead code!\";\n\nstring result2 = null ?? \"coalesced!\";\n result1 = \"\"\n\nresult2 = coalesced!\n"
},
{
"answer_id": 5004054,
"author": "user",
"author_id": 486504,
"author_profile": "https://Stackoverflow.com/users/486504",
"pm_score": 3,
"selected": false,
"text": "?: || + if ??"
},
{
"answer_id": 13594274,
"author": "Ryan",
"author_id": 490561,
"author_profile": "https://Stackoverflow.com/users/490561",
"pm_score": 4,
"selected": false,
"text": "?? int? test = null;\nvar result = test ?? 0; // 'result' is int, not int?\n Dictionary<int, int?> PurchaseQuantities;\n// PurchaseQuantities populated via ASP .NET MVC form.\nvar totalPurchased = PurchaseQuantities.Sum(kvp => kvp.Value ?? 0);\n// totalPurchased is int, not int?\n"
},
{
"answer_id": 17399581,
"author": "Niall Connaughton",
"author_id": 114200,
"author_profile": "https://Stackoverflow.com/users/114200",
"pm_score": 3,
"selected": false,
"text": "public void Method(Arg arg = null)\n{\n arg = arg ?? Arg.Default;\n ...\n"
},
{
"answer_id": 24309582,
"author": "mlnyc",
"author_id": 712399,
"author_profile": "https://Stackoverflow.com/users/712399",
"pm_score": 3,
"selected": false,
"text": "public class StackOverflow\n{\n private IEnumerable<string> _definitions;\n public IEnumerable<string> Definitions\n {\n get\n {\n return _definitions ?? (\n _definitions = new List<string>\n {\n \"definition 1\",\n \"definition 2\",\n \"definition 3\"\n }\n );\n }\n } \n}\n"
},
{
"answer_id": 32052205,
"author": "Fabio Lima",
"author_id": 5124648,
"author_profile": "https://Stackoverflow.com/users/5124648",
"pm_score": 5,
"selected": false,
"text": "public class A\n{\n var count = 0;\n private int? _prop = null;\n public int? Prop\n {\n get \n {\n ++count;\n return _prop\n }\n set\n {\n _prop = value;\n }\n }\n}\n var a = new A();\nvar b = a.Prop == null ? 0 : a.Prop;\n count var b = a.Prop ?? 0\n count"
},
{
"answer_id": 38102185,
"author": "Blue0500",
"author_id": 3026431,
"author_profile": "https://Stackoverflow.com/users/3026431",
"pm_score": 3,
"selected": false,
"text": "as object boxed = 4;\nint i = (boxed as int?) ?? 99;\n\nConsole.WriteLine(i); // Prints 4\n ?. int result = MyObj?.Prop?.Foo?.Val ?? 4;\nstring other = (MyObj?.Prop?.Foo?.Name as string)?.ToLower() ?? \"not there\";\n"
},
{
"answer_id": 41228718,
"author": "PaulG",
"author_id": 141661,
"author_profile": "https://Stackoverflow.com/users/141661",
"pm_score": 2,
"selected": false,
"text": "IDisposable Channel channel;\nAuthentication authentication;\n\nif (entities == null)\n{\n using (entities = Entities.GetEntities())\n {\n channel = entities.GetChannelById(googleShoppingChannelCredential.ChannelId);\n [...]\n }\n}\nelse\n{\n channel = entities.GetChannelById(googleShoppingChannelCredential.ChannelId);\n [...]\n}\n using (entities ?? Entities.GetEntities())\n{\n channel = entities.GetChannelById(googleShoppingChannelCredential.ChannelId);\n [...]\n}\n"
},
{
"answer_id": 57758170,
"author": "Muhammad Awais",
"author_id": 3901944,
"author_profile": "https://Stackoverflow.com/users/3901944",
"pm_score": 0,
"selected": false,
"text": "for (int i = 0; i < result.Count; i++)\n{\n object[] atom = result[i];\n\n atom[3] = atom[3] ?? 0;\n atom[4] = atom[4] != null ? \"Test\" : string.Empty;\n atom[5] = atom[5] ?? \"\";\n atom[6] = atom[6] ?? \"\";\n atom[7] = atom[7] ?? \"\";\n atom[8] = atom[8] ?? \"\";\n atom[9] = atom[9] ?? \"\";\n atom[10] = atom[10] ?? \"\";\n atom[12] = atom[12] ?? false;\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26931/"
] |
278,709
|
<p>I have some user generated content I'm trying to render on my site. The rich text box editor I'm using renders font changes using <code><font /></code> tags, which are overridden by CSS on the page.</p>
<p>Does anyone know if there is a way to allow rules defined using the <code><font /></code> tag to show through?</p>
<p><strong>UPDATE</strong><br>
Since changing the control I'm using for my rich text editor is not an option and my users have no knowledge of HTML to understand the difference between a <code><font></code> tag and any other type of tag, I had no choice but to create a hack to fix my problem. Below is the code I used to solve it. It's a jQuery script that changes all <code><font /></code> tag attributes into inline CSS. </p>
<pre><code>(function() {
$('font[size]').each(function() {
var fontSize = this.size;
if (fontSize == 1) {
$(this).css("font-size", 8);
} else if (fontSize == 2) {
$(this).css("font-size", 9);
} else if (fontSize == 3) {
$(this).css("font-size", 11);
} else if (fontSize == 4) {
$(this).css("font-size", 15);
} else if (fontSize == 5) {
$(this).css("font-size", 20);
} else if (fontSize == 6) {
$(this).css("font-size", 25);
}
});
$('font[face]').each(function() {
$(this).css('font-family', this.face);
});
$('font[color]').each(function() {
$(this).css('color', this.color);
});
})();
</code></pre>
|
[
{
"answer_id": 278717,
"author": "thismat",
"author_id": 14045,
"author_profile": "https://Stackoverflow.com/users/14045",
"pm_score": 2,
"selected": false,
"text": "div.MyClass p \n{ \nfont-size: 0.7em !important; \n}\n"
},
{
"answer_id": 278727,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 1,
"selected": false,
"text": "style"
},
{
"answer_id": 278994,
"author": "Mr. Shiny and New 安宇",
"author_id": 7867,
"author_profile": "https://Stackoverflow.com/users/7867",
"pm_score": 0,
"selected": false,
"text": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html>\n <head>\n <title></title>\n <style type=\"text/css\">\n body { color: black}\n a { color: red; font-family: Sans; font-size: 14px;}\n font * { color: inherit; font-family: inherit; font-size: inherit}\n </style>\n </head>\n <body>\n This is outside <a href=\"#\">inside</a> outside. <font color=\"green\" face=\"Times New Roman\" size=\"20\">Outside <a href=\"#\">inside</a> outside</font>.\n </body>\n</html>\n"
},
{
"answer_id": 1998107,
"author": "Rick Buczynski",
"author_id": 243038,
"author_profile": "https://Stackoverflow.com/users/243038",
"pm_score": 3,
"selected": true,
"text": "<FONT /> var fontEl=document.getElementsByTagName(\"font\");\nfor(var i=0;i<fontEl.length;i++) {\n var f = fontEl[i];\n if(f.size)\n f.style.fontSize=(Math.round(parseInt(f.size)*12*0.6)).toString()+'px';\n if(f.face)\n f.style.fontFamily=f.face;\n if(f.color)\n f.style.color=f.color;\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392/"
] |
278,719
|
<p>I have some code doing this :</p>
<pre><code> var changes = document.getElementsByName(from);
for (var c=0; c<changes.length; c++) {
var ch = changes[c];
var current = new String(ch.innerHTML);
etc.
}
</code></pre>
<p>This works fine in FF and Chrome but not in IE7. Presumably because getElementsByName isn't working in IE. What's the best workaround?</p>
|
[
{
"answer_id": 278741,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "id=\"\" name=\"\" name=\"\" <span> name=\"\" class=\"\" var changes = document.getElementById('text').getElementsByTagName('span');\nfor (var c=0; c<changes.length; c++) {\n var ch = changes[c];\n\n if (ch.className != from)\ncontinue;\n\n var current = new String(ch.innerHTML);\n"
},
{
"answer_id": 278773,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 5,
"selected": true,
"text": "getElementsByName() getAttribute() getElementsByTagName() <div id=\"Change0\">...</div>\n<div id=\"Change1\">...</div>\n<div id=\"Change2\">...</div>\n<div id=\"Change3\">...</div>\n // assumes consecutive numbering, starting at 0\nfunction getElementsByModifiedId(baseIdentifier) {\n var allWantedElements = [];\n var idMod = 0;\n while(document.getElementById(baseIdentifier + idMod)) { // will stop when it can't find any more\n allWantedElements.push(document.getElementById(baseIdentifier + idMod++));\n }\n return allWantedElements;\n}\n\n// call it like so:\nvar changes = getElementsByModifiedId(\"Change\");\n"
},
{
"answer_id": 278798,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": 2,
"selected": false,
"text": " $(\"*[name='whatevernameYouWant']\");\n"
},
{
"answer_id": 17750662,
"author": "smu johnson",
"author_id": 2600109,
"author_profile": "https://Stackoverflow.com/users/2600109",
"pm_score": 1,
"selected": false,
"text": "function getElementsByNameWrapper(name) {\n a = new Array();\n\n for (var i = 0; i < document.getElementsByName(name).length; ++i) {\n a.push(document.getElementsByName(name)[i]);\n }\n\n return a;\n}\n"
},
{
"answer_id": 19820203,
"author": "Davide Andrea",
"author_id": 719812,
"author_profile": "https://Stackoverflow.com/users/719812",
"pm_score": 1,
"selected": false,
"text": " var listOfElements = document.getElementsByName('aName'); // Replace aName with the name you're looking for\n // IE hack, because it doesn't properly support getElementsByName\n if (listOfElements.length == 0) { // If IE, which hasn't returned any elements\n var listOfElements = [];\n var spanList = document.getElementsByTagName('*'); // If all the elements are the same type of tag, enter it here (e.g.: SPAN)\n for(var i = 0; i < spanList.length; i++) {\n if(spanList[i].getAttribute('name') == 'aName') {\n listOfElements.push(spanList[i]);\n }\n }\n }\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36273/"
] |
278,732
|
<p>Currently have the following mapping file:</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="NHibernateHelpers"
assembly="App_Code.NHibernateHelpers">
<class name="NHibernateHelpers.Fixture, App_Code" table="Fixture_Lists">
<id name="Id" column="UniqRefNo">
<generator class="guid" />
</id>
<property name="Date" column="FixDate"/>
<property name="HomeTeamId" column="HomeId"/>
<property name="HomeTeamName" column="Home_Team"/>
<property name="AwayTeamId" column="AwayId"/>
<property name="AwayTeamName" column="Away_Team"/>
<property name="Kickoff" column="Kickoff"/>
<bag name="Goals">
<key column="FixID" />
<one-to-many class="NHibernateHelpers.Goal, App_Code"/>
</bag>
<bag name="Bookings">
<key column="FixID" />
<one-to-many class="NHibernateHelpers.Booking, App_Code"/>
</bag>
<many-to-one name="HomeTeam" class="NHibernateHelpers.Team" column="HomeId" />
<many-to-one name="AwayTeam" class="NHibernateHelpers.Team" column="AwayId" />
<many-to-one name="Division" class="NHibernateHelpers.Division" column="Div_Comp" />
<property name="HomeFullTimeScoreCode" column="Home_FT_Score"/>
<property name="AwayFullTimeScoreCode" column="Away_FT_Score"/>
</class>
</hibernate-mapping>
</code></pre>
<p>Which maps nicely to the legacy database I have inherited, but I would like to add a property named "MatchTime" that contains the output of the stored procedure:</p>
<pre><code>EXEC GetMatchTime @FixtureId = :Id
</code></pre>
<p>where :Id is the Id of the current Fixture object.</p>
<p>Is this possible in the mapping file?</p>
|
[
{
"answer_id": 278807,
"author": "Watson",
"author_id": 25807,
"author_profile": "https://Stackoverflow.com/users/25807",
"pm_score": 0,
"selected": false,
"text": "<property name='MatchTime' formula='(EXEC GetMatchTime Id)'/>\n"
},
{
"answer_id": 278966,
"author": "Mr Plough",
"author_id": 21940,
"author_profile": "https://Stackoverflow.com/users/21940",
"pm_score": 0,
"selected": false,
"text": "SELECT FieldA, FieldB, FieldC, ( EXEC GetMatchTime Id ) FROM Fixture_Lists\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21940/"
] |
278,738
|
<p>I have an XML schema that represents a product in a DB, and I am trying to figure out the best way to store the product image references as XML nodes. There will be a primary image, and then alternate images, each of them with sequences (display order). Would this be an appropriate format, or are there better approaches:</p>
<pre><code><item>
<id></id>
<images>
<image width="" height="" href="" alt="" sequence="1" />
<image width="" height="" href="" alt="" sequence="2" />
<image width="" height="" href="" alt="" sequence="3" />
<image width="" height="" href="" alt="" sequence="4" />
</images>
</item>
</code></pre>
<p>Obviously there will be more nodes than this, but I'm not showing them all. I figured my primary image would always be the first in the sequence. The problem I'm having is that each of these images will have a thumbnail, medium and large images, so I'm thinking this needs to be broken down further.</p>
|
[
{
"answer_id": 278748,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 3,
"selected": true,
"text": "sequence <images>\n <imageset>\n <image size=\"thumbnail\" width=\"\" height=\"\" href=\"\" alt=\"\" />\n <image size=\"medium\" width=\"\" height=\"\" href=\"\" alt=\"\" />\n <image size=\"large\" width=\"\" height=\"\" href=\"\" alt=\"\" />\n </imageset>\n <imageset>\n <image size=\"thumbnail\" width=\"\" height=\"\" href=\"\" alt=\"\" />\n <image size=\"medium\" width=\"\" height=\"\" href=\"\" alt=\"\" />\n <image size=\"large\" width=\"\" height=\"\" href=\"\" alt=\"\" />\n </imageset>\n</images>\n"
},
{
"answer_id": 279034,
"author": "Robert Rossney",
"author_id": 19403,
"author_profile": "https://Stackoverflow.com/users/19403",
"pm_score": 1,
"selected": false,
"text": "size <imageset>\n <thumbnail width=\"\"... />\n <medium width=\"\".../>\n <large width=\"\".../>\n</imageset>\n imageset image imageset/* imageset/image imageset/medium imageset/image[@size='medium'] imageset"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
278,746
|
<p>I really don't understand the fascination with XHTML strict. Inline JavaScript typically requires a rats nest of escapes to make it compatible with XHTML and semi-backwards compatible with MSIE 5 & 6. Then there is the issue of not being OCD enough on user input to make sure you don't miss any illegal characters. It just seems like more effort then its worth. Nevermind that almost every developer I've worked along side of keeps forgetting to ensure the content-type returned from the server is reset for XHTML pages from text/html to application/xhtml+xml.</p>
<p>Wish I knew the name of the blogger, but someone else pointed out that a majority of supposedly XHTML compliant websites and open source packages are actually not because of that last issue, forgetting to set the content-type header correctly.</p>
<p>I'm looking to understand why XHTML is useful, or build enough of an arsenal of arguments to prevent it ever being used in future projects that I have influence on.</p>
|
[
{
"answer_id": 280401,
"author": "Simon",
"author_id": 15371,
"author_profile": "https://Stackoverflow.com/users/15371",
"pm_score": 0,
"selected": false,
"text": "http://www.example.com/page.php?arg1=val1&arg2=val2\n http://www.example.com/page.php?arg1=val1&arg2=val2\n http://www.example.com/page.php?arg1=val1&arg2=val2\n"
},
{
"answer_id": 280410,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 0,
"selected": false,
"text": "/ > /> <p><p><p> <p/>"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278746",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9908/"
] |
278,758
|
<p>I run (and am presently completely overhauling) a website that deals with theater (njtheater.com if you're interested).</p>
<p>When I query a list of plays from the database, I'd like "The Merchant of Venice" to sort under the "M"s. Of course, when I display the name of the play, I need the "The" in front.</p>
<p>What the best way of designing the database to handle this?</p>
<p>(I'm using MS-SQL 2000)</p>
|
[
{
"answer_id": 278771,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 1,
"selected": false,
"text": "article varchar(4)\nsorttitle varchar(255)\ntitle computed (article + sortitle)\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12725/"
] |
278,761
|
<p>I was looking for something like Server.MapPath in the ASP.NET realm to convert the output of Assembly.GetExecutingAssembly().CodeBase into a file path with drive letter.</p>
<p>The following code works for the test cases I've tried:</p>
<pre>
private static string ConvertUriToPath(string fileName)
{
fileName = fileName.Replace("file:///", "");
fileName = fileName.Replace("/", "\\");
return fileName;
}
</pre>
<p>It seems like there should be something in the .NET Framework that would be much better--I just haven't been able to find it.</p>
|
[
{
"answer_id": 278812,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 0,
"selected": false,
"text": "Assembly.Location"
},
{
"answer_id": 278840,
"author": "Scott Dorman",
"author_id": 1559,
"author_profile": "https://Stackoverflow.com/users/1559",
"pm_score": 5,
"selected": true,
"text": "private static string ConvertUriToPath(string fileName)\n{\n Uri uri = new Uri(fileName);\n return uri.LocalPath;\n\n // Some people have indicated that uri.LocalPath doesn't \n // always return the corret path. If that's the case, use\n // the following line:\n // return uri.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped);\n}\n"
},
{
"answer_id": 9404443,
"author": "Artsiom",
"author_id": 1226924,
"author_profile": "https://Stackoverflow.com/users/1226924",
"pm_score": 2,
"selected": false,
"text": "private static string ConvertUriToPath(string fileName)\n{\n Uri uri = new Uri(fileName);\n return uri.LocalPath + Uri.UnescapeDataString(uri.Fragment).Replace('/', '\\\\');\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3475/"
] |
278,768
|
<p>If I'm reading a text file in shared access mode and another process truncates it, what is the easiest way to detect that? (I'm excluding the obvious choice of refreshing a FileInfo object periodically to check its size) Is there some convenient way to capture an event? (Filewatcher?)</p>
|
[
{
"answer_id": 278791,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 3,
"selected": true,
"text": "private void myForm_Load(object sender, EventArgs e)\n{\n var fileWatcher = new System.IO.FileSystemWatcher();\n\n // Monitor changes to PNG files in C:\\temp and subdirectories\n fileWatcher.Path = @\"C:\\temp\";\n fileWatcher.IncludeSubdirectories = true;\n fileWatcher.Filter = @\"*.png\";\n\n // Attach event handlers to handle each file system events\n fileWatcher.Changed += fileChanged;\n fileWatcher.Created += fileCreated;\n fileWatcher.Renamed += fileRenamed;\n\n // Start monitoring!\n fileWatcher.EnableRaisingEvents = true;\n}\n\nvoid fileRenamed(object sender, System.IO.FileSystemEventArgs e)\n{\n // a file has been renamed!\n}\n\nvoid fileCreated(object sender, System.IO.FileSystemEventArgs e)\n{\n // a file has been created!\n}\n\nvoid fileChanged(object sender, System.IO.FileSystemEventArgs e)\n{\n // a file is modified!\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29021/"
] |
278,769
|
<p>I have an asp.net image button and I want to cancel the click event incase he fails the client side validation... how do I do that?</p>
|
[
{
"answer_id": 278804,
"author": "Aaron Fischer",
"author_id": 5618,
"author_profile": "https://Stackoverflow.com/users/5618",
"pm_score": 1,
"selected": false,
"text": "<asp:Button ID=\"NavigateAway\" runat=\"server\" OnClientClick=\"javascript:return PromptToNavigateOff();\" OnClick=\"NavigateAwayButton_Click\" Text=\"Go Away\" />\n\n <script type=\"text/javascript\">\n function PromptToNavigateOff()\n {\n return confirm(\"Are you sure you want to continue and loose all your changes?\");\n }\n\n </script>\n"
},
{
"answer_id": 278819,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 1,
"selected": false,
"text": "<asp:ImageButton OnClientClick=\"return ValidatorOnSubmit()\" />\n function WebForm_OnSubmit() {\n if ( typeof(ValidatorOnSubmit) == \"function\" \n && ValidatorOnSubmit() == false) return false;\n\n return true;\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
278,784
|
<p>What is the best compiler to experiment with C++0x features? I have been experimenting with GNU g++ 4.4. </p>
|
[
{
"answer_id": 278830,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": true,
"text": "auto #geordi at irc.freenode.org"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8863/"
] |
278,788
|
<p>I'm trying to figure out how to parse out the text of an email from any quoted reply text that it might include. I've noticed that usually email clients will put an "On such and such date so and so wrote" or prefix the lines with an angle bracket. Unfortunately, not everyone does this. Does anyone have any idea on how to programmatically detect reply text? I am using C# to write this parser.</p>
|
[
{
"answer_id": 474174,
"author": "Oleg Yaroshevych",
"author_id": 48724,
"author_profile": "https://Stackoverflow.com/users/48724",
"pm_score": 5,
"selected": false,
"text": "new Regex(\"From:\\\\s*\" + Regex.Escape(_mail), RegexOptions.IgnoreCase);\nnew Regex(\"<\" + Regex.Escape(_mail) + \">\", RegexOptions.IgnoreCase);\nnew Regex(Regex.Escape(_mail) + \"\\\\s+wrote:\", RegexOptions.IgnoreCase);\nnew Regex(\"\\\\n.*On.*(\\\\r\\\\n)?wrote:\\\\r\\\\n\", RegexOptions.IgnoreCase | RegexOptions.Multiline);\nnew Regex(\"-+original\\\\s+message-+\\\\s*$\", RegexOptions.IgnoreCase);\nnew Regex(\"from:\\\\s*$\", RegexOptions.IgnoreCase);\n new Regex(\"^>.*$\", RegexOptions.IgnoreCase | RegexOptions.Multiline);\n From: test@test.com [mailto:test@test.com] \nSent: Tuesday, January 13, 2009 1:27 PM\n----\n2008/12/26 <test@test.com>\n\n> text\n----\ntest@test.com wrote:\n> text\n----\n test@test.com wrote: text\ntext\n----\n2009/1/13 <test@test.com>\n\n> text\n----\n test@test.com wrote: text\n text\n----\n2009/1/13 <test@test.com>\n\n> text\n> text\n----\n2009/1/13 <test@test.com>\n\n> text\n> text\n----\ntest@test.com wrote:\n> text\n> text\n<response here>\n----\n--- On Fri, 23/1/09, test@test.com <test@test.com> wrote:\n\n> text\n> text\n"
},
{
"answer_id": 7376064,
"author": "hurshagrawal",
"author_id": 938799,
"author_profile": "https://Stackoverflow.com/users/938799",
"pm_score": 5,
"selected": false,
"text": "def extract_reply(text, address)\n regex_arr = [\n Regexp.new(\"From:\\s*\" + Regexp.escape(address), Regexp::IGNORECASE),\n Regexp.new(\"<\" + Regexp.escape(address) + \">\", Regexp::IGNORECASE),\n Regexp.new(Regexp.escape(address) + \"\\s+wrote:\", Regexp::IGNORECASE),\n Regexp.new(\"^.*On.*(\\n)?wrote:$\", Regexp::IGNORECASE),\n Regexp.new(\"-+original\\s+message-+\\s*$\", Regexp::IGNORECASE),\n Regexp.new(\"from:\\s*$\", Regexp::IGNORECASE)\n ]\n\n text_length = text.length\n #calculates the matching regex closest to top of page\n index = regex_arr.inject(text_length) do |min, regex|\n [(text.index(regex) || text_length), min].min\n end\n\n text[0, index].strip\nend\n"
},
{
"answer_id": 14903620,
"author": "Austin",
"author_id": 32854,
"author_profile": "https://Stackoverflow.com/users/32854",
"pm_score": 3,
"selected": false,
"text": "public string ExtractReply(string text, string address)\n{\n var regexes = new List<Regex>() { new Regex(\"From:\\\\s*\" + Regex.Escape(address), RegexOptions.IgnoreCase),\n new Regex(\"<\" + Regex.Escape(address) + \">\", RegexOptions.IgnoreCase),\n new Regex(Regex.Escape(address) + \"\\\\s+wrote:\", RegexOptions.IgnoreCase),\n new Regex(\"\\\\n.*On.*(\\\\r\\\\n)?wrote:\\\\r\\\\n\", RegexOptions.IgnoreCase | RegexOptions.Multiline),\n new Regex(\"-+original\\\\s+message-+\\\\s*$\", RegexOptions.IgnoreCase),\n new Regex(\"from:\\\\s*$\", RegexOptions.IgnoreCase),\n new Regex(\"^>.*$\", RegexOptions.IgnoreCase | RegexOptions.Multiline)\n };\n\n var index = text.Length;\n\n foreach(var regex in regexes){\n var match = regex.Match(text);\n\n if(match.Success && match.Index < index)\n index = match.Index;\n }\n\n return text.Substring(0, index).Trim();\n}\n"
},
{
"answer_id": 15762420,
"author": "Amit M",
"author_id": 2229646,
"author_profile": "https://Stackoverflow.com/users/2229646",
"pm_score": 0,
"selected": false,
"text": "//Works for Gmail\nnew Regex(\"\\\\n.*On.*<(\\\\r\\\\n)?\" + Regex.Escape(address) + \"(\\\\r\\\\n)?>\", RegexOptions.IgnoreCase),\n//Works for Outlook 2010\nnew Regex(\"From:.*\" + Regex.Escape(address), RegexOptions.IgnoreCase),\n"
},
{
"answer_id": 74260292,
"author": "Artur INTECH",
"author_id": 2987689,
"author_profile": "https://Stackoverflow.com/users/2987689",
"pm_score": 1,
"selected": false,
"text": "text/html <div name=\"quote\"> <div class=\"moz-cite-prefix\"> <blockquote type=\"cite\"> <div class=\"gmail_quote\"> <blockquote type=\"cite\">"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4550/"
] |
278,789
|
<p>I have a type ahead text field, and when the user hits "Enter" I want to make an ajax call and not submit the form at the same time. My html looks like this:</p>
<pre><code><input id="drug_name" class="drugs_field" type="text" size="30" onkeypress="handleKeyPress(event,this.form); return false;" name="drug[name]" autocomplete="off"/>
<div id="drug_name_auto_complete" class="auto_complete" style="display: none;"/>
<script type="text/javascript">
//<![CDATA[
var drug_name_auto_completer = new Ajax.Autocompleter('drug_name', 'drug_name_auto_complete', '/sfc/pharmacy/auto_complete_for_drug_name', {})
//]]>
</script>
</code></pre>
|
[
{
"answer_id": 278816,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": 1,
"selected": false,
"text": "<input type='submit' value='submit' onclick='submiFunction(); return false;'>\n <form blabla onsubmit='someAjaxCall(); return false;'>\n"
},
{
"answer_id": 278833,
"author": "Zack The Human",
"author_id": 18265,
"author_profile": "https://Stackoverflow.com/users/18265",
"pm_score": 4,
"selected": true,
"text": "<form onsubmit=\"return someFunction();\">\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1486/"
] |
278,838
|
<p>By default when you add an image (icon, bitmap, etc.) as a resource to your project, the image's <strong>Build Action</strong> is set to <strong>None</strong>. This is done because the image is magically stored inside a .resources file.</p>
<p><strong><em>I</em></strong> want the resource to be stored as an embedded resource (my reasons are irrelevant, but let's just pretend it's so that I can see them inside <strong><a href="http://reflector.red-gate.com/" rel="nofollow noreferrer">RedGate's Reflector</a></strong>).</p>
<p>So I changed each image's <strong>Build Action</strong> to <strong>Embedded Resource</strong>, and the resource then appears inside Lutz's Reflector - exactly as I want. </p>
<p><strong>Unfortunately</strong>, <a href="http://msdn.microsoft.com/en-us/library/0c6xyb66(VS.80).aspx" rel="nofollow noreferrer">Microsoft says specifically not to do this</a>:</p>
<blockquote>
<p>Note that when the resource editor
adds an image, it sets <strong>Build Action</strong> to
<strong>None</strong>, because the .resx file
references the image file. At build
time, the image is pulled into the
.resources file created out of the
.resx file. The image can then easily
be accessed via the strongly-typed
class auto-generated for the .resx
file. </p>
<p>Therefore, you should not change
this setting to <strong>Embedded Resource</strong>,
because doing so would include the
image twice in the assembly.</p>
</blockquote>
<p>So what is the <strong>proper way</strong> to include an image as an embedded resource?</p>
|
[
{
"answer_id": 278911,
"author": "Todd",
"author_id": 31940,
"author_profile": "https://Stackoverflow.com/users/31940",
"pm_score": 3,
"selected": false,
"text": "ResourceManager Assembly.GetManifestResourceStream Embedded Resource Embedded Resource"
},
{
"answer_id": 483891,
"author": "Dirk Vollmar",
"author_id": 40347,
"author_profile": "https://Stackoverflow.com/users/40347",
"pm_score": 6,
"selected": true,
"text": "Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceUri)\n"
},
{
"answer_id": 491254,
"author": "MBoy",
"author_id": 15511,
"author_profile": "https://Stackoverflow.com/users/15511",
"pm_score": 3,
"selected": false,
"text": "btnStop.Image = myImages.Stop;\n"
},
{
"answer_id": 494583,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 4,
"selected": false,
"text": "[namespace].Properties.Resources.[yourResourceName]\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12597/"
] |
278,856
|
<p>I tried using the IHttpModule and managed to convert the urls just fine,
but all of my images returned path error (all going through the new url directory).</p>
<p>whats the solution?</p>
|
[
{
"answer_id": 278979,
"author": "Keltex",
"author_id": 28260,
"author_profile": "https://Stackoverflow.com/users/28260",
"pm_score": 1,
"selected": false,
"text": "<img src='images/something.gif' />\n <asp:image imageurl='~/images/something.gif' runat='server' id='img1'/>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
278,858
|
<p>Here is my code: </p>
<pre><code>ThreadStart threadStart = controller.OpenFile;
Thread thread = new Thread(threadStart);
thread.Start();
</code></pre>
<p>In the OpenFile function, my code looks like:</p>
<pre><code>System.Console.Error.WriteLine("Launching");
</code></pre>
<p>The code in OpenFile doesn't get executed for 30 seconds exactly. It starts immediately on my machine, but in our production environment it takes 30 seconds before that print statement will execute.</p>
<p>Is there a setting or something that might be doing this? Where would I start looking?</p>
|
[
{
"answer_id": 279011,
"author": "Roger Lipscombe",
"author_id": 8446,
"author_profile": "https://Stackoverflow.com/users/8446",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Threading;\n\nnamespace Net_Threading_Problem\n{\n class Program\n {\n static void Main()\n {\n Controller controller = new Controller();\n ThreadStart threadStart = controller.OpenFile;\n Thread thread = new Thread(threadStart);\n thread.Start();\n\n thread.Join();\n }\n }\n\n internal class Controller\n {\n public void OpenFile()\n {\n Console.Error.WriteLine(\"Launching\");\n }\n }\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12261/"
] |
278,868
|
<p>I am doing the following in PHP:</p>
<pre><code>exec('java -jar "/opt/flex3/lib/mxmlc.jar" +flexlib "/opt/flex3/frameworks" MyAS3App.as -default-size 360 280 -output MyAS3App.swf');
</code></pre>
<p>When I run this from the command line, it runs fine and finishes in a second or two.</p>
<p>When I run this command from PHP exec, the java process takes 100% CPU and never returns.</p>
<p>Any ideas?</p>
<p>I have also tried running the above command with '/usr/bin/java -Djava.awt.headless=true'.</p>
<p>I am running Mac OS X 10.5.5, MAMP 1.7, PHP 5.2.5</p>
|
[
{
"answer_id": 363758,
"author": "Keeth",
"author_id": 20588,
"author_profile": "https://Stackoverflow.com/users/20588",
"pm_score": 5,
"selected": true,
"text": "exec('java -version');\n export DYLD_LIBRARY_PATH=\"\";\n exec('export DYLD_LIBRARY_PATH=\"\"; mxmlc MyAS3App.as -default-size 360 280 -output MyAS3App.swf');\n"
},
{
"answer_id": 4488967,
"author": "Pontus",
"author_id": 548511,
"author_profile": "https://Stackoverflow.com/users/548511",
"pm_score": 2,
"selected": false,
"text": "export DYLD_LIBRARY_PATH=\"\";\nin the exec call:\n\n$argss = \"export DYLD_LIBRARY_PATH=\\\"\\\"; /usr/bin/java -jar /Applications/yourjarfile.jar\";\n$resultXML = exec($argss, $output);\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20588/"
] |
278,871
|
<p>I am using:</p>
<pre><code>set constraints all deferred;
(lots of deletes and inserts)
commit;
</code></pre>
<p>This works as expected. If there are any broken relationships then the commit fails and an error is raised listing ONE of the FKs that it fails on.</p>
<p>The user fixes the offending data and runs again. then hits another FK issue and repeats the process.</p>
<p>What I really want is a list of ALL FKs in one go that would cause the commit to fail.</p>
<p>I can of course write something to check every FK relationship through a select statement (one select per FK), but the beauty of using the deferred session is that this is all handled for me.</p>
|
[
{
"answer_id": 290971,
"author": "GHZ",
"author_id": 18138,
"author_profile": "https://Stackoverflow.com/users/18138",
"pm_score": 2,
"selected": false,
"text": "SQL> create table a (id number primary key);\n\nTable created.\n\nSQL> create table b (id number primary key, a_id number, constraint fk_b_to_a foreign key (a_id) references a deferrable initially immediate);\n\nTable created.\n\nSQL> create table c (id number primary key, b_id number, constraint fk_c_to_b foreign key (b_id) references b deferrable initially immediate);\n\nTable created.\n\nSQL> insert into a values (1);\n\n1 row created.\n\nSQL> insert into b values (1,1);\n\n1 row created.\n\nSQL> insert into c values (1,1);\n\n1 row created.\n\nSQL> commit;\n\nCommit complete.\n SQL> set constraints all deferred;\n\nConstraint set.\n\nSQL> delete from a;\n\n1 row deleted.\n\nSQL> delete from b;\n\n1 row deleted.\n\nSQL> insert into b values (10,10);\n\n1 row created.\n\nSQL> set constraint fk_b_to_a immediate;\nset constraint fk_b_to_a immediate\n*\nERROR at line 1:\nORA-02291: integrity constraint (GW.FK_B_TO_A) violated - parent key not foun\n\n\nSQL> set constraint fk_c_to_b immediate;\nset constraint fk_c_to_b immediate\n*\nERROR at line 1:\nORA-02291: integrity constraint (GW.FK_C_TO_B) violated - parent key not foun\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18138/"
] |
278,873
|
<p>you would think this would be obvious, but searching through documentation, SAP forums, Googling, etc., I've been spectacularly unsuccessful. I'm creating a file in ABAP on a solaris filesystem using the following code:</p>
<pre><code>OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
</code></pre>
<p>the resulting file is owned and grouped according to a pre-defined admin user, which is fine, but the sticky wicket is that the permissions are set to 660/rw-rw----, meaning I can't examine the results. is there a way (possibly using that vaguely defined TYPE addition?) I can specify the resulting permissions on the new file?</p>
<p>thanks!</p>
|
[
{
"answer_id": 303145,
"author": "tomdemuyt",
"author_id": 7602,
"author_profile": "https://Stackoverflow.com/users/7602",
"pm_score": 2,
"selected": false,
"text": "chmod man chmod CALL FUNCTION 'SXPG_COMMAND_EXECUTE'\n EXPORTING\n commandname = 'ZCHMOD'\n additional_parameters = l_par\n operatingsystem = l_os\n TABLES\n exec_protocol = it_log\n EXCEPTIONS\n no_permission = 1\n command_not_found = 2\n parameters_too_long = 3\n security_risk = 4\n wrong_check_call_interface = 5\n program_start_error = 6\n program_termination_error = 7\n x_error = 8\n parameter_expected = 9\n too_many_parameters = 10\n illegal_command = 11\n wrong_asynchronous_parameters = 12\n cant_enq_tbtco_entry = 13\n jobcount_generation_error = 14\n OTHERS = 15.\n"
},
{
"answer_id": 330365,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": true,
"text": " CONCATENATE 'chmod ugo=rw ' lc_filename\n INTO lc_chmod SEPARATED BY space.\n CALL 'SYSTEM' ID 'COMMAND' FIELD lc_chmod.\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278873",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29003/"
] |
278,882
|
<p>In PL/SQL, I would like to pass in a "source" schema as a parameter to a stored procedure. For instance:</p>
<pre><code>BEGIN
CURSOR my_cursor IS
SELECT my_field FROM <schema>.my_table
...
</code></pre>
<p>I want the 'schema' value to come from an input parameter into the stored procedure. Does anyone know how I could do that?</p>
<p>P.S. Sorry if this is a stupid simple question, but I'm new to PL/SQL and must get some functions written quickly.</p>
|
[
{
"answer_id": 278903,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 4,
"selected": true,
"text": "PROCEDURE select_from_schema( the_schema VARCHAR2)\nIS\n TYPE my_cursor_type IS REF CURSOR;\n my_cursor my_cursor_type;\nBEGIN\n OPEN my_cursor FOR 'SELECT my_field FROM '||the_schema||'.my_table';\n\n -- Do your FETCHes just as with a normal cursor\n\n CLOSE my_cursor;\nEND;\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20133/"
] |
278,896
|
<p>Our product has the requirement of exporting its native format (essentially an XML file) to Excel for viewing/editing. However, what this entails is having a dependency on Excel (or Office) itself for our product build - something that we do not want. </p>
<p>What we have done is export the data from our native format to a csv file which can be opened in Excel. If user selects an option to open the generated report as well, we (try to) launch Excel application to open it (ofcourse it requires Excel to be already present on the client system).</p>
<p>The data for most part is flat list of records.</p>
<p>Is there a better format (or even a better way) to handle this requirement? This is a common requirement for many products - how do you handle this?</p>
|
[
{
"answer_id": 15227291,
"author": "Mike Gledhill",
"author_id": 391605,
"author_profile": "https://Stackoverflow.com/users/391605",
"pm_score": 0,
"selected": false,
"text": "DataSet ds = CreateSampleData();\nCreateExcelFile.CreateExcelDocument(ds, \"C:\\\\Sample.xlsx\");\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1065163/"
] |
278,902
|
<p>I've got a bunch of properties which I am going to use read/write locks on. I can implement them either with a <code>try finally</code> or a <code>using</code> clause.</p>
<p>In the <code>try finally</code> I would acquire the lock before the <code>try</code>, and release in the <code>finally</code>. In the <code>using</code> clause, I would create a class which acquires the lock in its constructor, and releases in its Dispose method.</p>
<p>I'm using read/write locks in a lot of places, so I've been looking for ways that might be more concise than <code>try finally</code>. I'm interested in hearing some ideas on why one way may not be recommended, or why one might be better than another.</p>
<p>Method 1 (<code>try finally</code>):</p>
<pre><code>static ReaderWriterLock rwlMyLock_m = new ReaderWriterLock();
private DateTime dtMyDateTime_m
public DateTime MyDateTime
{
get
{
rwlMyLock_m .AcquireReaderLock(0);
try
{
return dtMyDateTime_m
}
finally
{
rwlMyLock_m .ReleaseReaderLock();
}
}
set
{
rwlMyLock_m .AcquireWriterLock(0);
try
{
dtMyDateTime_m = value;
}
finally
{
rwlMyLock_m .ReleaseWriterLock();
}
}
}
</code></pre>
<p>Method 2:</p>
<pre><code>static ReaderWriterLock rwlMyLock_m = new ReaderWriterLock();
private DateTime dtMyDateTime_m
public DateTime MyDateTime
{
get
{
using (new ReadLock(rwlMyLock_m))
{
return dtMyDateTime_m;
}
}
set
{
using (new WriteLock(rwlMyLock_m))
{
dtMyDateTime_m = value;
}
}
}
public class ReadLock : IDisposable
{
private ReaderWriterLock rwl;
public ReadLock(ReaderWriterLock rwl)
{
this.rwl = rwl;
rwl.AcquireReaderLock(0);
}
public void Dispose()
{
rwl.ReleaseReaderLock();
}
}
public class WriteLock : IDisposable
{
private ReaderWriterLock rwl;
public WriteLock(ReaderWriterLock rwl)
{
this.rwl = rwl;
rwl.AcquireWriterLock(0);
}
public void Dispose()
{
rwl.ReleaseWriterLock();
}
}
</code></pre>
|
[
{
"answer_id": 278924,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 8,
"selected": true,
"text": "{\n Font font1 = new Font(\"Arial\", 10.0f);\n try\n {\n byte charset = font1.GdiCharSet;\n }\n finally\n {\n if (font1 != null)\n ((IDisposable)font1).Dispose();\n }\n}\n"
},
{
"answer_id": 278925,
"author": "Luke",
"author_id": 261917,
"author_profile": "https://Stackoverflow.com/users/261917",
"pm_score": 2,
"selected": false,
"text": "using (obj)\n{\n try { }\n catch { }\n}\n"
},
{
"answer_id": 278926,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "private object _myDateTimeLock = new object();\nprivate DateTime _myDateTime;\n\npublic DateTime MyDateTime{\n get{\n lock(_myDateTimeLock){return _myDateTime;}\n }\n set{\n lock(_myDateTimeLock){_myDateTime = value;}\n }\n}\n"
},
{
"answer_id": 278951,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 3,
"selected": false,
"text": "try catch using try\n{\n try\n {\n //Reader-writer lock stuff\n }\n finally\n {\n //Release lock\n }\n }\n catch(Exception ex)\n {\n //Do something with exception\n }\n lock(this){return mydateetc;}"
},
{
"answer_id": 279084,
"author": "Rob Williams",
"author_id": 26682,
"author_profile": "https://Stackoverflow.com/users/26682",
"pm_score": 3,
"selected": false,
"text": "void doSomething()\n{\n using (CustomResource aResource = new CustomResource())\n {\n using (CustomThingy aThingy = new CustomThingy(aResource))\n {\n doSomething(aThingy);\n }\n }\n}\n\nvoid doSomething(CustomThingy theThingy)\n{\n try\n {\n // play with theThingy, which might result in exceptions\n }\n catch (SomeException aException)\n {\n // resolve aException somehow\n }\n}\n Dispose() IDisposable Dispose()"
},
{
"answer_id": 280060,
"author": "Ajaxx",
"author_id": 25228,
"author_profile": "https://Stackoverflow.com/users/25228",
"pm_score": 0,
"selected": false,
"text": "interface ILock {\n IDisposable Acquire();\n}\n\nclass MonitorLock : ILock {\n IDisposable Acquire() { ... acquire the lock for real ... }\n}\n"
},
{
"answer_id": 932659,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "class StackOTest\n{\n private delegate DateTime ReadLockMethod();\n private delegate void WriteLockMethod();\n\n static ReaderWriterLock rwlMyLock_m = new ReaderWriterLock();\n private DateTime dtMyDateTime_m;\n public DateTime MyDateTime\n {\n get\n {\n return ReadLockedMethod(\n rwlMyLock_m,\n delegate () { return dtMyDateTime_m; }\n );\n }\n set\n {\n WriteLockedMethod(\n rwlMyLock_m,\n delegate () { dtMyDateTime_m = value; }\n );\n }\n }\n\n private static DateTime ReadLockedMethod(\n ReaderWriterLock rwl,\n ReadLockMethod method\n )\n {\n rwl.AcquireReaderLock(0);\n try\n {\n return method();\n }\n finally\n {\n rwl.ReleaseReaderLock();\n }\n }\n\n private static void WriteLockedMethod(\n ReaderWriterLock rwl,\n WriteLockMethod method\n )\n {\n rwl.AcquireWriterLock(0);\n try\n {\n method();\n }\n finally\n {\n rwl.ReleaseWriterLock();\n }\n }\n}\n"
},
{
"answer_id": 932677,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "class StackOTest\n{\n private delegate DateTime ReadLockMethod();\n private delegate void WriteLockMethod();\n\n static ReaderWriterLock rwlMyLock_m = new ReaderWriterLock();\n private DateTime dtMyDateTime_m;\n public DateTime MyDateTime\n {\n get\n {\n return ReadLockedMethod(\n delegate () { return dtMyDateTime_m; }\n );\n }\n set\n {\n WriteLockedMethod(\n delegate () { dtMyDateTime_m = value; }\n );\n }\n }\n\n private DateTime ReadLockedMethod(ReadLockMethod method)\n {\n rwlMyLock_m.AcquireReaderLock(0);\n try\n {\n return method();\n }\n finally\n {\n rwlMyLock_m.ReleaseReaderLock();\n }\n }\n\n private void WriteLockedMethod(WriteLockMethod method)\n {\n rwlMyLock_m.AcquireWriterLock(0);\n try\n {\n method();\n }\n finally\n {\n rwlMyLock_m.ReleaseWriterLock();\n }\n }\n}\n"
},
{
"answer_id": 932727,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "class StackOTest\n{\n static ReaderWriterLock rwlMyLock_m = new ReaderWriterLock();\n private DateTime dtMyDateTime_m;\n public DateTime MyDateTime\n {\n get\n {\n DateTime retval = default(DateTime);\n ReadLockedMethod(\n delegate () { retval = dtMyDateTime_m; }\n );\n return retval;\n }\n set\n {\n WriteLockedMethod(\n delegate () { dtMyDateTime_m = value; }\n );\n }\n }\n\n private void ReadLockedMethod(Action method)\n {\n rwlMyLock_m.AcquireReaderLock(0);\n try\n {\n method();\n }\n finally\n {\n rwlMyLock_m.ReleaseReaderLock();\n }\n }\n\n private void WriteLockedMethod(Action method)\n {\n rwlMyLock_m.AcquireWriterLock(0);\n try\n {\n method();\n }\n finally\n {\n rwlMyLock_m.ReleaseWriterLock();\n }\n }\n}\n"
},
{
"answer_id": 9866373,
"author": "galaxis",
"author_id": 1172173,
"author_profile": "https://Stackoverflow.com/users/1172173",
"pm_score": 0,
"selected": false,
"text": "IDisposable Dispose() finally using IDisposable IDisposable"
},
{
"answer_id": 18708384,
"author": "Clint Chapman",
"author_id": 339380,
"author_profile": "https://Stackoverflow.com/users/339380",
"pm_score": 1,
"selected": false,
"text": "var rwlock = new ReaderWriterLockSlim();\nusing (var l = rwlock.ReadLock())\n{\n // read data\n}\nusing (var l = rwlock.WriteLock())\n{\n // write data\n}\n static class ReaderWriterLockExtensions() {\n /// <summary>\n /// Allows you to enter and exit a read lock with a using statement\n /// </summary>\n /// <param name=\"readerWriterLockSlim\">The lock</param>\n /// <returns>A new object that will ExitReadLock on dispose</returns>\n public static OnDispose ReadLock(this ReaderWriterLockSlim readerWriterLockSlim)\n {\n // Enter the read lock\n readerWriterLockSlim.EnterReadLock();\n // Setup the ExitReadLock to be called at the end of the using block\n return new OnDispose(() => readerWriterLockSlim.ExitReadLock());\n }\n /// <summary>\n /// Allows you to enter and exit a write lock with a using statement\n /// </summary>\n /// <param name=\"readerWriterLockSlim\">The lock</param>\n /// <returns>A new object that will ExitWriteLock on dispose</returns>\n public static OnDispose WriteLock(this ReaderWriterLockSlim rwlock)\n {\n // Enter the write lock\n rwlock.EnterWriteLock();\n // Setup the ExitWriteLock to be called at the end of the using block\n return new OnDispose(() => rwlock.ExitWriteLock());\n }\n}\n\n/// <summary>\n/// Calls the finished action on dispose. For use with a using statement.\n/// </summary>\npublic class OnDispose : IDisposable\n{\n Action _finished;\n\n public OnDispose(Action finished) \n {\n _finished = finished;\n }\n\n public void Dispose()\n {\n _finished();\n }\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] |
278,914
|
<p>The span element seems to be exactly like a div, but at the in-line level rather than at the block level. However, I can't seem to think of any beneficial logical divisions that the span element can provide. </p>
<p>A single sentence, or word if not contained in a sentence, seems to be the smallest logical part. Ignoring CSS, since CSS is only for layout and not for semantic meaning, <strong>when does span provide additional semantic value by chopping up a sentence or string of words</strong>? </p>
<p>It seems that in all cases, other elements are better suited to adding semantic value, making span a purely layout element. Is this true?</p>
|
[
{
"answer_id": 278930,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": false,
"text": "<div class=\"name\">\n <span class=\"firstname\">John</span>\n <span class=\"lastname\">Doe</span>\n</div>\n"
},
{
"answer_id": 278931,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "span class"
},
{
"answer_id": 278933,
"author": "alxp",
"author_id": 19513,
"author_profile": "https://Stackoverflow.com/users/19513",
"pm_score": 2,
"selected": false,
"text": "<span datafield=\"firstname\"></span>\n"
},
{
"answer_id": 278952,
"author": "Mr. Shiny and New 安宇",
"author_id": 7867,
"author_profile": "https://Stackoverflow.com/users/7867",
"pm_score": 6,
"selected": true,
"text": "<span class=\"tel\">\n <span class=\"type\">home</span>:\n <span class=\"value\">+1.415.555.1212</span>\n</span>\n"
},
{
"answer_id": 279008,
"author": "Lee Kowalkowski",
"author_id": 30945,
"author_profile": "https://Stackoverflow.com/users/30945",
"pm_score": 4,
"selected": false,
"text": "<p>Welcome to Audi UK, <span lang=\"de\">Vorsprung durch Technik</span>.</p>\n"
},
{
"answer_id": 279108,
"author": "davetron5000",
"author_id": 3029,
"author_profile": "https://Stackoverflow.com/users/3029",
"pm_score": 0,
"selected": false,
"text": "div span div span"
},
{
"answer_id": 279243,
"author": "Ross Patterson",
"author_id": 241753,
"author_profile": "https://Stackoverflow.com/users/241753",
"pm_score": 2,
"selected": false,
"text": "span span style=\"dropCap\" span p span style=\"dropCap\""
},
{
"answer_id": 508168,
"author": "vartec",
"author_id": 60711,
"author_profile": "https://Stackoverflow.com/users/60711",
"pm_score": 0,
"selected": false,
"text": "<P>Hello, my name is <SPAN class=\"name\"> Joe Sixpack </SPAN></P>\n <P>Hello, my name is <FOAF:name> Joe Sixpack </FOAF:name></P>\n"
},
{
"answer_id": 726526,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 0,
"selected": false,
"text": "<span style='color:blue'> <font color='blue'> <!-- Example of data from the client database: -->\n<!-- Name: Stephane Boyera, Tel: (212) 555-1212, Email: sb@foo.org -->\n\n<DIV id=\"client-boyera\" class=\"client\">\n<P><SPAN class=\"client-title\">Client information:</SPAN>\n<TABLE class=\"client-data\">\n<TR><TH>Last name:<TD>Boyera</TR>\n<TR><TH>First name:<TD>Stephane</TR>\n<TR><TH>Tel:<TD>(212) 555-1212</TR>\n<TR><TH>Email:<TD>sb@foo.org</TR>\n</TABLE>\n</DIV>\n\n<DIV id=\"client-lafon\" class=\"client\">\n<P><SPAN class=\"client-title\">Client information:</SPAN>\n<TABLE class=\"client-data\">\n<TR><TH>Last name:<TD>Lafon</TR>\n<TR><TH>First name:<TD>Yves</TR>\n<TR><TH>Tel:<TD>(617) 555-1212</TR>\n<TR><TH>Email:<TD>yves@coucou.com</TR>\n</TABLE>\n</DIV>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20770/"
] |
278,927
|
<p>I'm inserting an img tag into my document with the new Element constructor like this (this works just fine):</p>
<pre><code>$('placeholder').insert(new Element("img", {id:'something', src:myImage}))
</code></pre>
<p>I would like to trigger a function when this image loads, but I can't figure out the correct syntax. I'm guess it's something like this (which doesn't work).</p>
<pre><code>$('placeholder').insert(new Element("img",
{id:'something', src:myImage, onload:function(){alert("MOO")}}))
</code></pre>
<p>I'm hoping to do this in the same line of code and not to have to attach an event observer separately.</p>
<p><strong>EDIT:</strong> The event needs to be registered when the element is <strong>created</strong>, not after. If the image loads before the event is attached, the event will never fire.</p>
|
[
{
"answer_id": 278987,
"author": "sblundy",
"author_id": 4893,
"author_profile": "https://Stackoverflow.com/users/4893",
"pm_score": 0,
"selected": false,
"text": "$('placeholder').insert(new Element(\"img\", \n {id:'something', src:myImage, onload:\"javascript:moo()\"}))\n\nfunction moo() {\n alert(\"MOO\");\n}\n insert Element.observe $('placeholder').insert(new Element(\"img\", \n {id:'something', src:myImage})).observe('load', function(){alert(\"MOO\")});\n"
},
{
"answer_id": 278991,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 2,
"selected": false,
"text": "$('placeholder').insert(new Element(\"img\", {\n id: 'something', \n src:myImage\n}).observe('load', function() {\n // onload code here\n}));\n"
},
{
"answer_id": 339317,
"author": "thoughtcrimes",
"author_id": 37814,
"author_profile": "https://Stackoverflow.com/users/37814",
"pm_score": 0,
"selected": false,
"text": "var img = new Element('img', {id: 'something', src:'myImage.jpg'});\n$('placeholder').insert(img);\n// Element has loaded! It can now be mucked around with.\n// The onload code goes here...\n"
},
{
"answer_id": 361240,
"author": "Matt Kantor",
"author_id": 3625,
"author_profile": "https://Stackoverflow.com/users/3625",
"pm_score": 0,
"selected": false,
"text": "$('placeholder').insert(new Element(\"img\", {\n id:'something', src:myImage, onload:'alert(\"MOO\")'\n}));\n <img onload=\"function() {...}\" />\n var moo = function() { alert(\"MOO\"); };\n$('placeholder').insert(new Element(\"img\", {\n id:'something', src:myImage, onload:'(' + moo + ')()'\n}));\n $('placeholder').insert(new Element(\"img\", {\n id:'something', src:myImage, onload:'(' + function() { alert(\"MOO\"); } + ')()'\n}));\n"
},
{
"answer_id": 1549015,
"author": "ColinM",
"author_id": 187780,
"author_profile": "https://Stackoverflow.com/users/187780",
"pm_score": 3,
"selected": true,
"text": "var img = new Element('img',{id:'logo',alt:'Hooray!'});\nimg.onload = function(){ alert(this.alt); };\nimg.src = 'logo.jpg';\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12579/"
] |
278,932
|
<p>I'm building some custom tools to work against a JIRA install, and the exposed SOAP API is great, except that none of the arguments are named.</p>
<p>For example, the prototype for getIssue is:</p>
<pre><code>RemoteIssue getIssue (string in0, string in1);
</code></pre>
<p>All of the SOAP RPC methods follow this convention, so without documentation I'm pretty hardpressed to figure out what to pass on a lot of these.</p>
<p>Does anyone know of a definitive API documentation guide?</p>
|
[
{
"answer_id": 279078,
"author": "Tony Arkles",
"author_id": 13868,
"author_profile": "https://Stackoverflow.com/users/13868",
"pm_score": 2,
"selected": false,
"text": "self.proxy = WSDL.Proxy( jiraUrl )\nself.token = self.proxy.login(self.username, self.password)\n...\nissues = self.proxy.getIssuesFromFilter(self.token, args[0])\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
278,940
|
<p>I'm looking to vertically align text by adding <code><br /></code> tags between characters with jQuery.</p>
<pre><code><div id="foo"><label>Vertical Text</label></div>
</code></pre>
<p>would look like this:</p>
<p>V<br />
e<br />
r<br />
t<br />
i<br />
c<br />
a<br />
l<br />
<br />
T<br />
e<br />
x<br />
t<br /></p>
|
[
{
"answer_id": 278990,
"author": "okoman",
"author_id": 35903,
"author_profile": "https://Stackoverflow.com/users/35903",
"pm_score": 2,
"selected": false,
"text": "var element = $( '#foo label' );\nvar newData = '';\nvar data = element.text();\nvar length = data.length;\nvar i = 0;\n\nwhile( i < length )\n{\n\n newData += data.charAt( i ) + '<br />';\n i++;\n\n}\n\nelement.html( newData );\n"
},
{
"answer_id": 279021,
"author": "MrChrister",
"author_id": 24229,
"author_profile": "https://Stackoverflow.com/users/24229",
"pm_score": 1,
"selected": false,
"text": " var element = $( '#foo label' );\n var newData = '';\n var data = element.text();\n var length = data.length;\n var i = 0;\n $( '#foo label' ).html(\"\");\n while( i < length )\n {\n $( '#foo label' ).append(data.charAt( i ) + \"<br />\")\n i++;\n }\n"
},
{
"answer_id": 279098,
"author": "MrKurt",
"author_id": 35296,
"author_profile": "https://Stackoverflow.com/users/35296",
"pm_score": 5,
"selected": false,
"text": "$('#foo label').html($('#foo label').text().replace(/(.)/g,\"$1<br />\"));\n"
},
{
"answer_id": 279436,
"author": "picardo",
"author_id": 32816,
"author_profile": "https://Stackoverflow.com/users/32816",
"pm_score": 0,
"selected": false,
"text": "$.each(\n $('#foo').text(), function(){\n $('#foo').append(this + '');\n }\n );\n"
},
{
"answer_id": 3441479,
"author": "Code Commander",
"author_id": 385979,
"author_profile": "https://Stackoverflow.com/users/385979",
"pm_score": 2,
"selected": false,
"text": "$.each( $(\".verticalText\"), function () { $(this).html($(this).text().replace(/(.)/g, \"$1<br />\")) } ); class=\"verticalText\""
},
{
"answer_id": 3441567,
"author": "Incognito",
"author_id": 257493,
"author_profile": "https://Stackoverflow.com/users/257493",
"pm_score": 2,
"selected": false,
"text": "document.write(\"vertical text\".split(\"\").join(\"<br/>\"));"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9750/"
] |
278,941
|
<p>Im having problems displaying records to my view when passing viewdata to a user control.
This is only apparent for linq to sql objects where I am using table joins.</p>
<p>The exception I receive is "Unable to cast object of type '<>f__AnonymousType4<code>10[System.String,System.Int32,System.Nullable</code>1[System.DateTime],System.String,System.String,System.String,System.String,System.String,System.Nullable<code>1[System.Single],System.Nullable</code>1[System.Double]]' to type App.Models.table1."</p>
<p>I have searched for a fix to this issue but not too familiar on whats wrong here for me to search for the right subject. This should be working in theory and this works for single table retrieving but when I added a join in their I ran into problems. I am currently using a foreach statement to query through my data via single table declaration. Any help would be greatly appreciated. Thanks in advance.</p>
<p>My current setup is:</p>
<p>CViewDataUC.cs(my class to hold viewdata and data connections specifically for user controls)</p>
<pre><code>public void Info(ViewDataDictionary viewData, int id)
{
var dataContext = new testDataContext();
var info = from table1 in dataContext.table1
join table2 in dataContext.table2 on table1.type_id equals table2.type_id
join table3 in dataContext.table3 on table1.id equals table3.id
join table4 in dataContext.table4 on table1.id equals table4.id
where table1.id == id
select new
{
table1.column1,
table1.column2,
table1.column3,
table1.column4,
table1.column5,
table1.column6,
table1.column7,
table2.column1,
table3.column1,
table4.column1
};
viewData["vd_Info"] = info;
}
</code></pre>
<p>HomeController.cs(Controller)</p>
<pre><code>public ActionResult Information(int id)
{
ViewData["Title"] = "Information";
CViewDataUC o_info = new CViewDataUC();
o_info.Info(this.ViewData, id);
return View();
}
</code></pre>
<p>Information.aspx(View)</p>
<pre><code><%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true"
CodeBehind="Info.aspx.cs" Inherits="App.Views.Info" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<%Html.RenderPartial("~/Views/UserControls/Info.ascx", ViewData["vd_Info"]);%>
</asp:Content>
</code></pre>
<p>Info.ascx(User Control)</p>
<pre><code><%foreach (table1 m in (IEnumerable)ViewData.Model)
{ %>
<div class="left">
<br />
<br />
<p id="medium">
Column 1
<br />
<%= Html.TextBox("column1", m.column1, new {@class = "textBox", @readonly = "readonly" })%>
Column 1
<br />
<%= Html.TextBox("column2", m.column2, new {@class = "textBox", @readonly = "readonly" })%>
<br />
Column 1
<br />
<%= Html.TextBox("column3", m.column3, new {@class = "textBox", @readonly = "readonly" })%>
</p>
</div>
<%}%>
</code></pre>
|
[
{
"answer_id": 278964,
"author": "yfeldblum",
"author_id": 12349,
"author_profile": "https://Stackoverflow.com/users/12349",
"pm_score": 3,
"selected": true,
"text": "foreach (table1 m in (IEnumerable)ViewData.Model)\n m table1 select new { ... }"
},
{
"answer_id": 279136,
"author": "Ayo",
"author_id": 24130,
"author_profile": "https://Stackoverflow.com/users/24130",
"pm_score": 2,
"selected": false,
"text": "public CInformation() { }\n\npublic string _column1{ get; set; }\npublic string _column2{ get; set; }\n...\n var dataContext = new testDataContext();\n\n IQueryable<CInformation> info = from table1 in dataContext.table1\n join table2 in dataContext.table2 on table1.type_id equals table2.type_id \n join table3 in dataContext.table3 on table1.id equals table3.id \n join table4 in dataContext.table4 on table1.id equals table4.id \n where table1.test_id == id\n select new CInformation\n {\n _column1 = table1.column1.ToString(),\n _column2 = table2.column1.ToString(),\n ...\n }; \n\n viewData[\"vd_Info\"] = info;\n\n}\n m.column1\n m.column2\n ...\n"
},
{
"answer_id": 293779,
"author": "Jacqueline",
"author_id": 11101,
"author_profile": "https://Stackoverflow.com/users/11101",
"pm_score": 1,
"selected": false,
"text": "IQueryable<CInformation> info = from table1 in dataContext.table1\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24130/"
] |
278,943
|
<p>I am trying to do this...</p>
<pre><code><Image x:Name="imgGroupImage" Source="Images\unlock.png" Margin="0,0,5,0" />
</code></pre>
<p>But I get this error...</p>
<blockquote>
<p>Cannot convert string 'Images\unlock.png' in attribute 'Source' to object of type 'System.Windows.Media.ImageSource'. Cannot locate resource 'forms/images/unlock.png'. Error at object 'System.Windows.HierarchicalDataTemplate' in markup file 'Fuse;component/forms/mainwindow.xaml' Line 273 Position 51.</p>
</blockquote>
<p>As you can see, my form that includes this XAML is in a folder named Forms. My Images are in a folder named Images. How do I map from Forms to Images?</p>
<p>I tried <code>Source="..Images\unlock.png"</code> which does not work in WPF.</p>
<p>Any help?</p>
|
[
{
"answer_id": 278969,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 4,
"selected": true,
"text": "Source=\"/Images/unlock.png\"\n"
},
{
"answer_id": 278974,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<Image x:Name=\"imgGroupImage\" Margin=\"0,0,5,0\" >\n <Image.Source>\n <BitmapImage UriSource=\"Images/unlock.png\" />\n </Image.Source>\n</Image>\n Uri UriSource Uri BitmapSource Source"
},
{
"answer_id": 46044495,
"author": "Hekkaryk",
"author_id": 5887760,
"author_profile": "https://Stackoverflow.com/users/5887760",
"pm_score": 0,
"selected": false,
"text": "<Image Source=\"pack://application:,,,/Resources/image.png\"/>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6514/"
] |
278,965
|
<p>I use URLLoader to load data into my Flex app (mostly XML) and my buddy who is doing the same thing mostly uses HTTPService. Is there a specific or valid reason to use on over the other?</p>
|
[
{
"answer_id": 280795,
"author": "Matt MacLean",
"author_id": 22,
"author_profile": "https://Stackoverflow.com/users/22",
"pm_score": 5,
"selected": true,
"text": "var token:AsyncToken = httpService.send({someVariable: 123});\ntoken.requestStartTime = getTimer();\ntoken.addResponder(new AsyncResponder(\n function (evt:ResultEvent, token:Object):void {\n var xml:XML = evt.result as XML;\n var startTime = token.requestStartTime;\n var runTime = getTimer() - startTime;\n Alert.show(\"Request took \" + runTime + \" ms\");\n //handle response here\n },\n function (info:Object, token:Object):void {\n //handle fault here\n },\n token\n));\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3435/"
] |
278,982
|
<p>Would the following SQL statement automatically create an index on Table1.Table1Column, or must one be explicitly created?</p>
<p>Database engine is SQL Server 2000</p>
<pre><code> CREATE TABLE [Table1] (
. . .
CONSTRAINT [FK_Table1_Table2] FOREIGN KEY
(
[Table1Column]
) REFERENCES [Table2] (
[Table2ID]
)
)
</code></pre>
|
[
{
"answer_id": 33905720,
"author": "David Sopko",
"author_id": 1197553,
"author_profile": "https://Stackoverflow.com/users/1197553",
"pm_score": 3,
"selected": false,
"text": "CREATE TABLE MasterOrder (\n MasterOrderID INT PRIMARY KEY)\n\nCREATE TABLE OrderDetail(\n OrderDetailID INT,\n MasterOrderID INT FOREIGN KEY REFERENCES MasterOrder(MasterOrderID)\n)\n SELECT ..\n FROM \n MasterOrder ord\n LEFT JOIN OrderDetail det\n ON det.MasterOrderID = ord.MasterOrderID\n WHERE ord.OrderMasterID = @OrderMasterID\n CREATE TABLE CarType (\n CarTypeID INT PRIMARY KEY,\n CarTypeName VARCHAR(25)\n)\n\nINSERT CarType .. VALUES(1,'SEDAN')\nINSERT CarType .. VALUES(2,'COUP')\nINSERT CarType .. VALUES(3,'CONVERTABLE')\n\nCREATE TABLE CarInventory (\n CarInventoryID INT,\n CarTypeID INT FOREIGN KEY REFERENCES CarType(CarTypeID)\n)\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36307/"
] |
278,997
|
<p>More specifically, if I have:</p>
<pre><code>public class TempClass : TempInterface
{
int TempInterface.TempProperty
{
get;
set;
}
int TempInterface.TempProperty2
{
get;
set;
}
public int TempProperty
{
get;
set;
}
}
public interface TempInterface
{
int TempProperty
{
get;
set;
}
int TempProperty2
{
get;
set;
}
}
</code></pre>
<p>How do I use reflection to get all the propertyInfos for properties explicitly implementing TempInterface?</p>
<p>Thanks.</p>
|
[
{
"answer_id": 279087,
"author": "Robert Rossney",
"author_id": 19403,
"author_profile": "https://Stackoverflow.com/users/19403",
"pm_score": 0,
"selected": false,
"text": " var props = typeof(TempClass).GetInterfaces().Where(i => i.Name==\"TempInterface\").SelectMany(i => i.GetProperties());\n foreach (var prop in props)\n Console.WriteLine(prop);\n"
},
{
"answer_id": 279137,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 2,
"selected": false,
"text": " foreach (AssemblyName name in Assembly.GetEntryAssembly().GetReferencedAssemblies()) {\n Assembly asm = Assembly.Load(name);\n foreach (Type t in asm.GetTypes()) {\n if (t.IsAbstract) continue;\n foreach (MethodInfo mi in t.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)) {\n int dot = mi.Name.LastIndexOf('.');\n string s = mi.Name.Substring(dot + 1);\n if (!s.StartsWith(\"get_\") && !s.StartsWith(\"set_\")) continue;\n if (mi.IsFinal)\n Console.WriteLine(mi.Name);\n }\n }\n }\n"
},
{
"answer_id": 279780,
"author": "Jacob Carpenter",
"author_id": 26627,
"author_profile": "https://Stackoverflow.com/users/26627",
"pm_score": 2,
"selected": false,
"text": "var explicitProperties =\n from prop in typeof(TempClass).GetProperties(\n BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)\n let getAccessor = prop.GetGetMethod(true)\n where getAccessor.IsFinal && getAccessor.IsPrivate\n select prop;\n\nforeach (var p in explicitProperties)\n Console.WriteLine(p.Name);\n"
},
{
"answer_id": 848459,
"author": "Dane O'Connor",
"author_id": 1946,
"author_profile": "https://Stackoverflow.com/users/1946",
"pm_score": 2,
"selected": true,
"text": "var explicitProperties =\nfrom method in typeof(TempClass).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)\nwhere method.IsFinal && method.IsPrivate\nselect method;\n"
},
{
"answer_id": 1015590,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": false,
"text": "Type ifaceType = typeof(TempInterface);\nType tempType = typeof(TempClass);\nInterfaceMapping map = tempType.GetInterfaceMap(ifaceType);\nfor (int i = 0; i < map.InterfaceMethods.Length; i++)\n{\n MethodInfo ifaceMethod = map.InterfaceMethods[i];\n MethodInfo targetMethod = map.TargetMethods[i];\n Debug.WriteLine(String.Format(\"{0} maps to {1}\", ifaceMethod, targetMethod));\n}\n"
},
{
"answer_id": 6529576,
"author": "dtb",
"author_id": 76217,
"author_profile": "https://Stackoverflow.com/users/76217",
"pm_score": 2,
"selected": false,
"text": "var targetMethods =\n from iface in typeof(TempClass).GetInterfaces()\n from method in typeof(TempClass).GetInterfaceMap(iface).TargetMethods\n select method;\n\nvar explicitProps =\n from prop in typeof(TempClass).GetProperties(BindingFlags.Instance |\n BindingFlags.NonPublic)\n where targetMethods.Contains(prop.GetGetMethod(true)) ||\n targetMethods.Contains(prop.GetSetMethod(true))\n select prop;\n"
},
{
"answer_id": 7878684,
"author": "JonnyRaa",
"author_id": 962696,
"author_profile": "https://Stackoverflow.com/users/962696",
"pm_score": 0,
"selected": false,
"text": "public class PropertyInfoWrapper\n{\n private readonly object _parent;\n private readonly PropertyInfo _property;\n\n public PropertyInfoWrapper(object parent, string propertyToChange)\n {\n var type = parent.GetType();\n var privateProperties= type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance);\n\n var property = type.GetProperty(propertyToChange) ??\n privateProperties.FirstOrDefault(p => UnQualifiedNameFor(p) == propertyName);\n\n if (property == null)\n throw new Exception(string.Format(\"cant find property |{0}|\", propertyToChange));\n\n _parent = parent;\n _property = property;\n }\n\n private static string UnQualifiedNameFor(PropertyInfo p)\n {\n return p.Name.Split('.').Last();\n }\n\n public object Value\n {\n get { return _property.GetValue(_parent, null); }\n set { _property.SetValue(_parent, value, null); }\n }\n}\n"
},
{
"answer_id": 10191850,
"author": "lorond",
"author_id": 513392,
"author_profile": "https://Stackoverflow.com/users/513392",
"pm_score": 1,
"selected": false,
"text": "public class InterfacesPropertiesMap\n{\n private readonly Dictionary<Type, PropertyInfo[]> map;\n\n public InterfacesPropertiesMap(Type type)\n {\n this.Interfaces = type.GetInterfaces();\n var properties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);\n\n this.map = new Dictionary<Type, PropertyInfo[]>(this.Interfaces.Length);\n\n foreach (var intr in this.Interfaces)\n {\n var interfaceMap = type.GetInterfaceMap(intr);\n this.map.Add(intr, properties.Where(p => interfaceMap.TargetMethods\n .Any(t => t == p.GetGetMethod(true) ||\n t == p.GetSetMethod(true)))\n .Distinct().ToArray());\n }\n }\n\n public Type[] Interfaces { get; private set; }\n\n public PropertyInfo[] this[Type interfaceType]\n {\n get { return this.map[interfaceType]; }\n }\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/278997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1946/"
] |
279,001
|
<p>When using a Silverlight-enabled WCF service, where is the best place to instantiate the service and to call the CloseAsync() method?</p>
<p>Should you say, instantiate an instance each time you need to make a call to the service, or is it better to just instantiate an instance as a variable of the UserControl that will be making the calls?</p>
<p>Then, where is it better to call the CloseAsync method? Should you call it in each of the "someServiceCall_completed" event methods? Or, if created as a variable of the UserControl class, is there a single place to call it? Like a Dispose method, or something equivalent for the UserControl class.</p>
<p>Thanks,</p>
<p>Jeff</p>
|
[
{
"answer_id": 3045259,
"author": "WhiteN01se",
"author_id": 335525,
"author_profile": "https://Stackoverflow.com/users/335525",
"pm_score": 1,
"selected": false,
"text": "...\n{\n App.Client.MyOperationCompleted += Client_MyOperationCompleted;\n App.Client.MyOperationAsync(...);\n}\n\nvoid Client_MyOperationCompleted(object sender, MyOperationCompletedEventArgs e)\n{\n App.Client.MyOperationCompleted -= Client_MyOperationCompleted;\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12172/"
] |
279,019
|
<p>I am working an a search page that allows users to search for houses for sale. Typical search criteria include price/zip code/# bedrooms/etc.</p>
<p>I would like to allow the user to save this criteria in a database and email new homes daily.</p>
<p>I could either:</p>
<p>1) Serialize a "SavedSearch" object into a string and save that to the database, then deserialize as needed.</p>
<p>2) Have a list of columns in a tblSavedSearch corresponding to the search criteria - price/zip/# bedrooms/etc.</p>
<p>I am concerned that if I choose option 1, my saved search criteria will change and leave the searialized objects in the database invalid, but option 2 doesn't feel like an optimal solution either.</p>
<p>How have others solved this problem?</p>
|
[
{
"answer_id": 279070,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 4,
"selected": true,
"text": "search.action?price=20000&rooms=3\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36313/"
] |
279,024
|
<p>How would I return multiple values (say, a number and a string) from a user-defined function in SQL Server?</p>
|
[
{
"answer_id": 279061,
"author": "dkretz",
"author_id": 31641,
"author_profile": "https://Stackoverflow.com/users/31641",
"pm_score": 3,
"selected": false,
"text": "-- ============================================= \n-- Create inline function (IF) \n-- ============================================= \nIF EXISTS (SELECT * \n FROM sysobjects \n WHERE name = N'<inline_function_name, sysname, test_function>') \nDROP FUNCTION <inline_function_name, sysname, test_function> \nGO \n\nCREATE FUNCTION <inline_function_name, sysname, test_function> \n(<@param1, sysname, @p1> <data_type_for_param1, , int>, \n <@param2, sysname, @p2> <data_type_for_param2, , char>) \nRETURNS TABLE \nAS \nRETURN SELECT @p1 AS c1, \n @p2 AS c2 \nGO \n\n-- ============================================= \n-- Example to execute function \n-- ============================================= \nSELECT * \nFROM <owner, , dbo>.<inline_function_name, sysname, test_function> \n (<value_for_@param1, , 1>, \n <value_for_@param2, , 'a'>) \nGO \n"
},
{
"answer_id": 15771191,
"author": "surfmuggle",
"author_id": 819887,
"author_profile": "https://Stackoverflow.com/users/819887",
"pm_score": 2,
"selected": false,
"text": "Mr. Brownstone Create PROCEDURE MultipleOutParameter\n @Input int,\n @Out1 int OUTPUT, \n @Out2 int OUTPUT \nAS\nBEGIN\n Select @Out1 = @Input + 1\n Select @Out2 = @Input + 2 \n Select 'this returns your normal Select-Statement' as Foo\n , 'amazing is it not?' as Bar\n\n -- Return can be used to get even more (afaik only int) values \n Return(@Out1+@Out2+@Input)\nEND \n DECLARE @GetReturnResult int, @GetOut1 int, @GetOut2 int \nEXEC @GetReturnResult = MultipleOutParameter \n @Input = 1,\n @Out1 = @GetOut1 OUTPUT,\n @Out2 = @GetOut2 OUTPUT\n Select @GetReturnResult as ReturnResult, @GetOut1 as Out_1, @GetOut2 as Out_2 \n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9702/"
] |
279,038
|
<p>I'm trying to work through the problems on <a href="http://projecteuler.net" rel="noreferrer">projecteuler.net</a> but I keep running into a couple of problems.</p>
<p>The first is a question of storing large quanities of elements in a <code>List<t></code>. I keep getting OutOfMemoryException's when storing large quantities in the list.</p>
<p>Now I admit I might not be doing these things in the best way but, is there some way of defining how much memory the app can consume?</p>
<p>It usually crashes when I get abour 100,000,000 elements :S</p>
<p>Secondly, some of the questions require the addition of massive numbers. I use ulong data type where I think the number is going to get super big, but I still manage to wrap past the largest supported int and get into negative numbers.</p>
<p>Do you have any tips for working with incredibly large numbers?</p>
|
[
{
"answer_id": 45905678,
"author": "Abhilash Virat",
"author_id": 5255098,
"author_profile": "https://Stackoverflow.com/users/5255098",
"pm_score": 0,
"selected": false,
"text": "class Solution\n{\n static void Main(String[] args)\n {\n int n = 5;\n string[] unsorted = new string[6] { \"3141592653589793238\",\"1\", \"3\", \"5737362592653589793238\", \"3\", \"5\" };\n \n string[] result = SortStrings(n, unsorted);\n \n foreach (string s in result)\n Console.WriteLine(s);\n Console.ReadLine();\n }\n static string[] SortStrings(int size, string[] arr)\n {\n\n Array.Sort(arr, (left, right) =>\n {\n \n if (left.Length != right.Length)\n return left.Length - right.Length;\n return left.CompareTo(right);\n });\n \n return arr;\n }\n}\n"
},
{
"answer_id": 50436863,
"author": "Orif Milod",
"author_id": 8755035,
"author_profile": "https://Stackoverflow.com/users/8755035",
"pm_score": 0,
"selected": false,
"text": "string Add(string s1, string s2)\n{\n bool carry = false;\n string result = string.Empty;\n\n if (s1.Length < s2.Length)\n s1 = s1.PadLeft(s2.Length, '0');\n if(s2.Length < s1.Length)\n s2 = s2.PadLeft(s1.Length, '0');\n\n for(int i = s1.Length-1; i >= 0; i--)\n {\n var augend = Convert.ToInt64(s1.Substring(i,1));\n var addend = Convert.ToInt64(s2.Substring(i,1));\n var sum = augend + addend;\n sum += (carry ? 1 : 0);\n carry = false;\n if(sum > 9)\n {\n carry = true;\n sum -= 10;\n }\n result = sum.ToString() + result;\n }\n if(carry)\n {\n result = \"1\" + result;\n }\n\n return result;\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1741868/"
] |
279,043
|
<p>Let's take a very simple example:</p>
<ul>
<li>In my window1.xaml, i have a label
control named 'lblProduct'.</li>
<li>In my window1.xaml.cs, i have a
public method called
CalculateProduct(Int Var1, Int
Var2). CalculateProduct will, as
you may have guessed, calculate the
product of the variables passed in.</li>
</ul>
<p>I'd like to simply bind the results of 'CalculateProduct' to my label. My actual use case is a little more complicated than this. However, if I could get this up and running not only would I be quite happy, I'd be able to figure out the rest.</p>
<p>I've seen interesting examples using the ObjectDataProvider to bind to a static method of a new class. While this is well and good, I don't feel the need to create a new class when I've already instantiated the one for my window. In addition, there may be other global variables that I'd like to take advantage of in my Window1 class.</p>
<p>Thanks for your time and help,</p>
<p>Abel.</p>
|
[
{
"answer_id": 279139,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 1,
"selected": false,
"text": "ObjectDataProvider ObjectInstance"
},
{
"answer_id": 279250,
"author": "AJ.",
"author_id": 27457,
"author_profile": "https://Stackoverflow.com/users/27457",
"pm_score": 3,
"selected": true,
"text": "<Page x:Class=\"WpfBrowserApplication1.Page1\" \n blah blah blah \n xmlns:Commands=\"clr-namespace:WpfBrowserApplication1\">\n namespace WpfBrowserApplication1\n{\n public static class CommandHandlers\n {\n private static System.Windows.Input.RoutedUICommand _submitCommand;\n\n static CommandHandlers()\n {\n _submitCommand = new System.Windows.Input.RoutedUICommand(\"Submit\", \"SubmitCommand\", typeof(CommandHandlers));\n }\n\n public static void BindCommandsToPage(System.Windows.Controls.Page caller)\n {\n caller.CommandBindings.Add(new System.Windows.Input.CommandBinding(SubmitCommand, SubmitContact_Executed, SubmitContact_CanExecute));\n }\n\n public static System.Windows.Input.RoutedUICommand SubmitCommand\n {\n get { return _submitCommand; }\n }\n\n public static void SubmitContact_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)\n {\n ...do stuff...\n }\n\n public static void SubmitContact_CanExecute(object sender, System.Windows.Input.CanExecuteRoutedEventArgs e)\n {\n if (e.Source is System.Windows.Controls.Button)\n e.CanExecute = true;\n else\n e.CanExecute = false;\n }\n }\n}\n <Button Name=\"btnSubmit\" Command=\"Commands:CommandHandlers.SubmitCommand\" etc... />\n private void Page_Loaded(object sender, RoutedEventArgs e)\n{\n CommandHandlers.BindCommandsToPage(this);\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36308/"
] |
279,065
|
<p>I have this as Main</p>
<pre><code>int[] M ={ 10, 2, 30, 4, 50, 6, 7, 80 };
MyMath.Reverse(M);
for (int i = 0; i < M.Length; i++)
Console.WriteLine(M[i].ToString() + ", ");
</code></pre>
<hr>
<p>After I created the class MyMath I made the Reverse method </p>
<pre><code>public int Reverse(Array M)
{
int len = M.Length;
for (int i = 0; i < len / 2; i++)
{
int temp = M[i]; M[i] = M[len - i - 1]; M[len - i - 1] = temp;
}
}
</code></pre>
<p>but I'm sure it's wrong because it's not working :-) so do you have a different code to write in the reverse method?</p>
<p>note: I don't want to use the built in Reverse in the Array class</p>
<hr>
<p>yes guys when i used the built in reverse method i got this error</p>
<p>Process is terminated due to StackOverflowException.</p>
<p>thats after i wrote the method as</p>
<pre><code>public static int Reverse(Array M)
{
return Reverse(M);
}
</code></pre>
<p>So then I tried to create my own reverse method and there i got stuck </p>
|
[
{
"answer_id": 279100,
"author": "Michael Stum",
"author_id": 91,
"author_profile": "https://Stackoverflow.com/users/91",
"pm_score": 0,
"selected": false,
"text": "private void Whatever()\n{\n int[] M = { 10, 2, 30, 4, 50, 6, 7, 80 };\n ReverseArray(ref M);\n\n}\n\nprivate void ReverseArray(ref int[] input)\n{\n Stack<int> tmp = new Stack<int>();\n foreach (int i in input)\n {\n tmp.Push(i);\n }\n input = tmp.ToArray();\n}\n"
},
{
"answer_id": 279161,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 2,
"selected": false,
"text": "// the built-in returns void, so that needed to be changed...\npublic static void Reverse(Array M)\n{\n Array.Reverse(M); // you forgot to reference the Array class in yours\n}\n"
},
{
"answer_id": 279162,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 3,
"selected": true,
"text": "public static int Reverse(Array M)\n{\n return Reverse(M);\n}\n return Array.Reverse(M); Array.Reverse int Reverse void"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
279,066
|
<p>Our company uses an app that was originally ColdFusion + Access later converted to classic ASP + MS Sql for task/time tracking called the request system. It's broken down by department, so there's one for MIS, marketing, logistics, etc. The problem comes in when (mainly managers) are using more than one at a time, with 2 browser windows open. The request system uses session variables, a lot of session variables, "session" is referenced 2300 times in the application. When 2 are open at once as you can imagine this causes all sorts of anomalies from the variables getting mixed up.</p>
<p>There's a 3 year old MIS request in the system to "fix" this and it's been worked on by 3 developers, and now it's my turn to take a shot at it. I was wondering if anyone else has had to work on a project like this, and if there was some sort of hack to try and mitigate some of the problems. I was thinking of maybe calling something in global.asa to load misc. session variables from the querystring. The problem is, there's all sorts of this going on:</p>
<pre><code>If (Session("Application") <> Request("App")) and Request("App") <> "" THEN
Session("Application") = Request("App")
End If
</code></pre>
<p>Looking at the functions in include files, you'll have a function with 4 parameters, that makes references to 6 different session variables. So you get the idea, this is going to be painful.</p>
<p>Has anyone had to do anything like this in the past? Any hacks you found useful?</p>
|
[
{
"answer_id": 1077858,
"author": "davidsleeps",
"author_id": 51507,
"author_profile": "https://Stackoverflow.com/users/51507",
"pm_score": 0,
"selected": false,
"text": "Private Const PREFIX As String = \"MyPrefix_\"\nPublic Shared Property MyVariable() As String\n Get\n Return HttpContext.Current.Session(String.Concat(PREFIX, \"MyVariable\"))\n End Get\n Set(ByVal value As String)\n HttpContext.Current.Session(String.Concat(PREFIX, \"MyVariable\")) = value\n End Set\nEnd Property\n For Each Item As Object In HttpContext.Current.Session.Contents\n If Not Item.ToString.StartsWith(PREFIX) Then\n\n End If\nNext\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1302/"
] |
279,071
|
<p>I have an ASP.NET 2.0 (C#) webpage with a link that pulls a blob from a MS SQL database and ouputs it in the appropriat file format, i.e., Word, WordPerfect, PDF.</p>
<p>My users would like to print these files with one click. Right now they have to click the link to open the file, then click the "Print" button within the application that they file opened.</p>
<p>In addition, I would like to send multiple documents to the printer, using one click, if possible.</p>
<p>Thanks.</p>
|
[
{
"answer_id": 279099,
"author": "ine",
"author_id": 4965,
"author_profile": "https://Stackoverflow.com/users/4965",
"pm_score": 0,
"selected": false,
"text": "<body onload=\"window.print()\">\n...\n</body>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29613/"
] |
279,094
|
<p>I would like to use Python to script an application that advertises itself as providing an OLE component. How should I get started?</p>
<p>I don't yet know what methods I need to call on the COMponents I will be accessing. Should I use win32com to load those components, and then start pressing 'tab' in IPython?</p>
|
[
{
"answer_id": 279117,
"author": "Ali Afshar",
"author_id": 28380,
"author_profile": "https://Stackoverflow.com/users/28380",
"pm_score": 2,
"selected": false,
"text": "from win32com.client.dynamic import Dispatch\n\n# Excel\nexcel = Dispatch('Excel.Application')\n\n# Vim\nvim = Dispatch('Vim.Application')\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36330/"
] |
279,112
|
<p>What is the troubleshooting process for the "Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80080005" errors in .Net? To clarify: I am getting this at runtime, on my XP machine, with client being .net code running under admin account. {XXXX} refers to one of our in-house COM components. </p>
<p>From what I understand, 0x80080005 refers to "permission denied", but where do I go to check/change the permissions? Or am I completely wrong here, and the error is coming from the component itself, and not out of Windows COM subsystem?</p>
|
[
{
"answer_id": 279196,
"author": "Roger Lipscombe",
"author_id": 8446,
"author_profile": "https://Stackoverflow.com/users/8446",
"pm_score": 1,
"selected": false,
"text": "CO_E_SERVER_EXEC_FAILURE"
},
{
"answer_id": 279317,
"author": "Mark Brackett",
"author_id": 2199,
"author_profile": "https://Stackoverflow.com/users/2199",
"pm_score": 4,
"selected": true,
"text": "CO_E_SERVER_EXEC_FAILURE"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8032/"
] |
279,114
|
<p>I'm trying to read the contents of a text file, in this case a list of computer names (Computer1, computer2 etc,) and I thought that StreamReader would be what you would use but when I do the following:</p>
<pre><code>StreamReader arrComputer = new StreamReader(FileDialog.filename)();
</code></pre>
<p>I got this exception:</p>
<pre><code>The type or namespace name 'StreamReader' could not be found (are you missing a using directive or an assembly reference?)
</code></pre>
<p>I'm very new to C# so I'm sure I'm making a newbie mistake.</p>
|
[
{
"answer_id": 279118,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 2,
"selected": false,
"text": "using System.IO;\n\n\nStreamReader arrComputer = new StreamReader(FileDialog.filename);\n"
},
{
"answer_id": 279122,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 5,
"selected": true,
"text": "System.IO using System.IO;\n System.IO.StreamReader arrComputer = new System.IO.StreamReader(FileDialog.filename);\n"
},
{
"answer_id": 279124,
"author": "Werg38",
"author_id": 27569,
"author_profile": "https://Stackoverflow.com/users/27569",
"pm_score": 2,
"selected": false,
"text": "using System.IO"
},
{
"answer_id": 279126,
"author": "CheGueVerra",
"author_id": 17787,
"author_profile": "https://Stackoverflow.com/users/17787",
"pm_score": 2,
"selected": false,
"text": "using System.IO;\n"
},
{
"answer_id": 279127,
"author": "Eric W",
"author_id": 14972,
"author_profile": "https://Stackoverflow.com/users/14972",
"pm_score": 2,
"selected": false,
"text": "using System.IO; System.IO.StreamReader arrComputer = new System.IO.StreamReader(FileDialog.filename);\n"
},
{
"answer_id": 279128,
"author": "Quibblesome",
"author_id": 1143,
"author_profile": "https://Stackoverflow.com/users/1143",
"pm_score": 3,
"selected": false,
"text": "using System.IO;\n using(TextReader reader = new StreamReader(/* your args */))\n{\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35760/"
] |
279,119
|
<p>I like to use IPython's zope profile to inspect my Plone instance, but a few annoying permissions differences come up compared to inserting a breakpoint and hitting it with the admin user.</p>
<p>For example, I would like to iterate over the content objects in an unpublished testing folder. This query will return no results in the shell, but works from a breakpoint.</p>
<pre><code>$ bin/instance shell
$ ipython --profile=zope
from Products.CMFPlone.utils import getToolByName
catalog = getToolByName(context, 'portal_catalog')
catalog({'path':'Plone/testing'})
</code></pre>
<p>Can I authenticate as admin or otherwise rejigger the permissions to fully manipulate my site from ipython?</p>
|
[
{
"answer_id": 427914,
"author": "bruno desthuilliers",
"author_id": 41316,
"author_profile": "https://Stackoverflow.com/users/41316",
"pm_score": 2,
"selected": false,
"text": "from sys import stdin, stdout, exit\nimport base64\nfrom thread import get_ident\nfrom ZPublisher.HTTPRequest import HTTPRequest\nfrom ZPublisher.HTTPResponse import HTTPResponse\nfrom ZPublisher.BaseRequest import RequestContainer\nfrom ZPublisher import Publish\n\nfrom AccessControl import ClassSecurityInfo, getSecurityManager\nfrom AccessControl.SecurityManagement import newSecurityManager\nfrom AccessControl.User import UnrestrictedUser\n\ndef loginAsUnrestrictedUser():\n \"\"\"Exemple of use :\n old_user = loginAsUnrestrictedUser()\n # Manager stuff\n loginAsUser(old_user)\n \"\"\"\n current_user = getSecurityManager().getUser()\n newSecurityManager(None, UnrestrictedUser('manager', '', ['Manager'], []))\n return current_user\n\ndef loginAsUser(user):\n newSecurityManager(None, user)\n\ndef makerequest(app, stdout=stdout, query_string=None, user_pass=None):\n \"\"\"Make a request suitable for CMF sites & Plone\n - user_pass = \"user:pass\"\n \"\"\"\n # copy from Testing.makerequest\n resp = HTTPResponse(stdout=stdout)\n env = {}\n env['SERVER_NAME'] = 'lxtools.makerequest.fr'\n env['SERVER_PORT'] = '80'\n env['REQUEST_METHOD'] = 'GET'\n env['REMOTE_HOST'] = 'a.distant.host'\n env['REMOTE_ADDR'] = '77.77.77.77'\n env['HTTP_HOST'] = '127.0.0.1'\n env['HTTP_USER_AGENT'] = 'LxToolsUserAgent/1.0'\n env['HTTP_ACCEPT']='image/gif, image/x-xbitmap, image/jpeg, */* '\n if user_pass:\n env['HTTP_AUTHORIZATION']=\"Basic %s\" % base64.encodestring(user_pass)\n if query_string:\n p_q = query_string.split('?')\n if len(p_q) == 1: \n env['PATH_INFO'] = p_q[0]\n elif len(p_q) == 2: \n (env['PATH_INFO'], env['QUERY_STRING'])=p_q\n else: \n raise TypeError, ''\n req = HTTPRequest(stdin, env, resp)\n req['URL1']=req['URL'] # fix for CMFQuickInstaller\n #\n # copy/hacked from Localizer __init__ patches\n # first put the needed values in the request\n req['HTTP_ACCEPT_CHARSET'] = 'latin-9'\n #req.other['AcceptCharset'] = AcceptCharset(req['HTTP_ACCEPT_CHARSET'])\n #\n req['HTTP_ACCEPT_LANGUAGE'] = 'fr'\n #accept_language = AcceptLanguage(req['HTTP_ACCEPT_LANGUAGE'])\n #req.other['AcceptLanguage'] = accept_language \n # XXX For backwards compatibility\n #req.other['USER_PREF_LANGUAGES'] = accept_language\n #req.other['AcceptLanguage'] = accept_language \n #\n # Plone stuff\n #req['plone_skin'] = 'Plone Default'\n #\n # then store the request in Publish._requests\n # with the thread id\n id = get_ident()\n if hasattr(Publish, '_requests'):\n # we do not have _requests inside ZopeTestCase\n Publish._requests[id] = req\n # add a brainless session container\n req['SESSION'] = {}\n #\n # ok, let's wrap\n return app.__of__(RequestContainer(REQUEST = req))\n\n\ndef debug_init(app):\n loginAsUnrestrictedUser()\n app = makerequest(app)\n return app\n >> from Products.wshelpers import wsdebug\n>> app = wsdebug.debug_init(app)\n>> # now you're logged in as admin\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36330/"
] |
279,144
|
<p>I have a large Java app that is split up into multiple projects. Each project has its own folder in a Subversion repository like so:</p>
<p>AccountingCore</p>
<ul>
<li>trunk</li>
<li>branches</li>
<li>tags</li>
</ul>
<p>Common</p>
<ul>
<li>trunk</li>
<li>branches</li>
<li>tags</li>
</ul>
<p>WebCommon</p>
<ul>
<li>trunk</li>
<li>branches</li>
<li>tags</li>
</ul>
<p>etc...</p>
<p>I want to start using <strong>git-svn</strong> locally instead of subversion. </p>
<p>This may be a stupid question, but is there a way to checkout <em>all the projects</em> in the repository at once (including branches and all) instead checking out each project individually?</p>
<p>Thanks,
Tony</p>
|
[
{
"answer_id": 281010,
"author": "Bram Geron",
"author_id": 2147872,
"author_profile": "https://Stackoverflow.com/users/2147872",
"pm_score": 3,
"selected": true,
"text": "for DIR in AccountingCore Common WebCommon; do mkdir $DIR; cd $DIR; git init; git svn init -s svn://host/path/$DIR; git svn fetch; cd ..; done"
},
{
"answer_id": 281038,
"author": "Ben Collins",
"author_id": 3279,
"author_profile": "https://Stackoverflow.com/users/3279",
"pm_score": 0,
"selected": false,
"text": "git svn svn://host/path"
},
{
"answer_id": 9800063,
"author": "Kim Lindberg",
"author_id": 1282726,
"author_profile": "https://Stackoverflow.com/users/1282726",
"pm_score": 2,
"selected": false,
"text": "for DIR in AccountingCore Common WebCommon; do ...\n DIRS=`svn ls svn://host/path`; for DIR in $DIRS; do ...\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
279,145
|
<p>What is the most elegant way of bubble-sorting in F#?</p>
<p><strong>UPDATE</strong></p>
<p>As pointed out in one of the answers, bubble sorting isn't efficient in a functional language to begin with. A humourously-cynical commenter also pointed out that bubble sorting is only appropriate when the list is small and it's almost sorted anyway. </p>
<p>However, I'm curious to see how a clever bubble-sort can be written in F#, since I've done bubble sorts in C#, C++, and Java EE in the past, and since I'm an F# newbie.</p>
|
[
{
"answer_id": 279587,
"author": "Tomas Petricek",
"author_id": 33518,
"author_profile": "https://Stackoverflow.com/users/33518",
"pm_score": 5,
"selected": true,
"text": "let sort l = \n let rec sortUtil acc rev l =\n match l, rev with\n | [], true -> acc |> List.rev\n | [], false -> acc |> List.rev |> sortUtil [] true\n | x::y::tl, _ when x > y -> sortUtil (y::acc) false (x::tl)\n | hd::tl, _ -> sortUtil (hd::acc) rev tl\n sortUtil [] true l\n let sort (arr:'a[]) = \n let arr = arr |> Array.copy\n let swap i j = let tmp = arr.[i] in arr.[i] <- arr.[j]; arr.[j] <- tmp\n for i = arr.Length - 1 downto 0 do\n for j = 1 to i do\n if (arr.[j - 1] > arr.[j]) then swap (j-1) j\n arr\n"
},
{
"answer_id": 56571011,
"author": "J D",
"author_id": 13924,
"author_profile": "https://Stackoverflow.com/users/13924",
"pm_score": 2,
"selected": false,
"text": "let rec sort (a: int []) =\n let mutable fin = true\n for i in 0..a.Length-2 do\n if a.[i] > a.[i+1] then\n let t = a.[i]\n a.[i] <- a.[i+1]\n a.[i+1] <- t\n fin <- false\n if not fin then sort a\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32462/"
] |
279,148
|
<p>I have a table of 155K records. I can scroll only 65K records in combo box of a form having recordsource with query or sql, selecting three fields from that table. Why it does not list all 155K records even the query, which I am using as recordsource, shows all records outside of the form.</p>
|
[
{
"answer_id": 286853,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 0,
"selected": false,
"text": "SELECT tp.PersonKey, \n tp.Surname & \", \" & tp.Forename AS PersonName\nFROM tblPersons tp\nWHERE tp.Surname \nLIKE Forms!MyForm!txtSurname.Text\nORDER BY tp.Surname, tp.Forename\n"
},
{
"answer_id": 289268,
"author": "David-W-Fenton",
"author_id": 9787,
"author_profile": "https://Stackoverflow.com/users/9787",
"pm_score": 3,
"selected": false,
"text": " Dim strRowSource As String\n\n strRowSource = \"SELECT MyID, MyField FROM MyTable\"\n If Len(Me!cmbMyCombo.Text)=3 Then\n strRowSource = strRowSource & \" WHERE MyField Like '\" \n strRowSource = strRowSource & Me!cmbMyCombo.Text\n strRowSource = strRowSource & \"*'\"\n Me!cmbMyCombo.RowSource = strRowSource\n Me!cmbMyCombo.DropDown\n End If\n PARAMETERS [Forms]![MyForm]![MyField] Text ( 255 );\n SELECT MyID, MyField FROM MyTable WHERE MyField = [Forms]![MyForm]![MyField];\"\n Dim strRowSource As String\n\n strRowSource = \"PARAMETERS [Forms]![MyForm]![MyField] Long; \"\n strRowSource = strRowSource & \"SELECT MyID, MyField FROM MyTable \"\n strRowSource = strRowSource & \"WHERE MyField = [Forms]![MyForm]![MyID]\"\n strRowSource = strRowSource & \"UNION SELECT MyID, MyField FROM MyTable\"\n If Len(Me!cmbMyCombo.Text)=3 Then\n strRowSource = strRowSource & \" WHERE MyField Like '\" \n strRowSource = strRowSource & Me!cmbMyCombo.Text\n strRowSource = strRowSource & \"*'\"\n Me!cmbMyCombo.RowSource = strRowSource\n Me!cmbMyCombo.DropDown\n End If\n Dim strRowSource As String\n\n strRowSource = \"PARAMETERS [Forms]![MyForm]![MyField] Text ( 255 ); \"\n strRowSource = strRowSource & \"SELECT MyID, MyField FROM MyTable \"\n strRowSource = strRowSource & \"WHERE MyField = [Forms]![MyForm]![MyField]\"\n Me!cmbMyCombo.RowSource = strRowSource\n"
},
{
"answer_id": 34027413,
"author": "Steve Manser",
"author_id": 5626866,
"author_profile": "https://Stackoverflow.com/users/5626866",
"pm_score": 0,
"selected": false,
"text": "Private Sub POLICY_NO_Click()\n Set Me.Parent.Recordset = CurrentDb.OpenRecordset(\"qryHPolicy\")\n Me.Parent.Recordset.FindFirst \"[POLICY_NO]=\" & Me.POLICY_NO & \"\"\nEnd Sub\n Forms(Me_FormTo).Form.RecordSource = Me_RecSource\nForms(Me_FormTo).Combo6.Form.RecordSource = Me_RecSource\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
279,154
|
<p>I'm looking for a reliable, implementation-independent way to clone an entire Document. The Javadocs specifically say that calling cloneNode on a Document is implementation-specific. I've tried passing the Document through a no-op Transformer, but the resulting Node has no owner Document.</p>
<p>I could create a new Document and import the nodes from the old one, but I'm afraid there might be bits of Document metadata that get lost. Same thing with writing the Document to a string and parsing it back in.</p>
<p>Any ideas?</p>
<p>By the way, I'm stuck at Java 1.4.2, for reasons beyond my control.</p>
|
[
{
"answer_id": 2109128,
"author": "Ichiro Furusato",
"author_id": 230955,
"author_profile": "https://Stackoverflow.com/users/230955",
"pm_score": 3,
"selected": false,
"text": "TransformerFactory tfactory = TransformerFactory.newInstance();\nTransformer tx = tfactory.newTransformer();\nDOMSource source = new DOMSource(doc);\nDOMResult result = new DOMResult();\ntx.transform(source,result);\nreturn (Document)result.getNode();\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25498/"
] |
279,158
|
<p>I'm going to try to ask my question in the context of a simple example...</p>
<p>Let's say I have an abstract base class Car. Car has-a basic Engine object. I have a method StartEngine() in the abstract Car class that delegates the starting of the engine to the Engine object.</p>
<p>How do I allow subclasses of Car (like Ferrari) to declare the Engine object as a specific type of engine (e.g., TurboEngine)? Do I need another Car class (TurboCar)?</p>
<p>I'm inheriting a plain old Engine object and I cannot re-declare (or override) it as a TurboEngine in my Car subclasses. </p>
<p><strong>EDIT:</strong> I understand that I can plug any subclass of Engine into myEngine reference within my Ferrari class...but how can I call methods that only the TurboEngine exposes? Because myEngine is inherited as a base Engine, none of the turbo stuff is included. </p>
<p>Thanks!</p>
|
[
{
"answer_id": 279180,
"author": "Chris Boran",
"author_id": 25660,
"author_profile": "https://Stackoverflow.com/users/25660",
"pm_score": 0,
"selected": false,
"text": "setEngine() Car Ferrari setEngine() TurboEngine"
},
{
"answer_id": 279183,
"author": "Larry OBrien",
"author_id": 10116,
"author_profile": "https://Stackoverflow.com/users/10116",
"pm_score": 4,
"selected": true,
"text": " using System;\n\n\n abstract class CarFactory\n {\n public static CarFactory FactoryFor(string manufacturer){\n switch(manufacturer){\n case \"Ferrari\" : return new FerrariFactory();\n case \"Honda\" : return new HondaFactory();\n default:\n throw new ArgumentException(\"Unknown car manufacturer. Please bailout industry.\");\n }\n }\n\n public abstract Car createCar();\n public abstract Engine createEngine();\n public abstract Frame createFrame();\n\n }\n\n class FerrariFactory : CarFactory\n {\n public override Car createCar()\n {\n return new Ferrari(createEngine(), createFrame());\n }\n\n public override Engine createEngine()\n {\n return new TurboEngine();\n }\n\n public override Frame createFrame()\n {\n return new CarbonFrame();\n }\n }\n\n class HondaFactory : CarFactory\n {\n public override Car createCar()\n {\n return new Honda(createEngine(), createFrame());\n }\n\n public override Engine createEngine()\n {\n return new WeakEngine();\n }\n\n public override Frame createFrame()\n {\n return new WeakFrame();\n }\n }\n\n abstract class Car\n {\n private Engine engine;\n private Frame frame;\n\n public Car(Engine engine, Frame frame)\n {\n this.engine = engine;\n this.frame = frame;\n }\n\n public void accelerate()\n {\n engine.setThrottle(1.0f);\n frame.respondToSpeed();\n }\n\n }\n\n class Ferrari : Car\n {\n public Ferrari(Engine engine, Frame frame) : base(engine, frame)\n {\n Console.WriteLine(\"Setting sticker price to $250K\");\n }\n }\n\n class Honda : Car\n {\n public Honda(Engine engine, Frame frame) : base(engine, frame)\n {\n Console.WriteLine(\"Setting sticker price to $25K\");\n }\n }\n\n class KitCar : Car\n {\n public KitCar(String name, Engine engine, Frame frame)\n : base(engine, frame)\n {\n Console.WriteLine(\"Going out in the garage and building myself a \" + name);\n }\n }\n\n abstract class Engine\n {\n public void setThrottle(float percent)\n {\n Console.WriteLine(\"Stomping on accelerator!\");\n typeSpecificAcceleration();\n }\n\n protected abstract void typeSpecificAcceleration();\n }\n\n class TurboEngine : Engine\n {\n protected override void typeSpecificAcceleration()\n {\n Console.WriteLine(\"Activating turbo\");\n Console.WriteLine(\"Making noise like Barry White gargling wasps\");\n }\n }\n\n class WeakEngine : Engine\n {\n protected override void typeSpecificAcceleration()\n {\n Console.WriteLine(\"Provoking hamster to run faster\");\n Console.WriteLine(\"Whining like a dentist's drill\");\n }\n }\n\n abstract class Frame\n {\n public abstract void respondToSpeed();\n }\n\n class CarbonFrame : Frame\n {\n public override void respondToSpeed()\n {\n Console.WriteLine(\"Activating active suspension and extending spoilers\");\n }\n }\n\n class WeakFrame : Frame\n {\n public override void respondToSpeed()\n {\n Console.WriteLine(\"Loosening bolts and vibrating\");\n }\n }\n\n class TestClass\n {\n public static void Main()\n {\n CarFactory ferrariFactory = CarFactory.FactoryFor(\"Ferrari\");\n Car enzo = ferrariFactory.createCar();\n enzo.accelerate();\n\n Console.WriteLine(\"---\");\n CarFactory hondaFactory = CarFactory.FactoryFor(\"Honda\");\n Car civic = hondaFactory.createCar();\n civic.accelerate();\n\n Console.WriteLine(\"---\");\n Frame frame = hondaFactory.createFrame();\n Engine engine = ferrariFactory.createEngine();\n Car kitCar = new KitCar(\"Shaker\", engine, frame);\n kitCar.accelerate();\n\n Console.WriteLine(\"---\");\n Car kitCar2 = new KitCar(\"LooksGreatGoesSlow\", hondaFactory.createEngine(), ferrariFactory.createFrame());\n kitCar2.accelerate();\n }\n }\n"
},
{
"answer_id": 279194,
"author": "Greg Case",
"author_id": 462,
"author_profile": "https://Stackoverflow.com/users/462",
"pm_score": 1,
"selected": false,
"text": "public class Car {\n private Engine engine;\n\n public Car() {\n this(new Engine());\n }\n\n protected Car(Engine engine) {\n this.engine = engine;\n }\n\n public void start() {\n this.engine.start();\n }\n}\n\npublic class Ferrari {\n public Ferrari() {\n super(new TurboEngine());\n }\n}\n"
},
{
"answer_id": 279229,
"author": "Patrick Desjardins",
"author_id": 13913,
"author_profile": "https://Stackoverflow.com/users/13913",
"pm_score": 2,
"selected": false,
"text": "abstract class Car {\n private Engine engine;\n\n public Car() {\n this.engine = new Engine();\n }\n\n protected Car(Engine engine) {\n this.engine = engine;\n }\n\n public void Start()\n {\n this.StartEngine();\n }\n protected abstract void StartEngine();\n}\n\npublic class Ferrari : Car\n{\n public Ferrari() {\n\n }\n protected override void StartEngine()\n {\n Console.WriteLine(\"TURBO ENABLE!!!\");\n }\n\n}\n Car c = new Ferrari();\nc.Start();\n"
},
{
"answer_id": 279235,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 1,
"selected": false,
"text": "public class Car\n{\n private Engine engine;\n public virtual Engine CarEngine\n {\n get { return engine;}\n }\n\n public StartEngine()\n {\n CarEngine.Start();\n }\n}\n\npublic class Engine\n{\n public virtual void Start()\n {\n Console.Writeline(\"Vroom\");\n }\n} \n\npublic class TurboEngine : Engine\n{\n public override void Start()\n {\n Console.Writeline(\"Vroom pSHHHHHHH\");\n } \n\n // TurboEngine Only method\n public double BoostPressure()\n {\n }\n}\n\npublic class Ferrari : Car\n{\n private TurboEngine engine;\n public override Engine CarEngine\n {\n return engine;\n }\n}\n\nFerrari = car new Ferrari();\n// Will call Start on TurboEngine()\ncar.StartEngine();\n// Upcast to get TurboEngine stuff\nConsole.WriteLine(car.CarEngine as TurboEngine).BoostPressure();\n"
},
{
"answer_id": 279342,
"author": "Dan Vinton",
"author_id": 21849,
"author_profile": "https://Stackoverflow.com/users/21849",
"pm_score": 1,
"selected": false,
"text": "class Engine {}\n\nabstract class Car<E extends Engine> \n{\n private E engine;\n public E getEngine() { return engine; } \n}\n\nclass TurboEngine extends Engine {}\n\nclass Ferrari extends Car<TurboEngine> \n{\n // Ferrari now has a method with this signature:\n // public TurboEngine getEngine() {} \n}\n"
},
{
"answer_id": 279344,
"author": "Peter Crabtree",
"author_id": 36283,
"author_profile": "https://Stackoverflow.com/users/36283",
"pm_score": 1,
"selected": false,
"text": "Ferrari Engine TurboEngine Car EngineType Engine class Program\n{\n static void Main(string[] args)\n {\n Ferrari ferarri = new Ferrari();\n ferarri.Start();\n ferarri.Boost();\n }\n}\npublic class Car<EngineType> where EngineType : Engine, new()\n{\n protected EngineType engine;\n\n public Car()\n {\n this.CreateEngine();\n }\n protected void CreateEngine()\n {\n this.engine = new EngineType();\n }\n public void Start()\n {\n engine.Start();\n }\n}\n\npublic class Ferrari : Car<TurboEngine>\n{\n public void Boost()\n {\n engine.Boost();\n }\n}\n\npublic class Engine\n{\n public virtual void Start()\n {\n Console.WriteLine(\"Vroom!\");\n }\n}\npublic class TurboEngine : Engine\n{\n public void Boost()\n {\n Console.WriteLine(\"Hang on to your teeth...\");\n }\n public override void Start()\n {\n Console.WriteLine(\"VROOOOM! VROOOOM!\");\n }\n}\n"
},
{
"answer_id": 279355,
"author": "dnord",
"author_id": 3248,
"author_profile": "https://Stackoverflow.com/users/3248",
"pm_score": 1,
"selected": false,
"text": "TurboEngine TurboEngine TurboEngine"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279158",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/132931/"
] |
279,169
|
<p>Is it possible to deploy a website using <code>git push</code>? I have a hunch it has something to do with using <a href="http://www.git-scm.com/book/en/v2/Customizing-Git-Git-Hooks" rel="noreferrer">git hooks</a> to perform a <code>git reset --hard</code> on the server side, but how would I go about accomplishing this?</p>
|
[
{
"answer_id": 327315,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 9,
"selected": true,
"text": "[remote \"production\"]\n url = username@webserver:/path/to/htdocs/.git\n chmod +x .git/hooks/post-update\n git push production\n"
},
{
"answer_id": 2806602,
"author": "Lloyd Moore",
"author_id": 337710,
"author_profile": "https://Stackoverflow.com/users/337710",
"pm_score": 4,
"selected": false,
"text": "server = $1\nbranch = $2\ngit push $server $branch\nssh <username>@$server \"cd /path/to/www; git pull\"\n deploy ./deploy myserver mybranch"
},
{
"answer_id": 3387030,
"author": "Darío Javier Cravero",
"author_id": 408546,
"author_profile": "https://Stackoverflow.com/users/408546",
"pm_score": 6,
"selected": false,
"text": "[remote \"production\"]\n url = username@webserver:/path/to/htdocs/.git\n chmod +x .git/hooks/post-update\n git push production\n #!/bin/sh\n#\n# This hook does two things:\n#\n# 1. update the \"info\" files that allow the list of references to be\n# queries over dumb transports such as http\n#\n# 2. if this repository looks like it is a non-bare repository, and\n# the checked-out branch is pushed to, then update the working copy.\n# This makes \"push\" function somewhat similarly to darcs and bzr.\n#\n# To enable this hook, make this file executable by \"chmod +x post-update\". \ngit-update-server-info \nis_bare=$(git-config --get --bool core.bare) \nif [ -z \"$is_bare\" ]\nthen\n # for compatibility's sake, guess\n git_dir_full=$(cd $GIT_DIR; pwd)\n case $git_dir_full in */.git) is_bare=false;; *) is_bare=true;; esac\nfi \nupdate_wc() {\n ref=$1\n echo \"Push to checked out branch $ref\" >&2\n if [ ! -f $GIT_DIR/logs/HEAD ]\n then\n echo \"E:push to non-bare repository requires a HEAD reflog\" >&2\n exit 1\n fi\n if (cd $GIT_WORK_TREE; git-diff-files -q --exit-code >/dev/null)\n then\n wc_dirty=0\n else\n echo \"W:unstaged changes found in working copy\" >&2\n wc_dirty=1\n desc=\"working copy\"\n fi\n if git diff-index --cached HEAD@{1} >/dev/null\n then\n index_dirty=0\n else\n echo \"W:uncommitted, staged changes found\" >&2\n index_dirty=1\n if [ -n \"$desc\" ]\n then\n desc=\"$desc and index\"\n else\n desc=\"index\"\n fi\n fi\n if [ \"$wc_dirty\" -ne 0 -o \"$index_dirty\" -ne 0 ]\n then\n new=$(git rev-parse HEAD)\n echo \"W:stashing dirty $desc - see git-stash(1)\" >&2\n ( trap 'echo trapped $$; git symbolic-ref HEAD \"'\"$ref\"'\"' 2 3 13 15 ERR EXIT\n git-update-ref --no-deref HEAD HEAD@{1}\n cd $GIT_WORK_TREE\n git stash save \"dirty $desc before update to $new\";\n git-symbolic-ref HEAD \"$ref\"\n )\n fi \n # eye candy - show the WC updates :)\n echo \"Updating working copy\" >&2\n (cd $GIT_WORK_TREE\n git-diff-index -R --name-status HEAD >&2\n git-reset --hard HEAD)\n} \nif [ \"$is_bare\" = \"false\" ]\nthen\n active_branch=`git-symbolic-ref HEAD`\n export GIT_DIR=$(cd $GIT_DIR; pwd)\n GIT_WORK_TREE=${GIT_WORK_TREE-..}\n for ref\n do\n if [ \"$ref\" = \"$active_branch\" ]\n then\n update_wc $ref\n fi\n done\nfi\n"
},
{
"answer_id": 7171562,
"author": "Christian",
"author_id": 178597,
"author_profile": "https://Stackoverflow.com/users/178597",
"pm_score": 4,
"selected": false,
"text": "git ls-files -z | rsync --files-from - --copy-links -av0 . user@server.com:/var/www/project\n"
},
{
"answer_id": 8279779,
"author": "Karussell",
"author_id": 194609,
"author_profile": "https://Stackoverflow.com/users/194609",
"pm_score": 3,
"selected": false,
"text": "ssh -A ... [remote \"amazon\"]\n url = amazon:/path/to/project.git\n fetch = +refs/heads/*:refs/remotes/amazon/*\n amazon: Host amazon\n Hostname <YOUR_IP>\n User <USER>\n IdentityFile ~/.ssh/amazon-private-key\n git push amazon master\nssh <USER>@<YOUR_IP> 'cd /path/to/project && git pull'\n"
},
{
"answer_id": 13632105,
"author": "Supernini",
"author_id": 1240294,
"author_profile": "https://Stackoverflow.com/users/1240294",
"pm_score": 3,
"selected": false,
"text": "cap deploy\ncap deploy:start_rsync (when the staging is ok)\n cap deploy:rollback\ncap deploy:start_rsync\n"
},
{
"answer_id": 18667236,
"author": "Priit",
"author_id": 1354185,
"author_profile": "https://Stackoverflow.com/users/1354185",
"pm_score": 1,
"selected": false,
"text": "git archive --prefix=deploy/ master | tar -x -C $TMPDIR | rsync $TMPDIR/deploy/ --copy-links -av username@server.com:/home/user/my_app && rm -rf $TMPDIR/deploy\n"
},
{
"answer_id": 22557829,
"author": "Synox",
"author_id": 79461,
"author_profile": "https://Stackoverflow.com/users/79461",
"pm_score": 1,
"selected": false,
"text": "$ mkdir website.git && cd website.git\n$ git init --bare\nInitialized empty Git repository in /home/ams/website.git/\n $ mkdir /var/www/www.example.org\n$ cat > hooks/post-receive\n#!/bin/sh\nGIT_WORK_TREE=/var/www/www.example.org git checkout -f\nGIT_WORK_TREE=/var/www/www git clean -f -d # clean directory from removed files\n\n$ chmod +x hooks/post-receive\n $ mkdir website && cd website\n$ git init\nInitialized empty Git repository in /home/ams/website/.git/\n$ echo 'Hello, world!' > index.html\n$ git add index.html\n$ git commit -q -m \"The humble beginnings of my web site.\"\n\n$ git remote add web ssh://server.example.org/home/ams/website.git\n$ git push web +master:refs/heads/master\n $ git push web\n"
},
{
"answer_id": 28381235,
"author": "Ciro Santilli OurBigBook.com",
"author_id": 895245,
"author_profile": "https://Stackoverflow.com/users/895245",
"pm_score": 4,
"selected": false,
"text": "git config --local receive.denyCurrentBranch updateInstead push-to-checkout git init server\ncd server\ntouch a\ngit add .\ngit commit -m 0\ngit config --local receive.denyCurrentBranch updateInstead\n\ncd ..\ngit clone server local\ncd local\ntouch b\ngit add .\ngit commit -m 1\ngit push origin master:master\n\ncd ../server\nls\n a\nb\n"
},
{
"answer_id": 30029519,
"author": "manuelbcd",
"author_id": 3518053,
"author_profile": "https://Stackoverflow.com/users/3518053",
"pm_score": 1,
"selected": false,
"text": "git ftp push\n"
},
{
"answer_id": 33185123,
"author": "Attila Fulop",
"author_id": 1016746,
"author_profile": "https://Stackoverflow.com/users/1016746",
"pm_score": 3,
"selected": false,
"text": ".git git remote add live ssh://user@host:port/folder git config receive.denyCurrentBranch ignore nano .git/hooks/post-receive #!/bin/sh\nGIT_WORK_TREE=/var/www/vhosts/example.org git checkout -f chmod +x .git/hooks/post-receive git push live .git .htaccess RedirectMatch 404 /\\..*$"
},
{
"answer_id": 35407208,
"author": "klor",
"author_id": 4523359,
"author_profile": "https://Stackoverflow.com/users/4523359",
"pm_score": 0,
"selected": false,
"text": "#!/bin/bash \n# /git-repo/hooks/post-receive - file content on server (chmod as 755 to be executed)\n# DEPLOY SOLUTION 1 \n\n export GIT_DIR=/git/repo-bare.git\n export GIT_BRANCH1=master\n export GIT_TARGET1=/var/www/html\n export GIT_BRANCH2=dev\n export GIT_TARGET2=/var/www/dev\n echo \"GIT DIR: $GIT_DIR/\"\n echo \"GIT TARGET1: $GIT_TARGET1/\"\n echo \"GIT BRANCH1: $GIT_BRANCH1/\"\n echo \"GIT TARGET2: $GIT_TARGET2/\"\n echo \"GIT BRANCH2: $GIT_BRANCH2/\"\n echo \"\"\n\n cd $GIT_DIR/\n\nwhile read oldrev newrev refname\ndo\n branch=$(git rev-parse --abbrev-ref $refname)\n BRANCH_REGEX='^${GIT_BRANCH1}.*$'\n if [[ $branch =~ $BRANCH_REGEX ]] ; then\n export GIT_WORK_TREE=$GIT_TARGET1/.\n echo \"Checking out branch: $branch\";\n echo \"Checking out to workdir: $GIT_WORK_TREE\"; \n\n git checkout -f $branch\n fi\n\n BRANCH_REGEX='^${GIT_BRANCH2}.*$'\n if [[ $branch =~ $BRANCH_REGEX ]] ; then\n export GIT_WORK_TREE=$GIT_TARGET2/.\n echo \"Checking out branch: $branch\";\n echo \"Checking out to workdir: $GIT_WORK_TREE\"; \n\n git checkout -f $branch\n fi\ndone\n #!/bin/bash \n# /git-repo/hooks/post-receive - file content on server (chmod as 755 to be executed)\n# DEPLOY SOLUTION 2\n\n export GIT_DIR=/git/repo-bare.git\n export GIT_BRANCH1=master\n export GIT_TARGET1=/var/www/html\n export GIT_BRANCH2=dev\n export GIT_TARGET2=/var/www/dev\n export GIT_TEMP_DIR1=/tmp/deploy1\n export GIT_TEMP_DIR2=/tmp/deploy2\n echo \"GIT DIR: $GIT_DIR/\"\n echo \"GIT TARGET1: $GIT_TARGET1/\"\n echo \"GIT BRANCH1: $GIT_BRANCH1/\"\n echo \"GIT TARGET2: $GIT_TARGET2/\"\n echo \"GIT BRANCH2: $GIT_BRANCH2/\"\n echo \"GIT TEMP DIR1: $GIT_TEMP_DIR1/\"\n echo \"GIT TEMP DIR2: $GIT_TEMP_DIR2/\"\n echo \"\"\n\n cd $GIT_DIR/\n\nwhile read oldrev newrev refname\ndo\n branch=$(git rev-parse --abbrev-ref $refname)\n BRANCH_REGEX='^${GIT_BRANCH1}.*$'\n if [[ $branch =~ $BRANCH_REGEX ]] ; then\n export GIT_WORK_TREE=$GIT_TARGET1/.\n echo \"Checking out branch: $branch\";\n echo \"Checking out to workdir: $GIT_WORK_TREE\"; \n\n # DEPLOY SOLUTION 2: \n cd $GIT_DIR/; mkdir -p $GIT_TEMP_DIR1; \n export GIT_WORK_TREE=$GIT_TEMP_DIR1/.\n git checkout -f $branch\n export GIT_WORK_TREE=$GIT_TARGET1/.\n rsync $GIT_TEMP_DIR1/. -v -q --delete --delete-after -av $GIT_TARGET1/.\n rm -rf $GIT_TEMP_DIR1\n fi\n\n BRANCH_REGEX='^${GIT_BRANCH2}.*$'\n if [[ $branch =~ $BRANCH_REGEX ]] ; then\n export GIT_WORK_TREE=$GIT_TARGET2/.\n echo \"Checking out branch: $branch\";\n echo \"Checking out to workdir: $GIT_WORK_TREE\"; \n\n # DEPLOY SOLUTION 2: \n cd $GIT_DIR/; mkdir -p $GIT_TEMP_DIR2; \n export GIT_WORK_TREE=$GIT_TEMP_DIR2/.\n git checkout -f $branch\n export GIT_WORK_TREE=$GIT_TARGET2/.\n rsync $GIT_TEMP_DIR2/. -v -q --delete --delete-after -av $GIT_TARGET2/.\n rm -rf $GIT_TEMP_DIR2\n fi\ndone\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] |
279,170
|
<p>
I'm setting up a new server and want to support UTF-8 fully in my web application. I have tried this in the past on existing servers and always seem to end up having to fall back to ISO-8859-1.</p>
<p>Where exactly do I need to set the encoding/charsets? I'm aware that I need to configure Apache, MySQL, and PHP to do this — is there some standard checklist I can follow, or perhaps troubleshoot where the mismatches occur?</p>
<p>This is for a new Linux server, running MySQL 5, PHP, 5 and Apache 2.</p>
|
[
{
"answer_id": 279244,
"author": "chroder",
"author_id": 18802,
"author_profile": "https://Stackoverflow.com/users/18802",
"pm_score": 6,
"selected": false,
"text": "default_charset header() header('Content-Type: text/html; charset=utf-8');\n"
},
{
"answer_id": 279279,
"author": "chazomaticus",
"author_id": 30497,
"author_profile": "https://Stackoverflow.com/users/30497",
"pm_score": 11,
"selected": true,
"text": "utf8mb4 utf8mb4 utf8mb4_* utf8 utf8mb4 charset $dbh = new PDO('mysql:charset=utf8mb4');\n set_charset() $mysqli->set_charset('utf8mb4'); // object oriented style\n mysqli_set_charset($link, 'utf8mb4'); // procedural style\n mysql_set_charset SET NAMES 'utf8mb4' utf8mb4 utf8 Content-Type: text/html; charset=utf-8 default_charset header() json_encode() JSON_UNESCAPED_UNICODE mb_check_encoding() mbstring mbstring"
},
{
"answer_id": 285036,
"author": "mercator",
"author_id": 23263,
"author_profile": "https://Stackoverflow.com/users/23263",
"pm_score": 7,
"selected": false,
"text": "<meta charset=\"utf-8\">\n"
},
{
"answer_id": 4693147,
"author": "commonpike",
"author_id": 95733,
"author_profile": "https://Stackoverflow.com/users/95733",
"pm_score": 3,
"selected": false,
"text": "// Storage\n// Debian. Apparently already UTF-8\n\n// Retrieval\n// The MySQL database was stored in UTF-8,\n// but apparently PHP was requesting ISO 8859-1. This worked:\n// ***notice \"utf8\", without dash, this is a MySQL encoding***\nmysql_set_charset('utf8');\n\n// Delivery\n// File *php.ini* did not have a default charset,\n// (it was commented out, shared host) and\n// no HTTP encoding was specified in the Apache headers.\n// This made Apache send out a UTF-8 header\n// (and perhaps made PHP actually send out UTF-8)\n// ***notice \"utf-8\", with dash, this is a php encoding***\nini_set('default_charset','utf-8');\n\n// Submission\n// This worked in all major browsers once Apache\n// was sending out the UTF-8 header. I didn’t add\n// the accept-charset attribute.\n\n// Processing\n// Changed a few commands in PHP, like substr(),\n// to mb_substr()\n"
},
{
"answer_id": 9422287,
"author": "JDelage",
"author_id": 98361,
"author_profile": "https://Stackoverflow.com/users/98361",
"pm_score": 5,
"selected": false,
"text": "mb_split mb_regex_encoding('UTF-8'); mb_internal_encoding() mb_internal_encoding(\"UTF-8\");"
},
{
"answer_id": 12373363,
"author": "Jim",
"author_id": 398519,
"author_profile": "https://Stackoverflow.com/users/398519",
"pm_score": 5,
"selected": false,
"text": "$pdo = new PDO(\n 'mysql:host=mysql.example.com;dbname=example_db',\n \"username\",\n \"password\",\n array(PDO::MYSQL_ATTR_INIT_COMMAND => \"SET NAMES utf8\"));\n"
},
{
"answer_id": 21087860,
"author": "Miguel Stevens",
"author_id": 1731057,
"author_profile": "https://Stackoverflow.com/users/1731057",
"pm_score": 4,
"selected": false,
"text": "strtolower() mb_strtolower($string, 'UTF-8');\n"
},
{
"answer_id": 21376914,
"author": "Jimmy Kane",
"author_id": 1857292,
"author_profile": "https://Stackoverflow.com/users/1857292",
"pm_score": 5,
"selected": false,
"text": "stream_filter_append($fp, 'convert.iconv.ISO-2022-JP/EUC-JP')"
},
{
"answer_id": 28466887,
"author": "Budimir Grom",
"author_id": 3948809,
"author_profile": "https://Stackoverflow.com/users/3948809",
"pm_score": 3,
"selected": false,
"text": "skip-character-set-client-handshake my.cnf [mysqld] mysql"
},
{
"answer_id": 30063664,
"author": "Abdul Sadik Yalcin",
"author_id": 3397521,
"author_profile": "https://Stackoverflow.com/users/3397521",
"pm_score": 4,
"selected": false,
"text": "if (!$mysqli->set_charset(\"utf8\")) {\n printf(\"Error loading character set utf8: %s\\n\", $mysqli->error);\n} else {\n printf(\"Current character set: %s\\n\", $mysqli->character_set_name());\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1951/"
] |
279,173
|
<p>Is there anything in Visual Studio that will report memory leaks like Codeguard?</p>
<p>eg:</p>
<pre><code>Error 00001. 0x300010 (Thread 0x0FA4):
Resource leak: The object (0xC65D84) was never deleted
The object (0x00C65D84) [size: 4 bytes] was created with new
| element2.cpp line 3:
| #include "element2.h"
|
|>CS225::Element2::Element2(int _val) : p_val(new int(_val)) { }
|
| CS225::Element2::Element2(const Element2& rhs)
Call Tree:
0x0040E3A7(=bcc_cg.exe:0x01:00D3A7) element2.cpp#3
0x00409116(=bcc_cg.exe:0x01:008116) element-factory.h#19
0x0040D964(=bcc_cg.exe:0x01:00C964) array.cpp#87
0x00405308(=bcc_cg.exe:0x01:004308) driver.cpp#394
0x004054B5(=bcc_cg.exe:0x01:0044B5) driver.cpp#415
0x00405522(=bcc_cg.exe:0x01:004522) driver.cpp#420
------------------------------------------
Error 00002. 0x300010 (Thread 0x0FA4):
Resource leak: The object (0xC65D58) was never deleted
The object (0x00C65D58) [size: 4 bytes] was created with new
| element2.cpp line 6:
|
| CS225::Element2::Element2(const Element2& rhs)
|> : AbstractElement(), p_val(new int(*rhs.p_val))
| { }
|
Call Tree:
0x0040E4B7(=bcc_cg.exe:0x01:00D4B7) element2.cpp#6
0x0040E652(=bcc_cg.exe:0x01:00D652) element2.cpp#26
0x0040D8CD(=bcc_cg.exe:0x01:00C8CD) array.cpp#81
0x00405308(=bcc_cg.exe:0x01:004308) driver.cpp#394
0x004054B5(=bcc_cg.exe:0x01:0044B5) driver.cpp#415
0x00405522(=bcc_cg.exe:0x01:004522) driver.cpp#420
</code></pre>
|
[
{
"answer_id": 279188,
"author": "Roger Lipscombe",
"author_id": 8446,
"author_profile": "https://Stackoverflow.com/users/8446",
"pm_score": 3,
"selected": true,
"text": "<crtdbg.h"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34799/"
] |
279,190
|
<p>How can I extract the list of colors in the System.Drawing.Color struct into a collection or array?</p>
<p>Is there a more efficient way of getting a collection of colors than using this struct as a base?</p>
|
[
{
"answer_id": 279207,
"author": "jons911",
"author_id": 34375,
"author_profile": "https://Stackoverflow.com/users/34375",
"pm_score": 5,
"selected": true,
"text": "string[] colors = Enum.GetNames(typeof(System.Drawing.KnownColor));\n Type colorType = typeof(System.Drawing.Color);\n\nPropertyInfo[] propInfoList = colorType.GetProperties(BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public);\n\nforeach (System.Reflection.PropertyInfo c in propInfoList) {\n Console.WriteLine(c.Name);\n}\n"
},
{
"answer_id": 279219,
"author": "Roger Lipscombe",
"author_id": 8446,
"author_profile": "https://Stackoverflow.com/users/8446",
"pm_score": 3,
"selected": false,
"text": "foreach (KnownColor knownColor in Enum.GetValues(typeof(KnownColor)))\n{\n Trace.WriteLine(string.Format(\"{0}\", knownColor));\n}\n"
},
{
"answer_id": 279226,
"author": "Ryan Lundy",
"author_id": 5486,
"author_profile": "https://Stackoverflow.com/users/5486",
"pm_score": 3,
"selected": false,
"text": "Color"
},
{
"answer_id": 279294,
"author": "Steve T",
"author_id": 415,
"author_profile": "https://Stackoverflow.com/users/415",
"pm_score": 1,
"selected": false,
"text": "System.Collections.Generic.List<string> colors = \n new System.Collections.Generic.List<string>();\nType t = typeof(System.Drawing.Color);\nSystem.Reflection.PropertyInfo[] infos = t.GetProperties();\nforeach (System.Reflection.PropertyInfo info in infos)\n if (info.PropertyType == typeof(System.Drawing.Color))\n colors.Add(info.Name);\n"
},
{
"answer_id": 2102678,
"author": "grenade",
"author_id": 68115,
"author_profile": "https://Stackoverflow.com/users/68115",
"pm_score": 3,
"selected": false,
"text": "using System.Collections.Generic;\nusing System.Drawing;\nusing System.Linq;\n...\nstatic IEnumerable<Color> GetSystemColors() {\n Type type = typeof(Color);\n return type.GetProperties().Where(info => info.PropertyType == type).Select(info => (Color)info.GetValue(null, null));\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1583/"
] |
279,195
|
<p>I am trying to parse JSON in an Adobe Flex app, using http://www.mikechambers.com/blog/2006/03/28/tutorial-using-json-with-flex-2-and-actionscript-3/'>This Tutorial</p>
<p>Unfortunately, Flex Builder 3 is flagging a "Access of undefined property JSON" error on the line</p>
<p><code>var arr:Array = (JSON.decode(rawData) as Array);</code></p>
<p>I don't know what it wants, since I included the import line. </p>
|
[
{
"answer_id": 13985779,
"author": "Dinesh",
"author_id": 1059093,
"author_profile": "https://Stackoverflow.com/users/1059093",
"pm_score": 2,
"selected": false,
"text": "var arr:Array = (com.adobe.serialization.json.JSON.decode(rawData) as Array);\n var arr:Array = (JSON.decode(rawData) as Array);\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32392/"
] |
279,208
|
<p>After two years of C#, I'm now back to VB.net because of my current job. In C#, I can do a short hand testing for null or false value on a string variable like this:</p>
<pre><code>if(!String.IsNullOrEmpty(blah))
{
...code goes here
}
</code></pre>
<p>however I'm a little confused about how to do this in VB.net.</p>
<pre><code>if Not String.IsNullOrEmpty(blah) then
...code goes here
end if
</code></pre>
<p>Does the above statement mean if the string is not null or empty? Is the <code>Not</code> keyword operate like the C#'s <code>!</code> operator?</p>
|
[
{
"answer_id": 279224,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 3,
"selected": false,
"text": "Not ! Boolean Is If Not x Is Nothing Then ' … '\n' is the same as '\nIf x IsNot Nothing Then ' … '\n if (x != null) // or, rather, to be precise:\nif (object.ReferenceEquals(x, null))\n IsNot TypeOf"
},
{
"answer_id": 279309,
"author": "HTTP 410",
"author_id": 13118,
"author_profile": "https://Stackoverflow.com/users/13118",
"pm_score": 4,
"selected": false,
"text": "Not ! Not ! ~ useThis &= ~doNotUse; useThis = useThis And (Not doNotUse)"
},
{
"answer_id": 17426646,
"author": "Tihomir Tashev",
"author_id": 2412393,
"author_profile": "https://Stackoverflow.com/users/2412393",
"pm_score": 0,
"selected": false,
"text": " boolean example2 = !example1;\n dim example2 as boolean = Not example1\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28647/"
] |
279,220
|
<p>I've written a web service using ASP.NET (in C#) and I'm attempting to write an example PHP client using NuSOAP. Where I'm tripped up on are examples of how to do this; some show <code>soapval</code> being used (and I don't quite understand the parameters - for example passing <code>false</code> as <code>string</code> types, etc.), while others are just using straight <code>array</code>s. Let's say the WSDL for my web service as reported by <code>http://localhost:3333/Service.asmx?wsdl</code> looks something like:</p>
<pre><code>POST /Service.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/webservices/DoSomething"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<DoSomething xmlns="http://tempuri.org/webservices">
<anId>int</anId>
<action>string</action>
<parameters>
<Param>
<Value>string</Value>
<Name>string</Name>
</Param>
<Param>
<Value>string</Value>
<Name>string</Name>
</Param>
</parameters>
</DoSomething>
</soap:Body>
</soap:Envelope>
</code></pre>
<p>My first PHP attempt looks like:</p>
<pre><code><?php
require_once('lib/nusoap.php');
$client = new nusoap_client('http://localhost:3333/Service.asmx?wsdl');
$params = array(
'anId' => 3, //new soapval('anId', 'int', 3),
'action' => 'OMNOMNOMNOM',
'parameters' => array(
'firstName' => 'Scott',
'lastName' => 'Smith'
)
);
$result = $client->call('DoSomething', $params, 'http://tempuri.org/webservices/DoSomething', 'http://tempuri.org/webservices/DoSomething');
print_r($result);
?>
</code></pre>
<p>Now aside from the Param type being a complex type which I'm pretty sure my simple <code>$array</code> attempt will not automagically work with, I'm breakpointing in my web service and seeing the method I've marked as <code>WebMethod</code> (without renaming it, its literally <code>DoSomething</code>) and seeing the arguments are all default values (the <code>int</code> is <code>0</code>, the <code>string</code> is <code>null</code>, etc.).</p>
<p>What should my PHP syntax look like, and what do I have to do to pass the <code>Param</code> type correctly?</p>
|
[
{
"answer_id": 279407,
"author": "John Lemp",
"author_id": 12915,
"author_profile": "https://Stackoverflow.com/users/12915",
"pm_score": 4,
"selected": true,
"text": "<?php\nrequire_once('lib/nusoap.php');\n$client = new nusoap_client('http://localhost:3333/Service.asmx?wsdl');\n\n$params = array(\n 'anId' => 3,\n 'action' => 'OMNOMNOMNOM',\n 'parameters' => array(\n 'Param' => array(\n array('Name' => 'firstName', 'Value' => 'Scott'),\n array('Name' => 'lastName', 'Value' => 'Smith')\n )\n )\n);\n$result = $client->call('DoSomething', array($params), \n 'http://tempuri.org/webservices/DoSomething', \n 'http://tempuri.org/webservices/DoSomething');\nprint_r($result);\n?>\n"
},
{
"answer_id": 3352053,
"author": "Vladislav",
"author_id": 155687,
"author_profile": "https://Stackoverflow.com/users/155687",
"pm_score": 1,
"selected": false,
"text": " // Create a new soap client based on the service's metadata (WSDL)\n $client = new SoapClient(\"http://some.wsdl\",\n array('location' => 'http://127.0.0.100:80/IntegrationService/php'));\n\n $params = array();\n $params['lead']['Firstname'] = $user->firstname;\n $params['lead']['Lastname'] = $user->lastname;\n $params['lead']['Product'] = $product;\n $params['lead']['JobTitle'] = $user->job_title;\n $params['lead']['Email'] = $user->mail;\n $params['lead']['Phone'] = $user->phone;\n $params['lead']['CompanyName'] = $user->company_name;\n $params['lead']['City'] = $user->city;\n $params['lead']['Industry'] = $user->industry;\n\n $client->SubmitLead($params);\n <endpoint\n address=\"php\"\n binding=\"basicHttpBinding\"\n contract=\"Integration.Service.IDrupalIntegrationService\" />\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279220",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5645/"
] |
279,221
|
<p>I have a VB6 picture box that gets an image from a video capture device.</p>
<p>I'm trying to figure out how to then convert the picture box to a byte array.</p>
|
[
{
"answer_id": 279231,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 2,
"selected": false,
"text": "PropertyBag"
},
{
"answer_id": 281986,
"author": "Keith Maurino",
"author_id": 1096640,
"author_profile": "https://Stackoverflow.com/users/1096640",
"pm_score": 4,
"selected": true,
"text": "Private Type BITMAP\n bmType As Long\n bmWidth As Long\n bmHeight As Long\n bmWidthBytes As Long\n bmPlanes As Integer\n bmBitsPixel As Integer\n bmBits As Long\nEnd Type\n\nPrivate Declare Function GetObject Lib \"gdi32\" Alias \"GetObjectA\" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long\nPrivate Declare Function GetBitmapBits Lib \"gdi32\" (ByVal hBitmap As Long, ByVal dwCount As Long, lpBits As Any) As Long\n\nPrivate Sub GetPictureBytes()\n Dim PicBits() As Byte, PicInfo As BITMAP\n\n GetObject Picture1.Picture, Len(PicInfo), PicInfo\n\n ReDim PicBits((PicInfo.bmWidth * PicInfo.bmHeight * 3) - 1) As Byte\n\n GetBitmapBits Picture1.Picture, UBound(PicBits), PicBits(0)\nEnd Sub\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1096640/"
] |
279,236
|
<p>I'm attempting to resize pngs with transparent backgrounds in PHP and the code samples I've found online don't work for me. Here's the code I'm using, advice will be much appreciated!</p>
<pre><code>$this->image = imagecreatefrompng($filename);
imagesavealpha($this->image, true);
$newImage = imagecreatetruecolor($width, $height);
// Make a new transparent image and turn off alpha blending to keep the alpha channel
$background = imagecolorallocatealpha($newImage, 255, 255, 255, 127);
imagecolortransparent($newImage, $background);
imagealphablending($newImage, false);
imagesavealpha($newImage, true);
imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $newImage;
imagepng($this->image,$filename);
</code></pre>
<p><br />
<strong>Update</strong>
By 'not working' I meant to say the background color changes to black when I resize pngs.</p>
|
[
{
"answer_id": 279310,
"author": "Dycey",
"author_id": 35961,
"author_profile": "https://Stackoverflow.com/users/35961",
"pm_score": 7,
"selected": true,
"text": "false true <?php\n/**\n * https://stackoverflow.com/a/279310/470749\n * \n * @param resource $image\n * @param int $newWidth\n * @param int $newHeight\n * @return resource\n */\npublic function getImageResized($image, int $newWidth, int $newHeight) {\n $newImg = imagecreatetruecolor($newWidth, $newHeight);\n imagealphablending($newImg, false);\n imagesavealpha($newImg, true);\n $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);\n imagefilledrectangle($newImg, 0, 0, $newWidth, $newHeight, $transparent);\n $src_w = imagesx($image);\n $src_h = imagesy($image);\n imagecopyresampled($newImg, $image, 0, 0, 0, 0, $newWidth, $newHeight, $src_w, $src_h);\n return $newImg;\n}\n?>\n"
},
{
"answer_id": 1655575,
"author": "sbeam",
"author_id": 125875,
"author_profile": "https://Stackoverflow.com/users/125875",
"pm_score": 2,
"selected": false,
"text": " /**\n * usually when people use PNGs, it's because they need alpha channel \n * support (that means transparency kids). So here we jump through some \n * hoops to create a big transparent rectangle which the resampled image \n * will be copied on top of. This will prevent GD from using its default \n * background, which is black, and almost never correct. Why GD doesn't do \n * this automatically, is a good question.\n *\n * @param $w int width of target image\n * @param $h int height of target image\n * @return void\n * @private\n */\n function _preallocate_transparency($w, $h) {\n if (!empty($this->filetype) && !empty($this->new_img) && $this->filetype == 'image/png')) {\n if (function_exists('imagecolorallocatealpha')) {\n imagealphablending($this->new_img, false);\n imagesavealpha($this->new_img, true);\n $transparent = imagecolorallocatealpha($this->new_img, 255, 255, 255, 127);\n imagefilledrectangle($this->new_img, 0, 0, $tw, $th, $transparent);\n }\n }\n }\n"
},
{
"answer_id": 16194977,
"author": "Alexandr",
"author_id": 1693950,
"author_profile": "https://Stackoverflow.com/users/1693950",
"pm_score": 2,
"selected": false,
"text": " <?php\n$img_id = 153;\n\n$source = \"images/\".$img_id.\".png\";\n$source = imagecreatefrompng($source);\n$o_w = imagesx($source);\n$o_h = imagesy($source);\n\n$w = 200;\n$h = 200;\n\n$newImg = imagecreatetruecolor($w, $h);\nimagealphablending($newImg, false);\nimagesavealpha($newImg,true);\n$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);\nimagefilledrectangle($newImg, 0, 0, $w, $h, $transparent);\nimagecopyresampled($newImg, $source, 0, 0, 0, 0, $w, $h, $o_w, $o_h);\n\nimagepng($newImg, $img_id.\".png\");\n\n?>\n<img src=\"<?php echo $img_id.\".png\" ?>\" />\n"
},
{
"answer_id": 17427005,
"author": "Don Vaidoso",
"author_id": 2541603,
"author_profile": "https://Stackoverflow.com/users/2541603",
"pm_score": 1,
"selected": false,
"text": " header('Content-Type: image/png');\n\n$filename = \"url to some image\";\n\n$newWidth = 300;\n$newHeight = 300;\n\n$imageInfo = getimagesize($filename);\n\n$image = imagecreatefrompng($filename); //create source image resource\nimagesavealpha($image, true); //saving transparency\n\n$newImg = imagecreatetruecolor($newWidth, $newHeight); //creating conteiner for new image\nimagealphablending($newImg, false);\nimagesavealpha($newImg,true);\n$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127); //seting transparent background\nimagefilledrectangle($newImg, 0, 0, $newWidth, $newHeight, $transparent);\nimagecopyresampled($newImg, $image, 0, 0, 0, 0, $newWidth, $newHeight, $imageInfo[0], $imageInfo[1]);\n\nimagepng($newImg); //printout image string\n"
},
{
"answer_id": 18110532,
"author": "Michael",
"author_id": 1998322,
"author_profile": "https://Stackoverflow.com/users/1998322",
"pm_score": 4,
"selected": false,
"text": "function resizePng($im, $dst_width, $dst_height) {\n $width = imagesx($im);\n $height = imagesy($im);\n\n $newImg = imagecreatetruecolor($dst_width, $dst_height);\n\n imagealphablending($newImg, false);\n imagesavealpha($newImg, true);\n $transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);\n imagefilledrectangle($newImg, 0, 0, $width, $height, $transparent);\n imagecopyresampled($newImg, $im, 0, 0, 0, 0, $dst_width, $dst_height, $width, $height);\n\n return $newImg;\n}\n"
},
{
"answer_id": 29981457,
"author": "Capsule",
"author_id": 181206,
"author_profile": "https://Stackoverflow.com/users/181206",
"pm_score": 2,
"selected": false,
"text": "$image_p = imagecreatetruecolor(480, 270);\nimageAlphaBlending($image_p, false);\nimageSaveAlpha($image_p, true);\n$image = imagecreatefrompng('image_with_some_transaprency.png');\nimagecopyresampled($image_p, $image, 0, 0, 0, 0, 480, 270, 1920, 1080);\nimagepng($image_p, 'resized.png', 0);\n"
},
{
"answer_id": 39268493,
"author": "Kaushal Sachan",
"author_id": 2924492,
"author_profile": "https://Stackoverflow.com/users/2924492",
"pm_score": 2,
"selected": false,
"text": "list($width, $height) = getimagesize($filepath);\n$new_width = \"300\";\n$new_height = \"100\";\n\nif($width>$new_width && $height>$new_height)\n{\n $image_p = imagecreatetruecolor($new_width, $new_height);\n imagealphablending($image_p, false);\n imagesavealpha($image_p, true);\n $image = imagecreatefrompng($filepath);\n imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);\n imagepng($image_p,$filepath,5);\n}\n"
},
{
"answer_id": 39285060,
"author": "arc_shiva",
"author_id": 4583072,
"author_profile": "https://Stackoverflow.com/users/4583072",
"pm_score": 0,
"selected": false,
"text": "// upload directory\n$upload_dir = \"../uploads/\";\n// valid image formats\n$valid_formats = array(\"jpg\", \"jpeg\", \"png\");\n// maximum image size 1 mb\n$max_size = 1048576;\n// crop image width, height\n$nw = $nh = 800;\n$nw1 = $nh1 = 400;\n$nw3 = $nh3 = 200;\n$nw2 = $nh2 = 100;\n// checks that if upload_dir a directory/not\nif (is_dir($upload_dir) && is_writeable($upload_dir)) {\n // not empty file\n if (!empty($_FILES['image'])) {\n // assign file name \n $name = $_FILES['image']['name'];\n // $_FILES to execute all files within a loop\n if ($_FILES['image']['error'] == 4) {\n $message = \"Empty FIle\";\n }\n if ($_FILES['image']['error'] == 0) {\n if ($_FILES['image']['size'] > $max_size) {\n echo \"E-Image is too large!<br>\";\n $_SESSION['alert'] = \"Image is too large!!\";\n } else if (!in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats)) {\n $_SESSION['alert'] = \"This image is not a valid image format!!\";\n echo \"E-This image is not a valid image format<br>\";\n } else if (file_exists($upload_dir . $name)) {\n $_SESSION['alert'] = \"Image already exists!!\";\n echo \"E-Image already exists<br>\";\n } else { // No error found! Move uploaded files \n $size = getimagesize($_FILES['image']['tmp_name']);\n $x = (int) $_POST['x'];\n $y = (int) $_POST['y'];\n $w = (int) $_POST['w'] ? $_POST['w'] : $size[0];\n $h = (int) $_POST['h'] ? $_POST['h'] : $size[1];\n // path for big image\n $big_image_path = $upload_dir . \"big/\" . $name;\n // medium image path\n $medium_image_path = $upload_dir . \"medium/\" . $name;\n // small image path\n $small_image_path = $upload_dir . \"small/\" . $name;\n // check permission\n if (!is_dir($upload_dir . \"big/\") && !is_writeable($upload_dir . \"big/\")) {\n mkdir($upload_dir . \"big/\", 0777, false);\n }\n if (!is_dir($upload_dir . \"medium/\") && !is_writeable($upload_dir . \"medium/\")) {\n mkdir($upload_dir . \"medium/\", 0777, false);\n }\n if (!is_dir($upload_dir . \"small/\") && !is_writeable($upload_dir . \"small/\")) {\n mkdir($upload_dir . \"small/\", 0777, false);\n }\n // image raw data from form\n $data = file_get_contents($_FILES[\"image\"][\"tmp_name\"]);\n // create image\n $vImg = imagecreatefromstring($data);\n //create big image\n $dstImg = imagecreatetruecolor($nw, $nh);\n imagealphablending($dstImg, false);\n $trans_colour = imagecolorallocatealpha($dstImg, 0, 0, 0, 127);\n imagefilledrectangle($dstImg, 0, 0, $w, $h, $trans_colour);\n imagesavealpha($dstImg, true);\n imagecopyresampled($dstImg, $vImg, 0, 0, $x, $y, $nw, $nh, $w, $h);\n imagepng($dstImg, $big_image_path);\n //create medium thumb\n $dstImg1 = imagecreatetruecolor($nw1, $nh1);\n imagealphablending($dstImg1, false);\n $trans_colour1 = imagecolorallocatealpha($dstImg1, 0, 0, 0, 127);\n imagefilledrectangle($dstImg1, 0, 0, $w, $h, $trans_colour1);\n imagesavealpha($dstImg1, true);\n imagecopyresampled($dstImg1, $vImg, 0, 0, $x, $y, $nw1, $nh1, $w, $h);\n imagepng($dstImg1, $medium_image_path);\n // create smallest thumb\n $dstImg2 = imagecreatetruecolor($nw2, $nh2);\n imagealphablending($dstImg2, false);\n $trans_colour2 = imagecolorallocatealpha($dstImg2, 0, 0, 0, 127);\n imagefilledrectangle($dstImg2, 0, 0, $w, $h, $trans_colour2);\n imagesavealpha($dstImg2, true);\n imagecopyresampled($dstImg2, $vImg, 0, 0, $x, $y, $nw2, $nh2, $w, $h);\n imagepng($dstImg2, $small_image_path);\n /*\n * Database insertion\n */\n $sql = \"INSERT INTO tbl_inksand_product_gallery (\"\n . \"Product_Id,Gallery_Image_Big,Gallery_Image_Medium,Gallery_Image_Thumb,\"\n . \"Gallery_Status,Created_By,Created_Datetime\"\n . \") VALUES (\"\n . \"'{$Product_Id}','{$big_image_path}','{$medium_image_path}','{$small_image_path}',\"\n . \"'A','$Created_By','{$time}'\"\n . \")\";\n db_query($sql);\n if (db_affected_rows() == 1) {\n if (imagedestroy($dstImg)) {\n $_SESSION['success'] = \"Image uploaded successfully.\";\n echo \"S-Image uploaded successfully<br>\";\n } else {\n $_SESSION['alert'] = \"Image not uploaded!!\";\n echo \"S-Image not uploaded\";\n }\n } else {\n $_SESSION['alert'] = \"Error in uploading image!!\";\n echo \"E-Error in uploading image!!\";\n }\n }\n }\n }\n} else {\n mkdir($upload_dir, 0777);\n}\n"
},
{
"answer_id": 55342443,
"author": "hkiame",
"author_id": 6449441,
"author_profile": "https://Stackoverflow.com/users/6449441",
"pm_score": 3,
"selected": false,
"text": "$this->image = imagecreatefrompng($filename);\n$scaled = imagescale($this->image, $width);\nimagealphablending($scaled, false);\nimagesavealpha($scaled, true);\nimagepng($scaled, $filename);\n"
},
{
"answer_id": 69269919,
"author": "Lukas Schramm",
"author_id": 14625729,
"author_profile": "https://Stackoverflow.com/users/14625729",
"pm_score": 1,
"selected": false,
"text": "$image = imagescale($image, 720, -1, IMG_BICUBIC);\nimagepng($image);\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/956/"
] |
279,237
|
<p>How do I import a Python module given its relative path?</p>
<p>For example, if <code>dirFoo</code> contains <code>Foo.py</code> and <code>dirBar</code>, and <code>dirBar</code> contains <code>Bar.py</code>, how do I import <code>Bar.py</code> into <code>Foo.py</code>?</p>
<p>Here's a visual representation:</p>
<pre><code>dirFoo\
Foo.py
dirBar\
Bar.py
</code></pre>
<p><code>Foo</code> wishes to include <code>Bar</code>, but restructuring the folder hierarchy is not an option.</p>
|
[
{
"answer_id": 279253,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 8,
"selected": false,
"text": "__init__.py"
},
{
"answer_id": 279287,
"author": "bouvard",
"author_id": 24608,
"author_profile": "https://Stackoverflow.com/users/24608",
"pm_score": 6,
"selected": false,
"text": "src\\\n __init__.py\n main.py\n dirFoo\\\n __init__.py\n Foo.py\n dirBar\\\n __init__.py\n Bar.py\n import dirFoo.Foo\n from dirFoo.Foo import FooObject\n src site_packages __init__.py __init__.py"
},
{
"answer_id": 279338,
"author": "Andrew Cox",
"author_id": 27907,
"author_profile": "https://Stackoverflow.com/users/27907",
"pm_score": 8,
"selected": false,
"text": "import sys\nsys.path.insert(0, <path to dirFoo>)\nimport Bar\n"
},
{
"answer_id": 279389,
"author": "Peter Crabtree",
"author_id": 36283,
"author_profile": "https://Stackoverflow.com/users/36283",
"pm_score": 5,
"selected": false,
"text": "from ..dirBar import Bar\n"
},
{
"answer_id": 282778,
"author": "monkut",
"author_id": 24718,
"author_profile": "https://Stackoverflow.com/users/24718",
"pm_score": 6,
"selected": false,
"text": "# mod_name is the filename without the .py/.pyc extention\npy_mod = imp.load_source(mod_name,filename_path) # Loads .py file\npy_mod = imp.load_compiled(mod_name,filename_path) # Loads .pyc file \n imp.find_module(name[, path])\nimp.load_module(name, file, pathname, description)\n"
},
{
"answer_id": 2352563,
"author": "Josh",
"author_id": 283248,
"author_profile": "https://Stackoverflow.com/users/283248",
"pm_score": 3,
"selected": false,
"text": "dirFoo\\\n Foo.py\n dirBar\\\n __init__.py\n Bar.py\n import sys\nsys.path.append('dirBar')\nimport Bar\n"
},
{
"answer_id": 3714805,
"author": "jhana",
"author_id": 448012,
"author_profile": "https://Stackoverflow.com/users/448012",
"pm_score": 4,
"selected": false,
"text": "from dirBar.Bar import *\n"
},
{
"answer_id": 4284378,
"author": "lefakir",
"author_id": 199499,
"author_profile": "https://Stackoverflow.com/users/199499",
"pm_score": 7,
"selected": false,
"text": "import os\nimport sys\nlib_path = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'lib'))\nsys.path.append(lib_path)\n\nimport mymodule\n"
},
{
"answer_id": 4397291,
"author": "Deepak 'Kaseriya' ",
"author_id": 536273,
"author_profile": "https://Stackoverflow.com/users/536273",
"pm_score": 7,
"selected": false,
"text": "lib/abc.py\n __init__.py\n from lib.abc import <Your Module name>\n __init__.py"
},
{
"answer_id": 6098238,
"author": "sorin",
"author_id": 99834,
"author_profile": "https://Stackoverflow.com/users/99834",
"pm_score": 9,
"selected": true,
"text": "__init__.py import os, sys, inspect\n # realpath() will make your script run, even if you symlink it :)\n cmd_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile( inspect.currentframe() ))[0]))\n if cmd_folder not in sys.path:\n sys.path.insert(0, cmd_folder)\n\n # Use this if you want to include modules from a subfolder\n cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile( inspect.currentframe() ))[0],\"subfolder\")))\n if cmd_subfolder not in sys.path:\n sys.path.insert(0, cmd_subfolder)\n\n # Info:\n # cmd_folder = os.path.dirname(os.path.abspath(__file__)) # DO NOT USE __file__ !!!\n # __file__ fails if the script is called in different ways on Windows.\n # __file__ fails if someone does os.chdir() before.\n # sys.argv[0] also fails, because it doesn't not always contains the path.\n egg"
},
{
"answer_id": 7262716,
"author": "jgomo3",
"author_id": 344501,
"author_profile": "https://Stackoverflow.com/users/344501",
"pm_score": 4,
"selected": false,
"text": "from .dirBar import Bar\n from dirBar import Bar\n"
},
{
"answer_id": 7520383,
"author": "SuperFamousGuy",
"author_id": 823849,
"author_profile": "https://Stackoverflow.com/users/823849",
"pm_score": -1,
"selected": false,
"text": "import os, sys\nfrom subprocess import Popen, PIPE\ntry:\n path = Popen(\"find / -name 'file' -type f\", shell=True, stdout=PIPE).stdout.read().splitlines()[0]\n if not sys.path.__contains__(path):\n sys.path.append(path)\nexcept IndexError:\n raise RuntimeError(\"You must have FILE to run this program!\")\n"
},
{
"answer_id": 9037651,
"author": "Justin Muller",
"author_id": 961981,
"author_profile": "https://Stackoverflow.com/users/961981",
"pm_score": 1,
"selected": false,
"text": "#to import from one level above:\ncwd = os.getcwd()\nos.chdir(\"..\")\nbelow_path = os.getcwd()\nsys.path.append(below_path)\nos.chdir(cwd)\n"
},
{
"answer_id": 13963800,
"author": "Brent Bradburn",
"author_id": 86967,
"author_profile": "https://Stackoverflow.com/users/86967",
"pm_score": 4,
"selected": false,
"text": "ln -s (path)/module_name.py\n ln -s (path)/package_name\n __init__.py import"
},
{
"answer_id": 14803823,
"author": "James Gan",
"author_id": 389255,
"author_profile": "https://Stackoverflow.com/users/389255",
"pm_score": 5,
"selected": false,
"text": "export PYTHONPATH=/absolute/path/to/your/module\n print sys.path\n\n['', '/absolute/path/to/your/module', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']\n"
},
{
"answer_id": 25010192,
"author": "Der_Meister",
"author_id": 991267,
"author_profile": "https://Stackoverflow.com/users/991267",
"pm_score": 2,
"selected": false,
"text": "# /lib/my_module.py\n# /src/test.py\n\n\nif __name__ == '__main__' and __package__ is None:\n sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../lib')))\nimport my_module\n"
},
{
"answer_id": 26639332,
"author": "Al Conrad",
"author_id": 3457624,
"author_profile": "https://Stackoverflow.com/users/3457624",
"pm_score": 4,
"selected": false,
"text": "dirFoo\\\n __init__.py\n Foo.py\n dirBar\\\n __init__.py\n Bar.py\n from .dirBar import Bar\n from . import dirBar\n"
},
{
"answer_id": 29401990,
"author": "Avenida Gez",
"author_id": 2338481,
"author_profile": "https://Stackoverflow.com/users/2338481",
"pm_score": 2,
"selected": false,
"text": "D:/Books/MyBooks.py D:/Books/includes import sys,site\nsite.addsitedir(sys.path[0] + '\\\\includes')\nprint (sys.path) # Just verify it is there\nimport oldies\n print('done') oldies.py sys.path path[0] path[0] PYTHONPATH"
},
{
"answer_id": 38808859,
"author": "Niklas R",
"author_id": 791713,
"author_profile": "https://Stackoverflow.com/users/791713",
"pm_score": 2,
"selected": false,
"text": "Foo.py import require\nBar = require('./dirBar/Bar')\n"
},
{
"answer_id": 47204573,
"author": "Findon Fassbender",
"author_id": 6924739,
"author_profile": "https://Stackoverflow.com/users/6924739",
"pm_score": 0,
"selected": false,
"text": "project\\\n module_1.py \n module_2.py\n module_1.py func_1() from module_1 import func_1\n\ndef func_2():\n func_1()\n\nif __name__ == '__main__':\n func_2()\n python module_2.py func_1() from .module_1 import func_1 module_2.py No module named '__main__.module_1'; '__main__' is not a package module_2.py project\\\n package_1\\\n module_1.py\n module_2.py\n main.py\n from package_1.module_2 import func_2\n\ndef func_3():\n func_2()\n\nif __name__ == '__main__':\n func_3()\n . module_1 module_2.py main.py No module named 'module_1' module_1.py module_2.py func_1() module_1.py def func_1():\n print(__name__)\n __name__ . module_1 main.py package_1.module_1 module_1 func_1() main.py . module_1 module_2.py main.py module_1 package_1 config.ini project\\\n package_1\\\n module_1.py\n module_2.py\n config.py\n config.ini\n main.py\n module_2.py import ..config\n pass\n main.py ValueError:attempted relative import beyond top-level package main.py config.py main.py config.py main.py main.py main.py project\\\n package_1\\\n module_1.py\n module_2.py\n config.py\n config.ini\nmain.py\n"
},
{
"answer_id": 48468292,
"author": "0x1996",
"author_id": 9176105,
"author_profile": "https://Stackoverflow.com/users/9176105",
"pm_score": 2,
"selected": false,
"text": "from Desktop.filename import something test.py Users/user/Desktop from Desktop.test import *\n __init__.py"
},
{
"answer_id": 51527103,
"author": "californium",
"author_id": 9974017,
"author_profile": "https://Stackoverflow.com/users/9974017",
"pm_score": -1,
"selected": false,
"text": "sys with open(\"C:/yourpath/foobar.py\") as f:\n eval(f.read())\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1388/"
] |
279,240
|
<p>I know that CSS can be used to control the presentation of (X)HTML in modern browsers. I was under the impression that this was possible for arbitrary XML as well. (Am I mistaken?)</p>
<p><strong>A concrete example</strong>: given the following XML</p>
<pre><code><log>
<entry revision="1">
<author>J Random Hacker</author>
<message>Some pithy explanation</message>
</entry>
</log>
</code></pre>
<p>I'd like to associate a CSS with this XML such that when viewed in a modern (WebKit, FireFox) browser, I see something like:</p>
<pre><code>+----------------------------------+
| revision | 1 |
+----------------------------------+
| author | J Random Hacker |
+----------------------------------+
| message | Some pithy explanation|
+----------------------------------+
</code></pre>
<p>Where my oh-so-beautiful ascii-art is meant to indicate some table-like layout.</p>
<p>That is: XML+CSS --> "pixels for user" instead of XML+XSLT --> XHTML+CSS --> "pixels for user".</p>
<p>My hope is that this approach could be simpler way (for me) to present XML documents that are already document-like in their structure. I'm also just plain curious.</p>
|
[
{
"answer_id": 279260,
"author": "Vincent Ramdhanie",
"author_id": 27439,
"author_profile": "https://Stackoverflow.com/users/27439",
"pm_score": 1,
"selected": false,
"text": "author{\n display:block;\n color:#888888;\n}\n"
},
{
"answer_id": 279267,
"author": "Daan",
"author_id": 7922,
"author_profile": "https://Stackoverflow.com/users/7922",
"pm_score": 2,
"selected": false,
"text": "entry {\n display: block;\n}\nauthor {\n display: inline;\n font-weight: bold;\n}\n...\n <?xml-stylesheet href=\"common.css\" type=\"text/css\"?>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33412/"
] |
279,269
|
<p>If I have data in the following format</p>
<pre><code> id subid text
1 1 Hello
1 2 World
1 3 !
2 1 B
2 2 B
2 3 Q
</code></pre>
<p>And would like it in this format:</p>
<pre><code> id fold
1 HelloWorld!
2 BBQ
</code></pre>
<p>How could I accomplish it in T-SQL?</p>
|
[
{
"answer_id": 279274,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 2,
"selected": false,
"text": "--initial data table\ncreate table #tmp (\n id int,\n subid int,\n txt varchar(256)\n)\n\n--populate with sample data from original question\ninsert into #tmp (id,subid,txt) values (1, 1, 'Hello')\ninsert into #tmp (id,subid,txt) values (1, 2, 'World')\ninsert into #tmp (id,subid,txt) values (1, 3, '!')\ninsert into #tmp (id,subid,txt) values (2, 1, 'B')\ninsert into #tmp (id,subid,txt) values (2, 2, 'B')\ninsert into #tmp (id,subid,txt) values (2, 3, 'Q')\n\n--temp table for grouping results\ncreate table #tmpgrp (\n id int,\n txt varchar(4000)\n)\n\n--cursor for looping through data\ndeclare cur cursor local for\n select id, subid, txt from #tmp order by id, subid\n\ndeclare @id int\ndeclare @subid int\ndeclare @txt varchar(256)\n\ndeclare @curid int\ndeclare @curtxt varchar(4000)\n\n\nopen cur\n\nfetch next from cur into @id, @subid, @txt\n\nset @curid = @id\nset @curtxt = ''\n\nwhile @@FETCH_STATUS = 0 begin\n if @curid <> @id begin\n insert into #tmpgrp (id,txt) values (@curid,@curtxt)\n set @curid = @id\n set @curtxt = ''\n end\n set @curtxt = @curtxt + isnull(@txt,'')\n fetch next from cur into @id, @subid, @txt\nend\n\ninsert into #tmpgrp (id,txt) values (@curid,@curtxt)\n\nclose cur\n\ndeallocate cur\n\n--show output\nselect * from #tmpgrp\n\n--drop temp tables\ndrop table #tmp\ndrop table #tmpgrp\n"
},
{
"answer_id": 279311,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 0,
"selected": false,
"text": "DECLARE @returnValue varchar(4000)\n\nSELECT @returnValue = ISNULL(@returnValue + ', ' + myTable.text, myTable.text)\nFROM myTable \n\nRETURN @returnValue\n"
},
{
"answer_id": 4590453,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "declare @tmp table (id int, subid int,txt varchar(256) ) \n--populate with sample data from original question \ninsert into @tmp (id,subid,txt) values (1, 1, 'Hello') \ninsert into @tmp (id,subid,txt) values (1, 2, 'World') \ninsert into @tmp (id,subid,txt) values (1, 3, '!') \ninsert into @tmp (id,subid,txt) values (2, 1, 'B') \ninsert into @tmp (id,subid,txt) values (2, 2, 'B') \ninsert into @tmp (id,subid,txt) values (2, 3, 'Q') \n Select id, fold = (Select cast(txt as varchar(100)) from @tmp t2 where t1.id = t2.id for xml path(''))\nfrom @tmp t1\ngroup by t1.id\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8435/"
] |
279,270
|
<p>Which style of Ruby string quoting do you favour? Up until now I've always used <code>'single quotes'</code> unless the string contains certain escape sequences or interpolation, in which case I obviously have to use <code>"double quotes"</code>.</p>
<p>However, is there really any reason not to just use double quoted strings everywhere?</p>
|
[
{
"answer_id": 280113,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "mystring.gsub( /(fo+)bar/, '\\1baz' )\nmystring.gsub( /(fo+)bar/, \"\\\\1baz\" )"
},
{
"answer_id": 282567,
"author": "Myrddin Emrys",
"author_id": 9084,
"author_profile": "https://Stackoverflow.com/users/9084",
"pm_score": 5,
"selected": false,
"text": "<<END\nFor strings containing multiple newlines, \nparticularly when the string is going to\nbe output to the screen (and thus formatting\nmatters), I use heredocs.\nEND\n\n%q[Because I strongly dislike backslash quoting when unnecessary, I use %Q or %q\nfor strings containing ' or \" characters (usually with square braces, because they\nhappen to be the easiest to type and least likely to appear in the text inside).]\n\n\"For strings needing interpretation, I use %s.\"%['double quotes']\n\n'For the most common case, needing none of the above, I use single quotes.'\n"
},
{
"answer_id": 52701555,
"author": "Bhojendra Rauniyar",
"author_id": 2138752,
"author_profile": "https://Stackoverflow.com/users/2138752",
"pm_score": 1,
"selected": false,
"text": "\"Welcome #{@user.name} to App!\" \n 'Welcome #{@user.name} to App!'\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279270",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1450/"
] |
279,282
|
<p>Let's say I do something in Java like:</p>
<pre>
<code>
RemoteResponse response = null;
try {
FutureTask task new FutureTask(....);
executor.execute(task);
response = task.get(1000, TimeUnits.MILLISECONDS);
}
catch( TimeoutException te ) {
<b>
.. should I do something special here? ...
.. what happens to the return value of the task if task.get() throws an exception? ...
.. is it ever garbage collected? ..
</b>
}
</code>
</pre>
<p>My question is does something hold onto RemoteResponse in the case where TimeoutException is thrown? Will it get garbage collected? Do I have to call the cancel() method on the task for that to happen?</p>
|
[
{
"answer_id": 279321,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 3,
"selected": true,
"text": "response RemoteResponse task response task task close release task task get"
},
{
"answer_id": 1433218,
"author": "Nathan Feger",
"author_id": 8563,
"author_profile": "https://Stackoverflow.com/users/8563",
"pm_score": 1,
"selected": false,
"text": "Resource res = null;\ntry {\n resource = ResourceAquirer.claim()\n\n FutureTask<?> task = new FutureTask<?>(resource);\n executor.execute(task); \n response = task.get(1000, TimeUnits.MILLISECONDS);\n} catch (Exception e) {\n // logging\n} finally {\n if (resource != null) {\n resource.release();\n }\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3095/"
] |
279,293
|
<p>We are repurposing an application server running WebSphere 6.0.2.23. I would like to rename the various application server to better reflect its new role. </p>
<p>How can you rename an application server? </p>
<p>It seems like wsadmin can do it, but I'm struggling with the object hierarchy.</p>
|
[
{
"answer_id": 2681177,
"author": "ndarkduck",
"author_id": 322055,
"author_profile": "https://Stackoverflow.com/users/322055",
"pm_score": 2,
"selected": false,
"text": "/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/ws_ant.sh \\\n-profileName AppSrv01 \\\n-buildfile exportImport.xml \\\n-logfile rename.log \\\n-DoldServerName=server1 \\\n-DnewServerName=server2 \\\n-DnodeName=yourNode01 changeServerName\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16484/"
] |
279,296
|
<p>Given a date how can I add a number of days to it, but exclude weekends. For example, given 11/12/2008 (Wednesday) and adding five will result in 11/19/2008 (Wednesday) rather than 11/17/2008 (Monday).</p>
<p>I can think of a simple solution like looping through each day to add and checking to see if it is a weekend, but I'd like to see if there is something more elegant. I'd also be interested in any F# solution.</p>
|
[
{
"answer_id": 279316,
"author": "gnud",
"author_id": 27204,
"author_profile": "https://Stackoverflow.com/users/27204",
"pm_score": -1,
"selected": false,
"text": "W + N % 5.\n D + ((N / 5) * 7) + N % 5).\n"
},
{
"answer_id": 279357,
"author": "LeppyR64",
"author_id": 16592,
"author_profile": "https://Stackoverflow.com/users/16592",
"pm_score": 3,
"selected": false,
"text": "public DateTime AddBusinessDays(DateTime dt, int nDays)\n{\n int weeks = nDays / 5;\n nDays %= 5;\n while(dt.DayOfWeek == DayOfWeek.Saturday || dt.DayOfWeek == DayOfWeek.Sunday)\n dt = dt.AddDays(1);\n\n while (nDays-- > 0)\n {\n dt = dt.AddDays(1);\n if (dt.DayOfWeek == DayOfWeek.Saturday)\n dt = dt.AddDays(2);\n }\n return dt.AddDays(weeks*7);\n}\n"
},
{
"answer_id": 279370,
"author": "Paul Sonier",
"author_id": 28053,
"author_profile": "https://Stackoverflow.com/users/28053",
"pm_score": 3,
"selected": false,
"text": "int daysToAdd = weekDaysToAdd + ((weekDaysToAdd / 5) * 2) + (((origDate.DOW + (weekDaysToAdd % 5)) >= 5) ? 2 : 0);\n"
},
{
"answer_id": 1378992,
"author": "Simon",
"author_id": 53158,
"author_profile": "https://Stackoverflow.com/users/53158",
"pm_score": 6,
"selected": true,
"text": "var dateTime = DateTime.Now.AddBusinessDays(4);\n"
},
{
"answer_id": 18080665,
"author": "Arjen",
"author_id": 2623042,
"author_profile": "https://Stackoverflow.com/users/2623042",
"pm_score": 2,
"selected": false,
"text": "namespace Extensions.DateTime\n{\n public static class BusinessDays\n {\n public static System.DateTime AddBusinessDays(this System.DateTime source, int businessDays)\n {\n var dayOfWeek = businessDays < 0\n ? ((int)source.DayOfWeek - 12) % 7\n : ((int)source.DayOfWeek + 6) % 7;\n\n switch (dayOfWeek)\n {\n case 6:\n businessDays--;\n break;\n case -6:\n businessDays++;\n break;\n }\n\n return source.AddDays(businessDays + ((businessDays + dayOfWeek) / 5) * 2);\n }\n }\n}\n using System;\nusing System.Windows.Forms;\nusing Extensions.DateTime;\n\nnamespace AddBusinessDaysTest\n{\n public partial class Form1 : Form\n {\n public Form1()\n {\n InitializeComponent();\n label1.Text = DateTime.Now.AddBusinessDays(5).ToString();\n label2.Text = DateTime.Now.AddBusinessDays(-36).ToString();\n }\n }\n}\n"
},
{
"answer_id": 21756584,
"author": "ElmerMiller",
"author_id": 3306370,
"author_profile": "https://Stackoverflow.com/users/3306370",
"pm_score": 0,
"selected": false,
"text": "TSQL CREATE FUNCTION[dbo].[AddBusinessDays](@Date date,@n INT)RETURNS DATE AS BEGIN \nDECLARE @d INT;SET @d=4-SIGN(@n)*(4-DATEPART(DW,@Date));\nRETURN DATEADD(D,@n+((ABS(@n)+@d-2)/5)*2*SIGN(@n)-@d/7,@Date)END\n"
},
{
"answer_id": 37748024,
"author": "tocqueville",
"author_id": 2983749,
"author_profile": "https://Stackoverflow.com/users/2983749",
"pm_score": 3,
"selected": false,
"text": "public static DateTime AddWorkingDays(this DateTime date, int daysToAdd)\n{\n while (daysToAdd > 0)\n {\n date = date.AddDays(1);\n\n if (date.DayOfWeek != DayOfWeek.Saturday && date.DayOfWeek != DayOfWeek.Sunday)\n {\n daysToAdd -= 1;\n }\n }\n\n return date;\n}\n"
},
{
"answer_id": 37811257,
"author": "Ogglas",
"author_id": 3850405,
"author_profile": "https://Stackoverflow.com/users/3850405",
"pm_score": 3,
"selected": false,
"text": "var dateTime = DateTime.Now.AddBusinessDays(5);\n namespace ExtensionMethods\n{\n public static class MyExtensionMethods\n {\n public static DateTime AddBusinessDays(this DateTime current, int days)\n {\n var sign = Math.Sign(days);\n var unsignedDays = Math.Abs(days);\n for (var i = 0; i < unsignedDays; i++)\n {\n do\n {\n current = current.AddDays(sign);\n } while (current.DayOfWeek == DayOfWeek.Saturday ||\n current.DayOfWeek == DayOfWeek.Sunday);\n }\n return current;\n }\n }\n}\n"
},
{
"answer_id": 50439288,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "namespace FSharpBasics\n\nmodule BusinessDays =\n\n open System;\n\n let private weekLength = 5\n\n (*operation*)\n let addBusinessDays (numberOfBusinessDays: int) (startDate: DateTime) =\n let startWeekDay = startDate.DayOfWeek\n let sign = Math.Sign(numberOfBusinessDays) \n let weekendSlide, businessDaysSlide = \n match startWeekDay with\n | DayOfWeek.Saturday when sign > 0 -> (2, -1)\n | DayOfWeek.Saturday when sign < 0 -> (-1, 1) \n | DayOfWeek.Sunday when sign > 0 -> (1, -1)\n | DayOfWeek.Sunday when sign < 0 -> (-2, 1)\n | _ -> (0, 0)\n let baseStartDate = startDate.AddDays (float weekendSlide) \n let days = Math.Abs (numberOfBusinessDays + businessDaysSlide) % weekLength\n let weeks = Math.Abs (numberOfBusinessDays + businessDaysSlide) / weekLength\n let baseWeekDay = int baseStartDate.DayOfWeek\n let oneMoreWeekend =\n if sign = 1 && days + baseWeekDay > 5 || sign = -1 && days >= baseWeekDay then 2\n else 0\n let totalDays = (weeks * 7) + days + oneMoreWeekend\n baseStartDate.AddDays (float totalDays)\n\n [<EntryPoint>]\n let main argv =\n let now = DateTime.Now \n printfn \"Now is %A\" now\n printfn \"13 business days from now would be %A\" (addBusinessDays 13 now)\n System.Console.ReadLine() |> ignore\n 0 \n"
},
{
"answer_id": 57144578,
"author": "Mark Worrall",
"author_id": 355122,
"author_profile": "https://Stackoverflow.com/users/355122",
"pm_score": 0,
"selected": false,
"text": " public DateTime? CalculateSLADueDate(DateTime slaStartDateUTC, double slaDays)\n {\n if (slaDays < 0)\n {\n return null;\n }\n\n var dayCount = slaDays;\n var dueDate = slaStartDateUTC;\n\n var blPublicHoliday = new PublicHoliday();\n IList<BusObj.PublicHoliday> publicHolidays = blPublicHoliday.SelectAll();\n\n do\n {\n dueDate = dueDate.AddDays(1);\n\n if ((dueDate.DayOfWeek != DayOfWeek.Saturday)\n && (dueDate.DayOfWeek != DayOfWeek.Sunday)\n && !publicHolidays.Any(x => x.HolidayDate == dueDate.Date))\n {\n dayCount--;\n }\n }\n while (dayCount > 0);\n\n return dueDate;\n }\n"
},
{
"answer_id": 66324991,
"author": "Joerg",
"author_id": 15263283,
"author_profile": "https://Stackoverflow.com/users/15263283",
"pm_score": 0,
"selected": false,
"text": "enter code public static DateTime AddWorkDays(DateTime dt,int daysToAdd)\n {\n int temp = daysToAdd;\n DateTime endDateOri = dt.AddDays(daysToAdd);\n while (temp !=0)\n {\n if ((dt.AddDays(temp).DayOfWeek == DayOfWeek.Saturday)|| (dt.AddDays(temp).DayOfWeek == DayOfWeek.Sunday))\n {\n daysToAdd++;\n temp--;\n }\n else\n {\n temp--;\n }\n }\n while (endDateOri.AddDays(temp) != dt.AddDays(daysToAdd))\n {\n if ((dt.AddDays(temp).DayOfWeek == DayOfWeek.Saturday) || (dt.AddDays(temp).DayOfWeek == DayOfWeek.Sunday))\n {\n daysToAdd++;\n }\n temp++;\n }\n // final enddate check\n if (dt.AddDays(daysToAdd).DayOfWeek == DayOfWeek.Saturday)\n {\n daysToAdd = daysToAdd + 2;\n }\n else if (dt.AddDays(daysToAdd).DayOfWeek == DayOfWeek.Sunday)\n {\n daysToAdd++;\n }\n return dt.AddDays(daysToAdd);\n }\n"
},
{
"answer_id": 68661458,
"author": "Dominiq",
"author_id": 16598045,
"author_profile": "https://Stackoverflow.com/users/16598045",
"pm_score": 0,
"selected": false,
"text": "DateTime oDate2 = DateTime.Now;\n\nint days = 8;\n\nfor(int i = 1; i <= days; i++)\n{\n if (oDate.DayOfWeek == DayOfWeek.Saturday) \n {\n oDate = oDate.AddDays(2);\n }\n if (oDate.DayOfWeek == DayOfWeek.Sunday) \n {\n oDate = oDate.AddDays(1);\n }\n oDate = oDate.AddDays(1);\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45/"
] |
279,306
|
<p>Ok. I'm having an issue with the following bit of code:</p>
<pre><code>StreamReader arrComputer = new StreamReader(FileDialog.FileName);
</code></pre>
<p>My first question had been answered already now my second question focuses on the tail end of this code.</p>
<p>I'm reading a text file <code>StreamReader</code> that the user selects with a button event using <code>OpenFileDialog</code> </p>
<pre><code>private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.InitialDirectory = @"C:\";
fileDialog.Filter = "Text|*.txt|All|*.*";
if (fileDialog.ShowDialog() == DialogResult.OK) ;
textBox1.Text = fileDialog.FileName;
buttonRun.Enabled = true;
}
</code></pre>
<p>The later in the code the user will click a "Run" button to execute some code against each item in the list.</p>
<p>I'm having problems using StreamReader to parse the list using the following code:</p>
<pre><code>private void buttonRun_Click(object sender, EventArgs e)
{
StreamReader arrComputer = new StreamReader(FileDialog.FileName);
}
</code></pre>
<p>This is the error I receive from my coding:</p>
<pre><code>"An object reference is required for the non-static field, method, or property 'System.Windows.Forms.FileDialog.FileName.get' "
</code></pre>
<p>I think I understand the problem but I'm having a hard time working it out.</p>
|
[
{
"answer_id": 279314,
"author": "dnord",
"author_id": 3248,
"author_profile": "https://Stackoverflow.com/users/3248",
"pm_score": 0,
"selected": false,
"text": "FileDialog"
},
{
"answer_id": 279322,
"author": "shahkalpesh",
"author_id": 23574,
"author_profile": "https://Stackoverflow.com/users/23574",
"pm_score": 2,
"selected": false,
"text": " StreamReader arrComputer = new StreamReader(textBox1.Text);\n"
},
{
"answer_id": 279325,
"author": "Dylan Beattie",
"author_id": 5017,
"author_profile": "https://Stackoverflow.com/users/5017",
"pm_score": 1,
"selected": false,
"text": "private void buttonRun_Click(object sender, EventArgs e) {\n StreamReader arrComputer = new StreamReader(textBox1.Text);\n}\n"
},
{
"answer_id": 279328,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 2,
"selected": false,
"text": "FileDialog FileName fileDialog.FileName fileDialog button1_Click textBox1.Text StreamReader arrComputer = new StreamReader(textBox1.Text); \n"
},
{
"answer_id": 279332,
"author": "hectorsq",
"author_id": 14755,
"author_profile": "https://Stackoverflow.com/users/14755",
"pm_score": 0,
"selected": false,
"text": "button1_Click fileDialog buttonRun_Click FileDialog fileDialog FileDialog"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35760/"
] |
279,324
|
<p>Im trying to find a best practice to load usercontrols using Ajax.</p>
<p>My first approach where simply using an UpdatePanel and popuplating it with LoadControl() on ajax postbacks but this would rerender other loaded usercontrols in the same UpdatePanel. Also I cannot have a predefined set of UpdatePanels since the number of UserControls I need to load will vary.</p>
<p>Is there any best practice for this type of scenario?</p>
<p>If needed I could implement a framework or some type of custom controls if that would be a solution but I would love to do this with ASP.NET 3.5 and the AjaxControlToolkit if possible.</p>
|
[
{
"answer_id": 279486,
"author": "Morten Bergfall",
"author_id": 447694,
"author_profile": "https://Stackoverflow.com/users/447694",
"pm_score": 4,
"selected": true,
"text": "$('#SomeContainer').Load(\"default.aspx?What=GimmeSomeSweetAjax\");\n if(Request.QueryString[\"What\"]==GimmeSomeSweetAjax)\n{\n Page page = new Page();\n Control control = (Control)LoadControl(\"~/.../someUC.ascx\");\n StringWriter sw = new StringWriter();\n page.Controls.Add(control);\n Server.Execute(page, sw, false);\n Response.Write(sw.ToString());\n Response.Flush();\n Response.Close();\n}\n"
},
{
"answer_id": 13636651,
"author": "Parham",
"author_id": 1170355,
"author_profile": "https://Stackoverflow.com/users/1170355",
"pm_score": 1,
"selected": false,
"text": " var page = new Page();\n var sw = new StringWriter();\n var control = (UserControl)page.LoadControl(\"~/.../someUC.ascx\");\n\n var type = control.GetType();\n type.GetProperty(\"Prop1\").SetValue(control, value, null);\n page.Controls.Add(control);\n\n context.Server.Execute(page, sw, false);\n context.Response.ContentType = \"text/html\";\n context.Response.Write(sw.ToString());\n context.Response.Flush();\n context.Response.Close();\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19264/"
] |
279,326
|
<p>I'm working on a simple little function to download a file from an SSL-enabled website using the WinInet functions, namely InternetOpen and InternetOpenURL. I had was initially failing the call to InternetOpenURL with a <code>ERROR_INTERNET_INVALID_CA</code> (12045) because I was using a self-signed certificate on my test server, and found out (<a href="http://support.microsoft.com/kb/q182888/" rel="nofollow noreferrer">http://support.microsoft.com/kb/q182888/</a>) that the fix seemed to be to use the InternetQueryOption/InternetSetOption combination to pass various flags to <code>INTERNET_OPTION_SECURITY_FLAGS</code> option. Now, however, InternetQueryOption fails with a <code>ERROR_INTERNET_INCORRECT_HANDLE</code> (12018) response from GetLastError(). Any ideas why this would be the case? I'm using the handle that came directly from InternetOpen, which previously worked fine with a non-SSL InternetOpenURL. Shouldn't this be the correct handle?</p>
<p>I don't have the actual code (different computer), but it is very similar to the following, and fails on InternetGetOption with <code>ERROR_INTERNET_INCORRECT_HANDLE</code>:</p>
<pre><code> HINTERNET hReq = InternetOpen(...)
if (!hReq) { printf("InternetOpen Error: %d", GetLastError()); }
DWORD dwFlags = 0;
DWORD dwBuffLen = sizeof(dwFlags);
BOOL ret = false;
ret = InternetQueryOption(hReq, INTERNET_OPTION_SECURITY_FLAGS,
(LPVOID)&dwFlags, &dwBuffLen);
if (!ret) { printf("InternetQueryOption Error: %d", GetLastError()); }
dwFlags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
ret = InternetSetOption(hReq, INTERNET_OPTION_SECURITY_FLAGS,
&dwFlags, sizeof (dwFlags) );
if (!ret) { printf("InternetSetOption Error: %d", GetLastError()); }
InternetOpenURL(hReq, ...)
</code></pre>
|
[
{
"answer_id": 279419,
"author": "bdumitriu",
"author_id": 35415,
"author_profile": "https://Stackoverflow.com/users/35415",
"pm_score": 0,
"selected": false,
"text": "hReq InternetOpen InternetOpen if (hReq == NULL) {\n printf(\"InternetOpen Error: %d\", GetLastError());\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
279,329
|
<p>What's the quickest way to convert a date in one format, say </p>
<blockquote>
<p>2008-06-01</p>
</blockquote>
<p>to a date in another format, say </p>
<blockquote>
<p>Sun 1st June 2008</p>
</blockquote>
<p>The important bit is actually the 'Sun' because depending on the dayname, I may need to fiddle other things around - in a non-deterministic fashion. I'm running GNU bash, version <code>3.2.17(1)-release (i386-apple-darwin9.0)</code>.</p>
<p>[Background: The reason that I want to do it from the command line, is that what I really want is to write it into a TextMate command... It's an annoying task I have to do all the time in textMate.]</p>
|
[
{
"answer_id": 279340,
"author": "bdumitriu",
"author_id": 35415,
"author_profile": "https://Stackoverflow.com/users/35415",
"pm_score": 0,
"selected": false,
"text": "date -d yyyy-mm-dd\n date -d yyyy-mm-dd +%a\n"
},
{
"answer_id": 279352,
"author": "Brian L",
"author_id": 25848,
"author_profile": "https://Stackoverflow.com/users/25848",
"pm_score": 4,
"selected": true,
"text": "$ date -d '2005-06-30' +'%a %F'\nThu 2005-06-30\n man date date -j -f \"%Y-%m-%d\" 2006-06-30 +\"%a %F\"\n"
},
{
"answer_id": 279367,
"author": "Dycey",
"author_id": 35961,
"author_profile": "https://Stackoverflow.com/users/35961",
"pm_score": 0,
"selected": false,
"text": "date -d ... \n usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... \n [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]\n -d dst Set the kernel's value for daylight saving time. If dst is non-\n zero, future calls to gettimeofday(2) will return a non-zero for\n tz_dsttime.\n"
},
{
"answer_id": 279420,
"author": "Dycey",
"author_id": 35961,
"author_profile": "https://Stackoverflow.com/users/35961",
"pm_score": 1,
"selected": false,
"text": "date -j -f \"%Y-%m-%d\" \"2008-01-03\" +\"%a%e %b %Y\"\n ^ ^ ^\n parse using | output using\n this format | this format\n |\n date expressed in\n parsing format\n\nThu 3 Jan 2008\n"
},
{
"answer_id": 279462,
"author": "brian d foy",
"author_id": 2766176,
"author_profile": "https://Stackoverflow.com/users/2766176",
"pm_score": 0,
"selected": false,
"text": "%u $ date -j -f \"%Y-%m-%d\" \"2008-01-03\" +\"%u\"\n 4\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35961/"
] |
279,359
|
<p>I have this Array i wrote a function MostFreq that takes an array of integers and return 2 values : the more frequent number in the array and its frequency check this code i worte what do you think ? is there a better way to do it?</p>
<pre><code>static void Main()
{
int [] M={4,5,6,4,4,3,5,3};
int x;
int f=MyMath.MostFreq(M,out x );
console.WriteLine("the most Frequent Item = {0} with frequency = {1}",x,f);
}
</code></pre>
<p>=====</p>
<p>in the class Mymath</p>
<pre><code>public static int MostFreq(int[] _M, out int x)
{
//First I need to sort the array in ascending order
int Max_Freq, No_Freq, i, k;
Array.Sort(_M);
k = _M[0];
Max_Freq = 0; i = 0; x = 0;
while (i < _M.Length)
{
//No_Freq= the frequency of the current number
No_Freq = 0;
//X here is the number which is appear in the array Frequently
while (k == _M[i])
{
No_Freq++;
i++;
if (i == _M.Length)
break;
}
if (No_Freq > Max_Freq)
{
//so it will be printed the same
Max_Freq = No_Freq;
x = k;
}
if (i < _M.Length) k = _M[i];
}
return (Max_Freq);
}
</code></pre>
|
[
{
"answer_id": 279394,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 4,
"selected": true,
"text": "Dim i = From Numbers In ints _\n Group Numbers By Numbers Into Group _\n Aggregate feq In Group Into Count() _\n Select New With {.Number = Numbers, .Count = Count}\n var i = from numbers in M\n group numbers by numbers into grouped\n select new { Number = grouped.Key, Freq = grouped.Count()};\n"
},
{
"answer_id": 11483111,
"author": "wally",
"author_id": 1525445,
"author_profile": "https://Stackoverflow.com/users/1525445",
"pm_score": -1,
"selected": false,
"text": "int count = 1;\nint currentIndex = 0;\nfor (int i = 1; i < A.Length; i++)\n{\n if (A[i] == A[currentIndex])\n count++;\n else\n count--;\n if (count == 0)\n {\n currentIndex = i;\n count = 1;\n }\n}\n\nint mostFreq = A[currentIndex];\n"
},
{
"answer_id": 42591887,
"author": "AJIT AGARWAL",
"author_id": 3559818,
"author_profile": "https://Stackoverflow.com/users/3559818",
"pm_score": 0,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace MostFrequentElement\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] array = new int[] { 4, 1, 1, 4, 2, 3, 4, 4, 1, 2, 4, 9, 3, 1, 1, 7, 7, 7, 7, 7 };\n Array.Sort(array, (a, b) => a.CompareTo(b));\n int counter = 1;\n int temp=0 ;\n\n List<int> LOCE = new List<int>();\n foreach (int i in array)\n {\n counter = 1;\n foreach (int j in array)\n\n{\n if (array[j] == array[i])\n {\n counter++;\n }\n else {\n counter=1;\n }\n if (counter == temp)\n {\n LOCE.Add(array[i]);\n }\n if (counter > temp)\n {\n LOCE.Clear();\n LOCE.Add(array[i]);\n temp = counter;\n\n }\n }\n\n }\n foreach (var element in LOCE)\n {\n Console.Write(element + \",\");\n }\n Console.WriteLine();\n Console.WriteLine(\"(\" + temp + \" times)\");\n Console.Read();\n }\n }\n}\n"
},
{
"answer_id": 43887289,
"author": "Pazzo",
"author_id": 7956105,
"author_profile": "https://Stackoverflow.com/users/7956105",
"pm_score": 0,
"selected": false,
"text": "public class MostFrequentNumber\n{\n public static void Main()\n {\n int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();\n\n int counter = 0;\n int longestOccurance = 0;\n int mostFrequentNumber = 0;\n\n for (int i = 0; i < numbers.Length; i++)\n {\n counter = 0;\n\n for (int j = 0; j < numbers.Length; j++)\n {\n if (numbers[j] == numbers[i])\n {\n counter++;\n }\n }\n\n if (counter > longestOccurance)\n {\n longestOccurance = counter;\n mostFrequentNumber = numbers[i];\n }\n }\n\n Console.WriteLine(mostFrequentNumber);\n //Console.WriteLine($\"occured {longestOccurance} times\");\n }\n}\n"
},
{
"answer_id": 50585966,
"author": "AnthonyLambert",
"author_id": 31762,
"author_profile": "https://Stackoverflow.com/users/31762",
"pm_score": 1,
"selected": false,
"text": "public class PopularNumber\n {\n private Int32[] numbers = {5, 4, 3, 32, 6, 6, 3, 3, 2, 2, 31, 1, 32, 4, 3, 4, 5, 6};\n\n public PopularNumber()\n {\n Dictionary<Int32,Int32> bucket = new Dictionary<Int32,Int32>();\n Int32 maxInt = Int32.MinValue;\n Int32 maxCount = 0;\n Int32 count;\n\n foreach (var i in numbers)\n {\n if (bucket.TryGetValue(i, out count))\n {\n count++;\n bucket[i] = count;\n }\n else\n {\n count = 1;\n bucket.Add(i,count);\n }\n\n if (count >= maxCount)\n {\n maxInt = i;\n maxCount = count;\n }\n\n }\n\n Console.WriteLine(\"{0},{1}\",maxCount, maxInt);\n\n }\n }\n"
},
{
"answer_id": 62741671,
"author": "Ashish Jain",
"author_id": 11721366,
"author_profile": "https://Stackoverflow.com/users/11721366",
"pm_score": 0,
"selected": false,
"text": "int arr[] = {10, 20, 10, 20, 30, 20, 20,40,40,50,15,15,15};\n\nint max = 0;\nint result = 0;\nMap<Integer,Integer> map = new HashMap<>();\n\nfor (int i = 0; i < arr.length; i++) {\n if (map.containsKey(arr[i])) \n map.put(arr[i], map.get(arr[i]) + 1);\n else\n map.put(arr[i], 1);\n int key = map.keySet().iterator().next();\n if (map.get(key) > max) {\n max = map.get(key) ;\n result = key;\n }\n}\nSystem.out.println(result);\n"
},
{
"answer_id": 67182973,
"author": "BorisSh",
"author_id": 7505977,
"author_profile": "https://Stackoverflow.com/users/7505977",
"pm_score": 0,
"selected": false,
"text": "int[] arr = { 4, 5, 6, 4, 4, 3, 5, 3 };\nvar gr = arr.GroupBy(x => x).OrderBy(x => x.Count()).Last();\nConsole.WriteLine($\"The most Frequent Item = {gr.Key} with frequency = {gr.Count()}\"); // The most Frequent Item = 4 with frequency = 3\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
279,360
|
<p>I have a windows service that uses log4net. We noticed that the service in question was running painfully slow so we attached a debugger to it and stepped through. It appears that each time it tries to write an entry to the log via log4net that it takes anywhere from 10 to 30 seconds before the next line of code can execute. Obviously this adds up...</p>
<p>The service is 2.0 .net
We're using log4Net 1.2.0.30714.
We've tested this on a machine running vista and a machine running win sever 2003 and have seen the same or similar results.</p>
|
[
{
"answer_id": 281272,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<appender name=\"RollingFileAppender\" type=\"log4net.Appender.RollingFileAppender,log4net\">\n <file value=\"D:\\\\ROPLogFiles\\\\FileProcessor.txt\" />\n <appendToFile value=\"true\" />\n <datePattern value=\"yyyyMMdd\" />\n <rollingStyle value=\"Date\" />\n <layout type=\"log4net.Layout.PatternLayout,log4net\">\n <param name=\"ConversionPattern\" value=\"%d [%t] %-5p %c [%x] - %m%n\" />\n </layout>\n <threshold value=\"INFO\" />\n </appender>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
279,374
|
<p>I had the following line snippet of code that searches for a propery of an instance by name:</p>
<pre><code>var prop = Backend.GetType().GetProperty(fieldName);
</code></pre>
<p>Now I want to ignore the case of fieldName, so I tried the following:</p>
<pre><code>var prop = Backend.GetType().GetProperty(fieldName, BindingFlags.IgnoreCase);
</code></pre>
<p>... No dice. Now prop won't find field names that have the exact case.</p>
<p>Hence.....
How do I use .Net reflection to search for a property by name ignoring case?</p>
|
[
{
"answer_id": 279395,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 5,
"selected": true,
"text": "BindingFlags.Public | BindingFlags.Instance using System;\nusing System.Reflection;\n\npublic class Test\n{\n private int foo;\n\n public int Foo { get { return foo; } }\n\n static void Main()\n {\n var prop = typeof(Test).GetProperty(\"foo\",\n BindingFlags.Public\n | BindingFlags.Instance \n | BindingFlags.IgnoreCase);\n Console.WriteLine(prop);\n }\n}\n"
},
{
"answer_id": 279402,
"author": "Jeffrey Harrington",
"author_id": 4307,
"author_profile": "https://Stackoverflow.com/users/4307",
"pm_score": 2,
"selected": false,
"text": "var prop = Backend.GetType().GetProperty(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2744/"
] |
279,391
|
<p>When developing JavaScript, I tend to separate JavaScript code out into different files and then run a script to concatenate the files and compress or pack the resulting file. In the end, I have one file that I need to include on my production site. </p>
<p>This approach has usually worked, but I've started to run into a problems with prototypal inheritance. Specifically, if one class inherits from another class, the file for the parent class needs to be included already for the inheritance to work. If the concatenation script I'm using is simply concatenating a directory full of files, the child class might occur in the code before the parent class. Like this:</p>
<p><em>parent_class.js</em></p>
<pre><code>var Namespace = Namespace || {};
Namespace.Parent = function () { };
Namespace.Parent.prototype.doStuff = function () { ... };
</code></pre>
<p><em>child_class.js</em></p>
<pre><code>var NameSpace = Namespace || {};
Namespace.Child = function () { ... };
Namespace.Child.prototype = new Namespace.Parent();
</code></pre>
<p>The only way this works is if parent_class.js is included before child_class.js, which might not happen if the concatenation script places the child code before the parent code. </p>
<p>Is there a way to write this code so that the functionality is the same, but the order in which the code is written no longer matters?</p>
<p>Edit: I forgot that I'm using namespaces as well, so I added that to the code as well, which might change things a little bit.</p>
|
[
{
"answer_id": 279476,
"author": "mercutio",
"author_id": 1951,
"author_profile": "https://Stackoverflow.com/users/1951",
"pm_score": 3,
"selected": true,
"text": "01_parent.js\n02_child.js\n"
},
{
"answer_id": 279492,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 0,
"selected": false,
"text": "setTimeout(function() { \n if(typeof(Parent) != \"undefined\" && typeof(Child) != \"undefined\") { \n Child.prototype = new Parent(); \n } else {\n setTimeout(arguments.callee, 50);\n }\n}, 50);\n Parent Child"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22291/"
] |
279,392
|
<p>My SQL table looks like this:</p>
<pre><code>CREATE TABLE Page (
Id int primary key,
ParentId int, -- refers to Page.Id
Title varchar(255),
Content ntext
)
</code></pre>
<p>and maps to the following class in my ActiveRecord model:</p>
<pre><code>[ActiveRecord]
public class Page {
[PrimaryKey]
public int Id { get; set; }
[BelongsTo("Parent")]
public virtual Page Parent { get; set; }
[Property]
public string Title { get; set; }
[Property]
public string Content { get; set; }
[HasMany(typeof(Page), "Parent", "Page")]
public IList<Page> Children { get; set; }
}
</code></pre>
<p>I'm using ActiveRecord to retrieve the tree roots using the following code:</p>
<pre><code>var rootPages = new SimpleQuery<Page>(@"from Page p where p.Parent is null");
return(rootPages.Execute());
</code></pre>
<p>This gives me the correct object graph, but a SQL Profiler trace shows that child pages are being loaded by a separate query for every non-leaf node in the tree.</p>
<p>How can I get ActiveRecord to load the whole lot up front <code>("SELECT * FROM Page")</code> and then sort the in-memory objects to give me the required parent-child relationships?</p>
|
[
{
"answer_id": 290886,
"author": "Neil Hewitt",
"author_id": 22178,
"author_profile": "https://Stackoverflow.com/users/22178",
"pm_score": -1,
"selected": false,
"text": "var rootPages = new SimpleQuery<Page>(@\"from Page p left join fetch p.Children where p.Parent is null\");\nreturn(rootPages.Execute());\n"
},
{
"answer_id": 3349495,
"author": "oillio",
"author_id": 4354,
"author_profile": "https://Stackoverflow.com/users/4354",
"pm_score": 3,
"selected": true,
"text": "var AllPages = ActiveRecordMediator<Page>.FindAll();\nvar rootPages = AllPages.Where(p => p.Parent == null);\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279392",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5017/"
] |
279,398
|
<p>I have created a reference to an IIS hosted WCF service in my ASP.NET website project on my local workstation through the "Add Service Reference" option in Visual Studio 2008. I was able to execute the service from my local workstation.</p>
<p>When I move the ASP.NET web site using the "Copy Web Site" feature in Visual Studio 2008 to the development server and browse to the page consuming the service, I get the following error:</p>
<blockquote>
<p>Reference.svcmap: Specified argument
was out of the range of valid values.</p>
</blockquote>
<p>Has anyone experienced this same error and know how to resolve it?</p>
<p><b>EDIT:</b> My development server is Win2k3 with IIS 6</p>
|
[
{
"answer_id": 284516,
"author": "Michael Kniskern",
"author_id": 26327,
"author_profile": "https://Stackoverflow.com/users/26327",
"pm_score": 2,
"selected": true,
"text": "svcutil /t:code http://<service_url> /out:<file_name>.cs /config:<file_name>.config\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26327/"
] |
279,404
|
<p>I know that in the original C++0x standard there was a feature called <code>export</code>.</p>
<p>But I can't find a description or explanation of this feature. What is it supposed to do? Also: which compiler is supporting it?</p>
|
[
{
"answer_id": 279571,
"author": "Rodyland",
"author_id": 10681,
"author_profile": "https://Stackoverflow.com/users/10681",
"pm_score": 3,
"selected": false,
"text": "export export"
},
{
"answer_id": 3402843,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": true,
"text": "// ORIGINAL version of xyz.h\ntemplate <typename T>\nstruct xyz\n {\n xyz();\n ~xyz();\n };\n // ORIGINAL version of xyz.cpp\n#include \"xyz.h\"\n\ntemplate <typename T>\nxyz<T>::xyz() {}\n\ntemplate <typename T>\nxyz<T>::~xyz() {}\n // main.cpp\n#include \"xyz.h\"\n\nint main()\n {\n xyz<int> xyzint;\n\n return 0;\n }\n C:\\export>como xyz.cpp main.cpp\nC++'ing xyz.cpp...\nComeau C/C++ 4.3.4.1 (May 29 2004 23:08:11) for MS_WINDOWS_x86\nCopyright 1988-2004 Comeau Computing. All rights reserved.\nMODE:non-strict warnings microsoft C++\n\nC++'ing main.cpp...\nComeau C/C++ 4.3.4.1 (May 29 2004 23:08:11) for MS_WINDOWS_x86\nCopyright 1988-2004 Comeau Computing. All rights reserved.\nMODE:non-strict warnings microsoft C++\n\nmain.obj : error LNK2001: unresolved external symbol xyz<T1>::~xyz<int>() [with T1=int]\nmain.obj : error LNK2019: unresolved external symbol xyz<T1>::xyz<int>() [with T1=int] referenced in function _main\naout.exe : fatal error LNK1120: 2 unresolved externals\n xyz xyz<int> template xyz<int>;\n xyz<int> // xyztir.cpp\n#include \"xyz.cpp\" // .cpp file!!!, not .h file!!\n\ntemplate xyz<int>;\n #include \"xyz.cpp\" // xyz.h\n\n// ... previous content of xyz.h ...\n\n#include \"xyz.cpp\"\n // xyz.h\n\nexport\n// ... ORIGINAL contents of xyz.h ...\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35744/"
] |
279,406
|
<p>I have a sequential workflow with a number of Activities. One of these activities needs to access my paid S3 account. It works fine, but to be cautious, I would like to make sure it can handle unexpected situations, such as 'Host not found' or some timeout, etc.</p>
<p>So .. i would normally put the code inside a TRY / CATCH. That's fine .. but i'm not sure of what i should do with the workflow .. because if the code fails to complete correctly, the rest of the workflow shouldn't occur (based on the logic of this workflow).</p>
<p>So, i wanted to maybe retry the connect a few times .. and if that finally fails, call an Email Activity and terminate workflow.</p>
<p>Can anyone make any suggestions, links to vid's or screenies that help show what is the best practice for this?</p>
<p>cheers!</p>
|
[
{
"answer_id": 279612,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 3,
"selected": true,
"text": "FaultHandlerActivity FaultType Activity.HandleFault"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30674/"
] |
279,410
|
<p>Given an object on a plain white background, does anybody know if OpenCV provides functionality to easily detect an object from a captured frame? </p>
<p>I'm trying to locate the corner/center points of an object (rectangle). The way I'm currently doing it, is by brute force (scanning the image for the object) and not accurate. I'm wondering if there is functionality under the hood that i'm not aware of.</p>
<p><strong>Edit Details</strong>:
The size about the same as a small soda can. The camera is positioned above the object, to give it a 2D/Rectangle feel. The orientation/angle from from the camera is random, which is calculated from the corner points.</p>
<p>It's just a white background, with the object on it (black). The quality of the shot is about what you'd expect to see from a Logitech webcam.</p>
<p>Once I get the corner points, I calculate the center. The center point is then converted to centimeters.</p>
<p>It's refining just 'how' I get those 4 corners is what I'm trying to focus on. You can see my brute force method with this image: <a href="https://i.stack.imgur.com/jUV9H.png" rel="nofollow noreferrer">Image</a></p>
|
[
{
"answer_id": 321692,
"author": "Ismael C",
"author_id": 41096,
"author_profile": "https://Stackoverflow.com/users/41096",
"pm_score": 6,
"selected": true,
"text": "0. rectangles <- {}\n1. image <- load image\n2. for every channel:\n2.1 image_canny <- apply canny edge detector to this channel\n2.2 for threshold in bunch_of_increasing_thresholds:\n2.2.1 image_thresholds[threshold] <- apply threshold to this channel\n2.3 for each contour found in {image_canny} U image_thresholds:\n2.3.1 Approximate contour with polygons\n2.3.2 if the approximation has four corners and the angles are close to 90 degrees.\n2.3.2.1 rectangles <- rectangles U {contour}\n"
},
{
"answer_id": 12608954,
"author": "Rod Dockter",
"author_id": 1701318,
"author_profile": "https://Stackoverflow.com/users/1701318",
"pm_score": 3,
"selected": false,
"text": "cv::Point getCentroid(cv::Mat img)\n{\n cv::Point Coord;\n cv::Moments mm = cv::moments(img,false);\n double moment10 = mm.m10;\n double moment01 = mm.m01;\n double moment00 = mm.m00;\n Coord.x = int(moment10 / moment00);\n Coord.y = int(moment01 / moment00);\n return Coord;\n}\n"
},
{
"answer_id": 59959630,
"author": "nathancy",
"author_id": 11162165,
"author_profile": "https://Stackoverflow.com/users/11162165",
"pm_score": 1,
"selected": false,
"text": "findContours boundingRect -> Center: (100, 100)\n Center: (200, 200)\n Center: (300, 300)\n findContours boundingRect x,y,w,h rectangle moments import cv2\nimport numpy as np\n\n# Load image, convert to grayscale, and Otsu's threshold \nimage = cv2.imread('1.png')\ngray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)\nthresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]\n\n# Find contours and extract the bounding rectangle coordintes\n# then find moments to obtain the centroid\ncnts = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)\ncnts = cnts[0] if len(cnts) == 2 else cnts[1]\nfor c in cnts:\n # Obtain bounding box coordinates and draw rectangle\n x,y,w,h = cv2.boundingRect(c)\n cv2.rectangle(image, (x, y), (x + w, y + h), (36,255,12), 2)\n\n # Find center coordinate and draw center point\n M = cv2.moments(c)\n cx = int(M['m10']/M['m00'])\n cy = int(M['m01']/M['m00'])\n cv2.circle(image, (cx, cy), 2, (36,255,12), -1)\n print('Center: ({}, {})'.format(cx,cy))\n\ncv2.imshow('image', image)\ncv2.waitKey()\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/568/"
] |
279,414
|
<p>Been trying to upgrade my subversion installation, but due to (what I believe) are limited rights (I'm using hosted Linux account), I'm not able to properly "./configure" and compile the source code (see posts <a href="https://stackoverflow.com/questions/189906/upgrade-subversion-143-to-152-on-debian-hosted-account">Post1</a> and <a href="https://stackoverflow.com/questions/274656/building-subversion-154-on-debian-could-not-find-library-containing-rsanew">Post2</a> if very interested)</p>
<p>So, I'm thinking if I could just download <strong>pre-compiled binaries</strong>, the just might solve my problems. If you have better ideas - I'd love to hear that too!</p>
<p>NB: I'm not able to call <strong>aptitude</strong> or <strong>apt-get install subversion</strong> as suggested by <a href="http://subversion.tigris.org/getting.html#debian" rel="nofollow noreferrer">subversion.tigris.com</a></p>
<p><strong>I'm also interested in knowing how I would go about installing those pre-compiled binaries :)</strong></p>
|
[
{
"answer_id": 279424,
"author": "Can Berk Güder",
"author_id": 2119,
"author_profile": "https://Stackoverflow.com/users/2119",
"pm_score": 4,
"selected": true,
"text": "dpkg-deb -x"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18274/"
] |
279,421
|
<p>I have an html form that a user will fill out and print. Once printed, these forms will be faxed or mailed to a government agency, and need to look close enough like the original form published by said agency that a government bureaucrat doesn't spot that this is a reproduction. The data entered in the form is not saved anywhere or even submitted back to a web server. All that matters is that our users can easily find these forms on our intranet site and type into the form for printing with their normal keyboard.</p>
<p>On the screen I want to leave the radio button as-is, to enforce and communicate radio button usage (choose only one option). However, when it prints out I need it to print with the square checkbox style rather than the round radio button style. I know how to use a media selector to set styles for print only, so that's not the issue. It's just that I don't know if I can style the radio button like I want at all. </p>
<p>If I can't get this working I'm gonna have to create a checkbox to shadow each radio button, use javascript to keep the checkboxes and radio buttons in sync, and css to show the one I care about in the proper medium. Obviously if I can just style them it would save a lot of work.</p>
|
[
{
"answer_id": 279510,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 5,
"selected": false,
"text": "input[type=radio] {content:url(mycheckbox.png)}\ninput[type=radio]:checked {content:url(mycheckbox-checked.png)}\n <span class=fakecheckbox><input type=radio><img src=\"checkbox.png\" alt=\"\"></span>\n\n@media screen {.fakecheckbox img {display:none}}\n@media print {.fakecheckbox input {display:none;}}\n <img> <img> background-image"
},
{
"answer_id": 8079482,
"author": "Andy E",
"author_id": 94197,
"author_profile": "https://Stackoverflow.com/users/94197",
"pm_score": 7,
"selected": false,
"text": "appearance input[type=\"radio\"] {\n -webkit-appearance: checkbox; /* Chrome, Safari, Opera */\n -moz-appearance: checkbox; /* Firefox */\n -ms-appearance: checkbox; /* not currently supported */\n} <label><input type=\"radio\" name=\"radio\"> Checkbox 1</label>\n<label><input type=\"radio\" name=\"radio\"> Checkbox 2</label>"
},
{
"answer_id": 10533677,
"author": "Vincen77o",
"author_id": 1387042,
"author_profile": "https://Stackoverflow.com/users/1387042",
"pm_score": -1,
"selected": false,
"text": "<style type=\"text/css\" media=\"screen\">\n#ageBox {display: none;}\n</style>\n\n<style type=\"text/css\" media=\"print\">\n#ageButton {display: none;}\n</style>\n\n<tr><td>Age:</td>\n\n<td id=\"ageButton\">\n<input type=\"radio\" name=\"userAge\" value=\"18-24\">18-24\n<input type=\"radio\" name=\"userAge\" value=\"25-34\">25-34\n\n<td id=\"ageBox\">\n<input type=\"checkbox\">18-24\n<input type=\"checkbox\">25-34\n\n</td></tr>\n"
},
{
"answer_id": 19273941,
"author": "user2314737",
"author_id": 2314737,
"author_profile": "https://Stackoverflow.com/users/2314737",
"pm_score": 5,
"selected": false,
"text": "div.options > label > input {\n visibility: hidden;\n}\n\ndiv.options > label {\n display: block;\n margin: 0 0 0 -10px;\n padding: 0 0 20px 0; \n height: 20px;\n width: 150px;\n}\n\ndiv.options > label > img {\n display: inline-block;\n padding: 0px;\n height:30px;\n width:30px;\n background: none;\n}\n\ndiv.options > label > input:checked +img { \n background: url(http://cdn1.iconfinder.com/data/icons/onebit/PNG/onebit_34.png);\n background-repeat: no-repeat;\n background-position:center center;\n background-size:30px 30px;\n} <div class=\"options\">\n <label title=\"item1\">\n <input type=\"radio\" name=\"foo\" value=\"0\" /> \n Item 1\n <img />\n </label>\n <label title=\"item2\">\n <input type=\"radio\" name=\"foo\" value=\"1\" />\n Item 2\n <img />\n </label> \n <label title=\"item3\">\n <input type=\"radio\" name=\"foo\" value=\"2\" />\n Item 3\n <img />\n </label>\n</div>"
},
{
"answer_id": 26069370,
"author": "Beej",
"author_id": 813599,
"author_profile": "https://Stackoverflow.com/users/813599",
"pm_score": 3,
"selected": false,
"text": "div.checkRadioContainer > label > input {\n visibility: hidden;\n}\n\ndiv.checkRadioContainer {\n max-width: 10em;\n}\ndiv.checkRadioContainer > label {\n display: block;\n border: 2px solid grey;\n margin-bottom: -2px;\n cursor: pointer;\n}\n\ndiv.checkRadioContainer > label:hover {\n background-color: AliceBlue;\n}\n\ndiv.checkRadioContainer > label > span {\n display: inline-block;\n vertical-align: top;\n line-height: 2em;\n}\n\ndiv.checkRadioContainer > label > input + i {\n visibility: hidden;\n color: green;\n margin-left: -0.5em;\n margin-right: 0.2em;\n}\n\ndiv.checkRadioContainer > label > input:checked + i {\n visibility: visible;\n} <div class=\"checkRadioContainer\">\n <label>\n <input type=\"radio\" name=\"radioGroup\" />\n <i class=\"fa fa-check fa-2x\"></i>\n <span>Item 1</span>\n </label>\n <label>\n <input type=\"radio\" name=\"radioGroup\" />\n <i class=\"fa fa-check fa-2x\"></i>\n <span>Item 2</span>\n </label>\n <label>\n <input type=\"radio\" name=\"radioGroup\" />\n <i class=\"fa fa-check fa-2x\"></i>\n <span>Item 3</span>\n </label>\n</div>"
},
{
"answer_id": 32707360,
"author": "geek-merlin",
"author_id": 606859,
"author_profile": "https://Stackoverflow.com/users/606859",
"pm_score": 0,
"selected": false,
"text": "input[type=checkbox] {\n display: none;\n}\ninput[type=checkbox] + *:before {\n content: \"\";\n display: inline-block;\n margin: 0 0.4em;\n /* Make some horizontal space. */\n width: .6em;\n height: .6em;\n border-radius: 0.6em;\n box-shadow: 0px 0px 0px .5px #888\n /* An outer circle. */\n ;\n /* No inner circle. */\n background-color: #ddd;\n /* Inner color. */\n}\ninput[type=checkbox]:checked + *:before {\n box-shadow: 0px 0px 0px .5px #888\n /* An outer circle. */\n , inset 0px 0px 0px .14em #ddd;\n /* An inner circle with above inner color.*/\n background-color: #444;\n /* The dot color */\n} <div>\n <input id=\"check1\" type=\"checkbox\" name=\"check\" value=\"check1\" checked>\n <label for=\"check1\">Fake Checkbox1</label>\n</div>\n<div>\n <input id=\"check2\" type=\"checkbox\" name=\"check\" value=\"check2\">\n <label for=\"check2\">Fake Checkbox2</label>\n</div>\n<div>\n <input id=\"check2\" type=\"radio\" name=\"check\" value=\"radio1\" checked>\n <label for=\"check2\">Real Checkbox1</label>\n</div>\n<div>\n <input id=\"check2\" type=\"radio\" name=\"check\" value=\"radio2\">\n <label for=\"check2\">Real Checkbox2</label>\n</div>"
},
{
"answer_id": 37909047,
"author": "Md Rafee",
"author_id": 5998241,
"author_profile": "https://Stackoverflow.com/users/5998241",
"pm_score": 1,
"selected": false,
"text": "input[type=\"radio\"]{\n display: none;\n}\nlabel:before{\n content:url(http://strawberrycambodia.com/book/admin/templates/default/images/icons/16x16/checkbox.gif);\n}\ninput[type=\"radio\"]:checked+label:before{\n content:url(http://www.treatment-abroad.ru/img/admin/icons/16x16/checkbox.gif);\n} \n <input type=\"radio\" name=\"gender\" id=\"test1\" value=\"male\">\n <label for=\"test1\"> check 1</label>\n <input type=\"radio\" name=\"gender\" value=\"female\" id=\"test2\">\n <label for=\"test2\"> check 2</label>\n <input type=\"radio\" name=\"gender\" value=\"other\" id=\"test3\">\n <label for=\"test3\"> check 3</label> "
},
{
"answer_id": 60907846,
"author": "Azimer",
"author_id": 7905692,
"author_profile": "https://Stackoverflow.com/users/7905692",
"pm_score": -1,
"selected": false,
"text": "$fx = ((($w - $this->getAbsFontMeasure($tmpfont['cw'][`110`])) / 2) * $this->k);\n$fy = (($w - ((($tmpfont['desc']['Ascent'] - $tmpfont['desc']['Descent']) * $this->FontSizePt / 1000) / $this->k)) * $this->k);\n$popt['ap']['n'][$onvalue] = sprintf('q %s BT /F%d %F Tf %F %F Td ('.chr(`110`).') Tj ET Q', $this->TextColor, $tmpfont['i'], $this->FontSizePt, $fx, $fy);\n$popt['ap']['n']['Off'] = sprintf('q %s BT /F%d %F Tf %F %F Td ('.chr(`111`).') Tj ET Q', $this->TextColor, $tmpfont['i'], $this->FontSizePt, $fx, $fy);\n $fx = ((($w - $this->getAbsFontMeasure($tmpfont['cw'][`108`])) / 2) * $this->k);\n$fy = (($w - ((($tmpfont['desc']['Ascent'] - $tmpfont['desc']['Descent']) * $this->FontSizePt / 1000) / $this->k)) * $this->k);\n$popt['ap']['n']['Yes'] = sprintf('q %s BT /F%d %F Tf %F %F Td ('.chr(`108`).') Tj ET Q', $this->TextColor, $tmpfont['i'], $this->FontSizePt, $fx, $fy);\n$popt['ap']['n']['Off'] = sprintf('q %s BT /F%d %F Tf %F %F Td ('.chr(`109`).') Tj ET Q', $this->TextColor, $tmpfont['i'], $this->FontSizePt, $fx, $fy);\n"
},
{
"answer_id": 61402574,
"author": "somsgod",
"author_id": 10074522,
"author_profile": "https://Stackoverflow.com/users/10074522",
"pm_score": 2,
"selected": false,
"text": "input[type=radio] {\n -moz-appearance: none;\n -webkit-appearance: none;\n -o-appearance: none;\n outline: none;\n content: none;\n margin-left: 5px;\n}\n\ninput[type=radio]:before {\n font-family: \"FontAwesome\";\n content: \"\\f00c\";\n font-size: 25px;\n color: transparent !important;\n background: #fff;\n width: 25px;\n height: 25px;\n border: 2px solid black;\n margin-right: 5px;\n}\n\ninput[type=radio]:checked:before {\n color: black !important;\n}\n"
},
{
"answer_id": 63500543,
"author": "Muhammad Affan Aijaz",
"author_id": 12819539,
"author_profile": "https://Stackoverflow.com/users/12819539",
"pm_score": 3,
"selected": false,
"text": ".css-prp\n{\n color: #17CBF2;\n font-family: arial;\n}\n\n\n.con1 {\n display: block;\n position: relative;\n padding-left: 25px;\n margin-bottom: 12px;\n cursor: pointer;\n font-size: 15px;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n/* Hide the browser's default radio button */\n.con1 input {\n position: absolute;\n opacity: 0;\n cursor: pointer;\n}\n\n/* Create a custom radio button */\n.checkmark {\n position: absolute;\n top: 0;\n left: 0;\n height: 18px;\n width: 18px;\n background-color: lightgrey;\n border-radius: 10%;\n}\n\n/* When the radio button is checked, add a blue background */\n.con1 input:checked ~ .checkmark {\n background-color: #17CBF2;\n} <label class=\"con1\"><span>Yes</span>\n <input type=\"radio\" name=\"radio1\" checked>\n <span class=\"checkmark\"></span>\n</label>\n<label class=\"con1\"><span>No</span>\n <input type=\"radio\" name=\"radio1\">\n <span class=\"checkmark\"></span>\n</label>"
},
{
"answer_id": 66201076,
"author": "TK421",
"author_id": 2468607,
"author_profile": "https://Stackoverflow.com/users/2468607",
"pm_score": 3,
"selected": false,
"text": "appearance: none; input[type=\"radio\"]{\n appearance: none;\n border: 1px solid #d3d3d3;\n width: 30px;\n height: 30px;\n content: none;\n outline: none;\n margin: 0;\n box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;\n}\n\ninput[type=\"radio\"]:checked {\n appearance: none;\n outline: none;\n padding: 0;\n content: none;\n border: none;\n}\n\ninput[type=\"radio\"]:checked::before{\n position: absolute;\n color: green !important;\n content: \"\\00A0\\2713\\00A0\" !important;\n border: 1px solid #d3d3d3;\n font-weight: bolder;\n font-size: 21px;\n} <input type=\"radio\" name=\"radio\" checked>\n<input type=\"radio\" name=\"radio\">\n<input type=\"radio\" name=\"radio\">"
},
{
"answer_id": 72568775,
"author": "Nicols Martin Rojas Solano",
"author_id": 19310983,
"author_profile": "https://Stackoverflow.com/users/19310983",
"pm_score": 2,
"selected": false,
"text": " label{\n display: block;\n margin-bottom: 10px;\n }\n\ninput[type=radio] {\n appearance: none;\n background-color: #fff;\n width: 15px;\n height: 15px;\n border: 2px solid #ccc;\n border-radius: 2px;\n display: inline-grid;\n place-content: center; \n }\n\ninput[type=radio]::before {\n content: \"\";\n width: 10px;\n height: 10px;\n transform: scale(0);\n transform-origin: bottom left;\n background-color: #fff;\n clip-path: polygon(13% 50%, 34% 66%, 81% 2%, 100% 18%, 39% 100%, 0 71%);\n}\n\ninput[type=radio]:checked::before {\n transform: scale(1);\n}\ninput[type=radio]:checked{\n background-color: #0075FF;\n border: 2px solid #0075FF;\n} <label>\n <input type=\"radio\" name=\"fruit\"> Apple\n</label>\n<label>\n <input type=\"radio\" name=\"fruit\"> Banana\n</label>\n<label>\n <input type=\"radio\" name=\"fruit\"> Orange\n</label>\n<label>\n <input type=\"radio\" name=\"fruit\"> Avocado\n</label>"
},
{
"answer_id": 73233936,
"author": "Sanan Ali",
"author_id": 8049950,
"author_profile": "https://Stackoverflow.com/users/8049950",
"pm_score": 0,
"selected": false,
"text": ".custom-radio[type=\"radio\"]{\n appearance: none;\n border: 1px solid #d3d3d3;\n width: 18px;\n height: 18px;\n content: none;\n outline: none;\n border-radius:100%;\n margin: 0;\n \n}\n\n.custom-radio[type=\"radio\"]:checked {\n appearance: none;\n border-radius:100%;\n outline: none;\n padding: 0;\n content: none;\n border: none;\n}\n\n.custom-radio[type=\"radio\"]:checked::before{\n position: absolute;\n background:#0c1332 ;\n accent-color:blue;\n border-radius:100%;\n color: white !important;\n content: \"\\00A0\\2713\\00A0\" !important;\n border: 1px solid #d3d3d3;\n font-weight: bolder;\n font-size: 13px;\n} <p>Please select your favorite Web language:</p>\n <input type=\"radio\" id=\"html\" class=\"custom-radio\" name=\"fav_language\" value=\"HTML\">\n <label for=\"html\">HTML</label><br>\n <input type=\"radio\" id=\"css\" name=\"fav_language\" class=\"custom-radio\" value=\"CSS\">\n <label for=\"css\">CSS</label><br>\n <input type=\"radio\" id=\"javascript\" name=\"fav_language\" class=\"custom-radio\" value=\"JavaScript\">\n <label for=\"javascript\">JavaScript</label>"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3043/"
] |
279,431
|
<p>I'd like to find a way to do a SQL query that will calculate the cidr (bit representation) of a subnet mask stored in the database. So for example, I've got either 255.255.255.0 or its decimal value (4294967040) stored in the database. I'd like to do a select and get back /24 representation via the query.</p>
<p>I've done things like the following to determine the last IP of a subnet so I'm hoping to do something similar to determine the cidr representation of a mask.</p>
<pre><code>select concat(inet_ntoa(ip_addr),'-',
inet_ntoa(ip_addr+(POWER(2,32)-ip_mask-1))) range
from subnets
order by ip_addr
</code></pre>
<p>Preferably this would be a SQL statement that would work under mysql, postgres, oracle etc.</p>
|
[
{
"answer_id": 282528,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "https://Stackoverflow.com/users/20860",
"pm_score": 2,
"selected": false,
"text": "CREATE TABLE cidr (\n bits INT UNSIGNED PRIMARY KEY,\n mask INT UNSIGNED NOT NULL\n);\n\nINSERT INTO cidr (bits) VALUES\n ( 1), ( 2), ( 3), ( 4), ( 5), ( 6), ( 7), ( 8), ( 9), (10),\n (11), (12), (13), (14), (15), (16), (17), (18), (19), (20),\n (21), (22), (23), (24), (25), (26), (27), (28), (29), (30),\n (31), (32);\n\nUPDATE cidr SET mask = ((POWER(2,32)-1)<<(32-bits)) & (POWER(2,32)-1);\n\nSELECT CONCAT(s.ip_addr, '/', c.bits)\nFROM cidr c JOIN subnets s ON (c.mask = inet_aton(s.ip_mask));\n"
},
{
"answer_id": 401315,
"author": "Matt P",
"author_id": 14230,
"author_profile": "https://Stackoverflow.com/users/14230",
"pm_score": 4,
"selected": true,
"text": "select CONCAT(INET_NTOA(ip_addr),'/',32-log2((4294967296-ip_mask))) net \nfrom subnets \norder by ip_addr\n"
},
{
"answer_id": 20844957,
"author": "Steve",
"author_id": 3147216,
"author_profile": "https://Stackoverflow.com/users/3147216",
"pm_score": 0,
"selected": false,
"text": "--\n-- Dumping routines for database\n--\n/*!50003 DROP FUNCTION IF EXISTS `INET_ATOC` */;\n/*!50003 SET @saved_cs_client = @@character_set_client */ ;\n/*!50003 SET @saved_cs_results = @@character_set_results */ ;\n/*!50003 SET @saved_col_connection = @@collation_connection */ ;\n/*!50003 SET character_set_client = utf8 */ ;\n/*!50003 SET character_set_results = utf8 */ ;\n/*!50003 SET collation_connection = utf8_general_ci */ ;\n/*!50003 SET @saved_sql_mode = @@sql_mode */ ;\n/*!50003 SET sql_mode = 'ALLOW_INVALID_DATES' */ ;\nDELIMITER ;;\nCREATE DEFINER=`root`@`localhost` FUNCTION `INET_ATOC`(`paramNETMASK` varchar(15)) RETURNS int(2) unsigned\n DETERMINISTIC\n COMMENT 'Converts an IPv4 netmask in dotted decimal notation to a CIDR integer between 0 and 32'\nBEGIN\n DECLARE `netmask` int unsigned;\n DECLARE `cidr` int unsigned;\n SET `netmask` = INET_ATON(`paramNETMASK`);\n IF (`netmask` IS NULL)\n THEN\n RETURN NULL;\n ELSE\n SET `cidr` = 0;\n countNetBits: WHILE (`cidr` < 32)\n DO\n IF ( (0x80000000 & `netmask`) = 0x80000000 )\n THEN\n SET `netmask` = 0xFFFFFFFF & (`netmask` << 1);\n SET `cidr` = `cidr` + 1;\n ELSE\n LEAVE countNetBits;\n END IF;\n END WHILE;\n IF (`netmask` != 0)\n THEN\n RETURN NULL;\n END IF;\n RETURN `cidr`;\n END IF;\nEND ;;\nDELIMITER ;\n/*!50003 SET sql_mode = @saved_sql_mode */ ;\n/*!50003 SET character_set_client = @saved_cs_client */ ;\n/*!50003 SET character_set_results = @saved_cs_results */ ;\n/*!50003 SET collation_connection = @saved_col_connection */ ;\n/*!50003 DROP FUNCTION IF EXISTS `INET_CTOA` */;\n/*!50003 SET @saved_cs_client = @@character_set_client */ ;\n/*!50003 SET @saved_cs_results = @@character_set_results */ ;\n/*!50003 SET @saved_col_connection = @@collation_connection */ ;\n/*!50003 SET character_set_client = utf8 */ ;\n/*!50003 SET character_set_results = utf8 */ ;\n/*!50003 SET collation_connection = utf8_general_ci */ ;\n/*!50003 SET @saved_sql_mode = @@sql_mode */ ;\n/*!50003 SET sql_mode = 'ALLOW_INVALID_DATES' */ ;\nDELIMITER ;;\nCREATE DEFINER=`root`@`localhost` FUNCTION `INET_CTOA`(`paramCIDR` int) RETURNS varchar(15) CHARSET utf8\n DETERMINISTIC\n COMMENT 'Converts a CIDR suffix (integer between 0 and 32) to an IPv4 netmask in dotted decimal notation'\nBEGIN\n DECLARE `netmask` int unsigned;\n IF ( (`paramCIDR` < 0) OR (`paramCIDR` > 32) )\n THEN\n RETURN NULL;\n ELSE\n SET `netmask` = 0xFFFFFFFF - (pow( 2, (32-`paramCIDR`) ) - 1);\n RETURN INET_NTOA(`netmask`);\n END IF;\nEND ;;\nDELIMITER ;\n/*!50003 SET sql_mode = @saved_sql_mode */ ;\n/*!50003 SET character_set_client = @saved_cs_client */ ;\n/*!50003 SET character_set_results = @saved_cs_results */ ;\n/*!50003 SET collation_connection = @saved_col_connection */ ;\n/*!50003 DROP PROCEDURE IF EXISTS `getSubnet` */;\n/*!50003 SET @saved_cs_client = @@character_set_client */ ;\n/*!50003 SET @saved_cs_results = @@character_set_results */ ;\n/*!50003 SET @saved_col_connection = @@collation_connection */ ;\n/*!50003 SET character_set_client = utf8 */ ;\n/*!50003 SET character_set_results = utf8 */ ;\n/*!50003 SET collation_connection = utf8_general_ci */ ;\n/*!50003 SET @saved_sql_mode = @@sql_mode */ ;\n/*!50003 SET sql_mode = '' */ ;\nDELIMITER ;;\nCREATE DEFINER=`root`@`localhost` PROCEDURE `getSubnet`(INOUT `paramADDR` VARCHAR(15), INOUT `paramCIDR` INT, OUT `paramMASK` VARCHAR(15), OUT `paramNETWORK` VARCHAR(15), OUT `paramBROADCAST` VARCHAR(15), OUT `paramNUMHOSTS` INT) CHARSET utf8\n DETERMINISTIC\nBEGIN\n DECLARE `numaddrs` int unsigned;\n DECLARE `ipaddr` int unsigned;\n DECLARE `netmask` int unsigned;\n DECLARE `wildcard` int unsigned;\n DECLARE `network` int unsigned;\n DECLARE `broadcast` int unsigned;\n DECLARE `numhosts` int unsigned;\n\n SET `ipaddr` = INET_ATON(`paramADDR`);\n\n IF (`ipaddr` IS NULL) OR (`paramCIDR` < 1) OR (`paramCIDR` > 30)\n THEN\n SELECT\n NULL, NULL, NULL, NULL, NULL, NULL\n INTO\n `paramADDR`, `paramCIDR`, `paramMASK`, `paramNETWORK`, `paramBROADCAST`, `paramNUMHOSTS`;\n ELSE\n SET `numaddrs` = pow( 2, (32-`paramCIDR`) );\n SET `numhosts` = `numaddrs` - 2;\n SET `netmask` = 0xFFFFFFFF - (`numaddrs` - 1);\n SET `wildcard` = 0xFFFFFFFF & (~`netmask`);\n SET `network` = `ipaddr` & `netmask`;\n SET `broadcast` = `ipaddr` | `wildcard`;\n\n SELECT\n INET_NTOA(`ipaddr`), `paramCIDR`, INET_NTOA(`netmask`), INET_NTOA(`network`), INET_NTOA(`broadcast`), `numhosts`\n INTO\n `paramADDR`, `paramCIDR`, `paramMASK`, `paramNETWORK`, `paramBROADCAST`, `paramNUMHOSTS`;\n END IF;\nEND ;;\nDELIMITER ;\n/*!50003 SET sql_mode = @saved_sql_mode */ ;\n/*!50003 SET character_set_client = @saved_cs_client */ ;\n/*!50003 SET character_set_results = @saved_cs_results */ ;\n/*!50003 SET collation_connection = @saved_col_connection */ ;\n/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;\n\n/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;\n/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;\n/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;\n/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n"
},
{
"answer_id": 35433110,
"author": "Michael Kaška",
"author_id": 5935136,
"author_profile": "https://Stackoverflow.com/users/5935136",
"pm_score": 1,
"selected": false,
"text": "255.255.255.252 SELECT 32-length(trim(((split_part('255.255.255.252','.',1)::bigint*(256^3)::bigint +\n split_part('255.255.255.252','.',2)::bigint*(256^2)::bigint +\n split_part('255.255.255.252','.',3)::bigint*256 +\n split_part('255.255.255.252','.',4)::bigint)::bit(32))::text,'1'));\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14230/"
] |
279,434
|
<p>I am opening a process (with os.popen() ) that, for some commands, detects certain keypresses (e.g. ESC - not the character, the key). Is there a way to send keypress events to the process?</p>
|
[
{
"answer_id": 279477,
"author": "Alex Coventry",
"author_id": 1941213,
"author_profile": "https://Stackoverflow.com/users/1941213",
"pm_score": 1,
"selected": false,
"text": "Pexpect subprocess"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35305/"
] |
279,444
|
<p>I'm pulling email address records from a table in SQL Server 2005, and want to build a single string to use as the <code>@recipients</code> list with <code>sp_send_dbmail</code>. The table has a field called EmailAddress and there are 10 records in the table.</p>
<p>I'm doing this:</p>
<pre><code>DECLARE @email VARCHAR(MAX)
SELECT
@email = ISNULL(@email + '; ', '') + EmailAddress
FROM
accounts
</code></pre>
<p>Now @email has a semi-delimited list of 10 email address from the accounts table.</p>
<p>My questions is why/how does this work? Why doesn't @email only have the last email address in the table?</p>
|
[
{
"answer_id": 279467,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 4,
"selected": true,
"text": "@email EmailAddress"
},
{
"answer_id": 279490,
"author": "bdumitriu",
"author_id": 35415,
"author_profile": "https://Stackoverflow.com/users/35415",
"pm_score": 2,
"selected": false,
"text": "a@b.c\nb@b.c\nc@b.c\n @email NULL \"\" + \"a@b.c\" \"a@b.c\" @email \"a@b.c\" + \"; \" + \"b@b.c\" \"a@b.c; b@b.c\" @email \"a@b.c; b@b.c\" + \"; \" + \"c@b.c\" \"a@b.c; b@b.c; c@b.c\""
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6624/"
] |
279,451
|
<p>In Visual Studio website projects (in Visual Studio 2005 or later, not web application projects where there is still a .csproj file) how is the reference information stored, and is it possible to source control it without storing compiled binaries in source control?</p>
<p>If you right-click on a website project and select Property Pages, the first screen (References) lists all the project references.</p>
<p>System.* references are listed as type GAC, and other DLL files can be listed as BIN or Project.</p>
<p>The problem occurs when you include something as a project reference, and then commit it to source control (for us, Subversion, ignoring .dll and .pdb files.)</p>
<p>Another developer gets updated code from the repository and has to manually set up all of these project references, but I can't even determine where this information is stored, unless it's in that .suo, which is NOT source-control friendly.</p>
|
[
{
"answer_id": 279470,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 5,
"selected": true,
"text": "Project(\"{xxxxxxx-7377-xxxx-xxxx-BC803B73C61A}\") = \"XXXXXXX.Web\", \"XXXXXXX.Web\", \"{xxxxxxxx-BB14-xxxx-B3B6-8BF6D8BC5AFF}\"\n ProjectSection(WebsiteProperties) = preProject\n TargetFramework = \"3.5\"\n ProjectReferences = \"{xxxxxxxx-C3AB-xxxx-BBED-2055287036E5}|XXXXXX.Data.dll;\n ...\n"
},
{
"answer_id": 511245,
"author": "Atilla Ozgur",
"author_id": 41782,
"author_profile": "https://Stackoverflow.com/users/41782",
"pm_score": 0,
"selected": false,
"text": "foreach($dll in $dll_files)\n{\n\n copy-item $dll.FullName -destination \"$targetfolder\" -force #-Verbose\n}\n foreach($dll in $dll_files)\n{\n copy-item $dll.FullName -destination \"$targetfolder\" -force #-Verbose\n}\n"
},
{
"answer_id": 952460,
"author": "CodingWithSpike",
"author_id": 28278,
"author_profile": "https://Stackoverflow.com/users/28278",
"pm_score": 4,
"selected": false,
"text": "Project(\"{E24C65DC-7377-472B-9ABA-BC803B73C61A}\") = \"WebSite1\", \"..\\..\\WebSites\\WebSite1\\\", \"{F25DB9D6-810D-4C18-ACBB-BFC420D33B20}\"\nProjectSection(WebsiteProperties) = preProject\nTargetFramework = \"3.5\"\nProjectReferences = \"{11666201-E9E8-4F5A-A7AB-93D90F3AD9DC}|ClassLibrary1.dll;\"\n <compilation debug=\"false\">\n <assemblies>\n <add assembly=\"System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\"/>\n Oracle.DataAccess"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10039/"
] |
279,455
|
<p>On an ASP.NET page, I have a GridView populated with the results of a LINQ query. I'm setting the DataSource in code, then calling DataBind on it. In the GridView's RowDataBound event, I'm selectively hiding links in some GridView fields based on the query results. (For instance, I hide the "Show Parent" link of the row in question has no parent row.)</p>
<p>This works fine initially. But on postback (when I <em>don't</em> call DataBind, but the GridView stays populated through ViewState), the data displays, but the RowDataBound event (obviously) doesn't fire, and my links don't get hidden.</p>
<p>What's the best way to get the links to be hidden after a postback?</p>
|
[
{
"answer_id": 281768,
"author": "sirrocco",
"author_id": 5246,
"author_profile": "https://Stackoverflow.com/users/5246",
"pm_score": 1,
"selected": false,
"text": "Visible='<%#ShowParentLink()%>'\n"
},
{
"answer_id": 285458,
"author": "Ryan Lundy",
"author_id": 5486,
"author_profile": "https://Stackoverflow.com/users/5486",
"pm_score": 3,
"selected": true,
"text": "LinkVisibility LinkVisibility LinkVisibility"
},
{
"answer_id": 515798,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "void Process Rows()\n{\n ... do something\n ... process complete\n datagrid.DataBind();\n}\n"
},
{
"answer_id": 9941291,
"author": "Sachin Amale",
"author_id": 1303026,
"author_profile": "https://Stackoverflow.com/users/1303026",
"pm_score": 0,
"selected": false,
"text": "protected void btnHazardRating_Click(object sender, EventArgs e)\n{\n gvPanelRole.RowDataBound += new GridViewRowEventHandler(gvPanelRole_RowDataBound);\n\n gvPanelRole.DataSource = dtGo;\n gvPanelRole.DataBind();\n ModalPopup.Show();\n\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5486/"
] |
279,469
|
<p>I recently wrote a webservice to be used with Silverlight which uses the ASP.net membership and roles.</p>
<p>To validate the client in the service I look at the HTTPContext.Current.User (Which works when the service is called from Silverlight)</p>
<p>However, I've been trying to call the same service from an asp.net postback. But when I step-thru to the service the HTTPContext.Current has an emplty string for the username.</p>
<p>I'm guessing there is something that I'm not doing in the web.config file which is causing the httpContext to not be sent through the proxy to my service?</p>
<p>Any ideas would be appreciated. I need to be able to validate the client somehow using asp.net membership and roles and have it work from both an asp.net client and a silverlight client.</p>
|
[
{
"answer_id": 282894,
"author": "JSmyth",
"author_id": 54794,
"author_profile": "https://Stackoverflow.com/users/54794",
"pm_score": 2,
"selected": false,
"text": " using (OperationContextScope scope = new OperationContextScope(ws.InnerChannel))\n {\nHttpRequestMessageProperty httpRequest = new HttpRequestMessageProperty();\nOperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, httpRequest);\n\n HttpCookieCollection cc = Page.Request.Cookies;\n if (Request.Cookies[\".ASPXAUTH\"] != null)\n {\n HttpCookie aCookie = Request.Cookies[\".ASPXAUTH\"];\n String authcookieValue = Server.HtmlEncode(aCookie.Value);\n httpRequest.Headers.Add(\"Cookie: \" + \".ASPXAUTH=\" + authcookieValue);\n\n }\n// Webservice call goes here\n }\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/54794/"
] |
279,472
|
<p>I have a form with a lot of controls on it. How can I detect when the mouse leaves the form? I've tried wiring up a MouseLeave event for every single control and the form, but that does not work because those events fire all the time as the mouse passes over controls. Is there a way that actually works.?</p>
|
[
{
"answer_id": 279741,
"author": "Eren Aygunes",
"author_id": 27980,
"author_profile": "https://Stackoverflow.com/users/27980",
"pm_score": 4,
"selected": true,
"text": " protected override void OnControlAdded(ControlEventArgs e)\n {\n SubscribeEvents(e.Control);\n base.OnControlAdded(e);\n }\n\n protected override void OnControlRemoved(ControlEventArgs e)\n {\n UnsubscribeEvents(e.Control);\n base.OnControlRemoved(e);\n }\n\n private void SubscribeEvents(Control control)\n {\n control.MouseLeave += new EventHandler(control_MouseLeave);\n control.ControlAdded += new ControlEventHandler(control_ControlAdded);\n control.ControlRemoved += new ControlEventHandler(control_ControlRemoved);\n\n foreach (Control innerControl in control.Controls)\n {\n SubscribeEvents(innerControl);\n }\n }\n\n private void UnsubscribeEvents(Control control)\n {\n control.MouseLeave -= new EventHandler(control_MouseLeave);\n control.ControlAdded -= new ControlEventHandler(control_ControlAdded);\n control.ControlRemoved -= new ControlEventHandler(control_ControlRemoved);\n\n foreach (Control innerControl in control.Controls)\n {\n UnsubscribeEvents(innerControl);\n }\n }\n\n private void control_ControlAdded(object sender, ControlEventArgs e)\n {\n SubscribeEvents(e.Control);\n }\n\n private void control_ControlRemoved(object sender, ControlEventArgs e)\n {\n UnsubscribeEvents(e.Control);\n }\n\n protected override void OnMouseLeave(EventArgs e)\n {\n CheckMouseLeave();\n base.OnMouseLeave(e);\n }\n\n private void control_MouseLeave(object sender, EventArgs e)\n {\n CheckMouseLeave();\n }\n\n private void CheckMouseLeave()\n {\n Point pt = PointToClient(Cursor.Position);\n\n if (ClientRectangle.Contains(pt) == false)\n {\n OnMouseLeftFrom();\n }\n }\n\n private void OnMouseLeftFrom()\n {\n Console.WriteLine(\"Mouse left the form\");\n }\n"
},
{
"answer_id": 279852,
"author": "Stefan",
"author_id": 19307,
"author_profile": "https://Stackoverflow.com/users/19307",
"pm_score": 2,
"selected": false,
"text": "Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load\n AddMouseLeaveHandlers()\nEnd Sub\nSub AddMouseLeaveHandlers()\n For Each c As Control In Me.Controls\n HookItUp(c)\n Next\n AddHandler Me.MouseLeave, AddressOf CheckMouseLeave\nEnd Sub\nSub HookItUp(ByVal c As Control) \n AddHandler c.MouseLeave, AddressOf CheckMouseLeave\n If c.HasChildren Then\n For Each f As Control In c.Controls\n HookItUp(f)\n Next\n End If\nEnd Sub\nPrivate Sub CheckMouseLeave(ByVal sender As Object, ByVal e As System.EventArgs)\n Dim pt As Point = PointToClient(Cursor.Position)\n If ClientRectangle.Contains(pt) = False Then\n MsgBox(\"Mouse left form\")\n End If\nEnd Sub\n"
},
{
"answer_id": 282005,
"author": "Hans Passant",
"author_id": 17034,
"author_profile": "https://Stackoverflow.com/users/17034",
"pm_score": 3,
"selected": false,
"text": " public partial class Form1 : Form {\n Timer timer1 = new Timer();\n public Form1() {\n InitializeComponent();\n this.Opacity = 0.10;\n timer1.Tick += new EventHandler(timer1_Tick);\n timer1.Interval = 200;\n timer1.Enabled = true;\n }\n\n void timer1_Tick(object sender, EventArgs e) {\n Point pos = Control.MousePosition;\n bool inForm = pos.X >= Left && pos.Y >= Top && pos.X < Right && pos.Y < Bottom;\n this.Opacity = inForm ? 0.99 : 0.10;\n }\n }\n"
},
{
"answer_id": 15152417,
"author": "Shairoz N Kachchhi",
"author_id": 2122558,
"author_profile": "https://Stackoverflow.com/users/2122558",
"pm_score": 1,
"selected": false,
"text": "If PointToClient(MousePosition).X < Me.Size.Width AndAlso PointToClient(MousePosition).X > -1 AndAlso PointToClient(MousePosition).Y < Me.Size.Height AndAlso PointToClient(MousePosition).Y > -1 Then\n 'Mouse is inside the form\nElse\n 'Mouse is outside of form\nEnd If\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/279472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9382/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.