qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
245,532
|
<p>I have a web application that has many faces and so far I've implemented this through creating themes. A theme is a set of html, css and images to be used with the common back end.</p>
<p>Things are laid out like so:</p>
<pre><code>code/
themes/theme1
themes/theme2
</code></pre>
<p>And each instance of the web application has a configuration file that states which theme should be used. Example:</p>
<pre><code>theme="theme1"
</code></pre>
<p>Now new business rules are asking me to make changes to certain themes that can't be achieved through simply change the html/css/images and require changing the backend. In some cases these changes need to be applied to a group of themes.</p>
<p>I'm wondering how to best lay this out on disk, and also how to handle it in code. I'm sure someone else must have come up against this.</p>
<p>One idea is to have:</p>
<pre><code>code/common
code/theme1
code/theme2
themes/theme1
themes/theme2
</code></pre>
<p>Then have my common code set the <code>include_path</code> such that <code>code/theme1</code> is searched first, then <code>code/common</code>.</p>
<p>Then if I want to specialize say the <code>LogoutPage</code> class for <code>theme2</code>, I can simply copy the page from <code>code/common</code> to the same path under <code>code/theme2</code> and it will pick up the specialized version.</p>
<p>One problem with this idea is that there'll be multiple classes with the same name. Although in theory they would never be included in the same execution, I wouldn't be able to extend the original base class.</p>
<p>So what if I was to make a unique name for the base class? e.g. <code>Theme1LogoutPage extends LogoutPage</code>. One problem I can foresee with that is when some common code (say the Dispatcher) references <code>LogoutPage</code>. I can add conditions to the dispatcher, but I wonder if there's a more transparent way to handle this?</p>
<p>Another option I can think of is to maintain separate branches for each theme, but I think this could be a lot of work.</p>
<p>One final thing to consider is that features might originate in one theme and then require merging into the common codebase.</p>
<p>Any input greatly appreciated. If it makes any difference, it's a LAMP environment.</p>
|
[
{
"answer_id": 245707,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": false,
"text": "public interface ILogoutStrategy\n{\n void Logout();\n}\n\npublic abstract class AbstractLogoutStrategy : ILogoutStrategy\n{\n public virtual void Logout()\n {\n // kill the sesssion\n }\n}\n\npublic class SingleSiteLogoutStrategy : AbstractLogoutStrategy\n{\n public void Logout()\n {\n base.Logout();\n // redirect somewhere\n }\n}\n\npublic class CentralAuthenticationSystemLogoutStrategy : AbstractLogoutStrategy\n{\n public void Logout()\n {\n base.Logout();\n // send a logout request to the CAS\n // redirect somewhere\n }\n}\n\npublic static class StrategyFactory\n{\n public ILogoutStrategy GetLogoutStrategy(Configuration config)\n {\n switch (config.Mode)\n {\n case Mode.CAS:\n return new CentralAuthenticationSystemLogoutStrategy();\n break;\n default:\n case Mode.SingleSite:\n return new SingleSiteLogoutStrategy();\n break;\n\n }\n }\n}\n ILogoutStrategy logoutStrategy = StrategyFactory.GetLogoutStrategy( config );\nlogoutStrategy.Logout();\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
245,557
|
<p>Let's say I have two arrays:</p>
<blockquote>
<p>int ArrayA[] = {5, 17, 150, 230, 285};</p>
<p>int ArrayB[] = {7, 11, 57, 110, 230, 250};</p>
</blockquote>
<p>Both arrays are sorted and can be any size. I am looking for an efficient algorithm to find if the arrays contain any duplicated elements between them. I just want a true/false answer, I don't care which element is shared or how many.</p>
<p>The naive solution is to loop through each item in ArrayA, and do a <a href="http://en.wikipedia.org/wiki/Binary_search" rel="noreferrer">binary search</a> for it in ArrayB. I believe this complexity is O(m * log n).</p>
<p>Because both arrays are sorted, it seems like there should be a more efficient algorithm.</p>
<p>I would also like a generic solution that doesn't assume that the arrays hold numbers (i.e. the solution should also work for strings). However, the comparison operators are well defined and both arrays are sorted from least to greatest.</p>
|
[
{
"answer_id": 245563,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 6,
"selected": true,
"text": "counterA = 0;\ncounterB = 0;\nfor(;;) {\n if(counterA == ArrayA.length || counterB == ArrayB.length)\n return false;\n else if(ArrayA[counterA] == ArrayB[counterB])\n return true;\n else if(ArrayA[counterA] < ArrayB[counterB])\n counterA++;\n else if(ArrayA[counterA] > ArrayB[counterB])\n counterB++;\n else\n halt_and_catch_fire();\n}\n"
},
{
"answer_id": 245877,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 1,
"selected": false,
"text": "ArrayA.Intersect(ArrayB).Any()\n"
},
{
"answer_id": 248229,
"author": "David Nehme",
"author_id": 14167,
"author_profile": "https://Stackoverflow.com/users/14167",
"pm_score": 3,
"selected": false,
"text": " #include <vector>\n #include <algorithm>\n #include <iterator>\n using namespace std;\n// ... \n int ArrayA[] = {5, 17, 150, 230, 285};\n int ArrayB[] = {7, 11, 57, 110, 230, 250};\n vector<int> intersection;\n ThrowWhenWritten output_iterator;\n set_intersection(ArrayA, ArrayA + sizeof(ArrayA)/sizeof(int),\n ArrayB, ArrayB + sizeof(ArrayB)/sizeof(int),\n back_insert_iterator<vector<int> >(intersection));\n\n return !intersection.empty();\n template<typename InputIterator1, typename InputIterator2>\n bool \n has_intersection(InputIterator1 first1, InputIterator1 last1,\n InputIterator2 first2, InputIterator2 last2)\n {\n while (first1 != last1 && first2 != last2) \n {\n if (*first1 < *first2)\n ++first1;\n else if (*first2 < *first1)\n ++first2;\n else\n return true;\n }\n return false;\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3175/"
] |
245,565
|
<p>Most developers understand the concept of <a href="http://en.wikipedia.org/wiki/Wicked_problem" rel="nofollow noreferrer">wicked problems</a>. What's a good analogy to use when explaining this concept to project managers?</p>
|
[
{
"answer_id": 245596,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 1,
"selected": false,
"text": "trying to hit a moving taget that changes shape, \nwears disguises, hides in shadows, recruits minions,\nand shoots back\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13118/"
] |
245,569
|
<p>How do you properly ensure that a user isnt tampering with querystring values or action url values? For example, you might have a Delete Comment action on your CommentController which takes a CommentID. The action url might look like /Comments/Delete/3 to delete the comment with the id 3.</p>
<p>Now obviously you dont want anyone to be able to delete comment 3. Normally on the owner of the comment or an admin has permission to do so. Ive seen this security enforced different ways and would like to know how some of you do it.</p>
<p>Do you make multiple Database calls to retrieve the comment and check that the author of the comment matches the user invoking the delete action? </p>
<p>Do you instead pass the CommentID and the UserID down to the stored procedure who does the delete and do a Delete where UserID and CommentID equal the values passed in? </p>
<p>Is it better to encrypt the query string values? </p>
|
[
{
"answer_id": 245692,
"author": "Schotime",
"author_id": 29376,
"author_profile": "https://Stackoverflow.com/users/29376",
"pm_score": 1,
"selected": false,
"text": "[AcceptVerbs(HttpVerbs.Post)]\npublic ActionResult Delete(int? id)\n{\n //Delete\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10941/"
] |
245,584
|
<p>What is the coolest <strong>somewhat practical</strong> metaprogramming hack you've done or seen done in the D programming language? Somewhat practical means excluding, for example, the compile-time raytracer.</p>
|
[
{
"answer_id": 247766,
"author": "FeepingCreature",
"author_id": 59044,
"author_profile": "https://Stackoverflow.com/users/59044",
"pm_score": 3,
"selected": false,
"text": "template ElemType(T) {\n alias typeof((function() {\n foreach (elem; Init!(T)) return elem; assert(false);\n })()) ElemType;\n}\n\ntemplate KeyType(T) {\n alias typeof((function() {\n foreach (key, elem; Init!(T)) return key; assert(false);\n })()) KeyType;\n}\n"
},
{
"answer_id": 4595559,
"author": "A. Fournier",
"author_id": 418592,
"author_profile": "https://Stackoverflow.com/users/418592",
"pm_score": 2,
"selected": false,
"text": "template TStructReader() {\n private alias typeof(*this) T;\n static T opCall(Stream stream) {\n assert(stream.readable);\n T ret; stream.readExact(&ret, T.sizeof);\n return ret;\n }\n}\n\ntemplate TStructWriter() {\n private alias typeof(*this) T;\n void write(Stream stream) {\n assert(stream.writeable);\n stream.writeExact(this, T.sizeof);\n }\n}\n align (1) struct MyStruct {\n ... definitions here ...\n mixin TStructReader;\n mixin TStructWriter;\n}\n\nauto ms = MyStruct(stream);\nms.write(stream);\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23903/"
] |
245,592
|
<p>In DB2, you can name a column ORDER and write SQL like</p>
<pre><code>SELECT ORDER FROM tblWHATEVER ORDER BY ORDER
</code></pre>
<p>without even needing to put any special characters around the column name. This is causing me pain that I won't get into, but my question is: why do databases allow the use of SQL keywords for object names? Surely it would make more sense to just not allow this?</p>
|
[
{
"answer_id": 247503,
"author": "kristof",
"author_id": 3241,
"author_profile": "https://Stackoverflow.com/users/3241",
"pm_score": 1,
"selected": false,
"text": "create table [order](\nid int,\n[order] varchar(50) )\n select \n [order] \nfrom \n [order]\norder by [order]\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14606/"
] |
245,600
|
<p>In an information security lab I'm working on, I've been tasked with executing multiple commands with a single call to "system()" (written in C, running on Fedora). What is the syntax that will allow me to execute more than command through system()? (The idea being you could execute arbitrary commands through a program running on a remote computer, if the program interacts with the OS through the system() call.)</p>
<p>I.e.:</p>
<pre><code>char command[] = "????? \r\n";
system(command);
</code></pre>
|
[
{
"answer_id": 245608,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 5,
"selected": true,
"text": "; command1; command2; command3\n && ;"
},
{
"answer_id": 245609,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 1,
"selected": false,
"text": "system (\"cmd.exe /c \\\"x.cmd\\\"\");\n system (\"x.sh\");\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28076/"
] |
245,607
|
<p>I didn't attend PDC 2008, but I heard some news that C# 4.0 is announced to support Generic covariance and contra-variance. That is, <code>List<string></code> can be assigned to <code>List<object></code>. How could that be?</p>
<p>In Jon Skeet's book <strong><em>C# in Depth</em></strong>, it is explained why C# generics doesn't support covariance and contra-variance. It is mainly for writing secure code. Now, C# 4.0 changed to support them. Would it bring chaos?</p>
<p>Anybody know the details about C# 4.0 can give some explanation?</p>
|
[
{
"answer_id": 246101,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 8,
"selected": true,
"text": "List<Banana> List<Fruit> in out IEnumerable<T> IEnumerable<out T> IEnumerable<string> IEnumerable<object> Action<T> T Action<object> Action<string> object string"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] |
245,614
|
<p>Okay still fighting with doing some SqlCacheDependecy in my Asp.net MVC application</p>
<p>I got this piece of code from Microsoft to cache LINQtoSQL, basically what it does is it gets the SqlCommand text from the LINQ query and executes that via the System.Data.SqlClient.SqlCommand which SqlDependecy needs...</p>
<p>However there is one slight problem with this and that is whenever you do a where clause in LINQ the SQL generated is like so</p>
<pre><code>SELECT [t0].[MemberID], [t0].[Aspnetusername], [t0].[Aspnetpassword], [t0].[EmailAddr], [t0].[DateCreated], [t0].[Location], [t0].[DaimokuGoal], [t0].[PreviewImageID], [t0].[LastDaimoku] AS [LastDaimoku], [t0].[LastNotefied] AS [LastNotefied], [t0].[LastActivityDate] AS [LastActivityDate], [t0].[IsActivated]
FROM [dbo].[Members] AS [t0]
INNER JOIN [dbo].[MemberStats] AS [t1] ON [t0].[MemberID] = [t1].[MemberID]
WHERE [t1].[TotalDeterminations] > @p0
</code></pre>
<p>Notice the where [t1].[TotalDeterminations] > @p0, the SqlCommand yells at me because it wants me to declare a scalar variable of @p0... which obviously I can't</p>
<p>So how the heck does Microsoft which provides this code to cache Linq queries expect people to use where clauses? Anyone have any ideas around this?</p>
<p><strong>Edit</strong> Plus how the heck does SQL know what @p is anyhow when just executing the LINQ like normal the above query is whats getting passed in no matter what to the database?</p>
|
[
{
"answer_id": 245665,
"author": "Aaron Powell",
"author_id": 11388,
"author_profile": "https://Stackoverflow.com/users/11388",
"pm_score": 2,
"selected": true,
"text": "@something p# #"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22093/"
] |
245,624
|
<p>Are there any 'standard' plugins for detecting the CPU architecture in <strong>scons</strong>? </p>
<p>BTW, this question was asked already <a href="https://stackoverflow.com/questions/152016/detecting-cpu-architecture-compile-time">here</a> in a more general form... just wondering if anyone has already taken the time to incorporate this information into scons. </p>
|
[
{
"answer_id": 418719,
"author": "dsvensson",
"author_id": 5962,
"author_profile": "https://Stackoverflow.com/users/5962",
"pm_score": 2,
"selected": false,
"text": "env = Environment()\nconf = Configure(env)\nif conf.CheckDeclaration(\"__i386__\"):\n conf.Define(\"MY_ARCH\", \"blahblablah\")\nenv = conf.Finish()\n"
},
{
"answer_id": 510888,
"author": "David Cournapeau",
"author_id": 11465,
"author_profile": "https://Stackoverflow.com/users/11465",
"pm_score": 3,
"selected": false,
"text": "import platform\nprint platform.machine()\nprint platform.architecture()\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14069/"
] |
245,628
|
<pre><code>template <class T>
bool BST<T>::search(const T& x, int& len) const
{
return search(BT<T>::root, x);
}
template <class T>
bool BST<T>::search(struct Node<T>*& root, const T& x)
{
if (root == NULL)
return false;
else
{
if (root->data == x)
return true;
else if(root->data < x)
search(root->left, x);
else
search(root->right, x);
}
}
</code></pre>
<p>So this is my search function for my BST class with a T node. x is the data being searched for within the tree, len is just the amount of nodes it has to travel to come up with the matching node if it exists. I have not implented that yet, I'm just incrementally developing my assignment. I'm calling it by doing this:</p>
<pre><code>if(t.search(v[1], len) == true)
cout << endl << "true";
</code></pre>
<p>v is just a vector I had to create to compare it to, and so this is just supplying it with an int. The error I'm getting:</p>
<pre><code>BST.h: In member function âbool BST<T>::search(const T&, int&) const [with T = int]â:
prog5.cc:24: instantiated from here
BST.h:78: error: no matching function for call to âBST<int>::search(Node<int>* const&, const int&) constâ
BST.h:76: note: candidates are: bool BST<T>::search(const T&, int&) const [with T = int]
BST.h:83: note: bool BST<T>::search(Node<T>*&, const T&) [with T = int]
</code></pre>
<p>So I'm not sure what I'm doing wrong or where I'm doing wrong. </p>
|
[
{
"answer_id": 245636,
"author": "oz10",
"author_id": 14069,
"author_profile": "https://Stackoverflow.com/users/14069",
"pm_score": 3,
"selected": true,
"text": "bool BST<T>::search(struct Node<T>*& root, const T& x) bool BST<T>::search(struct Node<T>*& root, const T& x) const struct Node<T>*& Node<T>*"
},
{
"answer_id": 39881290,
"author": "rashedcs",
"author_id": 6714430,
"author_profile": "https://Stackoverflow.com/users/6714430",
"pm_score": 0,
"selected": false,
"text": " node* search(node* root, int data)\n {\n if (root==NULL || root->data==data) return root;\n\n if (root->data < data) return search(root->right, data);\n\n return search(root->left, data);\n }\n"
},
{
"answer_id": 40349944,
"author": "chqrlie",
"author_id": 4593267,
"author_profile": "https://Stackoverflow.com/users/4593267",
"pm_score": 1,
"selected": false,
"text": "root const const template <class T>\nbool BST<T>::search(const struct Node<T> *root, const T& x) const {\n if (root == NULL)\n return false;\n else\n if (root->data == x)\n return true;\n else\n if (root->data < x)\n return search(root->right, x);\n else \n return search(root->left, x);\n}\n template <class T>\nbool BST<T>::search(const struct Node<T> *root, const T& x) const {\n while (root != NULL) {\n if (root->data == x)\n return true;\n if (root->data < x)\n root = root->right;\n else \n root = root->left;\n }\n return false;\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245628",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28392/"
] |
245,654
|
<p>My database consists of 3 tables (one for storing all items, one for the tags, and one for the relation between the two):</p>
<p>Table: Post
Columns: PostID, Name, Desc</p>
<p>Table: Tag
Columns: TagID, Name</p>
<p>Table: PostTag
Columns: PostID, TagID</p>
<p>What is the best way to save a space separated string (e.g. "smart funny wonderful") into the 3 database tables shown above? </p>
<p>Ultimately I would also need to retrieve the tags and display it as a string again. Thanks!</p>
|
[
{
"answer_id": 245757,
"author": "Ken Gentle",
"author_id": 8709,
"author_profile": "https://Stackoverflow.com/users/8709",
"pm_score": 1,
"selected": false,
"text": "tag.id = 1; tag.name = 'smart'\ntag.id = 2; tag.name = 'funny'\ntag.id = 3; tag.name = 'wonderful'\n"
},
{
"answer_id": 248488,
"author": "Hates_",
"author_id": 3410,
"author_profile": "https://Stackoverflow.com/users/3410",
"pm_score": 3,
"selected": true,
"text": "class Post {\n static hasMany [tags:Tag]\n}\n\nclass Tag {\n static belongsTo = Post\n static hasMany [posts:Post]\n}\n\nclass someService {\n\n def createPostWithTags(name, desc, tags) { \n def post = new Post(name: name, desc: desc).save()\n tags.split(' ').each { tagName ->\n def tag = Tag.findByName(tag) ?: new Tag(name: tagName)\n post.addToTags(tag).save()\n } \n }\n\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27163/"
] |
245,666
|
<p>When I'm using an If statement and I want to check if a boolean is false should I use the "Not" keyword or just = false, like so</p>
<pre><code>If (Not myboolean) then
</code></pre>
<p>vs</p>
<pre><code>If (myboolean = False) then
</code></pre>
<p>Which is better practice and more readable?</p>
|
[
{
"answer_id": 245674,
"author": "James Curran",
"author_id": 12725,
"author_profile": "https://Stackoverflow.com/users/12725",
"pm_score": 6,
"selected": true,
"text": " if (node.HasChildren)\n"
},
{
"answer_id": 245890,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 2,
"selected": false,
"text": "True False bool"
},
{
"answer_id": 275813,
"author": "Ted",
"author_id": 7972,
"author_profile": "https://Stackoverflow.com/users/7972",
"pm_score": 2,
"selected": false,
"text": "if (condition)\n // true case\nelse\n // false case\n if (not condition)\n // false case\nelse\n // true case\n x is not None"
},
{
"answer_id": 275844,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 1,
"selected": false,
"text": "If Not x If x = False"
},
{
"answer_id": 25513534,
"author": "Jay",
"author_id": 3980399,
"author_profile": "https://Stackoverflow.com/users/3980399",
"pm_score": 0,
"selected": false,
"text": "If InStr(strLine, \"=\") = False Then _\nIf Not CBool(InStr(strLine, \"=\")) Then\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] |
245,677
|
<p>Many examples of macros seem to be about hiding lambdas, e.g. with-open-file in CL. I'm looking for some more exotic uses of macros, particularly in PLT Scheme. I'd like to get a feel for when to consider using a macro vs. using functions.</p>
|
[
{
"answer_id": 247229,
"author": "Nathan Shively-Sanders",
"author_id": 7851,
"author_profile": "https://Stackoverflow.com/users/7851",
"pm_score": 4,
"selected": true,
"text": "define-syntax (define-syntax [: x]\n (syntax-case x ()\n ([src-: e es ...]\n (syntax-case (datum->syntax-object #'src-: '_) ()\n (_ #'(lambda (_) (e es ...)))))))\n [: / _ 2] ; <-- much better than (lambda (x) (/ x 2))\n defmacro define-macro aif define-syntax (define-syntax (aif x)\n (syntax-case x ()\n [(src-aif test then else)\n (syntax-case (datum->syntax-object (syntax src-aif) '_) ()\n [_ (syntax (let ([_ test]) (if (and _ (not (null? _))) then else)))])]))\n define-syntax syntax-rules syntax-case defmacro define-macro"
},
{
"answer_id": 247912,
"author": "Matthias Benkard",
"author_id": 15517,
"author_profile": "https://Stackoverflow.com/users/15517",
"pm_score": 1,
"selected": false,
"text": "(with-slots (state door) car\n (when (eq state :stopped)\n (setq state :driving-around)\n (setq door :closed)))\n"
},
{
"answer_id": 262954,
"author": "soegaard",
"author_id": 23567,
"author_profile": "https://Stackoverflow.com/users/23567",
"pm_score": 3,
"selected": false,
"text": " ; Within a (with-modulus n form1 ...) the return values of\n ; the arithmetival operations +, -, * and ^ are automatically\n ; reduced modulo n. Furthermore (mod x)=(modulo x n) and\n ; (inv x)=(inverse x n).\n\n ; Example: (with-modulus 3 (^ 2 4)) ==> 1\n\n (define-syntax (with-modulus stx)\n (syntax-case stx ()\n [(with-modulus e form ...)\n (with-syntax ([+ (datum->syntax-object (syntax with-modulus) '+)]\n [- (datum->syntax-object (syntax with-modulus) '-)]\n [* (datum->syntax-object (syntax with-modulus) '*)]\n [^ (datum->syntax-object (syntax with-modulus) '^)]\n [mod (datum->syntax-object (syntax with-modulus) 'mod)]\n [inv (datum->syntax-object (syntax with-modulus) 'inv)])\n (syntax (let* ([n e]\n [mod (lambda (x) (modulo x n))]\n [inv (lambda (x) (inverse x n))]\n [+ (compose mod +)]\n [- (compose mod -)]\n [* (compose mod *)]\n [square (lambda (x) (* x x))]\n [^ (rec ^ (lambda (a b)\n (cond\n [(= b 0) 1]\n [(even? b) (square (^ a (/ b 2)))]\n [else (* a (^ a (sub1 b)))])))])\n form ...)))]))\n"
},
{
"answer_id": 330265,
"author": "Dustin",
"author_id": 39975,
"author_profile": "https://Stackoverflow.com/users/39975",
"pm_score": 1,
"selected": false,
"text": "curry"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28604/"
] |
245,698
|
<p>This is similar to <a href="https://stackoverflow.com/questions/105212/linux-recursively-list-all-files-in-a-directory-including-files-in-symlink-dire">this question</a>, but I want to include the path relative to the current directory in unix. If I do the following:</p>
<pre><code>ls -LR | grep .txt
</code></pre>
<p>It doesn't include the full paths. For example, I have the following directory structure:</p>
<pre><code>test1/file.txt
test2/file1.txt
test2/file2.txt
</code></pre>
<p>The code above will return:</p>
<pre><code>file.txt
file1.txt
file2.txt
</code></pre>
<p>How can I get it to include the paths relative to the current directory using standard Unix commands?</p>
|
[
{
"answer_id": 245710,
"author": "Jonathan Adelson",
"author_id": 8092,
"author_profile": "https://Stackoverflow.com/users/8092",
"pm_score": 5,
"selected": false,
"text": "find find [start directory] -name [what to find] find . -name \"*.txt\""
},
{
"answer_id": 245712,
"author": "Andru Luvisi",
"author_id": 5922,
"author_profile": "https://Stackoverflow.com/users/5922",
"pm_score": 9,
"selected": true,
"text": "find . -name \\*.txt -print\n"
},
{
"answer_id": 245716,
"author": "Sherm Pendley",
"author_id": 27631,
"author_profile": "https://Stackoverflow.com/users/27631",
"pm_score": 4,
"selected": false,
"text": "find . -name '*.txt'\n"
},
{
"answer_id": 1571652,
"author": "h-dima",
"author_id": 190533,
"author_profile": "https://Stackoverflow.com/users/190533",
"pm_score": 2,
"selected": false,
"text": "DIR=your_path\nfind $DIR | sed 's:\"\"$DIR\"\"::'\n"
},
{
"answer_id": 1807738,
"author": "Eric Keller",
"author_id": 219940,
"author_profile": "https://Stackoverflow.com/users/219940",
"pm_score": 1,
"selected": false,
"text": "sub format_lines($)\n{\n my $refonlines = shift;\n my @lines = @{$refonlines};\n my $tmppath = \"-\";\n\n foreach (@lines)\n {\n next if ($_ =~ /^\\s+/);\n if ($_ =~ /(^\\w+(\\/\\w*)*):/)\n {\n $tmppath = $1 if defined $1; \n next;\n }\n print \"$tmppath/$_\";\n }\n}\n\nsub main()\n{\n my @lines = ();\n\n while (<>) \n {\n push (@lines, $_);\n }\n format_lines(\\@lines);\n}\n\nmain();\n ls -LR | perl format_ls-LR.pl\n"
},
{
"answer_id": 2726134,
"author": "Stephen Irons",
"author_id": 327388,
"author_profile": "https://Stackoverflow.com/users/327388",
"pm_score": 6,
"selected": false,
"text": "tree -f -i tree -if --noreport .\ntree -if --noreport directory/\n grep # yum install tree -y\n $ sudo apt-get install tree -y\n"
},
{
"answer_id": 5490765,
"author": "rxw",
"author_id": 220472,
"author_profile": "https://Stackoverflow.com/users/220472",
"pm_score": 1,
"selected": false,
"text": ".zshrc .bashrc filepath() {\n echo $PWD/$1\n}\n\nfilepath2() {\n for i in $@; do\n echo $PWD/$i\n done\n}\n"
},
{
"answer_id": 8676573,
"author": "ZaSter",
"author_id": 552857,
"author_profile": "https://Stackoverflow.com/users/552857",
"pm_score": 3,
"selected": false,
"text": "find $(pwd) -name \\*.txt -print\n"
},
{
"answer_id": 15036235,
"author": "user2101432",
"author_id": 2101432,
"author_profile": "https://Stackoverflow.com/users/2101432",
"pm_score": 1,
"selected": false,
"text": "find / -name \"filename\" \n"
},
{
"answer_id": 18360502,
"author": "rajeshk",
"author_id": 2148088,
"author_profile": "https://Stackoverflow.com/users/2148088",
"pm_score": 1,
"selected": false,
"text": "sed \"s|<OLDPATH>|<NEWPATH>|g\" input_file > output_file\n"
},
{
"answer_id": 23039612,
"author": "Sireesh Yarlagadda",
"author_id": 2057902,
"author_profile": "https://Stackoverflow.com/users/2057902",
"pm_score": 0,
"selected": false,
"text": "file***.txt ls /some/path/here | find . -name 'file*.txt' (* represents some wild card search)\n"
},
{
"answer_id": 35998640,
"author": "El Guesto",
"author_id": 5233249,
"author_profile": "https://Stackoverflow.com/users/5233249",
"pm_score": 3,
"selected": false,
"text": "ls -R1 $PWD | while read l; do case $l in *:) d=${l%:};; \"\") d=;; *) echo \"$d/$l\";; esac; done | grep -i \".txt\" ls"
},
{
"answer_id": 55816586,
"author": "rien333",
"author_id": 1657933,
"author_profile": "https://Stackoverflow.com/users/1657933",
"pm_score": 1,
"selected": false,
"text": "$ ls **pdf\n"
},
{
"answer_id": 60542090,
"author": "kazuwombat",
"author_id": 5992952,
"author_profile": "https://Stackoverflow.com/users/5992952",
"pm_score": 0,
"selected": false,
"text": "tree -ifF ./dir | grep -v '^./dir$' | grep -v '.*/$' | grep '\\./.*' | while read file; do\n echo $file\ndone\n tree -ifF ./dir | grep -v '^./dir$' | grep -v '.*/$' | grep '\\./.*' | while read file; do\n echo $file | sed -e \"s|^.|$PWD|g\"\ndone\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] |
245,709
|
<p>When running PHP in CLI mode, <em>most</em> of the time (not always), the script will hang at the end of execution for about 5 seconds and then output this:</p>
<blockquote>
<p><code>Error in my_thread_global_end(): 1 threads didn't exit</code></p>
</blockquote>
<p>It doesn't seem to actually have any effect on the script itself.</p>
<p>Some web searches turned up blogs which suggest replacing the php_mysql.dll with a different version, however this has not solved the issue for me, and I suspect the info from those blogs is now out of date.</p>
<p>My setup:</p>
<ul>
<li>PHP Version 5.2.4</li>
<li>Apache/2.2.4 (Win32)</li>
<li>Windows Vista Home Premium SP1</li>
</ul>
|
[
{
"answer_id": 245824,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 0,
"selected": false,
"text": "Whenever a new thread is created libmysql is told about that by Windows. It then \nincreases a thread counter and initializes some data. When libmysql is being unloaded\nit checks whether all threads have finished, if not it tries to tell them \"close now\"\nand gives them 5 seconds for that. In general this works in a nice way.\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
245,725
|
<p>I am building a simple Django app that will use scribd to display documents. I would like to have a page where the administrator can upload documents to scribd through the website, since I need to know a few things about it before it gets to scribd. What is the best/easiest way to do this, display an upload page and then take the file that is uploaded and send it to scribd through the <a href="http://www.scribd.com/publisher/api?method_name=docs.upload" rel="nofollow noreferrer">docs.upload</a> method of their api? I'm a little new at this Python/Django/REST API thing, so sorry if this is too many questions at once.</p>
|
[
{
"answer_id": 245821,
"author": "Parand",
"author_id": 13055,
"author_profile": "https://Stackoverflow.com/users/13055",
"pm_score": 3,
"selected": true,
"text": "request.FILES['file']"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] |
245,727
|
<p>I have one website on my server, and my IIS Worker Process is using 4GB RAM consistently. What should I be checking?</p>
<pre><code>c:\windows\system32\inetsrv\w3wp.exe
</code></pre>
|
[
{
"answer_id": 245758,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 2,
"selected": false,
"text": "using Using"
},
{
"answer_id": 245876,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 5,
"selected": true,
"text": "IDispose Dispose() using perfmon.exe"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16794/"
] |
245,735
|
<p>By which I mean this:</p>
<p>Given the input set of numbers: </p>
<p>1,2,3,4,5 becomes "1-5".</p>
<p>1,2,3,5,7,9,10,11,12,14 becomes "1-3, 5, 7, 9-12, 14"</p>
<p>This is the best I managed to come up with: [C#]</p>
<p><em>Which feels a little sloppy to me, so the question is, is there somehow more readable and/or elegant solution to this?</em></p>
<pre><code>public static string[] FormatInts(int[] ints)
{
if (ints == null)
throw new ArgumentNullException("ints"); // hey what are you doing?
if (ints.Length == 0)
return new string[] { "" }; // nothing to process
if (ints.Length == 1)
return new string[] { ints[0].ToString() }; // nothing to process
Array.Sort<int>(ints); // need to sort these lil' babies
List<string> values = new List<string>();
int lastNumber = ints[0]; // start with the first number
int firstNumber = ints[0]; // same as above
for (int i = 1; i < ints.Length; i++)
{
int current = ints[i];
int difference = (lastNumber - current ); // compute difference between last number and current number
if (difference == -1) // the numbers are adjacent
{
if (firstNumber == 0) // this is the first of the adjacent numbers
{
firstNumber = lastNumber;
}
else // we're somehow in the middle or at the end of the adjacent number set
{
lastNumber = current;
continue;
}
}
else
{
if (firstNumber > 0 && firstNumber != lastNumber) // get ready to print a set of numbers
{
values.Add(string.Format("{0}-{1}", firstNumber, lastNumber));
firstNumber = 0; // reset
}
else // print a single value
{
values.Add(string.Format("{0}", lastNumber));
}
}
lastNumber = current;
}
if (firstNumber > 0) // if theres anything left, print it out
{
values.Add(string.Format("{0}-{1}", firstNumber, lastNumber));
}
return values.ToArray();
}
</code></pre>
|
[
{
"answer_id": 245788,
"author": "Christian C. Salvadó",
"author_id": 5445,
"author_profile": "https://Stackoverflow.com/users/5445",
"pm_score": 5,
"selected": true,
"text": " public static string[] FormatInts(int[] ints)\n {\n Array.Sort<int>(ints);\n List<string> values = new List<string>();\n\n for (int i = 0; i < ints.Length; i++)\n {\n int groupStart = ints[i];\n int groupEnd = groupStart;\n while (i < ints.Length - 1 && ints[i] - ints[i + 1] == -1)\n {\n groupEnd = ints[i + 1];\n i++;\n }\n values.Add(string.Format(groupEnd == groupStart ? \"{0}\":\"{0} - {1}\", groupStart, groupEnd));\n }\n return values.ToArray();\n }\n /////////////////\nint[] myInts = { 1,2,3,5,7,9,10,11,12,14 };\nstring[] result = FormatInts(myInts); // now result haves \"1-3\", \"5\", \"7\", \"9-12\", \"14\"\n"
},
{
"answer_id": 245875,
"author": "Robert Krimen",
"author_id": 25171,
"author_profile": "https://Stackoverflow.com/users/25171",
"pm_score": 1,
"selected": false,
"text": "#!/usr/bin/perl -w\n\nuse strict;\nuse warnings;\n\nuse Scalar::Util qw/looks_like_number/;\n\nsub adjacenify {\n my @input = @_; \n\n # Validate and sort\n looks_like_number $_ or\n die \"Saw '$_' which doesn't look like a number\" for @input;\n @input = sort { $a <=> $b } @input;\n\n my (@output, @range);\n @range = (shift @input);\n for (@input) {\n if ($_ - $range[-1] <= 1) {\n push @range, $_ unless $range[-1] == $_; # Prevent repetition\n }\n else {\n push @output, [ @range ];\n @range = ($_); \n }\n } \n push @output, [ @range ] if @range;\n\n # Return the result as a string. If a sequence is size 1, then it's just that number.\n # Otherwise, it's the first and last number joined by '-'\n return join ', ', map { 1 == @$_ ? @$_ : join ' - ', $_->[0], $_->[-1] } @output;\n}\n\nprint adjacenify( qw/1 2 3 5 7 9 10 11 12 14/ ), \"\\n\";\nprint adjacenify( 1 .. 5 ), \"\\n\";\nprint adjacenify( qw/-10 -9 -8 -1 0 1 2 3 5 7 9 10 11 12 14/ ), \"\\n\";\nprint adjacenify( qw/1 2 4 5 6 7 100 101/), \"\\n\";\nprint adjacenify( qw/1 62/), \"\\n\";\nprint adjacenify( qw/1/), \"\\n\";\nprint adjacenify( qw/1 2/), \"\\n\";\nprint adjacenify( qw/1 62 63/), \"\\n\";\nprint adjacenify( qw/-2 0 0 2/), \"\\n\";\nprint adjacenify( qw/-2 0 0 1/), \"\\n\";\nprint adjacenify( qw/-2 0 0 1 2/), \"\\n\";\n 1 - 3, 5, 7, 9 - 12, 14\n1 - 5\n-10 - -8, -1 - 3, 5, 7, 9 - 12, 14\n1 - 2, 4 - 7, 100 - 101\n1, 62\n1\n1 - 2\n1, 62 - 63\n-2, 0, 2\n-2, 0 - 1\n-2, 0 - 2\n-2, 0 - 2\n sub _recursive_adjacenify($$);\nsub _recursive_adjacenify($$) {\n my ($input, $range) = @_;\n\n return $range if ! @$input;\n\n my $number = shift @$input;\n\n if ($number - $range->[-1] <= 1) {\n return _recursive_adjacenify $input, [ @$range, $number ];\n }\n else {\n return $range, _recursive_adjacenify $input, [ $number ];\n }\n}\n\nsub recursive_adjacenify {\n my @input = @_;\n\n # Validate and sort\n looks_like_number $_ or\n die \"Saw '$_' which doesn't look like a number\" for @input;\n @input = sort { $a <=> $b } @input;\n\n my @output = _recursive_adjacenify \\@input, [ shift @input ];\n\n # Return the result as a string. If a sequence is size 1, \n # then it's just that number.\n # Otherwise, it's the first and last number joined by '-'\n return join ', ', map { 2 == @$_ && $_->[0] == $_->[1] ? $_->[0] : \n 1 == @$_ ? @$_ : \n join ' - ', $_->[0], $_->[-1] } @output;\n\n}\n"
},
{
"answer_id": 246039,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 1,
"selected": false,
"text": "public class IntListToRanges\n{\n // Assumes all numbers are above 0\n public static String[] MakeRanges(int[] numbers)\n {\n ArrayList<String> ranges = new ArrayList<String>();\n\n Arrays.sort(numbers);\n int rangeStart = 0;\n boolean bInRange = false;\n for (int i = 1; i <= numbers.length; i++)\n {\n if (i < numbers.length && numbers[i] - numbers[i - 1] == 1)\n {\n if (!bInRange)\n {\n rangeStart = numbers[i - 1];\n bInRange = true;\n }\n }\n else\n {\n if (bInRange)\n {\n ranges.add(rangeStart + \"-\" + numbers[i - 1]);\n bInRange = false;\n }\n else\n {\n ranges.add(String.valueOf(numbers[i - 1]));\n }\n }\n }\n return ranges.toArray(new String[ranges.size()]);\n }\n\n public static void ShowRanges(String[] ranges)\n {\n for (String range : ranges)\n {\n System.out.print(range + \",\"); // Inelegant but quickly coded...\n }\n System.out.println();\n }\n\n /**\n * @param args\n */\n public static void main(String[] args)\n {\n int[] an1 = { 1,2,3,5,7,9,10,11,12,14,15,16,22,23,27 };\n int[] an2 = { 1,2 };\n int[] an3 = { 1,3,5,7,8,9,11,12,13,14,15 };\n ShowRanges(MakeRanges(an1));\n ShowRanges(MakeRanges(an2));\n ShowRanges(MakeRanges(an3));\n int L = 100;\n int[] anr = new int[L];\n for (int i = 0, c = 1; i < L; i++)\n {\n int incr = Math.random() > 0.2 ? 1 : (int) Math.random() * 3 + 2;\n c += incr;\n anr[i] = c;\n }\n ShowRanges(MakeRanges(anr));\n }\n}\n"
},
{
"answer_id": 246075,
"author": "Deestan",
"author_id": 6848,
"author_profile": "https://Stackoverflow.com/users/6848",
"pm_score": 2,
"selected": false,
"text": "#!/bin/env python\n\ndef group(nums):\n def collect((acc, i_s, i_e), n):\n if n == i_e + 1: return acc, i_s, n\n return acc + [\"%d\"%i_s + (\"-%d\"%i_e)*(i_s!=i_e)], n, n\n s = sorted(nums)+[None]\n acc, _, __ = reduce(collect, s[1:], ([], s[0], s[0]))\n return \", \".join(acc)\n\nassert group([1,2,3,5,7,9,10,11,12,14]) == \"1-3, 5, 7, 9-12, 14\"\n"
},
{
"answer_id": 246093,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 2,
"selected": false,
"text": "void ranges(int n; int a[n], int n)\n{\n qsort(a, n, sizeof(*a), intcmp);\n for (int i = 0; i < n; ++i) {\n const int start = i;\n while(i < n-1 and a[i] >= a[i+1]-1)\n ++i;\n printf(\"%d\", a[start]);\n if (a[start] != a[i])\n printf(\"-%d\", a[i]);\n if (i < n-1)\n printf(\",\");\n }\n printf(\"\\n\");\n}\n"
},
{
"answer_id": 246259,
"author": "madlep",
"author_id": 14160,
"author_profile": "https://Stackoverflow.com/users/14160",
"pm_score": 1,
"selected": false,
"text": "def range_to_s(range)\n return range.first.to_s if range.size == 1\n return range.first.to_s + \"-\" + range.last.to_s\nend\n\ndef format_ints(ints)\n range = []\n 0.upto(ints.size-1) do |i|\n range << ints[i]\n unless (range.first..range.last).to_a == range\n return range_to_s(range[0,range.length-1]) + \",\" + format_ints(ints[i,ints.length-1])\n end\n end\n range_to_s(range) \nend\n"
},
{
"answer_id": 247226,
"author": "ephemient",
"author_id": 20713,
"author_profile": "https://Stackoverflow.com/users/20713",
"pm_score": 1,
"selected": false,
"text": "def seq_to_ranges(seq):\n first, last = None, None\n for x in sorted(seq):\n if last != None and last + 1 != x:\n yield (first, last)\n first = x\n if first == None: first = x\n last = x\n if last != None: yield (first, last)\ndef seq_to_ranges_str(seq):\n return \", \".join(\"%d-%d\" % (first, last) if first != last else str(first) for (first, last) in seq_to_ranges(seq))\n import Data.List\nseq_to_ranges :: (Enum a, Ord a) => [a] -> [(a, a)]\nseq_to_ranges = merge . foldl accum (id, Nothing) . sort where\n accum (k, Nothing) x = (k, Just (x, x))\n accum (k, Just (a, b)) x | succ b == x = (k, Just (a, x))\n | otherwise = (k . ((a, b):), Just (x, x))\n merge (k, m) = k $ maybe [] (:[]) m\nseq_to_ranges_str :: (Enum a, Ord a, Show a) => [a] -> String\nseq_to_ranges_str = drop 2 . concatMap r2s . seq_to_ranges where\n r2s (a, b) | a /= b = \", \" ++ show a ++ \"-\" ++ show b\n | otherwise = \", \" ++ show a\n"
},
{
"answer_id": 249173,
"author": "ephemient",
"author_id": 20713,
"author_profile": "https://Stackoverflow.com/users/20713",
"pm_score": 1,
"selected": false,
"text": " g =: 3 : '<@~.\"1((y~:1+({.,}:)y)#y),.(y~:(}.y,{:y)-1)#y'@/:~\"1\n g 1 2 3 4 5\n+---+\n|1 5|\n+---+\n g 1 2 3 5 7 9 10 11 12 14\n+---+-+-+----+--+\n|1 3|5|7|9 12|14|\n+---+-+-+----+--+\n g 12 2 14 9 1 3 10 5 11 7\n+---+-+-+----+--+\n|1 3|5|7|9 12|14|\n+---+-+-+----+--+\n g2 =: 4 : '<(>x),'' '',>y'/@:>@:(4 :'<(>x),''-'',>y'/&.>)@((<@\":)\"0&.>@g)\n g2 12 2 14 9 1 3 10 5 11 7\n+---------------+\n|1-3 5 7 9-12 14|\n+---------------+\n (;g2) 5 1 20 $ (i.100) /: ? 100 $ 100\n+-----------------------------------------------------------+\n|20 39 82 33 72 93 15 30 85 24 97 60 87 44 77 29 58 69 78 43|\n| |\n|67 89 17 63 34 41 53 37 61 18 88 70 91 13 19 65 99 81 3 62|\n| |\n|31 32 6 11 23 94 16 73 76 7 0 75 98 27 66 28 50 9 22 38|\n| |\n|25 42 86 5 55 64 79 35 36 14 52 2 57 12 46 80 83 84 90 56|\n| |\n| 8 96 4 10 49 71 21 54 48 51 26 40 95 1 68 47 59 74 92 45|\n+-----------------------------------------------------------+\n|15 20 24 29-30 33 39 43-44 58 60 69 72 77-78 82 85 87 93 97|\n+-----------------------------------------------------------+\n|3 13 17-19 34 37 41 53 61-63 65 67 70 81 88-89 91 99 |\n+-----------------------------------------------------------+\n|0 6-7 9 11 16 22-23 27-28 31-32 38 50 66 73 75-76 94 98 |\n+-----------------------------------------------------------+\n|2 5 12 14 25 35-36 42 46 52 55-57 64 79-80 83-84 86 90 |\n+-----------------------------------------------------------+\n|1 4 8 10 21 26 40 45 47-49 51 54 59 68 71 74 92 95-96 |\n+-----------------------------------------------------------+\n sub g {\n my ($i, @r, @s) = 0, local @_ = sort {$a<=>$b} @_;\n $_ && $_[$_-1]+1 == $_[$_] || push(@r, $_[$_]),\n $_<$#_ && $_[$_+1]-1 == $_[$_] || push(@s, $_[$_]) for 0..$#_;\n join ' ', map {$_ == $s[$i++] ? $_ : \"$_-$s[$i-1]\"} @r;\n}\n x /: y x y ~ /:~ 3 : '...' @ g =: 3 : '...' @ /:~ g \"1 y {. }: ({.,}:)y y 1+({.,}:)y ~: y~:1+({.,}:)y y (y~:1+({.,}:)y)#y y }. {: }.y,{:y y (}.y,{:y)-1 ~: # ,. ~. \"1 @ < g2"
},
{
"answer_id": 252877,
"author": "ja.",
"author_id": 15467,
"author_profile": "https://Stackoverflow.com/users/15467",
"pm_score": 1,
"selected": false,
"text": "runs lst = map showRun $ runs' lst\n\nruns' l = reverse $ map reverse $ foldl newOrGlue [[]] l \n\nshowRun [s] = show s\nshowRun lst = show (head lst) ++ \"-\" ++ (show $ last lst)\n\nnewOrGlue [[]] e = [[e]]\nnewOrGlue (curr:other) e | e == (1 + (head curr)) = ((e:curr):other)\nnewOrGlue (curr:other) e | otherwise = [e]:(curr:other)\n T> runs [1,2,3,5,7,9,10,11,12,14]\n\n[\"1-3\",\"5\",\"7\",\"9-12\",\"14\"]\n"
},
{
"answer_id": 1917673,
"author": "Geert Baeyaert",
"author_id": 233617,
"author_profile": "https://Stackoverflow.com/users/233617",
"pm_score": 2,
"selected": false,
"text": "public static string[] FormatInts(IEnumerable<int> ints)\n{\n var intGroups = ints\n .OrderBy(i => i)\n .Aggregate(new List<List<int>>(), (acc, i) =>\n {\n if (acc.Count > 0 && acc.Last().Last() == i - 1) acc.Last().Add(i);\n else acc.Add(new List<int> { i });\n\n return acc;\n });\n\n return intGroups\n .Select(g => g.First().ToString() + (g.Count == 1 ? \"\" : \"-\" + g.Last().ToString()))\n .ToArray();\n}\n"
},
{
"answer_id": 3569459,
"author": "emaxt6",
"author_id": 431114,
"author_profile": "https://Stackoverflow.com/users/431114",
"pm_score": 1,
"selected": false,
"text": "group(List) ->\n [First|_] = USList = lists:usort(List),\n getnext(USList, First, 0).\ngetnext([Head|Tail] = List, First, N) when First+N == Head ->\n getnext(Tail, First, N+1);\ngetnext([Head|Tail] = List, First, N) ->\n [ {First, First+N-1} | getnext(List, Head, 0) ];\ngetnext([], First, N) -> [{First, First+N-1}].\n%%%%%% pretty printer\ngroup_to_string({X,X}) -> integer_to_list(X);\ngroup_to_string({X,Y}) -> integer_to_list(X) ++ \"-\" ++ integer_to_list(Y);\ngroup_to_string(List) -> [group_to_string(X) || X <- group(List)].\n"
},
{
"answer_id": 27769172,
"author": "Christopher Thomas Nicodemus",
"author_id": 1620223,
"author_profile": "https://Stackoverflow.com/users/1620223",
"pm_score": 1,
"selected": false,
"text": "Public Function convertListToRange(lst As String) As String\n Dim splLst() As String\n splLst = Split(lst, \",\")\n Dim x As Long\n For x = 0 To UBound(splLst)\n Dim groupStart As Integer\n groupStart = splLst(x)\n Dim groupEnd As Integer\n groupEnd = groupStart\n Do While (x <= UBound(splLst) - 1)\n If splLst(x) - splLst(x + 1) <> -1 Then Exit Do\n groupEnd = splLst(x + 1)\n x = x + 1\n Loop\n convertListToRange = convertListToRange & IIf(groupStart = groupEnd, groupStart & \",\", groupStart & \"-\" & groupEnd & \",\")\n Next x\n convertListToRange = Left(convertListToRange, Len(convertListToRange) - 1)\nEnd Function\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245735",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15409/"
] |
245,740
|
<p>For example, when I'm dividing two ints and want a float returned, I superstitiously write something like this:</p>
<pre><code>int a = 2, b = 3;
float c = (float)a / (float)b;
</code></pre>
<p>If I do not cast <code>a</code> and <code>b</code> to floats, it'll do integer division and return an int.</p>
<p>Similarly, if I want to multiply a signed 8-bit number with an unsigned 8-bit number, I will cast them to signed 16-bit numbers before multiplying for fear of overflow:</p>
<pre><code>u8 a = 255;
s8 b = -127;
s16 = (s16)a * (s16)b;
</code></pre>
<p>How exactly does the compiler behave in these situations when not casting at all or when only casting one of the variables? Do I really need to explicitly cast all of the variables, or just the one on the left, or the one on the right?</p>
|
[
{
"answer_id": 245746,
"author": "wilhelmtell",
"author_id": 456,
"author_profile": "https://Stackoverflow.com/users/456",
"pm_score": 2,
"selected": false,
"text": "#include <iostream>\n#include <limits>\n\nusing namespace std;\nint main()\n{\n signed int a = numeric_limits<signed int>::max();\n unsigned int b = a + 1; // implicit cast, no overflow here\n cout << a << ' ' << b << endl;\n return 0;\n}\n"
},
{
"answer_id": 245908,
"author": "DarenW",
"author_id": 10468,
"author_profile": "https://Stackoverflow.com/users/10468",
"pm_score": 1,
"selected": false,
"text": "int a;\nint b;\nfloat z;\n\nz = a*1.0*b;\n"
},
{
"answer_id": 245986,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 5,
"selected": false,
"text": "int a = 2, b = 3;\nfloat c = static_cast<float>(a) / b; // need to convert 1 operand to a float\n std::numeric_limits<int>::max() / -1 // No Overflow\nstd::numeric_limits<int>::min() / -1 // Will Overflow\n"
},
{
"answer_id": 246476,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 0,
"selected": false,
"text": "int a = float(foo()) * float(c); \n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/813/"
] |
245,742
|
<p>In this thread, we look at examples of good uses of <code>goto</code> in C or C++. It's inspired by <a href="https://stackoverflow.com/questions/244445/best-refactoring-for-the-dreaded-while-true-loop#244644">an answer</a> which people voted up because they thought I was joking.</p>
<p>Summary (label changed from original to make intent even clearer):</p>
<pre><code>infinite_loop:
// code goes here
goto infinite_loop;
</code></pre>
<p>Why it's better than the alternatives:</p>
<ul>
<li>It's specific. <code>goto</code> is the
language construct which causes an
unconditional branch. Alternatives
depend on using structures
supporting conditional branches,
with a degenerate always-true
condition.</li>
<li>The label documents the intent
without extra comments.</li>
<li>The reader doesn't have to scan the
intervening code for early <code>break</code>s
(although it's still possible for an
unprincipled hacker to simulate
<code>continue</code> with an early <code>goto</code>).</li>
</ul>
<p><strong>Rules:</strong></p>
<ul>
<li>Pretend that the gotophobes didn't
win. It's understood that the above
can't be used in real code because
it goes against established idiom.</li>
<li>Assume that we have all heard of
'Goto considered harmful' and know
that goto can be used to write
spaghetti code.</li>
<li>If you disagree with an example,
criticize it on technical merit
alone ('Because people don't like
goto' is not a technical reason).</li>
</ul>
<p>Let's see if we can talk about this like grown ups.</p>
<p><strong>Edit</strong></p>
<p>This question seems finished now. It generated some high quality answers. Thanks to everyone,
especially those who took my little loop example seriously. Most skeptics were concerned
by the lack of block scope. As @quinmars pointed out in a comment, you can always put braces around the
loop body. I note in passing that <code>for(;;)</code> and <code>while(true)</code> don't give you the braces
for free either (and omitting them can cause vexing bugs). Anyway, I won't waste any more
of your brain power on this trifle - I can live with the harmless and idiomatic <code>for(;;)</code> and <code>while(true)</code> (just as well if I want to keep my job). </p>
<p>Considering the other responses, I see that many people view <code>goto</code> as something you always
have to rewrite in another way. Of course you can avoid a <code>goto</code> by introducing a loop,
an extra flag, a stack of nested <code>if</code>s, or whatever, but why not consider whether <code>goto</code> is
perhaps the best tool for the job? Put another way, how much ugliness are people prepared to endure to avoid using a built-in language feature for its intended purpose? My take is that
even adding a flag is too high a price to pay. I like my variables to represent things in
the problem or solution domains. 'Solely to avoid a <code>goto</code>' doesn't cut it.</p>
<p>I'll accept the first answer which gave the C pattern for branching to a cleanup block. IMO, this makes the strongest case for a <code>goto</code> of all the posted answers, certainly
if you measure it by the contortions a hater has to go through to avoid it.</p>
|
[
{
"answer_id": 245745,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 3,
"selected": false,
"text": "// No Code\n"
},
{
"answer_id": 245759,
"author": "fizzer",
"author_id": 18167,
"author_profile": "https://Stackoverflow.com/users/18167",
"pm_score": 5,
"selected": false,
"text": "restart:\n if (system_call() == -1) {\n if (errno == EINTR) goto restart;\n\n // handle real errors\n }\n"
},
{
"answer_id": 245760,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 4,
"selected": false,
"text": "void dsend(int count) {\n int n;\n if (!count) return;\n n = (count + 7) / 8;\n switch (count % 8) {\n case 0: do { puts(\"case 0\");\n case 7: puts(\"case 7\");\n case 6: puts(\"case 6\");\n case 5: puts(\"case 5\");\n case 4: puts(\"case 4\");\n case 3: puts(\"case 3\");\n case 2: puts(\"case 2\");\n case 1: puts(\"case 1\");\n } while (--n > 0);\n }\n}\n"
},
{
"answer_id": 245761,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 7,
"selected": true,
"text": "void foo()\n{\n if (!doA())\n goto exit;\n if (!doB())\n goto cleanupA;\n if (!doC())\n goto cleanupB;\n\n /* everything has succeeded */\n return;\n\ncleanupB:\n undoB();\ncleanupA:\n undoA();\nexit:\n return;\n}\n"
},
{
"answer_id": 245771,
"author": "Jim Nelson",
"author_id": 32168,
"author_profile": "https://Stackoverflow.com/users/32168",
"pm_score": 0,
"selected": false,
"text": "if(!foo_init())\n goto bye;\n\nif(!bar_init())\n goto foo_bye;\n\nif(!xyzzy_init())\n goto bar_bye;\n\nreturn TRUE;\n\nbar_bye:\n bar_terminate();\n\nfoo_bye:\n foo_terminate();\n\nbye:\n return FALSE;\n"
},
{
"answer_id": 245775,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": -1,
"selected": false,
"text": "void foo()\n{\n if (doA())\n { \n if (doB())\n {\n if (!doC())\n {\n UndoA();\n UndoB();\n }\n }\n else\n {\n UndoA();\n }\n }\n return;\n}\n"
},
{
"answer_id": 245780,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": false,
"text": " while (system_call() == -1)\n {\n if (errno != EINTR)\n {\n // handle real errors\n\n break;\n }\n }\n"
},
{
"answer_id": 245781,
"author": "ephemient",
"author_id": 20713,
"author_profile": "https://Stackoverflow.com/users/20713",
"pm_score": 4,
"selected": false,
"text": "do_stuff(thingy) {\n lock(thingy);\n\n foo;\n if (foo failed) {\n status = -EFOO;\n goto OUT;\n }\n\n bar;\n if (bar failed) {\n status = -EBAR;\n goto OUT;\n }\n\n do_stuff_to(thingy);\n\nOUT:\n unlock(thingy);\n return status;\n}\n goto do{}while(0)"
},
{
"answer_id": 245801,
"author": "Paul Nathan",
"author_id": 26227,
"author_profile": "https://Stackoverflow.com/users/26227",
"pm_score": 6,
"selected": false,
"text": "for ...\n for ...\n if(breakout_condition) \n goto final;\n\nfinal:\n"
},
{
"answer_id": 245848,
"author": "JaredPar",
"author_id": 23283,
"author_profile": "https://Stackoverflow.com/users/23283",
"pm_score": 3,
"selected": false,
"text": "#define IfFailGo(x) {hr = (x); if (FAILED(hr)) goto Error}\n...\nHRESULT SomeMethod(IFoo* pFoo) {\n HRESULT hr = S_OK;\n IfFailGo( pFoo->PerformAction() );\n IfFailGo( pFoo->SomeOtherAction() );\nError:\n return hr;\n}\n"
},
{
"answer_id": 246431,
"author": "Charles Beattie",
"author_id": 97554,
"author_profile": "https://Stackoverflow.com/users/97554",
"pm_score": 1,
"selected": false,
"text": "goto void foo()\n{\n bool doAsuccess = doA();\n bool doBsuccess = doAsuccess && doB();\n bool doCsuccess = doBsuccess && doC();\n\n if (!doCsuccess)\n {\n if (doBsuccess)\n undoB();\n if (doAsuccess)\n undoA();\n }\n}\n while(true) for (;;)\n{\n //code goes here\n}\n"
},
{
"answer_id": 21032091,
"author": "StrifeSephiroth",
"author_id": 3015167,
"author_profile": "https://Stackoverflow.com/users/3015167",
"pm_score": 0,
"selected": false,
"text": "#include <stdio.h>\n#include <string.h>\n\nint main()\n{\n char name[64];\n char url[80]; /*The final url name with http://www..com*/\n char *pName;\n int x;\n\n pName = name;\n\n INPUT:\n printf(\"\\nWrite the name of a web page (Without www, http, .com) \");\n gets(name);\n\n for(x=0;x<=(strlen(name));x++)\n if(*(pName+0) == '\\0' || *(pName+x) == ' ')\n {\n printf(\"Name blank or with spaces!\");\n getch();\n system(\"cls\");\n goto INPUT;\n }\n\n strcpy(url,\"http://www.\");\n strcat(url,name);\n strcat(url,\".com\");\n\n printf(\"%s\",url);\n return(0);\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18167/"
] |
245,747
|
<p>In SQL Server given a Table/View how can you generate a definition of the Table/View in the form:</p>
<blockquote>
<p>C1 int,<br>
C2 varchar(20),<br>
C3 double</p>
</blockquote>
<p>The information required to do it is contained in the meta-tables of SQL Server but is there a standard script / IDE faciltity to output the data contained there in the form described above ?. </p>
<p>For the curious I want this as I have to maintain a number of SP's which contain Table objects (that is a form of temporary table used by SQL Server). The Table objects need to match the definition of Tables or Views already in the database - it would make life a lot easier if these definitions could be generated automatically.</p>
|
[
{
"answer_id": 245935,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 0,
"selected": false,
"text": "select top 0\n *\ninto\n newtable\nfrom\n mytable\n"
},
{
"answer_id": 246435,
"author": "John Lemp",
"author_id": 12915,
"author_profile": "https://Stackoverflow.com/users/12915",
"pm_score": 1,
"selected": false,
"text": "select \n COLUMN_NAME, \n COLUMN_DEFAULT, \n IS_NULLABLE, \n DATA_TYPE, \n CHARACTER_MAXIMUM_LENGTH, \n NUMERIC_PRECISION, \n NUMERIC_SCALE\nfrom \n INFORMATION_SCHEMA.COLUMNS\nwhere \n TABLE_NAME = 'YOUR_TABLE_NAME_HERE' \norder by \n Ordinal_Position\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
245,765
|
<p>For example, using the answer for this question: </p>
<p><a href="https://stackoverflow.com/questions/152024/how-to-select-all-users-who-made-more-than-10-submissions">How to select all users who made more than 10 submissions</a>
"How to select all users who made more than 10 submissions."</p>
<pre><code>select userId
from submission
group by userId
having count(submissionGuid) > 10
</code></pre>
<p>Let's say now I want to know many rows this sql statement outputted. How scalable is the solution for counting the rows of counting the rows?</p>
|
[
{
"answer_id": 245769,
"author": "Dave Neeley",
"author_id": 9660,
"author_profile": "https://Stackoverflow.com/users/9660",
"pm_score": 2,
"selected": false,
"text": "select @@ROWCOUNT \n"
},
{
"answer_id": 245776,
"author": "BQ.",
"author_id": 4632,
"author_profile": "https://Stackoverflow.com/users/4632",
"pm_score": 3,
"selected": false,
"text": "select count(*) from\n (select userId\n from submission \n group by userId\n having count(submissionGuid) > 10) n\n"
},
{
"answer_id": 245786,
"author": "user12861",
"author_id": 12861,
"author_profile": "https://Stackoverflow.com/users/12861",
"pm_score": 4,
"selected": false,
"text": "\nselect count(*) from\n (select userId\n from submission \n group by userId\n having count(submissionGuid) > 10) t\n"
},
{
"answer_id": 61674782,
"author": "Apple Yellow",
"author_id": 10770048,
"author_profile": "https://Stackoverflow.com/users/10770048",
"pm_score": 0,
"selected": false,
"text": "select top(1) row_number() over(partition by count(userId) order by count(userId)) as RowNumber\nfrom submission\ngroup by userId\nhaving count(submissionGuid) > 10\norder by userId desc \n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10352/"
] |
245,766
|
<p>In a fictitious web application ...</p>
<ol>
<li>The user clicks a link </li>
<li>The server starts to prepare the response, but it takes several seconds</li>
<li>The user cancels the page load</li>
</ol>
<p>What happens to the request?
Does the server continue to prepare the response?
Does the response arrive to the browser?</p>
|
[
{
"answer_id": 245795,
"author": "Jack Leow",
"author_id": 31506,
"author_profile": "https://Stackoverflow.com/users/31506",
"pm_score": 4,
"selected": true,
"text": "java.net.SocketException: Connection reset by peer: socket write error\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14755/"
] |
245,768
|
<p>What I want to do is scroll down the window when I expand elements in my page. </p>
<p>The effect I am trying to achieve is like the Stack Overflow comments. If it expands beyond the page, it scrolls down to fit all the comments in the window.</p>
<p>What is the best way of doing this?</p>
<p>Edit: I am using JQuery.</p>
|
[
{
"answer_id": 245778,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 0,
"selected": false,
"text": "$(element).scrollTo() window.scrollTop window.scrollLeft"
},
{
"answer_id": 246624,
"author": "Diodeus - James MacFarlane",
"author_id": 12579,
"author_profile": "https://Stackoverflow.com/users/12579",
"pm_score": 0,
"selected": false,
"text": "new Effect.ScrollTo('someDiv',{...some parameters...})\n"
},
{
"answer_id": 303564,
"author": "Pim Jager",
"author_id": 35197,
"author_profile": "https://Stackoverflow.com/users/35197",
"pm_score": 0,
"selected": false,
"text": "function scrollTo( Selector ){\n $(Selector).before(\"<a name='scroll' id='scroll'></a>\");\n document.location.hash = 'scroll';\n $('scroll').remove();\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131/"
] |
245,783
|
<p>Like, let's say I had a tree structure, then I would use, naturally a tree control, since that GUI element maps perfectly to the structure.</p>
<p>But what I have is a graph, potentially too wide to fit in one web page. I can't think of examples of GUIs that really match the structure. Some ideas I have that don't quite fit are, the web itself, with hyperlinks, the browser back button, and the forward button. But that just shows you one node at a time. I would like to display as many nodes as I can, and allow navigation to a new area of the graph. Something like Google maps might be a good model, in that you have full freedom to scroll in any direction.</p>
|
[
{
"answer_id": 245796,
"author": "mipadi",
"author_id": 28804,
"author_profile": "https://Stackoverflow.com/users/28804",
"pm_score": 2,
"selected": false,
"text": "<canvas> <canvas>"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9328/"
] |
245,787
|
<p>Whenever I run any jython program in Eclipse, I got the following error in the beginning of the output: </p>
<blockquote>
<p>" Failed to
get environment, environ will be
empty: (0, 'Failed to execute command
([\'sh\', \'-c\', \'env\']):
java.io.IOException: Cannot run
program "sh": Crea teProcess error=2,
The system cannot find the file
specified')</p>
</blockquote>
<p>First, my environment is:</p>
<p>Windows 2008</p>
<p>JDK 1.6.0u10</p>
<p>jython 2.2.1</p>
<p>I did some digging, and I realized that this message is produced in the function javaos.getenv().
Whenever I call the javaos.getenv() function, it throws the following error:</p>
<p>C:\jython2.2.1>java -jar jython.jar</p>
<blockquote>
<blockquote>
<blockquote>
<p>import javaos</p>
<p>print javaos.getenv("user.name")</p>
</blockquote>
</blockquote>
<p>Failed to get environment, environ
will be empty: (0, 'Failed to execute
command ([\'sh\', \'-c\', \'env\']):
java.io.IOException: Cannot run
program "sh": Crea teProcess error=2,
The system cannot find the file
specified')</p>
</blockquote>
<p>This is strange, because I'm currently using a Windows machine, not an Unix.</p>
|
[
{
"answer_id": 246176,
"author": "Blauohr",
"author_id": 22176,
"author_profile": "https://Stackoverflow.com/users/22176",
"pm_score": 3,
"selected": true,
"text": "# python.os determines operating-specific features, similar to and overriding the\n# Java property \"os.name\".\n# Some generic values are also supported: 'nt', 'ce' and 'posix'.\n# Uncomment the following line for the most generic OS behavior available.\n#python.os=None\npython.os=nt\n# try nt or dos\n"
},
{
"answer_id": 2336254,
"author": "deeeptext",
"author_id": 173954,
"author_profile": "https://Stackoverflow.com/users/173954",
"pm_score": 0,
"selected": false,
"text": "C:\\eclipse-platform-3.5-win32\\eclipse\\plugins\\org.python.pydev.jython_1.4.8.2881\\Lib def _getOsType( os=None ):\n os = os or sys.registry.getProperty( \"python.os\" ) or \\\n java.lang.System.getProperty( \"os.name\" )\n\n_osTypeMap = (\n ( \"nt\", r\"(nt)|(Windows NT)|(Windows NT 4.0)|(WindowsNT)|\"\n r\"(Windows 2000)|(Windows XP)|(Windows CE)|(Windows Vista)\" ),\n ( \"dos\", r\"(dos)|(Windows 95)|(Windows 98)|(Windows ME)\" ),\n ( \"mac\", r\"(mac)|(MacOS.*)|(Darwin)\" ),\n ( \"None\", r\"(None)\" ),\n ( \"posix\", r\"(.*)\" ), # default - posix seems to vary mast widely\n )\nfor osType, pattern in _osTypeMap:\n if re.match( pattern, os ):\n break\nreturn osType\n"
},
{
"answer_id": 8359361,
"author": "Dave Patterson",
"author_id": 88556,
"author_profile": "https://Stackoverflow.com/users/88556",
"pm_score": 0,
"selected": false,
"text": "try:\n import javaos\n if javaos._osType == 'posix' and \\\n java.lang.System.getProperty('os.name').startswith('Windows'):\n sys.registry.setProperty('python.os', 'nt')\n reload(javaos)\nexcept:\n pass\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245787",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32267/"
] |
245,792
|
<p>This is rather the inverse of <a href="https://stackoverflow.com/questions/102535/what-can-you-use-python-generator-functions-for">What can you use Python generator functions for?</a>: python generators, generator expressions, and the <code>itertools</code> module are some of my favorite features of python these days. They're especially useful when setting up chains of operations to perform on a big pile of data--I often use them when processing DSV files.</p>
<p><strong>So when is it <em>not</em> a good time to use a generator, or a generator expression, or an <code>itertools</code> function?</strong></p>
<ul>
<li>When should I prefer <code>zip()</code> over <code>itertools.izip()</code>, or</li>
<li><code>range()</code> over <code>xrange()</code>, or</li>
<li><code>[x for x in foo]</code> over <code>(x for x in foo)</code>?</li>
</ul>
<p>Obviously, we eventually need to "resolve" a generator into actual data, usually by creating a list or iterating over it with a non-generator loop. Sometimes we just need to know the length. This isn't what I'm asking.</p>
<p>We use generators so that we're not assigning new lists into memory for interim data. This especially makes sense for large datasets. Does it make sense for small datasets too? Is there a noticeable memory/cpu trade-off?</p>
<p>I'm especially interested if anyone has done some profiling on this, in light of the eye-opening discussion of <a href="http://www.gossamer-threads.com/lists/python/python/76267" rel="noreferrer">list comprehension performance vs. map() and filter()</a>. (<a href="https://mail.python.org/pipermail//python-list/2001-December/096256.html" rel="noreferrer">alt link</a>)</p>
|
[
{
"answer_id": 245797,
"author": "Steven Huwig",
"author_id": 28604,
"author_profile": "https://Stackoverflow.com/users/28604",
"pm_score": 4,
"selected": false,
"text": "zip izip range xrange range xrange zip izip list(frob(x) for x in foo)"
},
{
"answer_id": 247527,
"author": "Jeremy Cantrell",
"author_id": 18866,
"author_profile": "https://Stackoverflow.com/users/18866",
"pm_score": 2,
"selected": false,
"text": "sorted(xrange(5))\n sorted(range(5))\n"
},
{
"answer_id": 255570,
"author": "Ryan Ginstrom",
"author_id": 10658,
"author_profile": "https://Stackoverflow.com/users/10658",
"pm_score": 3,
"selected": false,
"text": "import psyco\nimport time\nimport cStringIO\n\ndef time_func(func):\n \"\"\"The amount of time it requires func to run\"\"\"\n start = time.clock()\n func()\n return time.clock() - start\n\ndef fizzbuzz(num):\n \"\"\"That algorithm we all know and love\"\"\"\n if not num % 3 and not num % 5:\n return \"%d fizz buzz\" % num\n elif not num % 3:\n return \"%d fizz\" % num\n elif not num % 5:\n return \"%d buzz\" % num\n return None\n\ndef with_list(num):\n \"\"\"Try getting fizzbuzz with a list comprehension and range\"\"\"\n out = cStringIO.StringIO()\n for fibby in [fizzbuzz(x) for x in range(1, num) if fizzbuzz(x)]:\n print >> out, fibby\n return out.getvalue()\n\ndef with_genx(num):\n \"\"\"Try getting fizzbuzz with generator expression and xrange\"\"\"\n out = cStringIO.StringIO()\n for fibby in (fizzbuzz(x) for x in xrange(1, num) if fizzbuzz(x)):\n print >> out, fibby\n return out.getvalue()\n\ndef main():\n \"\"\"\n Test speed of generator expressions versus list comprehensions,\n with and without psyco.\n \"\"\"\n\n #our variables\n nums = [10000, 100000]\n funcs = [with_list, with_genx]\n\n # try without psyco 1st\n print \"without psyco\"\n for num in nums:\n print \" number:\", num\n for func in funcs:\n print func.__name__, time_func(lambda : func(num)), \"seconds\"\n print\n\n # now with psyco\n print \"with psyco\"\n psyco.full()\n for num in nums:\n print \" number:\", num\n for func in funcs:\n print func.__name__, time_func(lambda : func(num)), \"seconds\"\n print\n\nif __name__ == \"__main__\":\n main()\n without psyco\n number: 10000\nwith_list 0.0519102208309 seconds\nwith_genx 0.0535933367509 seconds\n\n number: 100000\nwith_list 0.542204280744 seconds\nwith_genx 0.557837353115 seconds\n\nwith psyco\n number: 10000\nwith_list 0.0286369007033 seconds\nwith_genx 0.0513424889137 seconds\n\n number: 100000\nwith_list 0.335414877839 seconds\nwith_genx 0.580363490491 seconds\n"
},
{
"answer_id": 26635939,
"author": "Raymond Hettinger",
"author_id": 424499,
"author_profile": "https://Stackoverflow.com/users/424499",
"pm_score": 7,
"selected": true,
"text": "for i in outer: # used once, okay to be a generator or return a list\n for j in inner: # used multiple times, reusing a list is better\n ...\n for i in reversed(data): ... # generators aren't reversible\n\ns[i], s[j] = s[j], s[i] # generators aren't indexable\n s = ''.join(data) # lists are faster than generators in this use case\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18950/"
] |
245,798
|
<p>I use screen to persist my work session and connect to the same session from multiple machines. How can I setup SSH and screen such that the XDISPLAY variable <em>inside</em> my persistent screen session is always set to the machine I am currently connecting from?</p>
<p>ie. I start the screen session at work and use gvim, which uses the X server running on my work machine. Later, I connect to the same session from home and also want to use gvim. But this time, I want gvim to use the X server on my home machine. I realize I could manually update XDISPLAY every time I connect from a different machine but I'd rather have an automated system.</p>
<p>Bonus points if I can actually <em>move</em> gvim from my work machine to my home machine while it is running. I tried <a href="http://manpages.ubuntu.com/manpages/hardy/man1/xmove.html" rel="nofollow noreferrer">xmove</a> but could never get it to play nice.</p>
|
[
{
"answer_id": 246046,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 2,
"selected": false,
"text": "XDISPLAY PROMPT_COMMAND X11vnc Xvnc"
},
{
"answer_id": 670984,
"author": "rampion",
"author_id": 9859,
"author_profile": "https://Stackoverflow.com/users/9859",
"pm_score": 4,
"selected": true,
"text": "screen -X # set future remote shells started by screen to have the correct XDISPLAY\n% screen -X \"setenv XDISPLAY $DISPLAY\" #...\n\n# set up the keystroke F1 to update the XDISPLAY in current shells\n% screen -X \"bindkey -k k1 stuff export XDISPLAY=$DISPLAY\\015\" #...\n :at XDISPLAY # update the XDISPLAY in all current windows\n% screen -X \"at % stuff export XDISPLAY=$DISPLAY\\015\" #...\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26715/"
] |
245,802
|
<p>I am using fscanf to read a file which has lines like<br>
Number <-whitespace-> string <-whitespace-> optional_3rd_column </p>
<p>I wish to extract the number and string out of each column, but ignore the 3rd_column if it exists</p>
<p>Example Data:<br>
12 foo something<br>
03 bar<br>
24 something #randomcomment</p>
<p>I would want to extract 12,foo; 03,bar; 24, something while ignoring "something" and "#randomcomment"</p>
<p>I currently have something like</p>
<pre><code>while(scanf("%d %s %*s",&num,&word)>=2)
{
assign stuff
}
</code></pre>
<p>However this does not work with lines with no 3rd column. How can I make it ignore everything after the 2nd string?</p>
|
[
{
"answer_id": 245845,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 4,
"selected": false,
"text": "%*s %d gets() sscanf() while(scanf(\"%d %s%*[^\\n]\", &num, &word) == 2)\n{ \n assign stuff \n} [^\\n] * %s %*[\\n] %*[\\n]"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25990/"
] |
245,803
|
<p>I have recently discovered the incredibly useful <a href="http://www.eclipse.org/mat/" rel="nofollow noreferrer">Eclipse Memory Analysis Tool</a>, which makes quick work of finding memory leaks in Java applications. Unfortunately, after switching my JDK to 1.6 (under Mac OS 10.5), the JVM terminates immediately upon startup. All that appears is a dialog stating "JVM terminated" with "Exit code = -1".</p>
<p>Anyone else encounter this one? Perhaps there is a way to configure it to use a different JDK? (such as 1.5: which it was shown to be compatible with)</p>
|
[
{
"answer_id": 246883,
"author": "Turismo",
"author_id": 5271,
"author_profile": "https://Stackoverflow.com/users/5271",
"pm_score": 3,
"selected": true,
"text": "eclipse -vm <path to java>\n <!-- to use a specific Java version (instead of the platform's default) uncomment one of the following options:\n <string>-vm</string><string>/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Commands/java</string>\n <string>-vm</string><string>/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java</string>\n-->\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9931/"
] |
245,825
|
<p>What does <code>InitializeComponent()</code> do, and how does it work in WPF?</p>
<p>In general first, but I would especially be interested to know the gory details of order of construction, and what happens when there are Attached Properties.</p>
|
[
{
"answer_id": 245881,
"author": "Brad Leach",
"author_id": 708,
"author_profile": "https://Stackoverflow.com/users/708",
"pm_score": 8,
"selected": true,
"text": "InitializeComponent() Window UserControl Window UserControl System.Windows.Application.LoadComponent() LoadComponent() LoadComponent XamlParser XamlParser.ProcessXamlNode() BamlRecordWriter InitializeComponent System.Windows.Markup.IComponentConnector Window UserControl"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/234288/"
] |
245,827
|
<p>I have a legacy app where it reads message from a client program from file descriptor 3. This is an external app so I cannot change this. The client is written in C#. How can we open a connection to a specific file descriptor in C#? Can we use something like AnonymousPipeClientStream()? But how do we specify the file descriptor to connect to?</p>
|
[
{
"answer_id": 493768,
"author": "Tamas Czinege",
"author_id": 8954,
"author_profile": "https://Stackoverflow.com/users/8954",
"pm_score": 3,
"selected": false,
"text": "// nativeHandle is the WINAPI handle you have acquired with the P/Invoke call\nSafeFileHandle safeHandle = new SafeFileHandle(nativeHandle, true);\n Stream stream = new FileStream(safeHandle, FileAccess.ReadWrite);\n"
},
{
"answer_id": 43494635,
"author": "Tim Cooper",
"author_id": 142162,
"author_profile": "https://Stackoverflow.com/users/142162",
"pm_score": 2,
"selected": false,
"text": "_get_osfhandle using System;\nusing System.IO;\nusing Microsoft.Win32.SafeHandles;\nusing System.Runtime.InteropServices;\n\nclass Comm : IDisposable\n{\n [DllImport(\"MSVCRT.DLL\", CallingConvention = CallingConvention.Cdecl)]\n extern static IntPtr _get_osfhandle(int fd);\n\n public readonly Stream Stream;\n\n public Comm(int fd)\n {\n var handle = _get_osfhandle(fd);\n if (handle == IntPtr.Zero || handle == (IntPtr)(-1) || handle == (IntPtr)(-2))\n {\n throw new ApplicationException(\"invalid handle\");\n }\n\n var fileHandle = new SafeFileHandle(handle, true);\n Stream = new FileStream(fileHandle, FileAccess.ReadWrite);\n }\n\n public void Dispose()\n {\n Stream.Dispose();\n } \n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
245,834
|
<p>I usually hate posting these types of questions as normally I find that the best way to really learn is to figure out the answer yourself. </p>
<p>However, I need an answer to this question really quickly as I have a client who can't run her business due to this problem.</p>
<p>Yesterday my ASP.NET host provider moved my application from a server running .NET 1.1 to one running .NET 1.1 and 2.0. My problem is that when I test the move the main site page (Default.aspx) will not load </p>
<p><strong>"Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.</strong> </p>
<p><strong>Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."</strong></p>
<p><strong>[SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +59
System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint) +147
System.Net.HttpRequestCreator.Create(Uri Uri) +26
System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) +298
System.Net.WebRequest.Create(Uri requestUri) +28
System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri uri) +30
System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest(Uri uri) +12
System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri uri) +4
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +52
PilatesPlusDublin.PilatesPlusDublinws.PilatesPlus.InsertException(String sModuleName, String sException, Int32 iUserID) +97
PilatesPlusDublin.MainDefault.Page_Load(Object sender, EventArgs e) +144
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.maindefault_aspx.ProcessRequest(HttpContext context) +4
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64"</strong></p>
<p>If WebPermission isn't available at the hosting site, how do I configure my site to allow access to the page? Is there some tags that need to be put into the web.config? Note - we have no access to machine.config or any other IIS settings. </p>
<p>I understand that people hate reading and answering these types of question but any help on what I, or my hosting site need to do to fix this would be appreciated enormously </p>
|
[
{
"answer_id": 270736,
"author": "Mun",
"author_id": 775,
"author_profile": "https://Stackoverflow.com/users/775",
"pm_score": 3,
"selected": false,
"text": "<trust level=\"Full\" />\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26300/"
] |
245,835
|
<p>I have a site behind basic authentication (IIS6).</p>
<p>Part of this site calls a web service that is also part of the site and thus behind basic authentication as well.</p>
<p>However, when this happens the calling code receives a 401 Authentication Error.</p>
<p>I've tried a couple of things, with the general recommendation being code like this:</p>
<pre><code>Service.ServiceName s = new Service.ServiceName();
s.PreAuthenticate = true;
s.Credentials = System.Net.CredentialCache.DefaultCredentials;
s.Method("Test");
</code></pre>
<p>However, this does not seem to resolve my problem.</p>
<p>Any advice?</p>
<p><strong>Edit</strong></p>
<p>This seems to be a not uncommon issue but so far I have found no solutions.
Here is <a href="http://forums.iis.net/t/1146546.aspx" rel="nofollow noreferrer">one thread</a> on the topic.</p>
|
[
{
"answer_id": 245946,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 0,
"selected": false,
"text": "s.Credentials = System.Net.CredentialCache.DefaultCredentials(); s.Credentials = HttpContext.Current.User.Identity;"
},
{
"answer_id": 248752,
"author": "Matt Mitchell",
"author_id": 364,
"author_profile": "https://Stackoverflow.com/users/364",
"pm_score": 3,
"selected": true,
"text": "public static void ServiceCall(Page p)\n{\n LocalServices.ServiceName s = new LocalServices.ServiceName();\n s.PreAuthenticate = true; /* Not sure if required */\n\n string username = \"\";\n string password = \"\";\n string domain = \"\";\n GetBasicCredentials(p, ref username, ref password, ref domain);\n\n s.Credentials = new NetworkCredential(username, password, domain);\n s.ServiceMethod();\n}\n\n\n/* Converted from: http://forums.asp.net/t/1172902.aspx */\nprivate static void GetBasicCredentials(Page p, ref string rstrUser, ref string rstrPassword, ref string rstrDomain)\n{\n if (p == null)\n {\n return;\n }\n\n rstrUser = \"\";\n rstrPassword = \"\";\n rstrDomain = \"\";\n\n rstrUser = p.Request.ServerVariables[\"AUTH_USER\"];\n rstrPassword = p.Request.ServerVariables[\"AUTH_PASSWORD\"];\n\n SplitDomainUserName(rstrUser, ref rstrDomain, ref rstrUser);\n\n /* MSDN KB article 835388\n BUG: The Request.ServerVariables(\"AUTH_PASSWORD\") object does not display certain characters from an ASPX page */\n string lstrHeader = p.Request.ServerVariables[\"HTTP_AUTHORIZATION\"];\n if (!string.IsNullOrEmpty(lstrHeader) && lstrHeader.StartsWith(\"Basic\"))\n {\n string lstrTicket = lstrHeader.Substring(6);\n lstrTicket = System.Text.Encoding.Default.GetString(Convert.FromBase64String(lstrTicket));\n rstrPassword = lstrTicket.Substring((lstrTicket.IndexOf(\":\") + 1));\n }\n\n /* At least on my XP Pro machine AUTH_USER is not set (probably because we're using Forms authentication \n But if the password is set (either by AUTH_PASSWORD or HTTP_AUTHORIZATION)\n then we can use LOGON_USER*/\n if (string.IsNullOrEmpty(rstrUser) && !string.IsNullOrEmpty(rstrPassword))\n {\n rstrUser = p.Request.ServerVariables[\"LOGON_USER\"];\n SplitDomainUserName(rstrUser, ref rstrDomain, ref rstrUser);\n }\n}\n\n/* Converted from: http://forums.asp.net/t/1172902.aspx */\nprivate static void SplitDomainUserName(string pstrDomainUserName, ref string rstrDomainName, ref string rstrUserName)\n{\n rstrDomainName = \"\";\n rstrUserName = pstrDomainUserName;\n\n int lnSlashPos = pstrDomainUserName.IndexOf(\"\\\\\");\n if (lnSlashPos > 0)\n {\n rstrDomainName = pstrDomainUserName.Substring(0, lnSlashPos);\n rstrUserName = pstrDomainUserName.Substring(lnSlashPos + 1);\n }\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] |
245,838
|
<p>Ok so I thought it was fixed, but I'm getting totally inconsistent results.
I rewrote it kind of from scratch to start fresh and here are my results. I get no errors, no crashing, it just doesn't remove them. It just totally messes up the tree and gives me a ton more leaves, and mixes everything up. Not sure where else to go</p>
<pre><code>template <class T>
void BST<T>::remove(struct Node<T>*& root, const T& x)
{
Node<T>* ptr = root;
bool found = false;
Node<T>* parent;
while (ptr != NULL && !found)
{
if (x < ptr->data)
{
parent = ptr;
ptr = ptr->left;
}
else if (x > ptr->data)
{
parent = ptr;
ptr = ptr->right;
}
else
found = true;
}
if (found == false)
return;
else
{
if(ptr->left != NULL && ptr->right != NULL)
{
Node<T>* inOrderPtr = ptr->left;
parent = ptr;
while (inOrderPtr->right != NULL)
{
parent = inOrderPtr;
inOrderPtr = inOrderPtr->right;
}
ptr->data = inOrderPtr->data;
ptr = inOrderPtr;
}
Node<T>* subPtr = ptr->left;
if (subPtr == NULL)
subPtr = ptr->right;
else if (parent->left == ptr)
parent->left = subPtr;
else
parent->right = subPtr;
delete ptr;
}
</code></pre>
|
[
{
"answer_id": 245883,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 0,
"selected": false,
"text": "remove() parent root data remove"
},
{
"answer_id": 245928,
"author": "Greg Rogers",
"author_id": 5963,
"author_profile": "https://Stackoverflow.com/users/5963",
"pm_score": 1,
"selected": true,
"text": "Node<T> *tmp_r = root->left;\nNode<T> *parent = root;\nwhile (tmp_r->right != NULL)\n{\n parent = tmp_r;\n tmp_r = tmp_r->right;\n}\nNode<T> *tmp_l = tmp_r;\nwhile (tmp_l->left != NULL)\n tmp_l = tmp_l->left;\n\ntmp_l->left = root->left;\ntmp_r->right = root->right;\nparent->right = NULL;\n\nparent = root;\nroot = tmp_r;\ndelete parent;\n"
},
{
"answer_id": 246019,
"author": "Doug",
"author_id": 28392,
"author_profile": "https://Stackoverflow.com/users/28392",
"pm_score": 1,
"selected": false,
"text": "if (root->data < x)\n remove(root->left, x);\n else \n remove(root->right, x);\n if(x < root->data)\nremove(root->left, x);\nelse\nremove(root->right, x);\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28392/"
] |
245,840
|
<p>Is there any way of batch renaming files in sub directories?</p>
<p>For example:</p>
<p>Rename <code>*.html</code> to <code>*.htm</code> in a folder which has directories and sub directories.</p>
|
[
{
"answer_id": 245854,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 3,
"selected": false,
"text": "for x in $(find . -name \\*.html); do\n mv $x $(echo \"$x\" | sed 's/\\.html$/.htm/')\ndone\n"
},
{
"answer_id": 245857,
"author": "albertb",
"author_id": 26715,
"author_profile": "https://Stackoverflow.com/users/26715",
"pm_score": 2,
"selected": false,
"text": "for f in $(find . -type f -name '*.html'); do \n mv $f $(echo \"$f\" | sed 's/html$/htm/')\ndone\n"
},
{
"answer_id": 245862,
"author": "Anonymous",
"author_id": 19650,
"author_profile": "https://Stackoverflow.com/users/19650",
"pm_score": 8,
"selected": true,
"text": "for /r %x in (*.html) do ren \"%x\" *.htm\n for /r %x in (website*.html) do ren \"%x\" site*.htm\n"
},
{
"answer_id": 245864,
"author": "Aditya Mukherji",
"author_id": 25990,
"author_profile": "https://Stackoverflow.com/users/25990",
"pm_score": 3,
"selected": false,
"text": "find . -regex \".*html$\" | while read line;\n do \n A=`basename ${line} | sed 's/html$/htm/g'`;\n B=`dirname ${line}`;\n mv ${line} \"${B}/${A}\";\n done\n"
},
{
"answer_id": 245874,
"author": "monkut",
"author_id": 24718,
"author_profile": "https://Stackoverflow.com/users/24718",
"pm_score": 3,
"selected": false,
"text": "import os\n\ntarget_dir = \".\"\n\nfor path, dirs, files in os.walk(target_dir):\n for file in files:\n filename, ext = os.path.splitext(file)\n new_file = filename + \".htm\"\n\n if ext == '.html':\n old_filepath = os.path.join(path, file)\n new_filepath = os.path.join(path, new_file)\n os.rename(old_filepath, new_filepath)\n"
},
{
"answer_id": 246015,
"author": "Alex",
"author_id": 30181,
"author_profile": "https://Stackoverflow.com/users/30181",
"pm_score": 0,
"selected": false,
"text": "ls dir_path/. | awk -F\".\" '{print \"mv file_name/\"$0\" dir_path/\"$1\".new_extension\"}' |csh\n"
},
{
"answer_id": 248147,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "In bash use command rename :)\n\n rename 's/\\.htm$/.html/' *.htm\n\n # or\n\n find . -name '*.txt' -print0 | xargs -0 rename 's/.txt$/.xml/'\n\n #Obs1: Above I use regex \\. --> literal '.' and $ --> end of line\n #Obs2: Use find -maxdepht 'value' for determine how recursive is\n #Obs3: Use -print0 to avoid 'names spaces asdfa' crash!\n"
},
{
"answer_id": 1783273,
"author": "BBX",
"author_id": 217038,
"author_profile": "https://Stackoverflow.com/users/217038",
"pm_score": 3,
"selected": false,
"text": "forfiles /S /M *.HTM /C \"cmd /c ren @file *.HTML\"\n"
},
{
"answer_id": 37085847,
"author": "Jahid",
"author_id": 3744681,
"author_profile": "https://Stackoverflow.com/users/3744681",
"pm_score": 0,
"selected": false,
"text": "rnm -rs '/\\.html$/.htm/' -fo -dp -1 *\n rnm -ns '/n/.htm' -ss '\\.html$' -fo -dp -1 *\n -ns /n/ -ss -rs /search_regex/replace_part/modifier -fo -dp"
},
{
"answer_id": 73785580,
"author": "vilem cech",
"author_id": 15067478,
"author_profile": "https://Stackoverflow.com/users/15067478",
"pm_score": 0,
"selected": false,
"text": "forfiles /? forfiles /S /M *.html /C \"cmd /c rename @file @fname.htm\"\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12178/"
] |
245,856
|
<p>For general code, do I really need to dispose an object? Can I just ignore it for the most part or is it a good idea to always dispose an object when your 100% sure you don't need it anymore? </p>
|
[
{
"answer_id": 245863,
"author": "John Sheehan",
"author_id": 1786,
"author_profile": "https://Stackoverflow.com/users/1786",
"pm_score": 4,
"selected": false,
"text": "using (SqlCommand cmd = new SqlCommand(conn)) {\n cmd.ExecuteNonQuery();\n}\n"
},
{
"answer_id": 245865,
"author": "berko",
"author_id": 4884,
"author_profile": "https://Stackoverflow.com/users/4884",
"pm_score": -1,
"selected": false,
"text": "using (var conn = new SqlConnection(connString)) {}\n"
},
{
"answer_id": 245896,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 3,
"selected": false,
"text": "Dispose() IDisposable using"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10352/"
] |
245,866
|
<p>Given a System.Timers.Timer, is there a way from the main thread to tell if the worker thread running the elapsed event code is still running?</p>
<p>In other words, how can one make sure the code running in the worker thread is not currently running before stopping the timer or the main app/service thread the timer is running in?</p>
<p>Is this a matter of ditching Timer for threading timer using state, or is it just time to use threads directly?</p>
|
[
{
"answer_id": 246013,
"author": "sliderhouserules",
"author_id": 31385,
"author_profile": "https://Stackoverflow.com/users/31385",
"pm_score": 2,
"selected": true,
"text": "// main thread owns this\nprivate List<ManualResetEvent> _resetEvents;\n...\n// main thread does this to wait for executing threads to finish\nWaitHandle.WaitAll(_resetEvents.ToArray(), 2000, false)\n...\n// worker threads do this to signal the thread is done\nmyResetEvent.Set();\n ...\nThreadPool.QueueUserWorkItem(new WaitCallback(MyWorkerDelegate),\n myCustomObjectThatContainsAResetEvent);\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245866",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91911/"
] |
245,868
|
<p>I have seen the following methods of putting JavaScript code in an <code><a></code> tag:</p>
<pre><code>function DoSomething() { ... return false; }
</code></pre>
<ol>
<li><code><a href="javascript:;" onClick="return DoSomething();">link</a></code></li>
<li><code><a href="javascript:DoSomething();">link</a></code></li>
<li><code><a href="javascript:void(0);" onClick="return DoSomething();">link</a></code></li>
<li><code><a href="#" onClick="return DoSomething();">link</a></code></li>
</ol>
<p>I understand the idea of trying to put a valid URL instead of just JavaScript code, just in case the user doesn't have JavaScript enabled. But for the purpose of this discussion, I need to assume JavaScript is enabled (they can't login without it).</p>
<p>I personally like option 2 as it allows you to see what's going to be run–especially useful when debuging where there are parameters being passed to the function. I have used it quite a bit and haven't found browser issues.</p>
<p>I have read that people recommend 4, because it gives the user a real link to follow, but really, # isn't "real". It will go absolutely no where.</p>
<p>Is there one that isn't support or is really bad, when you know the user has JavaScript enabled?</p>
<p>Related question: <em><a href="https://stackoverflow.com/questions/134845/href-for-javascript-links-or-javascriptvoid0">Href for JavaScript links: “#” or “javascript:void(0)”?</a></em>.</p>
|
[
{
"answer_id": 245886,
"author": "eyelidlessness",
"author_id": 17964,
"author_profile": "https://Stackoverflow.com/users/17964",
"pm_score": 3,
"selected": false,
"text": "addEventListener attachEvent href <a> <button>"
},
{
"answer_id": 245888,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 3,
"selected": false,
"text": "5: <a href=\"#\" id=\"myLink\">Link</a>\n document.getElementById('myLink').onclick = function() {\n // Do stuff.\n};\n"
},
{
"answer_id": 245889,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<a href=\"#\" onClick=\"DoSomething(); return false;\">link</a>\n <a href=\"#\" id = \"Link\">link</a>\n(document.getElementById(\"Link\")).onclick = function() {\n DoSomething();\n return false;\n};\n"
},
{
"answer_id": 245898,
"author": "cowgod",
"author_id": 6406,
"author_profile": "https://Stackoverflow.com/users/6406",
"pm_score": 7,
"selected": true,
"text": "href href <a href=\"javascript_required.html\" onclick=\"doSomething(); return false;\">go</a>\n"
},
{
"answer_id": 22793173,
"author": "JoelFan",
"author_id": 16012,
"author_profile": "https://Stackoverflow.com/users/16012",
"pm_score": 1,
"selected": false,
"text": "<a class=\"actor\" href=\"javascript:act1()\">Click me</a>\n <a class=\"actor\" onclick=\"act1();\">Click me</a>\n <script>$('.actor').click(act2);</script>\n act2 act1"
},
{
"answer_id": 23977642,
"author": "Timo Huovinen",
"author_id": 175071,
"author_profile": "https://Stackoverflow.com/users/175071",
"pm_score": 1,
"selected": false,
"text": "<!DOCTYPE html>\n<html>\n<head>\n<script type=\"text/javascript\">\n(function(doc){\n var hasClass = function(el,className) {\n return (' ' + el.className + ' ').indexOf(' ' + className + ' ') > -1;\n }\n doc.addEventListener('click', function(e){\n if(hasClass(e.target, 'click-me')){\n e.preventDefault();\n doSomething.call(e.target, e);\n }\n });\n})(document);\n\nfunction doSomething(event){\n console.log(this); // this will be the clicked element\n}\n</script>\n<!--... other head stuff ...-->\n</head>\n<body>\n\n<!--buttons can be used outside of forms https://stackoverflow.com/a/14461672/175071 -->\n<button class=\"click-me\">Button 1</button>\n<input class=\"click-me\" type=\"button\" value=\"Button 2\">\n\n</body>\n</html>\n <!DOCTYPE html>\n<html>\n<head>\n<script type=\"text/javascript\">\n(function(doc){\n var cb_addEventListener = function(obj, evt, fnc) {\n // W3C model\n if (obj.addEventListener) {\n obj.addEventListener(evt, fnc, false);\n return true;\n } \n // Microsoft model\n else if (obj.attachEvent) {\n return obj.attachEvent('on' + evt, fnc);\n }\n // Browser don't support W3C or MSFT model, go on with traditional\n else {\n evt = 'on'+evt;\n if(typeof obj[evt] === 'function'){\n // Object already has a function on traditional\n // Let's wrap it with our own function inside another function\n fnc = (function(f1,f2){\n return function(){\n f1.apply(this,arguments);\n f2.apply(this,arguments);\n }\n })(obj[evt], fnc);\n }\n obj[evt] = fnc;\n return true;\n }\n return false;\n };\n var hasClass = function(el,className) {\n return (' ' + el.className + ' ').indexOf(' ' + className + ' ') > -1;\n }\n\n cb_addEventListener(doc, 'click', function(e){\n if(hasClass(e.target, 'click-me')){\n e.preventDefault ? e.preventDefault() : e.returnValue = false;\n doSomething.call(e.target, e);\n }\n });\n})(document);\n\nfunction doSomething(event){\n console.log(this); // this will be the clicked element\n}\n</script>\n<!--... other head stuff ...-->\n</head>\n<body>\n\n<!--buttons can be used outside of forms https://stackoverflow.com/a/14461672/175071 -->\n<button class=\"click-me\">Button 1</button>\n<input class=\"click-me\" type=\"button\" value=\"Button 2\">\n\n</body>\n</html>\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5441/"
] |
245,878
|
<p>So if I have to choose between a hash table or a prefix tree what are the discriminating factors that would lead me to choose one over the other. From my own naive point of view it seems as though using a trie has some extra overhead since it isn't stored as an array but that in terms of run time (assuming the longest key is the longest english word) it can be essentially O(1) (in relation to the upper bound). Maybe the longest english word is 50 characters?</p>
<p>Hash tables are instant look up <em>once you get the index</em>. Hashing the key to get the index however seems like it could easily take near 50 steps.</p>
<p>Can someone provide me a more experienced perspective on this? Thanks!</p>
|
[
{
"answer_id": 26404720,
"author": "user3391564",
"author_id": 3391564,
"author_profile": "https://Stackoverflow.com/users/3391564",
"pm_score": 3,
"selected": false,
"text": "O(k) k"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9401/"
] |
245,882
|
<p>I have a vba macro which runs a loop for about 200 iterations, using up the ram page file as it runs.</p>
<p>I need some kind of quick fix to clear the page file after every iteration. I know the best fix would be to clean up the code, but time is a constraint here.</p>
|
[
{
"answer_id": 245921,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 2,
"selected": false,
"text": "Nothing"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
245,916
|
<p>What is the best way to extract the MAC address from <code>ifconfig</code>'s output?</p>
<p>Sample output:</p>
<pre><code>bash-3.00# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 1F:2E:19:10:3B:52
inet addr:127.0.0.66 Bcast:127.255.255.255 Mask:255.0.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
....
....
</code></pre>
<p>Should I use cut, <a href="http://en.wikipedia.org/wiki/AWK" rel="noreferrer">AWK</a> or anything else, and what are the merits and demerits of one method over the other.</p>
|
[
{
"answer_id": 245923,
"author": "albertb",
"author_id": 26715,
"author_profile": "https://Stackoverflow.com/users/26715",
"pm_score": 3,
"selected": false,
"text": "ifconfig eth0 | awk '/HWaddr/ {print $5}'\n"
},
{
"answer_id": 245925,
"author": "Robert Gamble",
"author_id": 25222,
"author_profile": "https://Stackoverflow.com/users/25222",
"pm_score": 6,
"selected": false,
"text": "ifconfig eth0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'\n [[:xdigit:]]{1,2}"
},
{
"answer_id": 246523,
"author": "Jerub",
"author_id": 14648,
"author_profile": "https://Stackoverflow.com/users/14648",
"pm_score": 5,
"selected": false,
"text": "$ ip link show eth0\n2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000\n link/ether 00:0c:29:30:21:48 brd ff:ff:ff:ff:ff:ff\n $ ip link show eth0 | awk '/ether/ {print $2}'\n00:0c:29:30:21:48\n $ ip -o link \n1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue \\ link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000\\ link/ether 00:0c:29:30:21:48 brd ff:ff:ff:ff:ff:ff\n3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000\\ link/ether 00:0c:29:30:21:52 brd ff:ff:ff:ff:ff:ff\n4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 100\\ link/[65534] \n5: sit0: <NOARP> mtu 1480 qdisc noop \\ link/sit 0.0.0.0 brd 0.0.0.0\n"
},
{
"answer_id": 4986764,
"author": "xebeche",
"author_id": 196133,
"author_profile": "https://Stackoverflow.com/users/196133",
"pm_score": 2,
"selected": false,
"text": "x=$(ifconfig eth0) && x=${x#*HWaddr } && echo ${x%% *}\n"
},
{
"answer_id": 5959167,
"author": "phoxis",
"author_id": 702361,
"author_profile": "https://Stackoverflow.com/users/702361",
"pm_score": 1,
"selected": false,
"text": "ifconfig eth0 | grep -Eo ..\\(\\:..\\){5}\n ifconfig eth0 | grep -Eo [:0-9A-F:]{2}\\(\\:[:0-9A-F:]{2}\\){5}\n ifconfig eth0 | head -n1 | tr -s ' ' | cut -d' ' -f5`\n"
},
{
"answer_id": 6334173,
"author": "Michalis",
"author_id": 528634,
"author_profile": "https://Stackoverflow.com/users/528634",
"pm_score": 7,
"selected": false,
"text": "/sys/class/ cat /sys/class/net/*/address\n eth0 cat /sys/class/net/eth0/address\n"
},
{
"answer_id": 7583842,
"author": "manafire",
"author_id": 805003,
"author_profile": "https://Stackoverflow.com/users/805003",
"pm_score": 2,
"selected": false,
"text": "ifconfig | grep \"inet \" | grep -v 127.0.0.1 | cut -d \" \" -f2\n echo \"alias myip=\\\"ifconfig | grep 'inet ' | grep -v 127.0.0.1 | cut -d ' ' -f2\\\"\" >> ~/.bash_profile\n"
},
{
"answer_id": 12180593,
"author": "Kyle Clegg",
"author_id": 654870,
"author_profile": "https://Stackoverflow.com/users/654870",
"pm_score": 0,
"selected": false,
"text": "ifconfig p2p0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'\n"
},
{
"answer_id": 15238227,
"author": "CRGreen",
"author_id": 2092796,
"author_profile": "https://Stackoverflow.com/users/2092796",
"pm_score": 0,
"selected": false,
"text": "ifconfig en0 | grep -Eo ..\\(\\:..\\){5}\n ifconfig en0 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'\n"
},
{
"answer_id": 17108392,
"author": "amar",
"author_id": 2357995,
"author_profile": "https://Stackoverflow.com/users/2357995",
"pm_score": -1,
"selected": false,
"text": "$ifconfig\n\neth0 Link encap:Ethernet HWaddr 00:1b:fc:72:84:12\n inet addr:172.16.1.13 Bcast:172.16.1.255 Mask:255.255.255.0\n inet6 addr: fe80::21b:fcff:fe72:8412/64 Scope:Link\n UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1\n RX packets:638661 errors:0 dropped:20 overruns:0 frame:0\n TX packets:93858 errors:0 dropped:0 overruns:0 carrier:2\n collisions:0 txqueuelen:1000\n RX bytes:101655955 (101.6 MB) TX bytes:42802760 (42.8 MB)\n Memory:dffc0000-e0000000\n\nlo Link encap:Local Loopback\n inet addr:127.0.0.1 Mask:255.0.0.0\n inet6 addr: ::1/128 Scope:Host\n UP LOOPBACK RUNNING MTU:16436 Metric:1\n RX packets:3796 errors:0 dropped:0 overruns:0 frame:0\n TX packets:3796 errors:0 dropped:0 overruns:0 carrier:0\n collisions:0 txqueuelen:0\n RX bytes:517624 (517.6 KB) TX bytes:517624 (517.6 KB)\n ifconfig | sed '1,1!d' | sed 's/.*HWaddr //' | sed 's/\\ .*//' | sed -e 's/:/-/g' > mac_address\n"
},
{
"answer_id": 19874909,
"author": "Ashwin Lakshmanan",
"author_id": 2485265,
"author_profile": "https://Stackoverflow.com/users/2485265",
"pm_score": 0,
"selected": false,
"text": "ifconfig | grep -i hwaddr | cut -d ' ' -f11\n"
},
{
"answer_id": 24263330,
"author": "yankeevader",
"author_id": 3748399,
"author_profile": "https://Stackoverflow.com/users/3748399",
"pm_score": -1,
"selected": false,
"text": "ifconfig eth0 | grep HWaddr\n ifconfig eth0 |grep HWaddr\n ifconfig eth0 down,\nifconfig eth0 hw ether (new MAC address),\nifconfig eth0 up\n"
},
{
"answer_id": 26122717,
"author": "Fernando_Jr",
"author_id": 3284089,
"author_profile": "https://Stackoverflow.com/users/3284089",
"pm_score": 1,
"selected": false,
"text": "ifconfig | grep HW\n"
},
{
"answer_id": 29298216,
"author": "Hugh",
"author_id": 1787982,
"author_profile": "https://Stackoverflow.com/users/1787982",
"pm_score": 0,
"selected": false,
"text": "ifconfig eth0 | grep HWaddr | cut -d ' ' -f 11\n"
},
{
"answer_id": 37125657,
"author": "Dogukan",
"author_id": 3916140,
"author_profile": "https://Stackoverflow.com/users/3916140",
"pm_score": 0,
"selected": false,
"text": "ifconfig -a | awk '/^[a-z]/ { iface=$1; mac=$NF; next } /inet addr:/ { print mac }' | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'\n"
},
{
"answer_id": 37580835,
"author": "nPcomp",
"author_id": 5074973,
"author_profile": "https://Stackoverflow.com/users/5074973",
"pm_score": 2,
"selected": false,
"text": "ifconfig | grep HW | awk '{print $5}'\n ip add | grep link/ether | awk '{print $2}'\n"
},
{
"answer_id": 57681372,
"author": "Adel Skn",
"author_id": 7027431,
"author_profile": "https://Stackoverflow.com/users/7027431",
"pm_score": 0,
"selected": false,
"text": "ifconfig eth0 | grep -o -E ..:..:..:..:..:..\n eth0"
},
{
"answer_id": 63900424,
"author": "Tarun Bansal",
"author_id": 12396277,
"author_profile": "https://Stackoverflow.com/users/12396277",
"pm_score": 1,
"selected": false,
"text": "ifconfig en1 | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' \n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29405/"
] |
245,929
|
<p>Some APIs, like the WebClient, use the <a href="http://msdn.microsoft.com/en-us/library/wewwczdw.aspx" rel="nofollow noreferrer">Event-based Async pattern</a>. While this looks simple, and probably works well in a loosely coupled app (say, BackgroundWorker in a UI), it doesn't chain together very well. </p>
<p>For instance, here's a program that's multithreaded so the async work doesn't block. (Imagine this is going in a server app and called hundreds of times -- you don't want to block your ThreadPool threads.) We get 3 local variables ("state"), then make 2 async calls, with the result of the first feeding into the second request (so they can't go parallel). State could mutate too (easy to add). </p>
<p>Using WebClient, things end up like the following (or you end up creating a bunch of objects to act like closures):</p>
<pre><code>using System;
using System.Net;
class Program
{
static void onEx(Exception ex) {
Console.WriteLine(ex.ToString());
}
static void Main() {
var url1 = new Uri(Console.ReadLine());
var url2 = new Uri(Console.ReadLine());
var someData = Console.ReadLine();
var webThingy = new WebClient();
DownloadDataCompletedEventHandler first = null;
webThingy.DownloadDataCompleted += first = (o, res1) => {
if (res1.Error != null) {
onEx(res1.Error);
return;
}
webThingy.DownloadDataCompleted -= first;
webThingy.DownloadDataCompleted += (o2, res2) => {
if (res2.Error != null) {
onEx(res2.Error);
return;
}
try {
Console.WriteLine(someData + res2.Result);
} catch (Exception ex) { onEx(ex); }
};
try {
webThingy.DownloadDataAsync(new Uri(url2.ToString() + "?data=" + res1.Result));
} catch (Exception ex) { onEx(ex); }
};
try {
webThingy.DownloadDataAsync(url1);
} catch (Exception ex) { onEx(ex); }
Console.WriteLine("Keeping process alive");
Console.ReadLine();
}
</code></pre>
<p>}</p>
<p>Is there an generic way to refactor this event-based async pattern? (I.e. not have to write detailed extension methods for each API thats like this?) BeginXXX and EndXXX make it easy, but this event way doesn't seem to offer any way.</p>
|
[
{
"answer_id": 246310,
"author": "Tim Robinson",
"author_id": 32133,
"author_profile": "https://Stackoverflow.com/users/32133",
"pm_score": 2,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Net;\n\nclass Program\n{\n static void onEx(Exception ex) {\n Console.WriteLine(ex.ToString());\n }\n\n static IEnumerable<Uri> Downloader(Func<DownloadDataCompletedEventArgs> getLastResult) {\n Uri url1 = new Uri(Console.ReadLine());\n Uri url2 = new Uri(Console.ReadLine());\n string someData = Console.ReadLine();\n yield return url1;\n\n DownloadDataCompletedEventArgs res1 = getLastResult();\n yield return new Uri(url2.ToString() + \"?data=\" + res1.Result);\n\n DownloadDataCompletedEventArgs res2 = getLastResult();\n Console.WriteLine(someData + res2.Result);\n }\n\n static void StartNextRequest(WebClient webThingy, IEnumerator<Uri> enumerator) {\n if (enumerator.MoveNext()) {\n Uri uri = enumerator.Current;\n\n try {\n Console.WriteLine(\"Requesting {0}\", uri);\n webThingy.DownloadDataAsync(uri);\n } catch (Exception ex) { onEx(ex); }\n }\n else\n Console.WriteLine(\"Finished\");\n }\n\n static void Main() {\n DownloadDataCompletedEventArgs lastResult = null;\n Func<DownloadDataCompletedEventArgs> getLastResult = delegate { return lastResult; };\n IEnumerable<Uri> enumerable = Downloader(getLastResult);\n using (IEnumerator<Uri> enumerator = enumerable.GetEnumerator())\n {\n WebClient webThingy = new WebClient();\n webThingy.DownloadDataCompleted += delegate(object sender, DownloadDataCompletedEventArgs e) {\n if (e.Error == null) {\n lastResult = e;\n StartNextRequest(webThingy, enumerator);\n }\n else\n onEx(e.Error);\n };\n\n StartNextRequest(webThingy, enumerator);\n }\n\n Console.WriteLine(\"Keeping process alive\");\n Console.ReadLine();\n }\n}\n"
},
{
"answer_id": 643520,
"author": "Anton Tykhyy",
"author_id": 77724,
"author_profile": "https://Stackoverflow.com/users/77724",
"pm_score": 2,
"selected": true,
"text": "F# F# F# async BeginXXX EndXXX"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245929",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27012/"
] |
245,932
|
<p>i would like to release a snapshot project 'foo-1.0-SNAPSHOT' using the maven release plugin. The project depends on a 3rd party module 'bar-1.0-SNAPSHOT' which is not released yet.
I use the option 'allowTimestampedSnapshots' in my project's pom.xml to allow timestamped snapshots but i assume that the 3rd party module (bar) is not timestamped unless i build it myself as maven still complains about unresolved SNAPSHOT dependencies.</p>
<p>Is there a way to release the project foo regardless of dependent SNAPSHOT projects and if not how could i add a timestamp to the 3rd party project?</p>
|
[
{
"answer_id": 3959507,
"author": "Stevo Slavić",
"author_id": 381140,
"author_profile": "https://Stackoverflow.com/users/381140",
"pm_score": 7,
"selected": false,
"text": "allowTimestampedSnapshots ignoreSnapshots -DignoreSnapshots=true"
},
{
"answer_id": 5964197,
"author": "Oleg Mayevskiy",
"author_id": 748606,
"author_profile": "https://Stackoverflow.com/users/748606",
"pm_score": 5,
"selected": false,
"text": "-DignoreSnapshots=true\n -DallowTimestampedSnapshots=true\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32279/"
] |
245,947
|
<p>I have <code>www.example.com</code> and also <code>store.example.com</code>.
(Yes they are subdomains of the same parent domain)</p>
<p><code>store.example.com</code> is on ASP.NET 1.1</p>
<p><code>www.example.com</code> is on ASP.NET 3.5</p>
<p>I want to know what options are available for sharing 'session' data between the two sites. I need some kind of shared login and also the abiltity to track user activity no matter which site they started on. </p>
<ul>
<li><p>Obvously I could send a GUID when transitioning from one site to the other. </p></li>
<li><p>I also believe I can set a cookie which can be shared across subdomains. I've never tried this but it is most likely what I will do. I'm not yet clear if this is a true 'session' cookie or if I just set a low expiration date?</p></li>
</ul>
<p>Are these my best options or is there somethin else?</p>
|
[
{
"answer_id": 1271463,
"author": "TWith2Sugars",
"author_id": 35389,
"author_profile": "https://Stackoverflow.com/users/35389",
"pm_score": 3,
"selected": false,
"text": " <machineKey decryptionKey=\"EDCDA6DF458176504BBCC720A4E29348E252E652591179E2\" validationKey=\"CC482ED6B5D3569819B3C8F07AC3FA855B2FED7F0130F55D8405597C796457A2F5162D35C69B61F257DB5EFE6BC4F6CEBDD23A4118C4519F55185CB5EB3DFE61\"/>\n namespace YourApp\n{\n using System.Configuration;\n using System.Reflection;\n using System.Web;\n\n /// <summary>class used for sharing the session between app domains</summary>\n public class SharedSessionModule : IHttpModule\n {\n #region IHttpModule Members\n /// <summary>\n /// Initializes a module and prepares it to handle requests.\n /// </summary>\n /// <param name=\"context\">An <see cref=\"T:System.Web.HttpApplication\"/>\n /// that provides access to the methods,\n /// properties, and events common to all application objects within an ASP.NET\n /// application</param>\n /// <created date=\"5/31/2008\" by=\"Peter Femiani\"/>\n public void Init(HttpApplication context)\n {\n // Get the app name from config file...\n string appName = ConfigurationManager.AppSettings[\"ApplicationName\"];\n if (!string.IsNullOrEmpty(appName))\n {\n FieldInfo runtimeInfo = typeof(HttpRuntime).GetField(\"_theRuntime\", BindingFlags.Static | BindingFlags.NonPublic);\n HttpRuntime theRuntime = (HttpRuntime)runtimeInfo.GetValue(null);\n FieldInfo appNameInfo = typeof(HttpRuntime).GetField(\"_appDomainAppId\", BindingFlags.Instance | BindingFlags.NonPublic);\n appNameInfo.SetValue(theRuntime, appName);\n }\n }\n\n /// <summary>\n /// Disposes of the resources (other than memory) used by the module that\n /// implements <see cref=\"T:System.Web.IHttpModule\"/>.\n /// </summary>\n /// <created date=\"5/31/2008\" by=\"Peter Femiani\"/>\n public void Dispose()\n {\n }\n #endregion\n }\n}\n <add name=\"SharedSessionModule\" type=\"YourApp.SharedSessionModule, YourApp, Version=1.0.0.0, Culture=neutral\" />\n var session = HttpContext.Current.Session;\n var request = HttpContext.Current.Request;\n var cookie = request.Cookies[\"ASP.NET_SessionId\"];\n if (cookie != null && session != null && session.SessionID != null)\n {\n cookie.Value = session.SessionID;\n cookie.Domain = \"yourappdomain.com\";\n\n // the full stop prefix denotes all sub domains\n cookie.Path = \"/\"; // default session cookie path root\n }\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] |
245,956
|
<p>How do you go about finding unused icons, images, strings in .resx files that may have become 'orphaned' and are no longer required?</p>
|
[
{
"answer_id": 246024,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 4,
"selected": true,
"text": "grep sed"
},
{
"answer_id": 13786472,
"author": "Uwe Keim",
"author_id": 107625,
"author_profile": "https://Stackoverflow.com/users/107625",
"pm_score": 3,
"selected": false,
"text": "Resources"
},
{
"answer_id": 14864573,
"author": "Craig Stewart",
"author_id": 2070218,
"author_profile": "https://Stackoverflow.com/users/2070218",
"pm_score": 2,
"selected": false,
"text": "? modTest.GetUnusedResources(\"C:\\Documents and Settings\\me\\My Documents\\Visual Studio 2010\\Projects\\myProj\\myProj.vbproj\", True, true) 'project file is the vbproj file for my solution\nPublic Function GetUnusedResources(projectFile As String, useClipboard As Boolean, strict As Boolean) As List(Of String)\n\n\n Dim myProjectFiles As New List(Of String)\n Dim baseFolder = System.IO.Path.GetDirectoryName(projectFile) + \"\\\"\n\n 'get list of project files \n Dim reader As Xml.XmlTextReader = New Xml.XmlTextReader(projectFile)\n Do While (reader.Read())\n Select Case reader.NodeType\n Case Xml.XmlNodeType.Element 'Display beginning of element.\n If reader.Name.ToLowerInvariant() = \"compile\" Then ' only get compile included files\n If reader.HasAttributes Then 'If attributes exist\n While reader.MoveToNextAttribute()\n If reader.Name.ToLowerInvariant() = \"include\" Then myProjectFiles.Add((reader.Value))\n End While\n End If\n End If\n End Select\n Loop\n\n 'now collect files into a single string\n Dim fileText As New System.Text.StringBuilder\n For Each fileItem As String In myProjectFiles\n Dim textFileStream As System.IO.TextReader\n textFileStream = System.IO.File.OpenText(baseFolder + fileItem)\n fileText.Append(textFileStream.ReadToEnd)\n textFileStream.Close()\n Next\n ' Debug.WriteLine(fileText)\n\n ' Create a ResXResourceReader for the file items.resx.\n Dim rsxr As New System.Resources.ResXResourceReader(baseFolder + \"My Project\\Resources.resx\")\n rsxr.BasePath = baseFolder + \"Resources\"\n Dim resourceList As New List(Of String)\n ' Iterate through the resources and display the contents to the console.\n For Each resourceValue As DictionaryEntry In rsxr\n ' Debug.WriteLine(resourceValue.Key.ToString())\n If TypeOf resourceValue.Value Is String Then ' or bitmap or other type if required\n resourceList.Add(resourceValue.Key.ToString())\n End If\n Next\n rsxr.Close() 'Close the reader.\n\n 'finally search file string for occurances of each resource string\n Dim unusedResources As New List(Of String)\n Dim clipBoardText As New System.Text.StringBuilder\n Dim searchText = fileText.ToString()\n For Each resourceString As String In resourceList\n Dim resourceCall = \"My.Resources.\" + resourceString ' find code reference to the resource name\n Dim resourceAttribute = \"(\"\"\" + resourceString + \"\"\")\" ' find attribute reference to the resource name\n Dim searchResult As Boolean = False\n searchResult = searchResult Or searchText.Contains(resourceCall)\n searchResult = searchResult Or searchText.Contains(resourceAttribute)\n If Not strict Then searchResult = searchResult Or searchText.Contains(resourceString)\n If Not searchResult Then ' resource name no found so add to list\n unusedResources.Add(resourceString)\n clipBoardText.Append(resourceString + vbCrLf)\n End If\n Next\n\n 'make clipboard object\n If useClipboard Then\n Dim dataObject As New DataObject ' Make a DataObject clipboard\n dataObject.SetData(DataFormats.Text, clipBoardText.ToString()) ' Add the data in string format.\n Clipboard.SetDataObject(dataObject) ' Copy data to the clipboard.\n End If\n\n Return unusedResources\n\nEnd Function\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3849/"
] |
245,957
|
<pre><code>void f(cli::array<PointF> ^points){
PointF& a = points[0];
// and so on...
}
</code></pre>
<p>Compile error at line 2. </p>
<pre><code>.\ndPanel.cpp(52) : error C2440: 'initializing' : cannot convert from 'System::Drawing::PointF' to 'System::Drawing::PointF &'
An object from the gc heap (element of a managed array) cannot be converted to a native reference
</code></pre>
<p>What is the managed way to declare a reference variable?</p>
|
[
{
"answer_id": 245981,
"author": "Bogdan Maxim",
"author_id": 23795,
"author_profile": "https://Stackoverflow.com/users/23795",
"pm_score": 1,
"selected": false,
"text": "gcroot vcclr.h // mcpp_gcroot.cpp\n// compile with: /clr\n#include <vcclr.h>\nusing namespace System;\n\nclass CppClass {\npublic:\n gcroot<String^> str; // can use str as if it were String^\n CppClass() {}\n};\n\nint main() {\n CppClass c;\n c.str = gcnew String(\"hello\");\n Console::WriteLine( c.str ); // no cast required\n}\n\n// mcpp_gcroot_2.cpp\n// compile with: /clr\n// compile with: /clr\n#include <vcclr.h>\nusing namespace System;\n\nstruct CppClass {\n gcroot<String ^> * str;\n CppClass() : str(new gcroot<String ^>) {}\n\n ~CppClass() { delete str; }\n\n};\n\nint main() {\n CppClass c;\n *c.str = gcnew String(\"hello\");\n Console::WriteLine( *c.str );\n}\n\n// mcpp_gcroot_3.cpp\n// compile with: /clr\n#include < vcclr.h >\nusing namespace System;\n\npublic value struct V {\n String^ str;\n};\n\nclass Native {\npublic:\n gcroot< V^ > v_handle;\n};\n\nint main() {\n Native native;\n V v;\n native.v_handle = v;\n native.v_handle->str = \"Hello\";\n Console::WriteLine(\"String in V: {0}\", native.v_handle->str);\n}\n"
},
{
"answer_id": 246076,
"author": "Bogdan Maxim",
"author_id": 23795,
"author_profile": "https://Stackoverflow.com/users/23795",
"pm_score": 0,
"selected": false,
"text": "void f(cli::array<gcroot<PointF ^>> points){\n gcroot<PointF ^> a = points[0];\n // and so on... }\n"
},
{
"answer_id": 246761,
"author": "Stu Mackellar",
"author_id": 28591,
"author_profile": "https://Stackoverflow.com/users/28591",
"pm_score": 3,
"selected": true,
"text": "void f(cli::array<PointF>^ points)\n{ \n PointF% a = points[0];\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45603/"
] |
245,963
|
<p>I have to refactor a large C# application, and I found a lot of functions that are never used. How can I check for unused code, so I can remove all the unused functions?</p>
|
[
{
"answer_id": 3619324,
"author": "Patrick from NDepend team",
"author_id": 27194,
"author_profile": "https://Stackoverflow.com/users/27194",
"pm_score": 4,
"selected": false,
"text": "// <Name>Dead Methods</Name>\nwarnif count > 0 \nfrom m in Application.Methods where !m.MethodsCallingMe.Any()\nselect m\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22562/"
] |
245,972
|
<p>Why does using Fiddler break my site sometimes on page transitions.</p>
<p>After a server side redirect -- in the http response (as found in Fiddler) I get this:</p>
<p>Object moved</p>
<h2>Object moved to here.</h2>
<p></p>
<p>The site is an ASP.NET 1.1 / VB.NET 1.1 [sic] site. </p>
<p>Why doesnt Fiddler just go there for me? i dont get it.</p>
<p>I'm fine with this issue when developing but I'm worried that other proxy servers might cause this issue for 'real customers'. Im not even clear exactly what is going on.</p>
|
[
{
"answer_id": 5383982,
"author": "ucla",
"author_id": 670204,
"author_profile": "https://Stackoverflow.com/users/670204",
"pm_score": 1,
"selected": false,
"text": "Server.Transfer(\"newpage.aspx\", true);\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/245972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] |
246,007
|
<p>When I type <code>uname -a</code>, it gives the following output.</p>
<pre><code>Linux mars 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 i686 i686 i386 GNU/Linux
</code></pre>
<p>How can I know from this that the given OS is 32 or 64 bit?</p>
<p>This is useful when writing <code>configure</code> scripts, for example: what architecture am I building for?</p>
|
[
{
"answer_id": 246012,
"author": "Thomas Watnedal",
"author_id": 4059,
"author_profile": "https://Stackoverflow.com/users/4059",
"pm_score": 7,
"selected": false,
"text": "uname -m\n getconf LONG_BIT\n"
},
{
"answer_id": 246014,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 11,
"selected": true,
"text": "uname -m uname --machine x86_64 ==> 64-bit kernel\ni686 ==> 32-bit kernel\n cat /proc/cpuinfo\n grep flags /proc/cpuinfo\n lm Long Mode lm ==> 64-bit processor\n lshw sudo lshw -class cpu|grep \"^ width\"|uniq|awk '{print $2}'\n"
},
{
"answer_id": 246018,
"author": "Louis Gerbarg",
"author_id": 30506,
"author_profile": "https://Stackoverflow.com/users/30506",
"pm_score": 3,
"selected": false,
"text": "uname Linux mars 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 x86_64 i686 x86_64 x86_64 GNU/Linux\n"
},
{
"answer_id": 246020,
"author": "Denis R.",
"author_id": 32015,
"author_profile": "https://Stackoverflow.com/users/32015",
"pm_score": 3,
"selected": false,
"text": "x86_64 ia64 uname -a"
},
{
"answer_id": 6200504,
"author": "kaiwan",
"author_id": 779269,
"author_profile": "https://Stackoverflow.com/users/779269",
"pm_score": 3,
"selected": false,
"text": "/*\n * check_os_64bit\n *\n * Returns integer:\n * 1 = it is a 64-bit OS\n * 0 = it is NOT a 64-bit OS (probably 32-bit)\n * < 0 = failure\n * -1 = popen failed\n * -2 = fgets failed\n *\n * **WARNING**\n * Be CAREFUL! Just testing for a boolean return may not cut it\n * with this (trivial) implementation! (Think of when it fails,\n * returning -ve; this could be seen as non-zero & therefore true!)\n * Suggestions?\n */\nstatic int check_os_64bit(void)\n{\n FILE *fp=NULL;\n char cb64[3];\n\n fp = popen (\"getconf LONG_BIT\", \"r\");\n if (!fp)\n return -1;\n\n if (!fgets(cb64, 3, fp))\n return -2;\n\n if (!strncmp (cb64, \"64\", 3)) {\n return 1;\n }\n else {\n return 0;\n }\n}\n"
},
{
"answer_id": 7030871,
"author": "Reed Hedges",
"author_id": 39686,
"author_profile": "https://Stackoverflow.com/users/39686",
"pm_score": 4,
"selected": false,
"text": "DEB_BUILD_ARCH=amd64\nDEB_BUILD_ARCH_OS=linux\nDEB_BUILD_ARCH_CPU=amd64\nDEB_BUILD_GNU_CPU=x86_64\nDEB_BUILD_GNU_SYSTEM=linux-gnu\nDEB_BUILD_GNU_TYPE=x86_64-linux-gnu\nDEB_HOST_ARCH=amd64\nDEB_HOST_ARCH_OS=linux\nDEB_HOST_ARCH_CPU=amd64\nDEB_HOST_GNU_CPU=x86_64\nDEB_HOST_GNU_SYSTEM=linux-gnu\nDEB_HOST_GNU_TYPE=x86_64-linux-gnu\n"
},
{
"answer_id": 11515090,
"author": "asharma",
"author_id": 1530443,
"author_profile": "https://Stackoverflow.com/users/1530443",
"pm_score": 6,
"selected": false,
"text": "lscpu Architecture: x86_64\nCPU op-mode(s): 32-bit, 64-bit\n...\n"
},
{
"answer_id": 11970831,
"author": "scotty",
"author_id": 1600775,
"author_profile": "https://Stackoverflow.com/users/1600775",
"pm_score": 4,
"selected": false,
"text": "#include <stdio.h>\n\nint main(void)\n{\n printf(\"%d\\n\", __WORDSIZE);\n return 0;\n}\n"
},
{
"answer_id": 15009534,
"author": "Michael Shigorin",
"author_id": 561921,
"author_profile": "https://Stackoverflow.com/users/561921",
"pm_score": 1,
"selected": false,
"text": "$ ls -l /lib*/ld-linux*.so.2\n /lib/ld-linux.so.2 /lib64/ld-linux-x86-64.so.2"
},
{
"answer_id": 17597274,
"author": "alex",
"author_id": 2573280,
"author_profile": "https://Stackoverflow.com/users/2573280",
"pm_score": 1,
"selected": false,
"text": "$ grep \"CONFIG_64\" /lib/modules/*/build/.config\n# CONFIG_64BIT is not set\n"
},
{
"answer_id": 21188486,
"author": "user3207041",
"author_id": 3207041,
"author_profile": "https://Stackoverflow.com/users/3207041",
"pm_score": 5,
"selected": false,
"text": "getconf LONG_BIT\n"
},
{
"answer_id": 24248455,
"author": "Greg von Winckel",
"author_id": 2308288,
"author_profile": "https://Stackoverflow.com/users/2308288",
"pm_score": 4,
"selected": false,
"text": "$ arch \n $ uname -m\n"
},
{
"answer_id": 26845387,
"author": "Luchostein",
"author_id": 2859065,
"author_profile": "https://Stackoverflow.com/users/2859065",
"pm_score": 2,
"selected": false,
"text": "if ((1 == 1<<32)); then\n echo 32bits\nelse\n echo 64bits\nfi\n"
},
{
"answer_id": 28500619,
"author": "Sandeep Giri",
"author_id": 96793,
"author_profile": "https://Stackoverflow.com/users/96793",
"pm_score": 2,
"selected": false,
"text": "if echo $((1<<32)) gives 1 then your system is 32 bit if echo $((1<<64)) gives 1 then your system is 64 bit"
},
{
"answer_id": 31239216,
"author": "Lakshmikandan",
"author_id": 2186189,
"author_profile": "https://Stackoverflow.com/users/2186189",
"pm_score": 1,
"selected": false,
"text": " if $(getconf LONG_BIT | grep '64'); then\n echo \"64 bit system\"\n else\n echo \"32 bit system\"\n fi\n"
},
{
"answer_id": 32717681,
"author": "Rolf of Saxony",
"author_id": 4637585,
"author_profile": "https://Stackoverflow.com/users/4637585",
"pm_score": 1,
"selected": false,
"text": "sudo lshw -class cpu\n"
},
{
"answer_id": 35247207,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "$ strace getconf LONG_BIT | wc -l\n253\n\n$ strace arch | wc -l\n280\n\n$ strace uname -m | wc -l\n281\n\n$ strace grep -q lm /proc/cpuinfo | wc -l\n301\n"
},
{
"answer_id": 35687825,
"author": "LinuxMaintwo",
"author_id": 5994607,
"author_profile": "https://Stackoverflow.com/users/5994607",
"pm_score": 2,
"selected": false,
"text": "echo $HOSTTYPE\n i386 x86_64"
},
{
"answer_id": 41116803,
"author": "79man",
"author_id": 4983314,
"author_profile": "https://Stackoverflow.com/users/4983314",
"pm_score": 1,
"selected": false,
"text": "[ -z `uname -m | grep 64` ] && echo \"32-bit\" || echo \"64-bit\" x86_64 i686"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11602/"
] |
246,011
|
<p>I'm rather confused about this. </p>
<p>And what's their relationship(e.g., how one can be used in the context of the other)? Much thanks!!</p>
|
[
{
"answer_id": 246056,
"author": "Daniel Rikowski",
"author_id": 23368,
"author_profile": "https://Stackoverflow.com/users/23368",
"pm_score": 0,
"selected": false,
"text": "typdef static final const"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21464/"
] |
246,017
|
<p>I have an oc4j installation bereft of any release notes or version documentation. In the absence of such documents, how do I know for sure, which version of oc4j I am using?</p>
|
[
{
"answer_id": 246034,
"author": "Maglob",
"author_id": 27520,
"author_profile": "https://Stackoverflow.com/users/27520",
"pm_score": 4,
"selected": true,
"text": "wget -S <url-to-server>\ncurl -I <url-to-server>\n Server: Oracle-Application-Server-10g/10.1.3.1.0 Oracle-HTTP-Server\n"
},
{
"answer_id": 253260,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 2,
"selected": false,
"text": "java -jar oc4j.jar -version\n"
},
{
"answer_id": 741002,
"author": "dstine",
"author_id": 84855,
"author_profile": "https://Stackoverflow.com/users/84855",
"pm_score": 1,
"selected": false,
"text": "<%= System.getProperty( \"oracle.j2ee.container.name\" ) %>\n <%= application.getAttribute( \"oracle.jsp.versionNumber\" ) %>\n"
},
{
"answer_id": 2314776,
"author": "RHT",
"author_id": 244461,
"author_profile": "https://Stackoverflow.com/users/244461",
"pm_score": 1,
"selected": false,
"text": "OPatch]$ ./opatch lsinventory -invPtrLoc ../oraInst.loc |grep \"Oracle Application Server\"\n\nOracle Application Server PatchSet 10.1.3.4.0\n"
},
{
"answer_id": 2419342,
"author": "BlakGeek",
"author_id": 290787,
"author_profile": "https://Stackoverflow.com/users/290787",
"pm_score": 0,
"selected": false,
"text": "grep Version $ORACLE_HOME/config/ias.properties\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11602/"
] |
246,028
|
<p>I'm using the MVP pattern in a windows form app. I need to change a radio button on the view. I can do this by exposing a Boolean property on the view, but should I be using events to manipulate the view instead?</p>
|
[
{
"answer_id": 246032,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 2,
"selected": false,
"text": "RadioButtonVisibilityChanged EventArgs"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,038
|
<p>What is the best way to unit test a method that doesn't return anything? Specifically in c#.</p>
<p>What I am really trying to test is a method that takes a log file and parses it for specific strings. The strings are then inserted into a database. Nothing that hasn't been done before but being VERY new to TDD I am wondering if it is possible to test this or is it something that doesn't really get tested.</p>
|
[
{
"answer_id": 246060,
"author": "Gishu",
"author_id": 1695,
"author_profile": "https://Stackoverflow.com/users/1695",
"pm_score": 8,
"selected": true,
"text": "void DeductFromBalance( dAmount ) \n void OnAccountDebit( dAmount ) // emails account holder with info\n string[] ExamineLogFileForX( string sFileName );\nvoid InsertStringsIntoDatabase( string[] );\n InsertStringsIntoDatabase( ExamineLogFileForX( \"c:\\OMG.log\" ) );\n"
},
{
"answer_id": 23959605,
"author": "Suamere",
"author_id": 1831054,
"author_profile": "https://Stackoverflow.com/users/1831054",
"pm_score": 4,
"selected": false,
"text": "public void SendEmailToCustomer()\n public bool TrySendEmailToCustomer()\n public StateEnum TrySendEmailToCustomer()\n public <Constructor/MethodName> (IBusinessDataEtc otherLayerOrTierObject, string[] stuffToInsert)\n IBusinessDataEtc IBusinessDataEtc int XMethodWasCalledCount IBusinessDataEtc IBusinessDataEtc"
},
{
"answer_id": 37180480,
"author": "Nathan Alard",
"author_id": 3733407,
"author_profile": "https://Stackoverflow.com/users/3733407",
"pm_score": 5,
"selected": false,
"text": "[TestMethod]\npublic void TestSomething()\n{\n try\n {\n YourMethodCall();\n Assert.IsTrue(true);\n }\n catch {\n Assert.IsTrue(false);\n }\n}\n"
},
{
"answer_id": 42490056,
"author": "Shreya Kesharkar",
"author_id": 7630697,
"author_profile": "https://Stackoverflow.com/users/7630697",
"pm_score": 0,
"selected": false,
"text": "Verfiy _Log LogMessage try\n{\n this._log.Verify(x => x.LogMessage(Logger.WillisLogLevel.Info, Logger.WillisLogger.Usage, \"Created the Student with name as\"), \"Failure\");\n}\nCatch \n{\n Assert.IsFalse(ex is Moq.MockException);\n}\n Verify"
},
{
"answer_id": 56358203,
"author": "Reyan Chougle",
"author_id": 3678363,
"author_profile": "https://Stackoverflow.com/users/3678363",
"pm_score": 4,
"selected": false,
"text": "[TestMethod]\npublic void ReadFiles()\n{\n try\n {\n Read();\n return; // indicates success\n }\n catch (Exception ex)\n {\n Assert.Fail(ex.Message);\n }\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/831/"
] |
246,041
|
<p>Actually I try to find a subclass of InputStream which is also Serializable. I think that doesn't exist. Since both Interfaces have many sublclasses it is hard to find one that is a subclass of both.</p>
<p>Until now I haven't found anything to help my search in Eclipse. Anyone ideas?</p>
<p>Edit: I understand now that serializing a Stream isn't really what one should do. But the essence of the Question is: how can I find a common subclass of two Interfaces.</p>
|
[
{
"answer_id": 25975994,
"author": "Andrejs",
"author_id": 1180621,
"author_profile": "https://Stackoverflow.com/users/1180621",
"pm_score": 0,
"selected": false,
"text": "Set<Class<? extends Serializable>> subTypes = \n reflections.getSubTypesOf(Serializable.class);\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15108/"
] |
246,058
|
<p>I got this error when trying to update an image.
It was a cross-thread update, but I used .Invoke(), so that shouldn't be the problem, should it.</p>
|
[
{
"answer_id": 246064,
"author": "Benjol",
"author_id": 11410,
"author_profile": "https://Stackoverflow.com/users/11410",
"pm_score": 4,
"selected": true,
"text": "var x = this.Handle; \n"
},
{
"answer_id": 246098,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "CreateHandle"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11410/"
] |
246,068
|
<p>I know about "class having a single reason to change". Now, what is that exactly? Are there some smells/signs that could tell that class does not have a single responsibility? Or could the real answer hide in YAGNI and only refactor to a single responsibility the first time your class changes?</p>
|
[
{
"answer_id": 246079,
"author": "David Schmitt",
"author_id": 4918,
"author_profile": "https://Stackoverflow.com/users/4918",
"pm_score": 5,
"selected": false,
"text": "CoffeeAndSoupFactory HotWaterGenerator Stirrer CoffeeFactory SoupFactory Coffee Soup"
},
{
"answer_id": 317331,
"author": "Lars Mæhlum",
"author_id": 960,
"author_profile": "https://Stackoverflow.com/users/960",
"pm_score": 2,
"selected": false,
"text": "MethodA MemberA MethodB MemberB ProgramNameBL ProgramNameDAL"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6846/"
] |
246,077
|
<p>For example VK_LEFT, VK_DELETE, VK_ESCAPE, VK_RETURN, etc. How and where are they declared? Are they constants, #defines, or something else? Where do they come from?</p>
<p>If possible, please provide a file name/path where they are declared. Or some other info as specific as possible.</p>
|
[
{
"answer_id": 246084,
"author": "ChrisN",
"author_id": 3853,
"author_profile": "https://Stackoverflow.com/users/3853",
"pm_score": 3,
"selected": true,
"text": "#define winuser.h C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\Include\\WinUser.h\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9403/"
] |
246,091
|
<p>The problem is very simple. An object needs to notify some events that might be of interest to observers.</p>
<p>When I sat to validate a design that I cooked up now in Ruby just to validate it.. I find myself stumped as to how to implement the object events. In .Net this would be a one-liner.. .Net also does handler method signature verification,etc. e.g.</p>
<pre><code>// Object with events
public delegate void HandlerSignature(int a);
public event HandlerSignature MyEvent;
public event HandlerSignature AnotherCriticalEvent;
// Client
MyObject.MyEvent += new HandlerSignature(MyHandlerMethod); // MyHandlerMethod has same signature as delegate
</code></pre>
<p>Is there an EventDispatcher module or something that I am missing that I can strap on to a Ruby class ? Hoping for an answer that plays along with Ruby's principle of least surprise.
<em>An event would be the name of the event plus a queue of [observer, methodName] objects that need to be invoked when the event takes place.</em></p>
|
[
{
"answer_id": 246245,
"author": "janm",
"author_id": 7256,
"author_profile": "https://Stackoverflow.com/users/7256",
"pm_score": 3,
"selected": false,
"text": "class EventBase\n def initialize\n @listeners = Hash.new\n end\n\n def listen_event(name, *func, &p)\n if p\n (@listeners[name] ||= Array.new) << p\n else\n (@listeners[name] ||= Array.new) << func[0]\n end\n end\n\n def ignore_event(name, func)\n return if !@listeners.has_key?(name)\n @listeners[name].delete_if { |o| o == func }\n end\n\n def trigger_event(name, *args)\n return if !@listeners.has_key?(name)\n @listeners[name].each { |f| f.call(*args) }\n end\nend\n\n\nclass MyClass < EventBase\n def raise_event1(*args)\n trigger_event(:event1, *args)\n end\n\n def raise_event2(*args)\n trigger_event(:event2, *args)\n end\nend\n\nclass TestListener\n def initialize(source)\n source.listen_event(:event1, method(:event1_arrival))\n source.listen_event(:event2) do |*a|\n puts \"event 2 arrival, args #{a}\"\n end\n end\n\n def event1_arrival(*a)\n puts \"Event 1 arrived, args #{a}\"\n end\nend\n\ns = MyClass.new\nl = TestListener.new(s)\n\ns.raise_event1(\"here is event 1\")\ns.raise_event2(\"here is event 2\")\n"
},
{
"answer_id": 2205919,
"author": "D. Rexin",
"author_id": 266896,
"author_profile": "https://Stackoverflow.com/users/266896",
"pm_score": 3,
"selected": false,
"text": "class Event\n def initialize\n @handlers = Array.new\n end\n\n def fire\n @handlers.each do |v|\n v.call\n end\n end\n\n def << handler\n @handlers << handler\n end\nend\n\ne = Event.new\n\ne << lambda { puts \"hello\" }\ne << lambda { puts \"test\" }\ne.fire\n"
},
{
"answer_id": 2735627,
"author": "Nathan Kleyn",
"author_id": 153432,
"author_profile": "https://Stackoverflow.com/users/153432",
"pm_score": 0,
"selected": false,
"text": "gem install ruby_events\n require 'rubygems'\nrequire 'ruby_events'\n\nclass Example\n def initialize\n events.listen(:test_event) do |event_data|\n puts 'Hai there!'\n puts event_data\n end\n end\n\n def call_me\n events.fire(:test_event, 'My name is Mr Test Man!')\n end\nend\n\ne = Example.new\ne.call_me # Fires the event, and our handler gets called!\n"
},
{
"answer_id": 11505253,
"author": "Kamil Szot",
"author_id": 166921,
"author_profile": "https://Stackoverflow.com/users/166921",
"pm_score": 0,
"selected": false,
"text": "module Observable\n class Event \n def initialize\n @to_call = []\n end\n def fire(*arguments)\n @to_call.each { |proc| proc.call(*arguments) }\n end\n def call(proc)\n @to_call << proc\n end\n def dont_call(proc)\n @to_call.delete proc\n end\n end\n def self.append_features(cls)\n def cls.event(sym)\n define_method(sym.to_s) do\n variable_name = \"@#{sym}\"\n if not instance_variable_defined? variable_name then\n instance_variable_set variable_name, Event.new\n end\n instance_variable_get variable_name\n end\n end\n end\nend\n\n# Example \n\nclass Actor \n include Observable\n event :whenActed\n def act\n whenActed.fire(\"Johnny\") # fire event whenActed with parameter Johnny\n end\nend\n\nactor = Actor.new\n\ndef apploud(whom)\n print \"Bravo #{whom}!\\n\"\nend\n\napplouder = method(:apploud)\n\nactor.whenActed.call applouder\n\nactor.act\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1695/"
] |
246,097
|
<p>I guess this is a multi-part question. I am building a membership site and want to have the accounts as international as possible.</p>
<ol>
<li><p>What is the best way to collect phone numbers on a form that allows for international numbers? I'm not worried about storing them, just collection and validation. What I have now is a drop down with a country list that will add the country code, and then the number itself with validation for us/can/uk based on the country code, and then the extension. These will be stored as strings in 3 fields for cc/number/ext Does anyone have a better, solid solution for this, or perhaps seen one in action anywhere?</p>
</li>
<li><p>Ditto for addresses. What is the best way to go? Address/City/State/Zip/Country or just lines? I would like to be able to sort by these, so a single text field isn't a very good solution, though it is the most flexible.</p>
<p>This is also important because we may be sending actual mail to our members. I am put in mind of a few members I've had for other services that had addresses in countries I had never heard of, that even the woman at the post office couldn't tell if they were formatted correctly.</p>
</li>
<li><p>I want to have geodata in the db, at least country/state, for things like populating a state dropdown after selecting a country, field standardization, etc. Does anyone know of a great database that can be used as the geodata base of an app?</p>
</li>
</ol>
|
[
{
"answer_id": 246147,
"author": "kender",
"author_id": 4172,
"author_profile": "https://Stackoverflow.com/users/4172",
"pm_score": 0,
"selected": false,
"text": "[0-9]{2}-[0-9]{3}"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27580/"
] |
246,112
|
<p>We are using LINQ very widely in our system. Particularly LINQ-to-objects. So in some places we end up having a LINQ query in memory build up from some huge expressions. The problem comes when there's some bug in the expressions. So we get NullReferenceException and the stack trace leads us nowhere (to [Lightweight Function]). The exception was thrown inside the dynamic method generated by LINQ.</p>
<p>Is there any easy way to debug such dynamic methods? Or do I have to sacrifice myself to learning WinDBG? :-)</p>
|
[
{
"answer_id": 246132,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": "IQueryable<T> Queryable >Where: x => ((x % 2) = 0)\n<Where: x => ((x % 2) = 0)\n>Count\n'WindowsFormsApplication2.vshost.exe' (Managed): Loaded 'Anonymously Hosted DynamicMethods Assembly'\n<Count\n using System;\nusing System.Diagnostics;\nusing System.Linq.Expressions;\n\nnamespace Demo\n{\n using DebugLinq;\n static class Program\n {\n static void Main()\n {\n var data = System.Linq.Queryable.AsQueryable(new[] { 1, 2, 3, 4, 5 });\n data.Where(x => x % 2 == 0).Count(); \n }\n }\n}\nnamespace DebugLinq\n{\n public static class DebugQueryable\n {\n public static int Count<T>(this System.Linq.IQueryable<T> source)\n {\n return Wrap(() => System.Linq.Queryable.Count(source), \"Count\");\n }\n\n public static System.Linq.IQueryable<T> Where<T>(this System.Linq.IQueryable<T> source, Expression<Func<T, bool>> predicate)\n {\n return Wrap(() => System.Linq.Queryable.Where(source, predicate), \"Where: \" + predicate);\n }\n static TResult Wrap<TResult>(Func<TResult> func, string caption)\n {\n Debug.WriteLine(\">\" + caption);\n try\n {\n TResult result = func();\n Debug.WriteLine(\"<\" + caption);\n return result;\n }\n catch\n {\n Debug.WriteLine(\"!\" + caption);\n throw;\n }\n }\n }\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18001/"
] |
246,121
|
<p>I have an Ant script that needs to checkout a directory from Subversion. This works using svnant/svnkit. However, Subversion access is authenticated, and I do not want to store my user password in a file.</p>
<p>Can I make svnkit pop up a password dialog?
Or even better, make it use the same credential caching that subversive/svnkit inside of Eclipse uses (the username can be read from the build.properties)?</p>
<p>I cannot switch to public key based authentication, as I do not control the subversion server.</p>
<p>Right now, it just says "svn: authentication cancelled".</p>
|
[
{
"answer_id": 246378,
"author": "Thilo",
"author_id": 14955,
"author_profile": "https://Stackoverflow.com/users/14955",
"pm_score": 2,
"selected": false,
"text": " <target name=\"checkout\">\n <input\n message=\"Please enter subversion password for ${username}:\"\n addproperty=\"password\"\n />\n\n <svn svnkit=\"${svnkit}\" username=\"${username}\" password=\"${password}\">\n <checkout url=\"${urlRepos}/project\" destPath=\"web/\" />\n </svn> \n</target>\n"
},
{
"answer_id": 248926,
"author": "Thilo",
"author_id": 14955,
"author_profile": "https://Stackoverflow.com/users/14955",
"pm_score": 2,
"selected": false,
"text": "<taskdef name=\"query\" classname=\"com.jera.anttasks.Query\" />\n<target name=\"checkout\">\n <query\n message=\"Please enter subversion password for ${username}:\"\n name=\"password\" password=\"true\"\n />\n\n <svn svnkit=\"${svnkit}\" username=\"${username}\" password=\"${password}\">\n <checkout url=\"${urlRepos}/project\" destPath=\"web/\" />\n </svn> \n</target>\n"
},
{
"answer_id": 1844546,
"author": "geowa4",
"author_id": 50214,
"author_profile": "https://Stackoverflow.com/users/50214",
"pm_score": 2,
"selected": false,
"text": "<input message=\"password:>\" addproperty=\"password\">\n <handler classname=\"org.apache.tools.ant.input.SecureInputHandler\" />\n</input>\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14955/"
] |
246,127
|
<p>Why is <code>volatile</code> needed in C? What is it used for? What will it do?</p>
|
[
{
"answer_id": 246139,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 6,
"selected": false,
"text": "volatile"
},
{
"answer_id": 246144,
"author": "Manoj Doubts",
"author_id": 31116,
"author_profile": "https://Stackoverflow.com/users/31116",
"pm_score": 8,
"selected": false,
"text": "volatile volatile volatile"
},
{
"answer_id": 246148,
"author": "Nils Pipenbrinck",
"author_id": 15955,
"author_profile": "https://Stackoverflow.com/users/15955",
"pm_score": 9,
"selected": false,
"text": "volatile volatile typedef struct\n{\n int command;\n int data;\n int isBusy;\n} MyHardwareGadget;\n void SendCommand (MyHardwareGadget * gadget, int command, int data)\n{\n // wait while the gadget is busy:\n while (gadget->isbusy)\n {\n // do nothing here.\n }\n // set data first:\n gadget->data = data;\n // writing the command starts the action:\n gadget->command = command;\n}\n isBusy gadget volatile void SendCommand (volatile MyHardwareGadget * gadget, int command, int data)\n{\n // wait while the gadget is busy:\n while (gadget->isBusy)\n {\n // do nothing here.\n }\n // set data first:\n gadget->data = data;\n // writing the command starts the action:\n gadget->command = command;\n}\n"
},
{
"answer_id": 246392,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 8,
"selected": false,
"text": "volatile int quit = 0;\nwhile (!quit)\n{\n /* very small loop which is completely visible to the compiler */\n}\n quit while (true) quit SIGINT SIGTERM quit volatile"
},
{
"answer_id": 3148813,
"author": "Alexandre C.",
"author_id": 373025,
"author_profile": "https://Stackoverflow.com/users/373025",
"pm_score": 4,
"selected": false,
"text": "f double der_f(double x)\n{\n static const double h = 1e-3;\n return (f(x + h) - f(x)) / h;\n}\n x+h-x h double der_f2(double x)\n{\n static const double h = 1e-3;\n double hh = x + h - x;\n return (f(x + hh) - f(x)) / hh;\n}\n volatile double hh = x + h;\n hh -= x;\n"
},
{
"answer_id": 3308849,
"author": "Robert S. Barnes",
"author_id": 71074,
"author_profile": "https://Stackoverflow.com/users/71074",
"pm_score": 5,
"selected": false,
"text": "C C++"
},
{
"answer_id": 12284234,
"author": "coanor",
"author_id": 342348,
"author_profile": "https://Stackoverflow.com/users/342348",
"pm_score": 2,
"selected": false,
"text": "volatile volatile"
},
{
"answer_id": 28123172,
"author": "Venkatakrishna Kalepalli",
"author_id": 4184683,
"author_profile": "https://Stackoverflow.com/users/4184683",
"pm_score": 5,
"selected": false,
"text": "volatile bool usb_interface_flag = 0;\nwhile(usb_interface_flag == 0)\n{\n // execute logic for the scenario where the USB isn't connected \n}\n usb_interface_flag while(true)"
},
{
"answer_id": 35991544,
"author": "Oliver",
"author_id": 3877336,
"author_profile": "https://Stackoverflow.com/users/3877336",
"pm_score": 3,
"selected": false,
"text": "volatile volatile volatile void SendCommand (volatile MyHardwareGadget * gadget, int command, int data)\n {\n // wait while the gadget is busy:\n while (gadget->isbusy)\n {\n // do nothing here.\n }\n // set data first:\n gadget->data = data;\n // writing the command starts the action:\n gadget->command = command;\n }\n gadget->data = data gadget->command = command"
},
{
"answer_id": 51333563,
"author": "supercat",
"author_id": 363751,
"author_profile": "https://Stackoverflow.com/users/363751",
"pm_score": 3,
"selected": false,
"text": "volatile volatile volatile"
},
{
"answer_id": 59235288,
"author": "Siddharth",
"author_id": 4287117,
"author_profile": "https://Stackoverflow.com/users/4287117",
"pm_score": 0,
"selected": false,
"text": "longjmp setjmp/longjmp"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,130
|
<p>I'm working on a eclipse plug-in and I've tried to create another test project seperate from the plug-in. The reason I do this is to not let the plug-in depend on jUnit when it is exported. However, I can't access the Eclipse Plug-in API when I do the testing. Whenever I try to add Plug-in dependencies the import list to that is empty.</p>
<p>Does anyone know how to import Eclipse plug-in API to an existing project? The workspace layout looks like this at the moment:</p>
<pre><code>+- com.foo.myplugin
| |
| +- JRE System Library
| |
| +- Plug-in Dependencies
| |
| +- src
| |
| +- icons, META-INF, plugin.xml, etc...
|
+- com.foo.myplugin.test
|
+- JRE System Library
|
+- JUnit 4
|
+- src
</code></pre>
|
[
{
"answer_id": 246179,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 0,
"selected": false,
"text": "<natures>\n\n <nature>org.eclipse.pde.PluginNature</nature>\n [...]\n</natures>\n <classpath>\n [...]\n <classpathentry kind=\"con\" path=\"org.eclipse.pde.core.requiredPlugins\"/>\n [...]\n</classpath>\n"
},
{
"answer_id": 246271,
"author": "Spoike",
"author_id": 3713,
"author_profile": "https://Stackoverflow.com/users/3713",
"pm_score": 2,
"selected": false,
"text": "com.foo.plugin"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246130",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3713/"
] |
246,137
|
<p>Im a coding a library including textual feedback that I need to translate.</p>
<p>I put the following lines in a <code>_config.py</code> module that I import everywhere in my app :</p>
<pre><code>import gettext, os, sys
pathname = os.path.dirname(sys.argv[0])
localdir = os.path.abspath(pathname) + "/locale"
gettext.install("messages", localdir)
</code></pre>
<p>I have the <code>*.mo</code> files in <code>./locale/lang_LANG/LC_MESSAGES</code> and I apply the <code>_()</code> function to all the strings that need to be translated.</p>
<p>Now I just added a feature for the user, supposedly a programmer, to be able to create his own messages. I don't want him to care about the underlying implementation, so I want him to be able to make it something straightforward like :</p>
<pre><code>lib_object.message = "My message"
</code></pre>
<p>I used properties to make it clean, but what if my user whats to translate his own code (that uses mine) and does something like :</p>
<pre><code>import gettext, os, sys
pathname = os.path.dirname(sys.argv[0])
localdir = os.path.abspath(pathname) + "/locale"
gettext.install("user_app", localdir)
lib_object.message = _("My message")
</code></pre>
<p>Is it a problem ? What can I do to avoid troubles without bothering my user ?</p>
|
[
{
"answer_id": 398420,
"author": "runeh",
"author_id": 2906,
"author_profile": "https://Stackoverflow.com/users/2906",
"pm_score": 3,
"selected": true,
"text": "_() import gettext\n\nclass MyClass(object):\n def __init__(self, locale_for_instance):\n self.lang = gettext.translation(\"appname\", localedir, \\\n locale=locale_for_instance)\n\n def some_method(self, arg):\n return self.lang.gettext(\"You called some method\")\n\n def other_method(self, arg): # does the same thing\n _ = self.lang.gettext\n return _(\"You called some method\")\n _() @with_local_gettext"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9951/"
] |
246,143
|
<p>this is my old code</p>
<hr>
<pre><code> protected override bool OnPreAction(string actionName, System.Reflection.MethodInfo methodInfo)
{
if ("|Register|RegisterPage|Login|LoginPage|Logout|Service".ToLower().Contains(actionName.ToLower()))
{
return base.OnPreAction(actionName, methodInfo);
}
Customer = CustomerHelper.GetCustomer();
if (Customer.IsSeccessedLogin())
{
return base.OnPreAction(actionName, methodInfo);
}
Response.Redirect("Login.html");
return false;
}
</code></pre>
|
[
{
"answer_id": 246778,
"author": "Craig Stuntz",
"author_id": 7714,
"author_profile": "https://Stackoverflow.com/users/7714",
"pm_score": 5,
"selected": true,
"text": "string actionName = (string)filterContext.RouteData.Values[\"action\"];\n"
},
{
"answer_id": 521437,
"author": "Tim Scott",
"author_id": 29493,
"author_profile": "https://Stackoverflow.com/users/29493",
"pm_score": 5,
"selected": false,
"text": "filterContext.ActionDescriptor.ActionName\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31966/"
] |
246,159
|
<p>In the recent project, we had an issue with the performance of few queries that relied heavily on ordering the results by datetime field (MSSQL 2008 database).</p>
<p>When we executed the queries with ORDER BY RecordDate DESC (or ASC) the queries executed 10x slower than without that. Ordering by any other field didn't produce such slow results.</p>
<p>We tried all the indexing options, used the tuning wizard, nothing really made any difference. </p>
<p>One of the suggested solutions was converting the datetime field to the integer field representing the number of seconds or miliseconds in that datetime field. It would be calculated by a simple algorithm, something like "get me the number of seconds from RecordDate to 1980-01-01". This value would be stored at insertion, and the all the sorting would be done on the integer field, and not on the datetime field. </p>
<p>We never tried it, but I'm curious what do you guys think?</p>
|
[
{
"answer_id": 246164,
"author": "Eoin Campbell",
"author_id": 30155,
"author_profile": "https://Stackoverflow.com/users/30155",
"pm_score": 1,
"selected": false,
"text": "ALTER TABLE dbo.MyTable ADD TickCount BigInt Null\n\nUpdate dbo.MyTable Set TickCount = CLRFunction(DateTimeColumn)\n"
},
{
"answer_id": 4812485,
"author": "Frank Pearson",
"author_id": 591633,
"author_profile": "https://Stackoverflow.com/users/591633",
"pm_score": 0,
"selected": false,
"text": "SELECT CAST(REPLACE(convert(varchar, GETDATE(), 102),'.','')AS INT) \n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,162
|
<p>can we output a .jpg image or .gif image in C? <p>I mean can we print a picture as output with the help of a C program?<p>Aslo can we write a script in C language for HTML pages as can be written in JavaScript? <p>Can the browsers operate on it?<p>If not possible is there any plugin for any of the browsers?
<p>Any example code or links please?</p>
|
[
{
"answer_id": 246174,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 3,
"selected": true,
"text": "#include <stdio.h>\n\nmain()\n{\n char *pageTitle = \"Look, a JPEG!\";\n char *urlImage = \"/myimage.jpeg\";\n\n// Send HTTP header.\n printf(\"Content-type: text/html\\r\\n\\r\\n\");\n\n// Send the generated HTML.\n printf(\"<html><head><title>%s</title></head>\\r\\n\"\n \"<body>\\r\\n\"\n \"<h1>%s</h1>\\r\\n\"\n \"<img src=\\\"%s\\\">\\r\\n\"\n \"</body></html>\\r\\n\",\n pageTitle, pageTitle, urlImage);\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246162",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31116/"
] |
246,172
|
<p>Our app is made up of several Modules, and we would like to take advantage of the XP feature that would allow these to be grouped together. For example all windows in "Module A" would be grouped together, separately from windows in "Module B". </p>
<p>I've tried setting the AssemblyTitle attribute in the
project's AssemblyInfo.cs file but still no title appears, only the count of
the number of items. </p>
<p>Is there any way to have control over this, or is it all controlled by Windows?</p>
<p>This is in a WinForms application, for Windows XP. Note that all modules are launched/hosted by a single process but what we want to do is group together all windows contained in a certain module. The Application style is SDI/MDI hybrid, just like MS Word.</p>
<p>Thanks</p>
|
[
{
"answer_id": 246187,
"author": "Eoin Campbell",
"author_id": 30155,
"author_profile": "https://Stackoverflow.com/users/30155",
"pm_score": 0,
"selected": false,
"text": "[assembly: AssemblyDescription(\"MyAssemblyDescription\")]\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] |
246,192
|
<p>Instead of hardcoding the default @author template I would like Eclipse to use user's real name taken from account information (in Linux - but Windows solution is also welcome). Entering it somewhere into Eclipse configuration would be acceptable, too, alas I can't find the right place.</p>
|
[
{
"answer_id": 246264,
"author": "Davide Inglima",
"author_id": 32041,
"author_profile": "https://Stackoverflow.com/users/32041",
"pm_score": 9,
"selected": true,
"text": "user.name eclipse.ini -showsplash\norg.eclipse.platform\n--launcher.XXMaxPermSize\n256M\n-vmargs\n-Dosgi.requiredJavaVersion=1.5\n-Duser.name=Davide Inglima\n-Xms40m\n-Xmx512m \n"
},
{
"answer_id": 9303226,
"author": "Łukasz Siwiński",
"author_id": 235973,
"author_profile": "https://Stackoverflow.com/users/235973",
"pm_score": 2,
"selected": false,
"text": "$ pwd /Users/You/YourEclipseInstalationDirectory \n$ cd Eclipse.app/Contents/MacOS/ \n$ echo \"-Duser.name=Your Name\" >> eclipse.ini \n$ cat eclipse.ini\n"
},
{
"answer_id": 13206097,
"author": "Anuj Balan",
"author_id": 818557,
"author_profile": "https://Stackoverflow.com/users/818557",
"pm_score": 4,
"selected": false,
"text": "${user} -Duser.name=Whateverpleaseyou eclipse.ini"
},
{
"answer_id": 23194284,
"author": "Sumit Singh",
"author_id": 942391,
"author_profile": "https://Stackoverflow.com/users/942391",
"pm_score": 5,
"selected": false,
"text": "Windows > Preferences > Java > Code Style > Code Templates > Comments\n eclipse.ini -Duser.name=Sumit Singh // Your Name\n"
},
{
"answer_id": 34661765,
"author": "parasrish",
"author_id": 4361073,
"author_profile": "https://Stackoverflow.com/users/4361073",
"pm_score": 0,
"selected": false,
"text": "/etc/eclipse.ini -Duser.name=myname"
},
{
"answer_id": 41412349,
"author": "Frelling",
"author_id": 3304238,
"author_profile": "https://Stackoverflow.com/users/3304238",
"pm_score": 4,
"selected": false,
"text": "${user} user.name user.name user.author ${<name>:git_config(<key>)} <name> <key> /**\n * @author ${author:git_config(user.author)}\n *\n * ${tags}\n */\n user.author @author git config --system user.author “SET ME IN GLOBAL(USER) or REPOSITORY(LOCAL) SETTINGS”\n @author git config --global user.author “Mr. John Smith”\n @author git config --local user.author “smithy”\n ${user}"
},
{
"answer_id": 55655586,
"author": "Waqas Ahmed",
"author_id": 5679543,
"author_profile": "https://Stackoverflow.com/users/5679543",
"pm_score": -1,
"selected": false,
"text": "/**\n * @author ${user}\n *\n * ${tags}\n */\n /**\n * @author Waqas Ahmed\n *\n * ${tags}\n */\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29576/"
] |
246,193
|
<p>While working on a project, I came across a JS-script created by a former employee that basically creates a report in the form of</p>
<pre><code>Name : Value
Name2 : Value2
</code></pre>
<p>etc.</p>
<p>The peoblem is that the values can sometimes be floats (with different precision), integers, or even in the form <code>2.20011E+17</code>. What I want to output are pure integers. I don't know a lot of JavaScript, though. How would I go about writing a method that takes these sometimes-floats and makes them integers?</p>
|
[
{
"answer_id": 246203,
"author": "Aron Rotteveel",
"author_id": 11568,
"author_profile": "https://Stackoverflow.com/users/11568",
"pm_score": 4,
"selected": false,
"text": "Math.round(532.24) => 532\n"
},
{
"answer_id": 246447,
"author": "aemkei",
"author_id": 28150,
"author_profile": "https://Stackoverflow.com/users/28150",
"pm_score": 7,
"selected": true,
"text": "function toInteger(number){ \n return Math.round( // round to nearest integer\n Number(number) // type cast your input\n ); \n};\n function toInt(n){ return Math.round(Number(n)); };\n toInteger(2.5); // 3\ntoInteger(1000); // 1000\ntoInteger(\"12345.12345\"); // 12345\ntoInteger(\"2.20011E+17\"); // 220011000000000000\n"
},
{
"answer_id": 478445,
"author": "Raj Rao",
"author_id": 44815,
"author_profile": "https://Stackoverflow.com/users/44815",
"pm_score": 7,
"selected": false,
"text": "function roundNumber(number, digits) {\n var multiple = Math.pow(10, digits);\n var rndedNum = Math.round(number * multiple) / multiple;\n return rndedNum;\n }\n"
},
{
"answer_id": 10453009,
"author": "Maxime Pacary",
"author_id": 488666,
"author_profile": "https://Stackoverflow.com/users/488666",
"pm_score": 5,
"selected": false,
"text": "Math.round() // 'improve' Math.round() to support a second argument\nvar _round = Math.round;\nMath.round = function(number, decimals /* optional, default 0 */)\n{\n if (arguments.length == 1)\n return _round(number);\n\n var multiplier = Math.pow(10, decimals);\n return _round(number * multiplier) / multiplier;\n}\n\n// examples\nMath.round('123.4567', 2); // => 123.46\nMath.round('123.4567'); // => 123\n"
},
{
"answer_id": 10480103,
"author": "irfandar",
"author_id": 1379441,
"author_profile": "https://Stackoverflow.com/users/1379441",
"pm_score": 4,
"selected": false,
"text": "toFixed(x) toPrecision(x)"
},
{
"answer_id": 18741520,
"author": "user2768720",
"author_id": 2768720,
"author_profile": "https://Stackoverflow.com/users/2768720",
"pm_score": 0,
"selected": false,
"text": "function Rounding (number, precision){\n\nvar newNumber;\nvar sNumber = number.toString();\n\nvar increase = precision + sNumber.length - sNumber.indexOf('.') + 1;\n\nif (number < 0)\n newNumber = (number - 5 * Math.pow(10,-increase));\nelse\n newNumber = (number + 5 * Math.pow(10,-increase));\n\nvar multiple = Math.pow(10,precision);\n\nreturn Math.round(newNumber * multiple)/multiple;\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18673/"
] |
246,211
|
<p>What is the default capacity of a <code>StringBuilder</code>?</p>
<p>And when should (or shouldn't) the default be used?</p>
|
[
{
"answer_id": 246218,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": -1,
"selected": false,
"text": "StringList StringCollection ArrayList List<string> T[] ArrayList Add List<T>"
},
{
"answer_id": 246465,
"author": "baretta",
"author_id": 30052,
"author_profile": "https://Stackoverflow.com/users/30052",
"pm_score": 5,
"selected": false,
"text": "// where 96 is a rough estimate of the size needed for each item\nStringBuilder sb = new StringBuilder ( count * 96 );\nfor ( int i = 0; i < count; i++ )\n{\n...\n}\n"
},
{
"answer_id": 8523449,
"author": "Jon Hanna",
"author_id": 400547,
"author_profile": "https://Stackoverflow.com/users/400547",
"pm_score": 4,
"selected": false,
"text": "StringBuilder Append StringBuilder"
},
{
"answer_id": 18909245,
"author": "Jigna",
"author_id": 2761122,
"author_profile": "https://Stackoverflow.com/users/2761122",
"pm_score": 1,
"selected": false,
"text": "StringBuilder StringBuilder builder = new StringBuilder();\nvar capacity = builder.Capacity;\nvar maxCapacity = builder.MaxCapacity;\n StringBuilder StringBuilder Max Capacity Int32"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1755/"
] |
246,215
|
<p>I am writing a shell script that takes file paths as input.</p>
<p>For this reason, I need to generate recursive file listings with full paths. For example, the file <code>bar</code> has the path:</p>
<pre><code>/home/ken/foo/bar
</code></pre>
<p>but, as far as I can see, both <code>ls</code> and <code>find</code> only give relative path listings:</p>
<pre><code>./foo/bar (from the folder ken)
</code></pre>
<p>It seems like an obvious requirement, but I can't see anything in the <code>find</code> or <code>ls</code> man pages.</p>
<p>How can I generate a list of files in the shell including their absolute paths?</p>
|
[
{
"answer_id": 246220,
"author": "Matthew Scharley",
"author_id": 15537,
"author_profile": "https://Stackoverflow.com/users/15537",
"pm_score": 10,
"selected": true,
"text": "find find \"$(pwd)\" -name .htaccess\n $PWD find \"$PWD\" -name .htaccess\n find pwd -P"
},
{
"answer_id": 246221,
"author": "David Arno",
"author_id": 7122,
"author_profile": "https://Stackoverflow.com/users/7122",
"pm_score": -1,
"selected": false,
"text": "find / -print"
},
{
"answer_id": 246224,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 6,
"selected": false,
"text": "find $PWD \n"
},
{
"answer_id": 1427114,
"author": "didi",
"author_id": 53094,
"author_profile": "https://Stackoverflow.com/users/53094",
"pm_score": 5,
"selected": false,
"text": "ls -d \"$PWD/\"*\n"
},
{
"answer_id": 2162261,
"author": "Trudius",
"author_id": 261847,
"author_profile": "https://Stackoverflow.com/users/261847",
"pm_score": 3,
"selected": false,
"text": "find /home/ken/foo/ -name bar -print \n find . -name bar -print /home/ken/foo/bar\n ls -l ls -l find /home/ken/foo -name bar -exec ls -l {} ;\\ \n {} ; -rw-r--r-- 1 ken admin 181 Jan 27 15:49 /home/ken/foo/bar\n find / -name bar -exec ls -l {} ;\\ 2> /dev/null\n 2>"
},
{
"answer_id": 3105345,
"author": "Albert",
"author_id": 374636,
"author_profile": "https://Stackoverflow.com/users/374636",
"pm_score": -1,
"selected": false,
"text": "ls -1 | awk -vpath=$PWD/ '{print path$1}'\n"
},
{
"answer_id": 3572628,
"author": "user431529",
"author_id": 431529,
"author_profile": "https://Stackoverflow.com/users/431529",
"pm_score": 7,
"selected": false,
"text": "/ ** ls -d -1 \"$PWD/\"**/\n . ls -d -1 \"$PWD/\"*.*\n ls -d -1 \"$PWD/\"**/*\n ** shopt -s globstar"
},
{
"answer_id": 4577170,
"author": "balki",
"author_id": 463758,
"author_profile": "https://Stackoverflow.com/users/463758",
"pm_score": 8,
"selected": false,
"text": "readlink -f filename \n"
},
{
"answer_id": 5493917,
"author": "rxw",
"author_id": 220472,
"author_profile": "https://Stackoverflow.com/users/220472",
"pm_score": 1,
"selected": false,
"text": "lspwd() { for i in $@; do ls -d -1 $PWD/$i; done }\n"
},
{
"answer_id": 7000260,
"author": "Gurpreet",
"author_id": 365358,
"author_profile": "https://Stackoverflow.com/users/365358",
"pm_score": 3,
"selected": false,
"text": "$PWD find $PWD -type f -name \"*.c\" \n find $PWD -type f\n"
},
{
"answer_id": 54975344,
"author": "Mike Behr",
"author_id": 10860023,
"author_profile": "https://Stackoverflow.com/users/10860023",
"pm_score": 1,
"selected": false,
"text": "find . -type f -name \"extr*\" -exec echo `pwd`/{} \\; | sed \"s|\\./||\"\n"
},
{
"answer_id": 55251492,
"author": "GSM",
"author_id": 2714227,
"author_profile": "https://Stackoverflow.com/users/2714227",
"pm_score": 4,
"selected": false,
"text": "ls -1 -d \"$PWD/\"* [root@kubenode1 ssl]# ls -1 -d \"$PWD/\"*\n/etc/kubernetes/folder/file-test-config.txt\n/etc/kubernetes/folder/file-test.txt\n/etc/kubernetes/folder/file-client.txt\n"
},
{
"answer_id": 58537748,
"author": "Raveen Kumar",
"author_id": 7914647,
"author_profile": "https://Stackoverflow.com/users/7914647",
"pm_score": 1,
"selected": false,
"text": "find \"$(pwd)\" -maxdepth 1\n ls -d -1 \"$PWD/\".*; ls -d -1 \"$PWD/\"*;\n"
},
{
"answer_id": 58540753,
"author": "kenorb",
"author_id": 55075,
"author_profile": "https://Stackoverflow.com/users/55075",
"pm_score": 1,
"selected": false,
"text": "stat stat -c %n \"$PWD\"/foo/bar\n"
},
{
"answer_id": 58540801,
"author": "kenorb",
"author_id": 55075,
"author_profile": "https://Stackoverflow.com/users/55075",
"pm_score": 3,
"selected": false,
"text": "fd fd find fd . foo -a\n . foo etc fd . /etc -a -a --absolute-path"
},
{
"answer_id": 59637390,
"author": "Marisha",
"author_id": 12005509,
"author_profile": "https://Stackoverflow.com/users/12005509",
"pm_score": 3,
"selected": false,
"text": "ls -d \"$PWD/\"* \n * echo \"$PWD/\"*\n -1"
},
{
"answer_id": 60597033,
"author": "fangxlmr",
"author_id": 11372883,
"author_profile": "https://Stackoverflow.com/users/11372883",
"pm_score": 2,
"selected": false,
"text": "for name in /home/ken/foo/bar/*\ndo\n echo $name\ndone\n for echo find"
},
{
"answer_id": 61906980,
"author": "Thyag",
"author_id": 1338875,
"author_profile": "https://Stackoverflow.com/users/1338875",
"pm_score": 3,
"selected": false,
"text": "find $PWD -type f\n find $PWD -maxdepth 1 -type f\n"
},
{
"answer_id": 62272135,
"author": "JGurtz",
"author_id": 287746,
"author_profile": "https://Stackoverflow.com/users/287746",
"pm_score": 1,
"selected": false,
"text": "realpath FILENAME realpath -s FILENAME"
},
{
"answer_id": 62365350,
"author": "Adam",
"author_id": 13741548,
"author_profile": "https://Stackoverflow.com/users/13741548",
"pm_score": 1,
"selected": false,
"text": "find / -iname \"*SEARCH TERM spaces are okay*\" -print 2>&1 | grep -v denied |grep -v permitted |sed -E 's/\\ /\\\\ /g'\n"
},
{
"answer_id": 63319024,
"author": "linux.cnf",
"author_id": 10000566,
"author_profile": "https://Stackoverflow.com/users/10000566",
"pm_score": 0,
"selected": false,
"text": "/var/log/ find /var/log/ -type f #listing file recursively \n for i in $(find $PWD -type f) ; do cat /dev/null > \"$i\" ; done #empty files recursively \n ls -ltr $(find /var/log/ -type f ) # listing file used in recent\n $PWD /var/log"
},
{
"answer_id": 66028792,
"author": "Michael Yan",
"author_id": 10330832,
"author_profile": "https://Stackoverflow.com/users/10330832",
"pm_score": 0,
"selected": false,
"text": "tree -iFL 1 [DIR]\n -i -f -L 1"
},
{
"answer_id": 66289574,
"author": "Jabir Ali",
"author_id": 4594212,
"author_profile": "https://Stackoverflow.com/users/4594212",
"pm_score": 3,
"selected": false,
"text": "ls -1 |xargs realpath\n ls -1 $FILEPATH |xargs realpath\n"
},
{
"answer_id": 67534394,
"author": "Koder95",
"author_id": 12581888,
"author_profile": "https://Stackoverflow.com/users/12581888",
"pm_score": 4,
"selected": false,
"text": "find \"$PWD\"/\n"
},
{
"answer_id": 67995568,
"author": "geosmart",
"author_id": 3480359,
"author_profile": "https://Stackoverflow.com/users/3480359",
"pm_score": 2,
"selected": false,
"text": "`ls -R |grep \"\\.jar$\" | xargs readlink -f` \n /opt/tool/dev/maven_repo/com/oracle/ojdbc/ojdbc8-19.3.0.0.jar\n/opt/tool/dev/maven_repo/com/oracle/ojdbc/ons-19.3.0.0.jar\n/opt/tool/dev/maven_repo/com/oracle/ojdbc/oraclepki-19.3.0.0.jar\n/opt/tool/dev/maven_repo/com/oracle/ojdbc/osdt_cert-19.3.0.0.jar\n/opt/tool/dev/maven_repo/com/oracle/ojdbc/osdt_core-19.3.0.0.jar\n/opt/tool/dev/maven_repo/com/oracle/ojdbc/simplefan-19.3.0.0.jar\n/opt/tool/dev/maven_repo/com/oracle/ojdbc/ucp-19.3.0.0.jar\n\n"
},
{
"answer_id": 69397542,
"author": "Daniel Kobe",
"author_id": 4885784,
"author_profile": "https://Stackoverflow.com/users/4885784",
"pm_score": 2,
"selected": false,
"text": "lfp ()\n{\n ls -1 $1 | xargs -I{} echo $(realpath $1)/{}\n}\n\n"
},
{
"answer_id": 73065141,
"author": "Renju Ashokan",
"author_id": 6531633,
"author_profile": "https://Stackoverflow.com/users/6531633",
"pm_score": 0,
"selected": false,
"text": "lsf() {\nls `pwd`/$1\n}\n lsf test.sh \n /home/testuser/Downloads/test.sh\n"
},
{
"answer_id": 73781205,
"author": "YouJiacheng",
"author_id": 16613821,
"author_profile": "https://Stackoverflow.com/users/16613821",
"pm_score": 1,
"selected": false,
"text": "for p in <either relative of absolute path of the directory>/*; do\n echo $(realpath -s $p)\ndone\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20074/"
] |
246,223
|
<p>Is there any way to export data (not necessarily schema) to an access database via asp.net?</p>
<p>The server has no office components installed and the process must occur via a webpage (like an excel export).</p>
|
[
{
"answer_id": 246959,
"author": "Eduardo Molteni",
"author_id": 2385,
"author_profile": "https://Stackoverflow.com/users/2385",
"pm_score": 3,
"selected": true,
"text": " 'select References from the Project Menu, choose the COM tab, \n 'and add a reference to Microsoft ADO Ext. 2.7 for DDL and Security\n\n Public Function CreateAccessDatabase( ByVal DatabaseFullPath As String) As Boolean\n Dim bAns As Boolean\n Dim cat As New ADOX.Catalog()\n Try\n\n\n 'Make sure the folder\n 'provided in the path exists. If file name w/o path \n 'is specified, the database will be created in your\n 'application folder.\n\n Dim sCreateString As String\n sCreateString = _\n \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\" & _\n DatabaseFullPath\n cat.Create(sCreateString)\n\n bAns = True\n\n Catch Excep As System.Runtime.InteropServices.COMException\n bAns = False\n 'do whatever else you need to do here, log, \n 'msgbox etc.\n Finally\n cat = Nothing\n End Try\n Return bAns\n End Function\n\n\n DEMO\n ====\n\n\n ' If CreateAccessDatabase(\"F:\\test.mdb\") = True Then\n ' MsgBox(\"Database Created\")\n ' Else\n ' MsgBox(\"Database Creation Failed\")\n ' End If\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23230/"
] |
246,225
|
<p>I need to create a midnight DateTime</p>
<p>I've just done this:</p>
<pre><code>DateTime endTime = DateTime.Now;
endTime.Subtract(endTime.TimeOfDay);
</code></pre>
<p>Haven't test it yet, I'm assuming it works but is there a better/cleaner way?</p>
|
[
{
"answer_id": 246229,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 9,
"selected": true,
"text": "foo.Date DateTime.Today"
},
{
"answer_id": 246237,
"author": "WebDude",
"author_id": 15360,
"author_profile": "https://Stackoverflow.com/users/15360",
"pm_score": 4,
"selected": false,
"text": "DateTime.Now AddDays(1) Date"
},
{
"answer_id": 246253,
"author": "zendar",
"author_id": 25732,
"author_profile": "https://Stackoverflow.com/users/25732",
"pm_score": 5,
"selected": false,
"text": "DateTime endTime = DateTime.Now.Date;\n endTime.TimeOfDay.ToString() \"00:00:00\""
},
{
"answer_id": 40780390,
"author": "Aruna",
"author_id": 2047527,
"author_profile": "https://Stackoverflow.com/users/2047527",
"pm_score": 4,
"selected": false,
"text": "DateTime.Today DateTime today = DateTime.Today;\n DateTime mid = today.AddDays(1).AddSeconds(-1);\n Console.WriteLine(string.Format(\"Today: {0} , Mid Night: {1}\", today.ToString(), mid.ToString()));\n\n Console.ReadLine();\n Today: 11/24/2016 10:00:00 AM , Mid Night: 11/24/2016 11:59:59 PM\n"
},
{
"answer_id": 41837573,
"author": "David Petersen",
"author_id": 7322542,
"author_profile": "https://Stackoverflow.com/users/7322542",
"pm_score": -1,
"selected": false,
"text": " private bool IsServiceDatabaseProcessReadyToStart()\n {\n bool isGoodParms = true;\n DateTime currentTime = DateTime.Now;\n //24 Hour Clock\n string[] timeSpan = currentTime.ToString(\"HH:mm:ss\").Split(':');\n //Default to Noon\n int hr = 12;\n int mn = 0;\n int sc = 0;\n\n if (!string.IsNullOrEmpty(timeSpan[0]))\n {\n hr = Convert.ToInt32(timeSpan[0]);\n }\n else\n {\n isGoodParms = false;\n }\n\n if (!string.IsNullOrEmpty(timeSpan[1]))\n {\n mn = Convert.ToInt32(timeSpan[1]);\n }\n else\n {\n isGoodParms = false;\n }\n\n if (!string.IsNullOrEmpty(timeSpan[2]))\n {\n sc = Convert.ToInt32(timeSpan[2]);\n }\n else\n {\n isGoodParms = false;\n }\n\n if (isGoodParms == true )\n {\n TimeSpan currentTimeSpan = new TimeSpan(hr, mn, sc);\n TimeSpan minTimeSpan = new TimeSpan(0, 0, 0);\n TimeSpan maxTimeSpan = new TimeSpan(0, 04, 59);\n if (currentTimeSpan >= minTimeSpan && currentTimeSpan <= maxTimeSpan)\n {\n return true;\n }\n else\n {\n return false;\n }\n }\n else\n {\n return false;\n }\n }\n"
},
{
"answer_id": 54315961,
"author": "Peter",
"author_id": 9221484,
"author_profile": "https://Stackoverflow.com/users/9221484",
"pm_score": 1,
"selected": false,
"text": "var dateMidnight = DateTime.ParseExact(DateTime.Now.ToString(\"yyyyMMdd\"), \"yyyyMMdd\", CultureInfo.InvariantCulture);\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25462/"
] |
246,227
|
<p>There's an option to hide the version so it will display only nginx, but is there a way to hide that too so it will not show anything or change the header?</p>
|
[
{
"answer_id": 246294,
"author": "joelhardi",
"author_id": 11438,
"author_profile": "https://Stackoverflow.com/users/11438",
"pm_score": 7,
"selected": true,
"text": "src/http/ngx_http_header_filter_module.c ## vi src/http/ngx_http_header_filter_module.c (lines 48 and 49)\nstatic char ngx_http_server_string[] = \"Server: MyDomain.com\" CRLF;\nstatic char ngx_http_server_full_string[] = \"Server: MyDomain.com\" CRLF;\n"
},
{
"answer_id": 729553,
"author": "Jauder Ho",
"author_id": 26366,
"author_profile": "https://Stackoverflow.com/users/26366",
"pm_score": 2,
"selected": false,
"text": "Server: Hai\n"
},
{
"answer_id": 2280486,
"author": "Flavius",
"author_id": 88054,
"author_profile": "https://Stackoverflow.com/users/88054",
"pm_score": 5,
"selected": false,
"text": "Content-Type Content-Length Server -s -t"
},
{
"answer_id": 8139116,
"author": "Rui Marques",
"author_id": 379556,
"author_profile": "https://Stackoverflow.com/users/379556",
"pm_score": 5,
"selected": false,
"text": "#server_tokens off;\n"
},
{
"answer_id": 9253190,
"author": "Brandon Rhodes",
"author_id": 85360,
"author_profile": "https://Stackoverflow.com/users/85360",
"pm_score": 7,
"selected": false,
"text": "Server: server {…} proxy_pass_header Server;\n"
},
{
"answer_id": 23589719,
"author": "Farshid Ashouri",
"author_id": 895659,
"author_profile": "https://Stackoverflow.com/users/895659",
"pm_score": 5,
"selected": false,
"text": "server_tokens off;\nmore_set_headers 'Server: My Very Own Server';\n"
},
{
"answer_id": 29881550,
"author": "Parthian Shot",
"author_id": 3680301,
"author_profile": "https://Stackoverflow.com/users/3680301",
"pm_score": 4,
"selected": false,
"text": "sed -i 's/nginx\\r/thing\\r/' `which nginx`\n server_tokens off"
},
{
"answer_id": 33513698,
"author": "james-see",
"author_id": 1215344,
"author_profile": "https://Stackoverflow.com/users/1215344",
"pm_score": 7,
"selected": false,
"text": "sudo apt-get update\nsudo apt-get install nginx-extras\n http nginx.conf sudo nano /etc/nginx/nginx.conf\nserver_tokens off; # removed pound sign\nmore_set_headers 'Server: Eff_You_Script_Kiddies!';\n sudo service nginx restart"
},
{
"answer_id": 44325540,
"author": "Aamish Baloch",
"author_id": 4776650,
"author_profile": "https://Stackoverflow.com/users/4776650",
"pm_score": 5,
"selected": false,
"text": "sudo apt-get update\nsudo apt-get install nginx-extras\n more_clear_headers Server;\nserver_tokens off;\n"
},
{
"answer_id": 51746866,
"author": "Afrig Aminuddin",
"author_id": 1124942,
"author_profile": "https://Stackoverflow.com/users/1124942",
"pm_score": 2,
"selected": false,
"text": "/usr/sbin/nginx Server: nginx/1.12.2\nServer: nginx/1.12.2\nServer: nginx\n server_tokens on; sed -i 's/Server: nginx/Server: thing/' `which nginx`\n <hr><center>nginx</center>\n sed -i 's/center>nginx/center>thing/' `which nginx`\n"
},
{
"answer_id": 55952210,
"author": "Adrian",
"author_id": 4681265,
"author_profile": "https://Stackoverflow.com/users/4681265",
"pm_score": 3,
"selected": false,
"text": "Syntax: server_tokens on | off | build | string;\n"
},
{
"answer_id": 61628484,
"author": "LazyDeveloper",
"author_id": 10012744,
"author_profile": "https://Stackoverflow.com/users/10012744",
"pm_score": 0,
"selected": false,
"text": " server_tokens '';\n server_tokens off;\n"
},
{
"answer_id": 73401209,
"author": "Kristofer",
"author_id": 1398417,
"author_profile": "https://Stackoverflow.com/users/1398417",
"pm_score": 0,
"selected": false,
"text": "sed -i 's/Server: nginx/My-Header: hi/' `which nginx`\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9789/"
] |
246,228
|
<p>If I make a JFrame like this</p>
<pre><code>public static void main(String[] args) {
new JFrame().setVisible(true);
}
</code></pre>
<p>then after closing the window the appication doesn't stop (I need to kill it).</p>
<p>What is the proper way of showing application's main windows ?</p>
<p>I'd also like to know a reason of a proposed solution.</p>
<p>Thanks in advance.</p>
|
[
{
"answer_id": 246234,
"author": "Burkhard",
"author_id": 12860,
"author_profile": "https://Stackoverflow.com/users/12860",
"pm_score": 6,
"selected": true,
"text": "setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); public static void main(String[] args) {\n Runnable guiCreator = new Runnable() {\n public void run() {\n JFrame fenster = new JFrame(\"Hallo Welt mit Swing\");\n fenster.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n fenster.setVisible(true);\n }\n };\n SwingUtilities.invokeLater(guiCreator);\n}\n"
},
{
"answer_id": 246250,
"author": "Yuval",
"author_id": 2819,
"author_profile": "https://Stackoverflow.com/users/2819",
"pm_score": 2,
"selected": false,
"text": "main() System.exit(0);"
},
{
"answer_id": 246279,
"author": "jassuncao",
"author_id": 1009,
"author_profile": "https://Stackoverflow.com/users/1009",
"pm_score": 2,
"selected": false,
"text": "DISPOSE_ON_CLOSE EXIT_ON_CLOSE DISPOSE_ON_CLOSE EXIT_ON_CLOSE System.exit DISPOSE_ON_CLOSE"
},
{
"answer_id": 8660157,
"author": "giannis christofakis",
"author_id": 839554,
"author_profile": "https://Stackoverflow.com/users/839554",
"pm_score": 0,
"selected": false,
"text": "frame.addWindowListener(new WindowAdapter() {\n public void windowClosing(WindowEvent e) {\n System.exit(0);\n }\n}\n"
},
{
"answer_id": 43114906,
"author": "Steve Smith",
"author_id": 1551685,
"author_profile": "https://Stackoverflow.com/users/1551685",
"pm_score": 0,
"selected": false,
"text": "windowClosing() dispose(); System.exit() setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24028/"
] |
246,232
|
<p>I have the following text</p>
<pre><code>tooooooooooooon
</code></pre>
<p>According to this book I'm reading, when the <code>?</code> follows after any quantifier, it becomes non greedy.</p>
<p>My regex <code>to*?n</code> is still returning <code>tooooooooooooon</code>.</p>
<p>It should return <code>ton</code> shouldn't it?</p>
<p>Any idea why?</p>
|
[
{
"answer_id": 246239,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 7,
"selected": true,
"text": "toooooooonoooooon\n t.*n\n toooooooonoooooon\n t.*?n\n toooooooon\n"
},
{
"answer_id": 246244,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": false,
"text": "$a = \"toooooo\";\n$b = \"toooooon\";\n\nif ($a =~ m/(to*?)/) {\n print $1,\"\\n\";\n}\nif ($b =~ m/(to*?n)/) {\n print $1,\"\\n\";\n}\n\n~>perl ex.pl\nt\ntoooooon\n"
},
{
"answer_id": 249069,
"author": "Brad Gilbert",
"author_id": 1337,
"author_profile": "https://Stackoverflow.com/users/1337",
"pm_score": 2,
"selected": false,
"text": "/o*?/ 'o' \"tooooon\" 'o' 'n' 'o' 'o' /to*+n/ 'o'"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17211/"
] |
246,233
|
<p>I'm trying to print to Dot Matrix printers (various models) out of C#, currently I'm using Win32 API (you can find alot of examples online) calls to send escape codes directly to the printer out of my C# application. This works great, but...</p>
<p>My problem is because I'm generating the escape codes and not relying on the windows print system the printouts can't be sent to any "normal" printers or to things like PDF print drivers. (This is now causing a problem as we're trying to use the application on a 2008 Terminal Server using Easy Print [Which is XPS based])</p>
<p>The question is:
How can I print formatted documents (invoices on pre-printed stationary) to Dot Matrix printers (Epson, Oki and Panasonic... various models) out of C# not using direct printing, escape codes etc.</p>
<p>**Just to clarify, I'm trying things like GDI+ (System.Drawing.Printing) but the problem is that its very hard, to get things to line up like the old code did. (The old code sent the characters direct to the printer bypassing the windows driver.) Any suggestions how things could be improved so that they could use GDI+ but still line up like the old code did?</p>
|
[
{
"answer_id": 249807,
"author": "alexandrul",
"author_id": 19756,
"author_profile": "https://Stackoverflow.com/users/19756",
"pm_score": 3,
"selected": false,
"text": "type file.txt > lpt1 NOTEPAD /P file.txt"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32305/"
] |
246,249
|
<p>Is there any way to add iCal event to the iPhone Calendar from the custom App?</p>
|
[
{
"answer_id": 3177284,
"author": "WoodenKitty",
"author_id": 2684342,
"author_profile": "https://Stackoverflow.com/users/2684342",
"pm_score": 7,
"selected": false,
"text": "#import \"EventTestViewController.h\"\n#import <EventKit/EventKit.h>\n\n@implementation EventTestViewController\n\n- (void)viewDidLoad {\n [super viewDidLoad];\n\n EKEventStore *eventStore = [[EKEventStore alloc] init];\n\n EKEvent *event = [EKEvent eventWithEventStore:eventStore];\n event.title = @\"EVENT TITLE\";\n\n event.startDate = [[NSDate alloc] init];\n event.endDate = [[NSDate alloc] initWithTimeInterval:600 sinceDate:event.startDate];\n\n [event setCalendar:[eventStore defaultCalendarForNewEvents]];\n NSError *err;\n [eventStore saveEvent:event span:EKSpanThisEvent error:&err]; \n}\n\n@end\n"
},
{
"answer_id": 11397272,
"author": "Iggy",
"author_id": 216354,
"author_profile": "https://Stackoverflow.com/users/216354",
"pm_score": 3,
"selected": false,
"text": " - (void)addAnEvent {\n // Make a new event, and show it to the user to edit\n GTLCalendarEvent *newEvent = [GTLCalendarEvent object];\n newEvent.summary = @\"Sample Added Event\";\n newEvent.descriptionProperty = @\"Description of sample added event\";\n\n // We'll set the start time to now, and the end time to an hour from now,\n // with a reminder 10 minutes before\n NSDate *anHourFromNow = [NSDate dateWithTimeIntervalSinceNow:60*60];\n GTLDateTime *startDateTime = [GTLDateTime dateTimeWithDate:[NSDate date]\n timeZone:[NSTimeZone systemTimeZone]];\n GTLDateTime *endDateTime = [GTLDateTime dateTimeWithDate:anHourFromNow\n timeZone:[NSTimeZone systemTimeZone]];\n\n newEvent.start = [GTLCalendarEventDateTime object];\n newEvent.start.dateTime = startDateTime;\n\n newEvent.end = [GTLCalendarEventDateTime object];\n newEvent.end.dateTime = endDateTime;\n\n GTLCalendarEventReminder *reminder = [GTLCalendarEventReminder object];\n reminder.minutes = [NSNumber numberWithInteger:10];\n reminder.method = @\"email\";\n\n newEvent.reminders = [GTLCalendarEventReminders object];\n newEvent.reminders.overrides = [NSArray arrayWithObject:reminder];\n newEvent.reminders.useDefault = [NSNumber numberWithBool:NO];\n\n // Display the event edit dialog\n EditEventWindowController *controller = [[[EditEventWindowController alloc] init] autorelease];\n [controller runModalForWindow:[self window]\n event:newEvent\n completionHandler:^(NSInteger returnCode, GTLCalendarEvent *event) {\n // Callback\n if (returnCode == NSOKButton) {\n [self addEvent:event];\n }\n }];\n}\n"
},
{
"answer_id": 17331677,
"author": "William T.",
"author_id": 1807644,
"author_profile": "https://Stackoverflow.com/users/1807644",
"pm_score": 8,
"selected": true,
"text": "#import <EventKit/EventKit.h> EKEventStore *store = [EKEventStore new];\n [store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {\n if (!granted) { return; }\n EKEvent *event = [EKEvent eventWithEventStore:store];\n event.title = @\"Event Title\";\n event.startDate = [NSDate date]; //today\n event.endDate = [event.startDate dateByAddingTimeInterval:60*60]; //set 1 hour meeting\n event.calendar = [store defaultCalendarForNewEvents];\n NSError *err = nil;\n [store saveEvent:event span:EKSpanThisEvent commit:YES error:&err];\n self.savedEventId = event.eventIdentifier; //save the event id if you want to access this later\n }];\n EKEventStore* store = [EKEventStore new];\n [store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {\n if (!granted) { return; }\n EKEvent* eventToRemove = [store eventWithIdentifier:self.savedEventId];\n if (eventToRemove) {\n NSError* error = nil;\n [store removeEvent:eventToRemove span:EKSpanThisEvent commit:YES error:&error];\n }\n }];\n import EventKit\n let store = EKEventStore()\nstore.requestAccessToEntityType(.Event) {(granted, error) in\n if !granted { return }\n var event = EKEvent(eventStore: store)\n event.title = \"Event Title\"\n event.startDate = NSDate() //today\n event.endDate = event.startDate.dateByAddingTimeInterval(60*60) //1 hour long meeting\n event.calendar = store.defaultCalendarForNewEvents\n do {\n try store.saveEvent(event, span: .ThisEvent, commit: true)\n self.savedEventId = event.eventIdentifier //save event id to access this particular event later\n } catch {\n // Display error to user\n }\n}\n let store = EKEventStore()\nstore.requestAccessToEntityType(EKEntityTypeEvent) {(granted, error) in\n if !granted { return }\n let eventToRemove = store.eventWithIdentifier(self.savedEventId)\n if eventToRemove != nil {\n do {\n try store.removeEvent(eventToRemove, span: .ThisEvent, commit: true)\n } catch {\n // Display error to user\n }\n }\n}\n"
},
{
"answer_id": 34790334,
"author": "Dashrath",
"author_id": 1510544,
"author_profile": "https://Stackoverflow.com/users/1510544",
"pm_score": 3,
"selected": false,
"text": "import EventKit @IBAction func addtoCalendarClicked(sender: AnyObject) {\n\n let eventStore = EKEventStore()\n\n eventStore.requestAccess( to: EKEntityType.event, completion:{(granted, error) in\n\n if (granted) && (error == nil) {\n print(\"granted \\(granted)\")\n print(\"error \\(error)\")\n\n let event = EKEvent(eventStore: eventStore)\n\n event.title = \"Event Title\"\n event.startDate = Date()\n event.endDate = Date()\n event.notes = \"Event Details Here\"\n event.calendar = eventStore.defaultCalendarForNewEvents\n\n var event_id = \"\"\n do {\n try eventStore.save(event, span: .thisEvent)\n event_id = event.eventIdentifier\n }\n catch let error as NSError {\n print(\"json error: \\(error.localizedDescription)\")\n }\n\n if(event_id != \"\"){\n print(\"event added !\")\n }\n }\n })\n}\n"
},
{
"answer_id": 38269271,
"author": "halbano",
"author_id": 677210,
"author_profile": "https://Stackoverflow.com/users/677210",
"pm_score": 1,
"selected": false,
"text": "\"Error Domain=EKErrorDomain Code=3 \"No end date has been set.\" UserInfo={NSLocalizedDescription=No end date has been set.}\"\n EKEventStore *store = [EKEventStore new];\n[store requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {\n if (!granted) { return; }\n EKEvent *calendarEvent = [EKEvent eventWithEventStore:store];\n calendarEvent.title = [NSString stringWithFormat:@\"CEmprendedor: %@\", _event.name];\n calendarEvent.startDate = _event.date;\n // 5 hours of duration, we must add the duration of the event to the API\n NSDate *endDate = [_event.date dateByAddingTimeInterval:60*60*5];\n calendarEvent.endDate = endDate;\n calendarEvent.calendar = [store defaultCalendarForNewEvents];\n NSError *err = nil;\n [store saveEvent:calendarEvent span:EKSpanThisEvent commit:YES error:&err];\n self.savedEventId = calendarEvent.eventIdentifier; //saving the calendar event id to possibly deleted them\n}];\n"
},
{
"answer_id": 46721030,
"author": "luhuiya",
"author_id": 932672,
"author_profile": "https://Stackoverflow.com/users/932672",
"pm_score": 2,
"selected": false,
"text": "import UIKit\nimport EventKit\n\nclass ViewController: UIViewController {\n\n override func viewDidLoad() {\n super.viewDidLoad()\n\n let eventStore = EKEventStore()\n\n eventStore.requestAccess( to: EKEntityType.event, completion:{(granted, error) in\n\n if (granted) && (error == nil) {\n\n\n let event = EKEvent(eventStore: eventStore)\n\n event.title = \"My Event\"\n event.startDate = Date(timeIntervalSinceNow: TimeInterval())\n event.endDate = Date(timeIntervalSinceNow: TimeInterval())\n event.notes = \"Yeah!!!\"\n event.calendar = eventStore.defaultCalendarForNewEvents\n\n var event_id = \"\"\n do{\n try eventStore.save(event, span: .thisEvent)\n event_id = event.eventIdentifier\n }\n catch let error as NSError {\n print(\"json error: \\(error.localizedDescription)\")\n }\n\n if(event_id != \"\"){\n print(\"event added !\")\n }\n }\n })\n }\n\n override func didReceiveMemoryWarning() {\n super.didReceiveMemoryWarning()\n // Dispose of any resources that can be recreated.\n }\n\n\n}\n"
},
{
"answer_id": 52961768,
"author": "Alok",
"author_id": 3024579,
"author_profile": "https://Stackoverflow.com/users/3024579",
"pm_score": 2,
"selected": false,
"text": "import UIKit\nimport EventKit\nimport EventKitUI\n\nclass yourViewController: UIViewController{\n\n let eventStore = EKEventStore()\n\n func addEventToCalendar() {\n\n eventStore.requestAccess( to: EKEntityType.event, completion:{(granted, error) in\n DispatchQueue.main.async {\n if (granted) && (error == nil) {\n let event = EKEvent(eventStore: self.eventStore)\n event.title = self.headerDescription\n event.startDate = self.parse(self.requestDetails.value(forKey: \"session_time\") as? String ?? \"\")\n event.endDate = self.parse(self.requestDetails.value(forKey: \"session_end_time\") as? String ?? \"\")\n let eventController = EKEventEditViewController()\n eventController.event = event\n eventController.eventStore = self.eventStore\n eventController.editViewDelegate = self\n self.present(eventController, animated: true, completion: nil)\n\n }\n }\n\n\n })\n }\n\n}\n extension viewController: EKEventEditViewDelegate {\n\n func eventEditViewController(_ controller: EKEventEditViewController, didCompleteWith action: EKEventEditViewAction) {\n controller.dismiss(animated: true, completion: nil)\n\n }\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26980/"
] |
246,272
|
<p>I have a problem with how ASP.Net generates the <strong>img</strong> tag.
I have a server control like this: </p>
<pre><code><asp:Image runat="server" ID="someWarning" ImageUrl="~/images/warning.gif" AlternateText="Warning" />
</code></pre>
<p>I expect it to generate this: </p>
<pre><code><img id="ctl00_ContentPlaceHolder1_ctl00_someWarning" src="../images/warning.gif" />
</code></pre>
<p>but instead it generates this:</p>
<pre><code><img alt="" src="/Image.ashx;img=%2fimages%2fwarning.gif"</img>
</code></pre>
<p>This give me errors when I execute the following js:</p>
<pre><code>document.getElementById('ctl00_ContentPlaceHolder1_someWarning')
</code></pre>
<p>Any idea why it won't generate the expected html?</p>
|
[
{
"answer_id": 251353,
"author": "AaronS",
"author_id": 26932,
"author_profile": "https://Stackoverflow.com/users/26932",
"pm_score": 0,
"selected": false,
"text": "document.getElementById('<%=ddlCountry.ClientID%>').style.display = \"block\";\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2099426/"
] |
246,274
|
<p>I want to be able to run a function in my firefox sidebar js file when the selected tab in the main content window is reloaded or changed. So the sidebar can change depending on the site the user is looking at. </p>
<p>Anyone able to point me in the right direction?</p>
|
[
{
"answer_id": 301756,
"author": "user11198",
"author_id": 11198,
"author_profile": "https://Stackoverflow.com/users/11198",
"pm_score": 2,
"selected": false,
"text": "//add the load eventListener to the window object\nwindow.addEventListener(\"load\", function() { functioname.init(); }, true);\n\n\nvar functionname = { \n //add the listener for the document load event\ninit: function() {\n var appcontent = document.getElementById(\"appcontent\"); // browser\n if(appcontent)\n appcontent.addEventListener(\"DOMContentLoaded\", functionname.onPageLoad, false);\n },\n //function called on document load\n onPageLoad: function(aEvent) {\n if(aEvent.originalTarget.nodeName == \"#document\"){\n }\n }\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11198/"
] |
246,275
|
<p>I am working on a git repository with a master branch and another the topic branch. I have switched to topic branch and modified a file. Now, if I switched to the master branch, that same file is shown as modified.</p>
<p>For example:</p>
<p>git status in git-build branch:</p>
<pre><code># On branch git-build
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: cvsup_current
#
</code></pre>
<p>Switch to master branch</p>
<pre><code>[root@redbull builder_scripts (git-build)]# git co master
M builder_scripts/cvsup_current
Switched to branch "master"
</code></pre>
<p>git status in master branch</p>
<pre><code>[root@redbull builder_scripts (master)]# git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: cvsup_current
#
</code></pre>
<p>Why is that the file is shown as modified in the master branch even though it was modified in git-build branch?</p>
<p>My understanding was that the branches are independent of each other and when I change from one branch to another the changes do not "spill over" from one branch to another. So I am obviously missing something here.</p>
<p>Has anyone got a clue stick?</p>
|
[
{
"answer_id": 246343,
"author": "Peter Burns",
"author_id": 101,
"author_profile": "https://Stackoverflow.com/users/101",
"pm_score": 5,
"selected": false,
"text": "git stash git stash #work saved\ngit checkout master\n#edit files\ngit commit\ngit checkout git-build\ngit stash apply #restore earlier work\n git stash"
},
{
"answer_id": 30775199,
"author": "Raviteja",
"author_id": 2067448,
"author_profile": "https://Stackoverflow.com/users/2067448",
"pm_score": 2,
"selected": false,
"text": "-f git stash git stash apply"
},
{
"answer_id": 74043944,
"author": "mirekphd",
"author_id": 9962007,
"author_profile": "https://Stackoverflow.com/users/9962007",
"pm_score": 0,
"selected": false,
"text": "git git checkout git commit git checkout git add git rm git checkout"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25453/"
] |
246,280
|
<p>I have seen a function whose prototype is:</p>
<pre><code>int myfunc(void** ppt)
</code></pre>
<p>This function is called in a C file as
a = myfunc(mystruct **var1);</p>
<p>where mystruct is typedef for one of structure we have. </p>
<p>This works without any compilation errors in MSVC6.0, But when I compile it with some other C compiler, it gives an error at the place where this function is called with error message:</p>
<p><strong>Argument of type mystruct ** is incompatible with parameter of type void **</strong></p>
<p>The argument of myfunc() is kept as void** because it seems to be a generic malloc kind of function to be called with various structure variable types for memory allocation </p>
<ol>
<li>Is there any type such as void ** allowed in C standard/any C compilers?</li>
<li>How do I fix this? [I tried casting the function call argument to <code>mystruct**</code>, but it didn't work]</li>
</ol>
<p>-AD</p>
|
[
{
"answer_id": 246288,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 4,
"selected": true,
"text": "void** mystruct **var1;\nx = myfunc ((void**) var1);\n myfunc void** void*"
},
{
"answer_id": 246291,
"author": "unwind",
"author_id": 28169,
"author_profile": "https://Stackoverflow.com/users/28169",
"pm_score": 1,
"selected": false,
"text": "void ** void var1 mystruct ** a = func(var1); void **"
},
{
"answer_id": 246372,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 2,
"selected": false,
"text": "mystruct** void** void stupid(struct mystruct **a, struct myotherstruct **b)\n{\n void **x = (void **)a;\n *x = *b;\n}\n myotherstruct* void* *x = *b myotherstruct mystruct mystruct"
},
{
"answer_id": 248215,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "void ** void **foo void *bar void ** void * char * void * char *"
},
{
"answer_id": 250706,
"author": "George Eadon",
"author_id": 30530,
"author_profile": "https://Stackoverflow.com/users/30530",
"pm_score": 5,
"selected": false,
"text": "void ** void ** void * (void **)&dp some_type *var1 = foo();\nvoid *tmp_void_ptr = (void *)var1;\nmyfunc(&tmp_void_ptr);\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2759376/"
] |
246,293
|
<p>Is there any good practice related to dynamic_cast error handling (except not using it when you don't have to)? I'm wondering how should I go about NULL and bad_cast it can throw.
Should I check for both? And if I catch bad_cast or detect NULL I probably can't recover anyway...
For now, I'm using assert to check if dynamic_cast returned not NULL value. Would you accept this solution on a code review?</p>
|
[
{
"answer_id": 246313,
"author": "Johann Gerell",
"author_id": 6345,
"author_profile": "https://Stackoverflow.com/users/6345",
"pm_score": 1,
"selected": false,
"text": "dynamic_cast std::bad_cast"
},
{
"answer_id": 246323,
"author": "Magnus Hoff",
"author_id": 2971,
"author_profile": "https://Stackoverflow.com/users/2971",
"pm_score": 6,
"selected": true,
"text": "dynamic_cast boost::polymorphic_downcast assert(dynamic_cast<T*>(o) == static_cast<T*>(o));\nreturn static_cast<T*>(o);\n dynamic_cast bad_cast T& t = dynamic_cast<T&>(o);\nt.func(); //< Use t here, no extra check required\n dynamic_cast if if (T* t = dynamic_cast<T*>(o)) {\n t->func(); //< Use t here, it is valid\n}\n// consider having an else-clause\n dynamic_cast assert"
},
{
"answer_id": 246328,
"author": "Pieter",
"author_id": 5822,
"author_profile": "https://Stackoverflow.com/users/5822",
"pm_score": 5,
"selected": false,
"text": "dynamic_cast< Derived & >(baseclass)\n dynamic_cast< Derived * >(&baseclass)\n"
},
{
"answer_id": 246331,
"author": "Dave",
"author_id": 32300,
"author_profile": "https://Stackoverflow.com/users/32300",
"pm_score": 0,
"selected": false,
"text": "ptr = dynamic_cast<MyClass>(obj);\nASSERT(ptr);\nif(ptr)\n{\n // do stuff\n}\n"
},
{
"answer_id": 292356,
"author": "Nicola Bonelli",
"author_id": 19630,
"author_profile": "https://Stackoverflow.com/users/19630",
"pm_score": 2,
"selected": false,
"text": "boost::polymorphic_downcast<> dynamic_cast<> polymorphic_downcast<> dynamic_cast<> if (T1* t1 = dynamic_cast<T1*>(o)) \n{ }\nif (T2* t2 = dynamic_cast<T2*>(o)) \n{ }\nif (T3* t3 = dynamic_cast<T3*>(o)) \n{ }\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3579/"
] |
246,300
|
<p>I'm looking for a Report Designer that will allow me to connect to a RESTful webservice. Ideally I would like one that has a royalty-free End-User Report Designer. WE will be hosting it in an ASP.NET web site. So something compatable with that would be ideal ;)</p>
<p>We used to use <a href="http://www.datadynamics.com/Products/ProductOverview.aspx?Product=ARNET3" rel="nofollow noreferrer">Data Dynamics Active Reports</a>. However this doesn't allow connections to webservices.</p>
<p>Any help, very much appreciated.</p>
<p>Thanks in advance.</p>
<p>Crafty</p>
|
[
{
"answer_id": 250444,
"author": "CraftyFella",
"author_id": 30317,
"author_profile": "https://Stackoverflow.com/users/30317",
"pm_score": 0,
"selected": false,
"text": "HTTP/1.1 200 OK\nServer: ASP.NET Development Server/9.0.0.0\nDate: Thu, 30 Oct 2008 14:30:22 GMT\nX-AspNet-Version: 2.0.50727\nTransfer-Encoding: chunked\nCache-Control: private\nContent-Type: text/xml; charset=utf-8\nConnection: Close\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30317/"
] |
246,306
|
<p>How do I convert a keycode to a keychar in .NET?</p>
|
[
{
"answer_id": 246309,
"author": "Ady",
"author_id": 31395,
"author_profile": "https://Stackoverflow.com/users/31395",
"pm_score": 4,
"selected": false,
"text": "ChrW(70)\n (char) 70\n"
},
{
"answer_id": 5629660,
"author": "Yiu Korochko",
"author_id": 325238,
"author_profile": "https://Stackoverflow.com/users/325238",
"pm_score": -1,
"selected": false,
"text": " Private Declare Function GetAsyncKeyState Lib \"user32\" (ByVal vKey As Long) As Integer\n Public sub harry()\n For i = 1 to 255\n If Chr(i) = Convert.ToChar(Keys.Enter) Then\n Label1.Text &= \" [Enter] \"\n ElseIf Chr(i) = Convert.ToChar(Keys.Delete) Then\n Label1.Text &= \" [Delete] \"\n End If\n Next i\n End Sub\n"
},
{
"answer_id": 6670641,
"author": "MRb",
"author_id": 841511,
"author_profile": "https://Stackoverflow.com/users/841511",
"pm_score": 1,
"selected": false,
"text": "Private Sub StartValue_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles StartValue.KeyPress\n If ChrW(13).ToString = e.KeyChar And StartValue.Text = \"\" Then\n StartValue.Text = \"0\"\n End If\nEnd Sub\n"
},
{
"answer_id": 6957338,
"author": "Pablo Rausch",
"author_id": 880683,
"author_profile": "https://Stackoverflow.com/users/880683",
"pm_score": 3,
"selected": false,
"text": "Imports System.Runtime.InteropServices\n\nPublic Class KeyCodeToAscii\n\n <DllImport(\"User32.dll\")> _\n Public Shared Function ToAscii(ByVal uVirtKey As Integer, _\n ByVal uScanCode As Integer, _\n ByVal lpbKeyState As Byte(), _\n ByVal lpChar As Byte(), _\n ByVal uFlags As Integer) _\n As Integer\n End Function\n\n <DllImport(\"User32.dll\")> _\n Public Shared Function GetKeyboardState(ByVal pbKeyState As Byte()) _\n As Integer\n\n End Function\n\n Public Shared Function GetAsciiCharacter(ByVal uVirtKey As Integer) _\n As Char\n\n Dim lpKeyState As Byte() = New Byte(255) {}\n GetKeyboardState(lpKeyState)\n Dim lpChar As Byte() = New Byte(1) {}\n If ToAscii(uVirtKey, 0, lpKeyState, lpChar, 0) = 1 Then\n Return Convert.ToChar((lpChar(0)))\n Else\n Return New Char()\n End If\n End Function\n\nEnd Class\n"
},
{
"answer_id": 12894492,
"author": "Hasitha D",
"author_id": 1576214,
"author_profile": "https://Stackoverflow.com/users/1576214",
"pm_score": 1,
"selected": false,
"text": "Char.ConvertFromUtf32(e.KeyValue)\n"
},
{
"answer_id": 19838142,
"author": "Nooa",
"author_id": 2965149,
"author_profile": "https://Stackoverflow.com/users/2965149",
"pm_score": -1,
"selected": false,
"text": "#region Just for fun :D\n\nprivate string _lastKeys = \"\";\n\nprivate readonly Dictionary<string, string[]> _keyChecker = _\n new Dictionary<string, string[]>\n {\n // Key code to press, msgbox header, msgbox text\n {\"iddqd\", new[] {\"Cheater! :-)\", \"Godmode activated!\"}},\n {\"idkfa\", new[] {\"Cheater! :-)\", \"All Weapons unlocked!\"}},\n {\"aAa\", new[] {\"Testing\", \"Test!\"}},\n {\"aaa\", new[] {\"function\", \"close\"}}\n };\n\nprivate void KeyChecker(KeyPressEventArgs e)\n{\n _lastKeys += e.KeyChar;\n\n foreach (var key in _keyChecker.Keys)\n if (_lastKeys.EndsWith(key))\n if (_keyChecker[key][0] != \"function\")\n MessageBox.Show(_keyChecker[key][1], _keyChecker[key][0]);\n else\n KeyCheckerFunction(_keyChecker[key][1]);\n\n while (_lastKeys.Length > 100)\n _lastKeys = _lastKeys.Substring(1);\n}\n\nprivate void KeyCheckerFunction(string func)\n{\n switch (func)\n {\n case \"close\":\n Close();\n break;\n }\n}\n\nprivate void FormMain_KeyPress(object sender, KeyPressEventArgs e)\n{\n KeyChecker(e);\n}\n\n#endregion Just for fun :D\n"
},
{
"answer_id": 70236087,
"author": "Philippe Hollmuller",
"author_id": 17596014,
"author_profile": "https://Stackoverflow.com/users/17596014",
"pm_score": -1,
"selected": false,
"text": "Private Sub Command1_KeyDown(KeyCode As Integer, Shift As Integer)\n Label1.Caption = \"\"\"\" & KeyCodeToUnicodeString(CLng(KeyCode)) & \"\"\"\"\nEnd Sub\n Option Explicit\n'VB6\nPrivate Declare Function ToUnicode Lib \"user32\" (ByVal wVirtKey As Long, ByVal wScanCode As Long, lpKeyState As Byte, ByVal pwszBuff As String, ByVal cchBuff As Long, ByVal wFlags As Long) As Long\nPrivate Declare Function GetKeyboardState Lib \"user32\" (pbKeyState As Byte) As Long\n\n''VBA\n'#If VBA7 And Win64 Then\n' 'VBA7 And Win64\n' Private Declare PtrSafe Function GetKeyboardState Lib \"user32\" (pbKeyState As Byte) As Long\n' 'must be tested, maybe Long has to be replaced by Integer for 64 bit:\n' Private Declare PtrSafe Function ToUnicode Lib \"user32\" (ByVal wVirtKey As Long, ByVal wScanCode As Long, lpKeyState As Byte, ByVal pwszBuff As String, ByVal cchBuff As Long, ByVal wFlags As Long) As Long\n'#Else\n' 'VBA 32 bit\n' Private Declare Function GetKeyboardState Lib \"user32\" (pbKeyState As Byte) As Long\n' Private Declare Function ToUnicode Lib \"user32\" (ByVal wVirtKey As Long, ByVal wScanCode As Long, lpKeyState As Byte, ByVal pwszBuff As String, ByVal cchBuff As Long, ByVal wFlags As Long) As Long\n'#End If\n\n'Returns the text of the KeyCode pressed depending of the Keyboard language\n'Does not work on Win98 (returns \"\") but works well on winXP and onwards\nPublic Function KeyCodeToUnicodeString(KeyCode As Long) As String\n On Error GoTo KeyCodeToUnicodeString_End\n Dim ret As Long\n Dim keyBoardState(0 To 255) As Byte\n Dim buffer As String * 256\n ret = GetKeyboardState(keyBoardState(0))\n Dim i As Long\n \n 'Special: This portion of code is important for the function to work properly after compilation.\n 'Why I do not know, but if removed, the next call to ret = ToUnicode will make a OutOfMemory Error\n 'because the keyBoardState array is not yet in a correct state.\n 'Tried Sleep or Byte b = keyBoardState(i) within the loop,\n 'but the only way to make it work properlyIN vb6 is coded here.\n 'If used in VBA, this part of code may be removed\n Dim s As String\n For i = 0 To 255\n s = s & CStr(keyBoardState(i)) & \"-\"\n Next i\n 'end of special portion of code\n \n If ret <> 0 Then\n ret = ToUnicode(KeyCode, 0, keyBoardState(0), buffer, Len(buffer), 0)\n buffer = StrConv(buffer, vbFromUnicode)\n If ret <> 0 Then\n On Error Resume Next\n KeyCodeToUnicodeString = Left(buffer, InStr(buffer, vbNullChar) - 1)\n Else\n KeyCodeToUnicodeString = \"\"\n End If\n End If\nKeyCodeToUnicodeString_End:\nEnd Function\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
246,315
|
<p>I'm trying to compile such code:</p>
<pre><code>#include <iostream>
using namespace std;
class CPosition
{
private:
int itsX,itsY;
public:
void Show();
void Set(int,int);
};
void CPosition::Set(int a, int b)
{
itsX=a;
itsY=b;
}
void CPosition::Show()
{
cout << "x:" << itsX << " y:" << itsY << endl;
}
class CCube
{
friend class CPosition;
private:
CPosition Position;
};
main()
{
CCube cube1;
cube1.Position.Show();
cube1.Position.Set(2,3);
cube1.Position.Show();
}
</code></pre>
<p>but get 'CCube::Position' is not accessible in function main() 3 times.
I want class CPosition to be declared outside CCube so that I can use it in future in new classes e.g. CBall :) but how can I make it work without using inheritance. Is it possible :)?</p>
<p>Regards,
PK</p>
|
[
{
"answer_id": 246327,
"author": "Jasper Bekkers",
"author_id": 31486,
"author_profile": "https://Stackoverflow.com/users/31486",
"pm_score": 2,
"selected": false,
"text": "friend class CPosition; class CCube\n{\n public:\n CPosition Position;\n};\n"
},
{
"answer_id": 246341,
"author": "James Hopkin",
"author_id": 11828,
"author_profile": "https://Stackoverflow.com/users/11828",
"pm_score": 1,
"selected": false,
"text": "friend int main();\n"
},
{
"answer_id": 246391,
"author": "Moomin",
"author_id": 32312,
"author_profile": "https://Stackoverflow.com/users/32312",
"pm_score": 0,
"selected": false,
"text": "class CCube\n{\n private:\n CPosition Position;\n public:\n CPosition& getPosition() { return Position; }\n};\n\nmain()\n{\n CCube cube1;\n\n cube1.getPosition().Show();\n cube1.getPosition().Set(2,3);\n cube1.getPosition().Show();\n}\n"
},
{
"answer_id": 246429,
"author": "xtofl",
"author_id": 6610,
"author_profile": "https://Stackoverflow.com/users/6610",
"pm_score": 0,
"selected": false,
"text": "CPosition CPosition int radius friend CCube CCube CCube::Position CCube::MoveTo( const CPosition& p ) CCube::GetPosition() const friend"
},
{
"answer_id": 246611,
"author": "Martin York",
"author_id": 14065,
"author_profile": "https://Stackoverflow.com/users/14065",
"pm_score": 4,
"selected": true,
"text": "class CCube\n{\n private:\n CPosition Position;\n public:\n CPosition& getPosition() { return Position; }\n CPosition const& getPosition() const { return Position; }\n};\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32312/"
] |
246,317
|
<p>I want to create a trigger to check what is being deleted against business rules and then cancel the deletion if needed. Any ideas?</p>
<p>The solution used the Instead of Delete trigger. The Rollback tran stopped the delete. I was afraid that I would have a cascade issue when I did the delete but that didn't seem to happen. Maybe a trigger cannot trigger itself.</p>
|
[
{
"answer_id": 246322,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 5,
"selected": true,
"text": "INSTEAD OF DELETE"
},
{
"answer_id": 246405,
"author": "Leandro López",
"author_id": 22695,
"author_profile": "https://Stackoverflow.com/users/22695",
"pm_score": 1,
"selected": false,
"text": "INSTEAD OF DELETE INSTEAD OF"
},
{
"answer_id": 246432,
"author": "Leo Moore",
"author_id": 6336,
"author_profile": "https://Stackoverflow.com/users/6336",
"pm_score": 3,
"selected": false,
"text": "ALTER TRIGGER [dbo].[tr_ValidateDeleteForAssignedCalls]\non [dbo].[CAL]\n INSTEAD OF DELETE\nAS \nBEGIN\n -- SET NOCOUNT ON added to prevent extra result sets from\n -- interfering with SELECT statements.\n SET NOCOUNT ON;\n\n DECLARE @RecType VARCHAR(1)\n DECLARE @UserID VARCHAR(8)\n DECLARE @CreateBy VARCHAR(8)\n DECLARE @RecID VARCHAR(20)\n\n SELECT @RecType =(SELECT RecType FROM DELETED)\n SELECT @UserID =(SELECT UserID FROM DELETED)\n SELECT @CreateBy =(SELECT CreateBy FROM DELETED)\n SELECT @RecID =(SELECT RecID FROM DELETED)\n\n -- Check to see if the type is a Call and the item was created by a different user\n IF @RECTYPE = 'C' and not (@USERID=@CREATEBY)\n\n BEGIN\n RAISERROR ('Cannot delete call.', 16, 1)\n ROLLBACK TRAN\n RETURN\n END\n\n -- Go ahead and do the update or some other business rules here\n ELSE\n Delete from CAL where RecID = @RecID \n\nEND\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6336/"
] |
246,321
|
<p>Here's a very simple question. I have an SP that inserts a row into a table and at the end there's the statement RETURN @@IDENTITY. What I can't seem to find is a way to retrieve this value in C#. I'm using the Enterprise library and using the method:</p>
<pre><code>db.ExecuteNonQuery(cmd);
</code></pre>
<p>I've tried <strong>cmd.Parameters[0].Value</strong> to get the value but that returns 0 all the time. Any ideas?</p>
|
[
{
"answer_id": 246332,
"author": "Craig Norton",
"author_id": 24804,
"author_profile": "https://Stackoverflow.com/users/24804",
"pm_score": 3,
"selected": true,
"text": "Dim c as new sqlcommand(\"...\")\n\nDim d As New SqlParameter()\nd.Direction = ParameterDirection.ReturnValue\nc.parameters.add(d)\n\nc.executeNonQuery\n\n(@@IDENTITY) = d.value\n"
},
{
"answer_id": 246352,
"author": "thmsn",
"author_id": 28145,
"author_profile": "https://Stackoverflow.com/users/28145",
"pm_score": 0,
"selected": false,
"text": "SqlCommand.ExecuteScalar()\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246321",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688440/"
] |
246,329
|
<p>This might be a naive question. I have to manually edit a .WXS file to make it support select features from command line.</p>
<p>For example, there are 3 features in .WXS file.</p>
<pre><code><Feature Id="AllFeature" Level='1'>
<Feature Id="Feature1" Level='1'> </Feature>
<Feature Id="Feature2" Level='1'> </Feature>
<Feature Id="Feature3" Level='1'> </Feature>
</Feature>
</code></pre>
<p>Now, I want to select features from command line. Say, if I type "msiexec /i install.msi FEATURE=A", then "Feature1" and "Feature2" is installed; if I type "msiexec/i install.msi FEATURE=B", then "Feature1" and "Feature3" is installed. In this case, "A" maps to Feature 1 and 2; "B" maps to Feature 1 and 3.</p>
<p>How to accomplish this in WIX?</p>
|
[
{
"answer_id": 246920,
"author": "CheGueVerra",
"author_id": 17787,
"author_profile": "https://Stackoverflow.com/users/17787",
"pm_score": 6,
"selected": true,
"text": "<Feature Id=\"FEATUREA\" Title=\"Super\" Level=\"1\" >\n <ComponentRef Id=\"Component1\" />\n <ComponentRef Id=\"Component2\" />\n</Feature>\n\n<Feature Id=\"FEATUREB\" Title=\"Super1\" Level=\"1\" >\n <ComponentRef Id=\"Component1\" />\n <ComponentRef Id=\"Component3\"/>\n</Feature>\n msiexec /i install.msi ADDLOCAL=[FEATUREA | FEATUREB]\n"
},
{
"answer_id": 463875,
"author": "Wim Coenen",
"author_id": 52626,
"author_profile": "https://Stackoverflow.com/users/52626",
"pm_score": 6,
"selected": false,
"text": "msiexec /i install.msi ADDLOCAL=Feature1,Feature2\n msiexec /i install.msi ADDLOCAL=Feature2,Feature3\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246329",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] |
246,357
|
<p>I am reading WIX script written by others. There are some code really confuses me. </p>
<pre><code><Custom Action='UnLoadSchedulerPerfCounters' After='InstallInitialize'>
<![CDATA[(Installed) AND (!Scheduler = 3)]]>
</Custom>
<Custom Action='RollbackSchedulerPerfCounters' After='WriteRegistryValues'>
<![CDATA[(&Scheduler = 3)]]>
</Custom>
</code></pre>
<p>So, what's the difference between <code>!Scheduler</code> and <code>&Scheduler</code>?
Is any special meaning when property is prefix-ed by <code>&</code> or <code>!</code>?</p>
|
[
{
"answer_id": 246411,
"author": "xsl",
"author_id": 11387,
"author_profile": "https://Stackoverflow.com/users/11387",
"pm_score": 4,
"selected": true,
"text": "% environment variable (name is case insensitive)\n$ action state of component\n? installed state of component\n& action state of feature\n! installed state of feature\n -1 no action to be taken\n1 advertised (only for components)\n2 not present\n3 on the local computer\n4 run from the source\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] |
246,364
|
<p>I'm working on a piece of library code around <code>IDisposable</code>. The managed path (via <code>using</code>) is easily testable. I'm wondering about the finalizer though: Is calling <a href="http://msdn.microsoft.com/en-us/library/xe0c2357.aspx" rel="noreferrer"><code>System.GC.Collect()</code></a> sufficient to force the finalizer to run?</p>
|
[
{
"answer_id": 246366,
"author": "brien",
"author_id": 4219,
"author_profile": "https://Stackoverflow.com/users/4219",
"pm_score": 0,
"selected": false,
"text": "IDisposable Dispose"
},
{
"answer_id": 246375,
"author": "RickL",
"author_id": 7261,
"author_profile": "https://Stackoverflow.com/users/7261",
"pm_score": 4,
"selected": true,
"text": "System.GC.WaitForPendingFinalizers();\n"
},
{
"answer_id": 538203,
"author": "Rob McCready",
"author_id": 47525,
"author_profile": "https://Stackoverflow.com/users/47525",
"pm_score": 2,
"selected": false,
"text": "~ComplexCleanupBase()\n{\n Dispose(false);\n}\n\npublic void Dispose()\n{\n Dispose(true);\n GC.SuppressFinalize(this);\n}\n\nprotected override void Dispose(bool disposing)\n{\n if (!disposed)\n {\n if (disposing)\n {\n // dispose-only, i.e. non-finalizable logic\n }\n\n // new shared cleanup logic\n disposed = true;\n }\n\n base.Dispose(disposing);\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4918/"
] |
246,367
|
<p>My programming environment includes scripts for setting up my autobuild on a clean machine.</p>
<p>One step uses a vbscript to configure a website on IIS that is used to monitor the build.</p>
<p>On a particular machine I will be running apache on port 80 for a separate task.</p>
<p>I would like my vbscript to set the port to 8080 for the new site that it is adding.</p>
<p>How can I do this?</p>
|
[
{
"answer_id": 246366,
"author": "brien",
"author_id": 4219,
"author_profile": "https://Stackoverflow.com/users/4219",
"pm_score": 0,
"selected": false,
"text": "IDisposable Dispose"
},
{
"answer_id": 246375,
"author": "RickL",
"author_id": 7261,
"author_profile": "https://Stackoverflow.com/users/7261",
"pm_score": 4,
"selected": true,
"text": "System.GC.WaitForPendingFinalizers();\n"
},
{
"answer_id": 538203,
"author": "Rob McCready",
"author_id": 47525,
"author_profile": "https://Stackoverflow.com/users/47525",
"pm_score": 2,
"selected": false,
"text": "~ComplexCleanupBase()\n{\n Dispose(false);\n}\n\npublic void Dispose()\n{\n Dispose(true);\n GC.SuppressFinalize(this);\n}\n\nprotected override void Dispose(bool disposing)\n{\n if (!disposed)\n {\n if (disposing)\n {\n // dispose-only, i.e. non-finalizable logic\n }\n\n // new shared cleanup logic\n disposed = true;\n }\n\n base.Dispose(disposing);\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246367",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5427/"
] |
246,395
|
<p>The problem is quite basic. I have a JTable showing cached data from a database. If a user clicks in a cell for editing, I want to attempt a lock on that row in the database. If the lock does not succeed, I want to prevent editing.</p>
<p>But I can't seem to find any clean way to accomplish this. Am I missing something?</p>
|
[
{
"answer_id": 246513,
"author": "Nick Pierpoint",
"author_id": 4003,
"author_profile": "https://Stackoverflow.com/users/4003",
"pm_score": 1,
"selected": false,
"text": "select * into v_row from my_table where my_table_id = 1\nfor update;\n select * into v_row from my_table where my_table_id = 1\nfor update nowait;\n ORA-00054: resource busy and acquire with NOWAIT specified.\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15932/"
] |
246,400
|
<p>What is the best way of working with calculated fields of Propel objects?</p>
<p>Say I have an object "Customer" that has a corresponding table "customers" and each column corresponds to an attribute of my object. What I would like to do is: add a calculated attribute "Number of completed orders" to my object when using it on View A but not on Views B and C.</p>
<p>The calculated attribute is a COUNT() of "Order" objects linked to my "Customer" object via ID.</p>
<p>What I can do now is to first select all Customer objects, then iteratively count Orders for all of them, but I'd think doing it in a single query would improve performance. But I cannot properly "hydrate" my Propel object since it does not contain the definition of the calculated field(s).</p>
<p>How would you approach it?</p>
|
[
{
"answer_id": 246900,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "class Order {\n...\n public function save($conn = null) {\n $customer = $this->getCustomer();\n $customer->setOrdersCount($customer->getOrdersCount() + 1);\n $custoner->save();\n parent::save();\n }\n...\n}"
},
{
"answer_id": 247259,
"author": "Peter Bailey",
"author_id": 8815,
"author_profile": "https://Stackoverflow.com/users/8815",
"pm_score": 3,
"selected": true,
"text": "<?php\n\nclass TablePeer extends BaseTablePeer\n{\n public static function selectWithCalculatedColumns()\n {\n // Do our custom selection, still using propel's column data constants\n $sql = \"\n SELECT \" . implode( ', ', self::getFieldNames( BasePeer::TYPE_COLNAME ) ) . \"\n , count(\" . JoinedTablePeer::ID . \") AS calc_col\n FROM \" . self::TABLE_NAME . \"\n LEFT JOIN \" . JoinedTablePeer::TABLE_NAME . \"\n ON \" . JoinedTablePeer::ID . \" = \" . self::FKEY_COLUMN\n ;\n\n // Get the result set\n $conn = Propel::getConnection();\n $stmt = $conn->prepareStatement( $sql );\n $rs = $stmt->executeQuery( array(), ResultSet::FETCHMODE_NUM );\n\n // Create an empty rowset\n $rowset = array();\n\n // Iterate over the result set\n while ( $rs->next() )\n {\n // Create each row individually\n $row = new Table();\n $startcol = $row->hydrate( $rs );\n\n // Use our custom setter to populate the new column\n $row->setCalcCol( $row->get( $startcol ) );\n $rowset[] = $row;\n }\n return $rowset;\n }\n}\n"
},
{
"answer_id": 250928,
"author": "Nathan Strong",
"author_id": 9780,
"author_profile": "https://Stackoverflow.com/users/9780",
"pm_score": 0,
"selected": false,
"text": "customer:\n id:\n name:\n ...\n\norder:\n id:\n customer_id: # links to customer table automagically\n completed: { type: boolean, default false }\n ...\n // in lib/model/Customer.php\n class Customer extends BaseCustomer\n {\n public function CountOrders()\n {\n $connection = Propel::getConnection();\n $query = \"SELECT COUNT(*) AS count FROM %s WHERE customer_id='%s'\";\n $statement = $connection->prepareStatement(sprintf($query, CustomerPeer::TABLE_NAME, $this->getId());\n $resultset = $statement->executeQuery();\n $resultset->next();\n return $resultset->getInt('count');\n }\n ...\n }\n"
},
{
"answer_id": 675263,
"author": "apinstein",
"author_id": 72114,
"author_profile": "https://Stackoverflow.com/users/72114",
"pm_score": 1,
"selected": false,
"text": "// in peer\npublic static function locationAsEWKTColumnIndex()\n{\n return GeographyPeer::NUM_COLUMNS - GeographyPeer::NUM_LAZY_LOAD_COLUMNS;\n}\n\npublic static function polygonAsEWKTColumnIndex()\n{\n return GeographyPeer::NUM_COLUMNS - GeographyPeer::NUM_LAZY_LOAD_COLUMNS + 1;\n}\n\npublic static function addSelectColumns(Criteria $criteria)\n{\n parent::addSelectColumns($criteria);\n $criteria->addAsColumn(\"locationAsEWKT\", \"AsEWKT(\" . GeographyPeer::LOCATION . \")\");\n $criteria->addAsColumn(\"polygonAsEWKT\", \"AsEWKT(\" . GeographyPeer::POLYGON . \")\");\n}\n// in object\npublic function hydrate($row, $startcol = 0, $rehydrate = false)\n{\n $r = parent::hydrate($row, $startcol, $rehydrate);\n if ($row[GeographyPeer::locationAsEWKTColumnIndex()]) // load GIS info from DB IFF the location field is populated. NOTE: These fields are either both NULL or both NOT NULL, so this IF is OK\n {\n $this->location_ = GeoPoint::PointFromEWKT($row[GeographyPeer::locationAsEWKTColumnIndex()]); // load gis data from extra select columns See GeographyPeer::addSelectColumns().\n $this->polygon_ = GeoMultiPolygon::MultiPolygonFromEWKT($row[GeographyPeer::polygonAsEWKTColumnIndex()]); // load gis data from extra select columns See GeographyPeer::addSelectColumns().\n } \n return $r;\n} \n"
},
{
"answer_id": 2523488,
"author": "Ashton King",
"author_id": 302496,
"author_profile": "https://Stackoverflow.com/users/302496",
"pm_score": 1,
"selected": false,
"text": "foreach ($pager->getResults() as $project):\n\n echo $project->getName() . ' and ' . $project->getNumMembers()\n\nendforeach;\n getNumMembers() $project // symfony_behaviors behavior\nforeach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook)\n{\n call_user_func($sf_hook, 'BaseTsProjectPeer', $criteria, $con);\n}\n // copied into ProjectPeer - overrides BaseProjectPeer::doSelectJoinUser()\npublic static function doSelectJoinUser(Criteria $criteria, ...)\n{\n // copied from parent method, along with everything else\n ProjectPeer::addSelectColumns($criteria);\n $startcol = (ProjectPeer::NUM_COLUMNS - ProjectPeer::NUM_LAZY_LOAD_COLUMNS);\n UserPeer::addSelectColumns($criteria);\n\n // now add our custom COUNT column after all other columns have been added\n // so as to not screw up Propel's position matching system when hydrating\n // the Project and User objects.\n $criteria->addSelectColumn('COUNT(' . ProjectMemberPeer::ID . ')');\n\n // now add the GROUP BY clause to count members by project\n $criteria->addGroupByColumn(self::ID);\n\n // more parent code\n\n ...\n\n // until we get to this bit inside the hydrating loop:\n\n $obj1 = new $cls();\n $obj1->hydrate($row);\n\n // AND...hydrate our custom COUNT property (the last column)\n $obj1->setNumMembers($row[count($row) - 1]);\n\n // more code copied from parent\n\n ...\n\n return $results; \n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246400",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2706/"
] |
246,407
|
<p>Does anyone know how could I programatically disable/enable sleep mode on Windows Mobile?</p>
<p>Thanks!</p>
|
[
{
"answer_id": 248673,
"author": "Shane Powell",
"author_id": 23235,
"author_profile": "https://Stackoverflow.com/users/23235",
"pm_score": 4,
"selected": true,
"text": "#include <windows.h>\n#include <commctrl.h>\n\nextern \"C\"\n{\n void WINAPI SHIdleTimerReset();\n};\n\nvoid KeepAlive()\n{\n static DWORD LastCallTime = 0;\n DWORD TickCount = GetTickCount();\n if ((TickCount - LastCallTime) > 1000 || TickCount < LastCallTime) // watch for wraparound\n {\n SystemIdleTimerReset();\n SHIdleTimerReset();\n keybd_event(VK_LBUTTON, 0, KEYEVENTF_SILENT, 0);\n keybd_event(VK_LBUTTON, 0, KEYEVENTF_KEYUP | KEYEVENTF_SILENT, 0);\n LastCallTime = TickCount;\n }\n}\n if(!::PowerPolicyNotify (PPN_UNATTENDEDMODE, TRUE))\n{\n // handle error\n}\n\n// do long running process\n\nif(!::PowerPolicyNotify (PPN_UNATTENDEDMODE, FALSE))\n{\n // handle error\n}\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22996/"
] |
246,422
|
<p>How can I deploy an iPhone application from Xcode to real iPhone device without having a US$99 Apple certificate?</p>
|
[
{
"answer_id": 252173,
"author": "rpetrich",
"author_id": 4007,
"author_profile": "https://Stackoverflow.com/users/4007",
"pm_score": 7,
"selected": true,
"text": "ldid -S /Applications/AccelerometerGraph.app/AccelerometerGraph chmod +x /Applications/AccelerometerGraph.app/AccelerometerGraph"
},
{
"answer_id": 4180498,
"author": "cregox",
"author_id": 274502,
"author_profile": "https://Stackoverflow.com/users/274502",
"pm_score": 7,
"selected": false,
"text": "sudo /usr/bin/sed -i .bak 's/XCiPhoneOSCodeSignContext/XCCodeSignContext/' /Developer/Platforms/iPhoneOS.platform/Info.plist\n sudo /usr/bin/sed -i .bak '/_REQUIRED/N;s/YES/NO/' /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist\n iPhoneOS5.0.sdk sudo /usr/bin/sed -i .bak '/_REQUIRED/N;s/YES/NO/' /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/SDKSettings.plist\n cd /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins/iPhoneOS\\ Build\\ System\\ Support.xcplugin/Contents/MacOS/\ndd if=iPhoneOS\\ Build\\ System\\ Support of=working bs=500 count=255\nprintf \"\\xc3\\x26\\x00\\x00\" >> working\n/bin/mv -n iPhoneOS\\ Build\\ System\\ Support iPhoneOS\\ Build\\ System\\ Support.original\n/bin/mv working iPhoneOS\\ Build\\ System\\ Support\nchmod a+x iPhoneOS\\ Build\\ System\\ Support\n mkdir /Developer/iphoneentitlements401\ncd /Developer/iphoneentitlements401\ncurl -O http://www.alexwhittemore.com/iphone/gen_entitlements.txt\nmv gen_entitlements.txt gen_entitlements.py\nchmod 777 gen_entitlements.py\n export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate\nif [ \"${PLATFORM_NAME}\" == \"iphoneos\" ]; then\n/Developer/iphoneentitlements401/gen_entitlements.py \"my.company.${PROJECT_NAME}\" \"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent\";\ncodesign -f -s \"iPhone Developer\" --entitlements \"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent\" \"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/\"\nfi\n sudo mv -f /Developer/Platforms/iPhoneOS.platform/Info.plist.bak /Developer/Platforms/iPhoneOS.platform/Info.plist\n sudo mv -f /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist.bak /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/SDKSettings.plist\nsudo mv -f iPhoneOS\\ Build\\ System\\ Support.original iPhoneOS\\ Build\\ System\\ Support\n sudo mv -f /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/SDKSettings.plist.bak /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/SDKSettings.plist\n /Developer/iphoneentitlements401/gen_entitlements.py sudo rm -f /Developer/iphoneentitlements401/gen_entitlements.py\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16066/"
] |
246,430
|
<p>0x34363932353433373538323038353135353439</p>
|
[
{
"answer_id": 246437,
"author": "Diomidis Spinellis",
"author_id": 20520,
"author_profile": "https://Stackoverflow.com/users/20520",
"pm_score": 2,
"selected": false,
"text": "$ bc\nibase=16\n34363932353433373538323038353135353439\n1164362276596472215941024063897591129839055929\n"
},
{
"answer_id": 246493,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 1,
"selected": false,
"text": "ruby -e 'p 0x34363932353433373538323038353135353439'\n"
}
] |
2008/10/29
|
[
"https://Stackoverflow.com/questions/246430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.