qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
---|---|---|---|---|
53,426 |
<p>What memory leak detectors have people had a good experience with?</p>
<p>Here is a summary of the answers so far:</p>
<p><a href="http://valgrind.org/" rel="noreferrer">Valgrind</a> - Instrumentation framework for building dynamic analysis tools.</p>
<p><a href="http://directory.fsf.org/project/ElectricFence/" rel="noreferrer">Electric Fence</a> - A tool that works with GDB</p>
<p><a href="http://splint.org/" rel="noreferrer">Splint</a> - Annotation-Assisted Lightweight Static Checking</p>
<p><a href="http://www.glowcode.com/" rel="noreferrer">Glow Code</a> - This is a complete real-time performance and memory profiler for Windows and .NET programmers who develop applications with C++, C#, or any .NET Framework</p>
<p>Also see this <a href="https://stackoverflow.com/questions/45627/how-do-you-detectavoid-memory-leaks-in-your-unmanaged-code">stackoverflow post</a>.</p>
|
[
{
"answer_id": 276821,
"author": "Artelius",
"author_id": 31945,
"author_profile": "https://Stackoverflow.com/users/31945",
"pm_score": 2,
"selected": false,
"text": "-fmudflap -lmudflap\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2064/"
] |
53,428 |
<p>I'm evaluating and looking at using CherryPy for a project that's basically a JavaScript front-end from the client-side (browser) that talks to a Python web service on the back-end. So, I really need something fast and lightweight on the back-end that I can implement using Python that then speaks to the PostgreSQL DB via an ORM (JSON to the browser).</p>
<p>I'm also looking at Django, which I like, since its ORM is built-in. However, I think Django might be a little more than I really need (i.e. more features than I really need == slower?).</p>
<p>Anyone have any experience with different Python ORM solutions that can compare and contrast their features and functionality, speed, efficiency, etc.?</p>
|
[
{
"answer_id": 53463,
"author": "Yon",
"author_id": 3117,
"author_profile": "https://Stackoverflow.com/users/3117",
"pm_score": -1,
"selected": false,
"text": ">>> ed_user = User('ed', 'Ed Jones', 'edspassword')\n>>> session.add(ed_user)\n>>> our_user = session.query(User).filter_by(name='ed').first() \n>>> our_user\n <User('ed','Ed Jones', 'edspassword')>\n"
},
{
"answer_id": 384781,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": "from storm.locals import *\n\nclass Foo:\n __storm_table__ = 'foos'\n id = Int(primary=True)\n\n\nclass Thing:\n __storm_table__ = 'things'\n id = Int(primary=True)\n name = Unicode()\n description = Unicode()\n foo_id = Int()\n foo = Reference(foo_id, Foo.id)\n\ndb = create_database('sqlite:')\nstore = Store(db)\n\nfoo = Foo()\nstore.add(foo)\nthing = Thing()\nthing.foo = foo\nstore.add(thing)\nstore.commit()\n store.execute('UPDATE bars SET bar_name=? WHERE bar_id like ?', []) \nstore.commit()\n"
},
{
"answer_id": 407556,
"author": "zzzeek",
"author_id": 34549,
"author_profile": "https://Stackoverflow.com/users/34549",
"pm_score": 4,
"selected": false,
"text": "Base = declarative_base()\n\nclass Foo(Base):\n __tablename__ = 'foos'\n id = Column(Integer, primary_key=True)\n\nclass Thing(Base):\n __tablename__ = 'things'\n\n id = Column(Integer, primary_key=True)\n name = Column(Unicode)\n description = Column(Unicode)\n foo_id = Column(Integer, ForeignKey('foos.id'))\n foo = relation(Foo)\n\nengine = create_engine('sqlite://')\n\nBase.metadata.create_all(engine) # issues DDL to create tables\n\nsession = sessionmaker(bind=engine)()\n\nfoo = Foo()\nsession.add(foo)\nthing = Thing(name='thing1', description='some thing')\nthing.foo = foo # also adds Thing to session\nsession.commit()\n"
},
{
"answer_id": 7439694,
"author": "coleifer",
"author_id": 254346,
"author_profile": "https://Stackoverflow.com/users/254346",
"pm_score": 7,
"selected": false,
"text": "import datetime\nfrom peewee import *\n\nclass Blog(Model):\n name = CharField()\n\nclass Entry(Model):\n blog = ForeignKeyField(Blog)\n title = CharField()\n body = TextField()\n pub_date = DateTimeField(default=datetime.datetime.now)\n\n# query it like django\nEntry.filter(blog__name='Some great blog')\n\n# or programmatically for finer-grained control\nEntry.select().join(Blog).where(Blog.name == 'Some awesome blog')\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5499/"
] |
53,435 |
<p>I'm doing something bad in my ASP.NET app. It could be the any number of CTP libraries I'm using or I'm just not disposing something properly. But when I redeploy my ASP.NET to my Vista IIS7 install or my server's IIS6 install I crash an IIS worker process.</p>
<p>I've narrowed the problem down to my HTTP crawler, which is a multithreaded beast that crawls sites for useful information when asked to. After I start a crawler and redeploy the app over the top, rather than gracefully unloading the appDomain and reloading, an IIS worker process will crash (popping up a crash message) and continue reloading the app domain.</p>
<p>When this crash happens, where can I find the crash dump for analysis?</p>
|
[
{
"answer_id": 66625,
"author": "sachaa",
"author_id": 1152057,
"author_profile": "https://Stackoverflow.com/users/1152057",
"pm_score": 5,
"selected": true,
"text": "cscript adplus.vbs -crash -pn w3wp.exe\n .loadby sos mscorwks\n !clrstack\n kpn 200\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209/"
] |
53,472 |
<p>I have some Ruby code which takes dates on the command line in the format:</p>
<pre><code>-d 20080101,20080201..20080229,20080301
</code></pre>
<p>I want to run for all dates between <code>20080201</code> and <code>20080229</code> inclusive and the other dates present in the list.</p>
<p>I can get the string <code>20080201..20080229</code>, so is the best way to convert this to a Range instance? Currently, I am using <code>eval</code>, but it feels like there should be a better way.</p>
<hr>
<p>@Purfideas I was kind of looking for a more general answer for converting any string of type <code>int..int</code> to a Range I guess.</p>
|
[
{
"answer_id": 53504,
"author": "Purfideas",
"author_id": 4615,
"author_profile": "https://Stackoverflow.com/users/4615",
"pm_score": 2,
"selected": false,
"text": "require 'date'\n\nends = '20080201..20080229'.split('..').map{|d| Date.parse(d)}\n(ends[0]..ends[1]).each do |d|\n p d.day\nend\n"
},
{
"answer_id": 53588,
"author": "Purfideas",
"author_id": 4615,
"author_profile": "https://Stackoverflow.com/users/4615",
"pm_score": 5,
"selected": true,
"text": "ends = '20080201..20080229'.split('..').map{|d| Integer(d)}\nends[0]..ends[1]\n"
},
{
"answer_id": 54647,
"author": "theschmitzer",
"author_id": 2167252,
"author_profile": "https://Stackoverflow.com/users/2167252",
"pm_score": 3,
"selected": false,
"text": "rng='20080201..20080229'.split('..').inject { |s,e| s.to_i..e.to_i }\n class Range\n def self.from_ary(a)\n a.inject{|s,e| s..e }\n end\nend\n\nrng = Range.from_ary('20080201..20080229'.split('..').map{|s| s.to_i})\nrng.class # => Range\n"
},
{
"answer_id": 3243732,
"author": "ujifgc",
"author_id": 391229,
"author_profile": "https://Stackoverflow.com/users/391229",
"pm_score": 5,
"selected": false,
"text": "Range.new(*self.split(\"..\").map(&:to_i))\n"
},
{
"answer_id": 21399899,
"author": "MetalArend",
"author_id": 1945685,
"author_profile": "https://Stackoverflow.com/users/1945685",
"pm_score": 0,
"selected": false,
"text": "if !value[/^[0-9]+\\.\\.[0-9]+$/].nil?\n ends = value.split('..').map{|d| Integer(d)}\n value = ends[0]..ends[1]\nend\n"
},
{
"answer_id": 26996959,
"author": "nurettin",
"author_id": 227755,
"author_profile": "https://Stackoverflow.com/users/227755",
"pm_score": 0,
"selected": false,
"text": "v= \"20140101..20150101\"\nraise \"Error: invalid format: #{v}\" if /\\d{8}\\.\\.\\d{8}/ !~ v\nr= eval(v)\n v= \"20140101..20150101\"\nraise \"Error: invalid format: #{v}\" if /\\d{8}\\.\\.\\d{8}/ !~ v\nr= Range.new(*v.split(/\\.\\./).map(&:to_i))\nraise \"Error: invalid range: #{v}\" if r.first> r.last\n"
},
{
"answer_id": 29943562,
"author": "Epigene",
"author_id": 3319298,
"author_profile": "https://Stackoverflow.com/users/3319298",
"pm_score": 1,
"selected": false,
"text": "eval"
},
{
"answer_id": 48169090,
"author": "shubham mishra",
"author_id": 7516788,
"author_profile": "https://Stackoverflow.com/users/7516788",
"pm_score": 0,
"selected": false,
"text": "hash_1 = {1..5 => 'a', 6..12 => 'b', 13..67 => 'c', 68..9999999 => 'd'}\n JSON.parse(SystemConstant.get('Constant_name')).each{|key,val| temp_k=key.split('..').map{|d| Integer(d)}; hash_2[temp_k[0]..temp_k[1]] = val}\n"
},
{
"answer_id": 65895545,
"author": "Matthew",
"author_id": 145725,
"author_profile": "https://Stackoverflow.com/users/145725",
"pm_score": 0,
"selected": false,
"text": "def numbers(from_string:)\n if from_string.include?('-')\n return Range.new(*from_string.split('-').map(&:to_i))\n else\n return [from_string.to_i] # put number in an array so we can enumerate over it\n end\nend\n from_string.include?('-') ? Range.new(*from_string.split('-').map(&:to_i)) : [from_string.to_i]\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4121/"
] |
53,473 |
<p>I am trying to apply styles to HTML tags dynamically by reading in the value of certain HTML attributes and applying a class name based on their values. For instance, if I have:</p>
<pre><code><p height="30">
</code></pre>
<p>I want to apply a <code>class="h30"</code> to that paragraph so that I can style it in my style sheet. I can't find any information on getting the value of an attribute that is not an <code>id</code> or <code>class</code>. Help?</p>
|
[
{
"answer_id": 53475,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 0,
"selected": false,
"text": "for (e in ...) {\n if (e.height == 30) {\n e.className = \"h30\";\n }\n}\n"
},
{
"answer_id": 53593,
"author": "SeanDowney",
"author_id": 5261,
"author_profile": "https://Stackoverflow.com/users/5261",
"pm_score": 4,
"selected": true,
"text": "$(\"#someId\").addClass(\"newClass\");\n $(\"p[height='30']\").addClass(\"h30\");\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5512/"
] |
53,480 |
<p>Hey, I'm using <a href="http://en.wikipedia.org/wiki/Levenshtein_distance" rel="nofollow noreferrer">Levenshteins</a> algorithm to get distance between source and target string.</p>
<p>also I have method which returns value from 0 to 1:</p>
<pre><code>/// <summary>
/// Gets the similarity between two strings.
/// All relation scores are in the [0, 1] range,
/// which means that if the score gets a maximum value (equal to 1)
/// then the two string are absolutely similar
/// </summary>
/// <param name="string1">The string1.</param>
/// <param name="string2">The string2.</param>
/// <returns></returns>
public static float CalculateSimilarity(String s1, String s2)
{
if ((s1 == null) || (s2 == null)) return 0.0f;
float dis = LevenshteinDistance.Compute(s1, s2);
float maxLen = s1.Length;
if (maxLen < s2.Length)
maxLen = s2.Length;
if (maxLen == 0.0F)
return 1.0F;
else return 1.0F - dis / maxLen;
}
</code></pre>
<p>but this for me is not enough. Because I need more complex way to match two sentences.</p>
<p>For example I want automatically tag some music, I have original song names, and i have songs with trash, like <em>super, quality,</em> years like <em>2007, 2008,</em> etc..etc.. also some files have just <a href="http://trash..thash..song_name_mp3.mp3" rel="nofollow noreferrer">http://trash..thash..song_name_mp3.mp3</a>, other are normal. I want to create an algorithm which will work just more perfect than mine now.. Maybe anyone can help me?</p>
<p>here is my current algo:</p>
<pre><code>/// <summary>
/// if we need to ignore this target.
/// </summary>
/// <param name="targetString">The target string.</param>
/// <returns></returns>
private bool doIgnore(String targetString)
{
if ((targetString != null) && (targetString != String.Empty))
{
for (int i = 0; i < ignoreWordsList.Length; ++i)
{
//* if we found ignore word or target string matching some some special cases like years (Regex).
if (targetString == ignoreWordsList[i] || (isMatchInSpecialCases(targetString))) return true;
}
}
return false;
}
/// <summary>
/// Removes the duplicates.
/// </summary>
/// <param name="list">The list.</param>
private void removeDuplicates(List<String> list)
{
if ((list != null) && (list.Count > 0))
{
for (int i = 0; i < list.Count - 1; ++i)
{
if (list[i] == list[i + 1])
{
list.RemoveAt(i);
--i;
}
}
}
}
/// <summary>
/// Does the fuzzy match.
/// </summary>
/// <param name="targetTitle">The target title.</param>
/// <returns></returns>
private TitleMatchResult doFuzzyMatch(String targetTitle)
{
TitleMatchResult matchResult = null;
if (targetTitle != null && targetTitle != String.Empty)
{
try
{
//* change target title (string) to lower case.
targetTitle = targetTitle.ToLower();
//* scores, we will select higher score at the end.
Dictionary<Title, float> scores = new Dictionary<Title, float>();
//* do split special chars: '-', ' ', '.', ',', '?', '/', ':', ';', '%', '(', ')', '#', '\"', '\'', '!', '|', '^', '*', '[', ']', '{', '}', '=', '!', '+', '_'
List<String> targetKeywords = new List<string>(targetTitle.Split(ignoreCharsList, StringSplitOptions.RemoveEmptyEntries));
//* remove all trash from keywords, like super, quality, etc..
targetKeywords.RemoveAll(delegate(String x) { return doIgnore(x); });
//* sort keywords.
targetKeywords.Sort();
//* remove some duplicates.
removeDuplicates(targetKeywords);
//* go through all original titles.
foreach (Title sourceTitle in titles)
{
float tempScore = 0f;
//* split orig. title to keywords list.
List<String> sourceKeywords = new List<string>(sourceTitle.Name.Split(ignoreCharsList, StringSplitOptions.RemoveEmptyEntries));
sourceKeywords.Sort();
removeDuplicates(sourceKeywords);
//* go through all source ttl keywords.
foreach (String keyw1 in sourceKeywords)
{
float max = float.MinValue;
foreach (String keyw2 in targetKeywords)
{
float currentScore = StringMatching.StringMatching.CalculateSimilarity(keyw1.ToLower(), keyw2);
if (currentScore > max)
{
max = currentScore;
}
}
tempScore += max;
}
//* calculate average score.
float averageScore = (tempScore / Math.Max(targetKeywords.Count, sourceKeywords.Count));
//* if average score is bigger than minimal score and target title is not in this source title ignore list.
if (averageScore >= minimalScore && !sourceTitle.doIgnore(targetTitle))
{
//* add score.
scores.Add(sourceTitle, averageScore);
}
}
//* choose biggest score.
float maxi = float.MinValue;
foreach (KeyValuePair<Title, float> kvp in scores)
{
if (kvp.Value > maxi)
{
maxi = kvp.Value;
matchResult = new TitleMatchResult(maxi, kvp.Key, MatchTechnique.FuzzyLogic);
}
}
}
catch { }
}
//* return result.
return matchResult;
}
</code></pre>
<p>This works normally but just in some cases, a lot of titles which should match, does not match... I think I need some kind of formula to play with weights and etc, but i can't think of one.. </p>
<p>Ideas? Suggestions? Algos?</p>
<p>by the way I already know this topic (My colleague already posted it but we cannot come with a proper solution for this problem.):
<a href="https://stackoverflow.com/questions/49263/approximate-string-matching-algorithms">Approximate string matching algorithms</a></p>
|
[
{
"answer_id": 10079256,
"author": "Alain",
"author_id": 529618,
"author_profile": "https://Stackoverflow.com/users/529618",
"pm_score": 4,
"selected": false,
"text": "Public Function valuePhrase#(ByRef S1$, ByRef S2$)\n valuePhrase = LevenshteinDistance(S1, S2)\nEnd Function\n\nPublic Function valueWords#(ByRef S1$, ByRef S2$)\n Dim wordsS1$(), wordsS2$()\n wordsS1 = SplitMultiDelims(S1, \" _-\")\n wordsS2 = SplitMultiDelims(S2, \" _-\")\n Dim word1%, word2%, thisD#, wordbest#\n Dim wordsTotal#\n For word1 = LBound(wordsS1) To UBound(wordsS1)\n wordbest = Len(S2)\n For word2 = LBound(wordsS2) To UBound(wordsS2)\n thisD = LevenshteinDistance(wordsS1(word1), wordsS2(word2))\n If thisD < wordbest Then wordbest = thisD\n If thisD = 0 Then GoTo foundbest\n Next word2\nfoundbest:\n wordsTotal = wordsTotal + wordbest\n Next word1\n valueWords = wordsTotal\nEnd Function\n\n''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\n' SplitMultiDelims\n' This function splits Text into an array of substrings, each substring\n' delimited by any character in DelimChars. Only a single character\n' may be a delimiter between two substrings, but DelimChars may\n' contain any number of delimiter characters. It returns a single element\n' array containing all of text if DelimChars is empty, or a 1 or greater\n' element array if the Text is successfully split into substrings.\n' If IgnoreConsecutiveDelimiters is true, empty array elements will not occur.\n' If Limit greater than 0, the function will only split Text into 'Limit'\n' array elements or less. The last element will contain the rest of Text.\n''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''\nFunction SplitMultiDelims(ByRef Text As String, ByRef DelimChars As String, _\n Optional ByVal IgnoreConsecutiveDelimiters As Boolean = False, _\n Optional ByVal Limit As Long = -1) As String()\n Dim ElemStart As Long, N As Long, M As Long, Elements As Long\n Dim lDelims As Long, lText As Long\n Dim Arr() As String\n\n lText = Len(Text)\n lDelims = Len(DelimChars)\n If lDelims = 0 Or lText = 0 Or Limit = 1 Then\n ReDim Arr(0 To 0)\n Arr(0) = Text\n SplitMultiDelims = Arr\n Exit Function\n End If\n ReDim Arr(0 To IIf(Limit = -1, lText - 1, Limit))\n\n Elements = 0: ElemStart = 1\n For N = 1 To lText\n If InStr(DelimChars, Mid(Text, N, 1)) Then\n Arr(Elements) = Mid(Text, ElemStart, N - ElemStart)\n If IgnoreConsecutiveDelimiters Then\n If Len(Arr(Elements)) > 0 Then Elements = Elements + 1\n Else\n Elements = Elements + 1\n End If\n ElemStart = N + 1\n If Elements + 1 = Limit Then Exit For\n End If\n Next N\n 'Get the last token terminated by the end of the string into the array\n If ElemStart <= lText Then Arr(Elements) = Mid(Text, ElemStart)\n 'Since the end of string counts as the terminating delimiter, if the last character\n 'was also a delimiter, we treat the two as consecutive, and so ignore the last elemnent\n If IgnoreConsecutiveDelimiters Then If Len(Arr(Elements)) = 0 Then Elements = Elements - 1\n\n ReDim Preserve Arr(0 To Elements) 'Chop off unused array elements\n SplitMultiDelims = Arr\nEnd Function\n value = Min(phraseWeight*phraseValue, wordsWeight*wordsValue)*minWeight + \n Max(phraseWeight*phraseValue, wordsWeight*wordsValue)*maxWeight + lengthWeight*lengthValue\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5369/"
] |
53,482 |
<p>I have long since forgotten the password for the root user on one of my boxes. Is there a way I can change it without having to log in to the instance, or will I have to reinstall?</p>
|
[
{
"answer_id": 53483,
"author": "Nick Stinemates",
"author_id": 4960,
"author_profile": "https://Stackoverflow.com/users/4960",
"pm_score": 2,
"selected": false,
"text": "mysqladmin -u root password <password>\n"
},
{
"answer_id": 53567,
"author": "BlaM",
"author_id": 999,
"author_profile": "https://Stackoverflow.com/users/999",
"pm_score": 3,
"selected": true,
"text": "shell> /etc/init.d/mysql stop\n shell> mysqld --user=mysql --pid-file=/var/lib/mysql/mysqld.pid \\\n --socket=/var/lib/mysql/mysql.sock --datadir=/var/lib/mysql \\\n --skip-grant-tables --skip-networking &\n shell> mysql --database mysql --socket=/var/lib/mysql/mysql.sock\n mysql> select User, password from user;\n mysql> update user set password=password('NEW PASS') WHERE User='USERNAME';\n mysql> exit\n shell> kill `cat /var/lib/mysql/mysqld.pid`\nshell> /etc/init.d/mysql start\n"
},
{
"answer_id": 22678039,
"author": "user12345",
"author_id": 1048805,
"author_profile": "https://Stackoverflow.com/users/1048805",
"pm_score": 0,
"selected": false,
"text": "sudo dpkg-reconfigure mysql-server-5.5\n sudo dpkg-reconfigure mysql-server-5.1\n dpkg --get-selections | grep mysql-server\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4960/"
] |
53,491 |
<p>How do I enable external access to MySQL Server? I can connect locally but I cannot connect from another box on the network.</p>
<p>I just tried</p>
<pre><code>grant all privileges on *.* to root@'%' identified by '*****' with grant option;
</code></pre>
<p>And restarted MySQL Server with no success.</p>
|
[
{
"answer_id": 53512,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 6,
"selected": true,
"text": "bind-address"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4960/"
] |
53,497 |
<p>I'm having trouble writing a regular expression that matches valid IPv6 addresses, including those in their compressed form (with <code>::</code> or leading zeros omitted from each byte pair). </p>
<p>Can someone suggest a regular expression that would fulfill the requirement?</p>
<p>I'm considering expanding each byte pair and matching the result with a simpler regex.</p>
|
[
{
"answer_id": 53499,
"author": "Factor Mystic",
"author_id": 1569,
"author_profile": "https://Stackoverflow.com/users/1569",
"pm_score": 5,
"selected": false,
"text": "(\\A([0-9a-f]{1,4}:){1,1}(:[0-9a-f]{1,4}){1,6}\\Z)|\n(\\A([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,5}\\Z)|\n(\\A([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,4}\\Z)|\n(\\A([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,3}\\Z)|\n(\\A([0-9a-f]{1,4}:){1,5}(:[0-9a-f]{1,4}){1,2}\\Z)|\n(\\A([0-9a-f]{1,4}:){1,6}(:[0-9a-f]{1,4}){1,1}\\Z)|\n(\\A(([0-9a-f]{1,4}:){1,7}|:):\\Z)|\n(\\A:(:[0-9a-f]{1,4}){1,7}\\Z)|\n(\\A((([0-9a-f]{1,4}:){6})(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3})\\Z)|\n(\\A(([0-9a-f]{1,4}:){5}[0-9a-f]{1,4}:(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3})\\Z)|\n(\\A([0-9a-f]{1,4}:){5}:[0-9a-f]{1,4}:(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\Z)|\n(\\A([0-9a-f]{1,4}:){1,1}(:[0-9a-f]{1,4}){1,4}:(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\Z)|\n(\\A([0-9a-f]{1,4}:){1,2}(:[0-9a-f]{1,4}){1,3}:(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\Z)|\n(\\A([0-9a-f]{1,4}:){1,3}(:[0-9a-f]{1,4}){1,2}:(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\Z)|\n(\\A([0-9a-f]{1,4}:){1,4}(:[0-9a-f]{1,4}){1,1}:(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\Z)|\n(\\A(([0-9a-f]{1,4}:){1,5}|:):(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\Z)|\n(\\A:(:[0-9a-f]{1,4}){1,5}:(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}\\Z)\n"
},
{
"answer_id": 60946,
"author": "Brad Gilbert",
"author_id": 1337,
"author_profile": "https://Stackoverflow.com/users/1337",
"pm_score": 3,
"selected": false,
"text": "use Net::IPv6Addr;\n\nif( defined Net::IPv6Addr::is_ipv6($ip_address) ){\n print \"Looks like an ipv6 address\\n\";\n}\n use NetAddr::IP;\n\nmy $obj = NetAddr::IP->new6($ip_address);\n use Validate::IP qw'is_ipv6';\n\nif( is_ipv6($ip_address) ){\n print \"Looks like an ipv6 address\\n\";\n}\n"
},
{
"answer_id": 81899,
"author": "Joe Hildebrand",
"author_id": 8388,
"author_profile": "https://Stackoverflow.com/users/8388",
"pm_score": 5,
"selected": false,
"text": "import socket\n\ndef check_ipv6(n):\n try:\n socket.inet_pton(socket.AF_INET6, n)\n return True\n except socket.error:\n return False\n\nprint check_ipv6('::1') # True\nprint check_ipv6('foo') # False\nprint check_ipv6(5) # TypeError exception\nprint check_ipv6(None) # TypeError exception\n inet_pton socket.AF_INET"
},
{
"answer_id": 1572953,
"author": "Aeron",
"author_id": 190680,
"author_profile": "https://Stackoverflow.com/users/190680",
"pm_score": -1,
"selected": false,
"text": "25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d"
},
{
"answer_id": 1934546,
"author": "Michael",
"author_id": 215384,
"author_profile": "https://Stackoverflow.com/users/215384",
"pm_score": 6,
"selected": false,
"text": "'/^(?>(?>([a-f0-9]{1,4})(?>:(?1)){7}|(?!(?:.*[a-f0-9](?>:|$)){8,})((?1)(?>:(?1)){0,6})?::(?2)?)|(?>(?>(?1)(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})(?3)?::(?>((?1)(?>:(?1)){0,4}):)?)?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\\.(?4)){3}))$/iD'\n"
},
{
"answer_id": 3837430,
"author": "user463639",
"author_id": 463639,
"author_profile": "https://Stackoverflow.com/users/463639",
"pm_score": 1,
"selected": false,
"text": "sun.net.util.IPAddressUtil IPAddressUtil.isIPv6LiteralAddress(iPaddress);\n"
},
{
"answer_id": 5567938,
"author": "janCoffee",
"author_id": 513481,
"author_profile": "https://Stackoverflow.com/users/513481",
"pm_score": 3,
"selected": false,
"text": "\"^\\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}))|:)))(%.+)?\\s*$\"\n"
},
{
"answer_id": 14365005,
"author": "Ahamx",
"author_id": 1984714,
"author_profile": "https://Stackoverflow.com/users/1984714",
"pm_score": 1,
"selected": false,
"text": "/^(((?=.*(::))(?!.*\\3.+\\3))\\3?|[\\dA-F]{1,4}:)([\\dA-F]{1,4}(\\3|:\\b)|\\2){5}(([\\dA-F]{1,4}(\\3|:\\b|$)|\\2){2}|(((2[0-4]|1\\d|[1-9])?\\d|25[0-5])\\.?\\b){4})\\z/i\n"
},
{
"answer_id": 14960927,
"author": "Remi Morin",
"author_id": 2087666,
"author_profile": "https://Stackoverflow.com/users/2087666",
"pm_score": 3,
"selected": false,
"text": "^([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4})$\n ^([0-9A-Fa-f]{0,4}:){2,7} [0-9A-Fa-f]{1,4}$ ((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}"
},
{
"answer_id": 15988275,
"author": "JinnKo",
"author_id": 506757,
"author_profile": "https://Stackoverflow.com/users/506757",
"pm_score": 3,
"selected": false,
"text": "([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}\n"
},
{
"answer_id": 17836822,
"author": "Harry",
"author_id": 126537,
"author_profile": "https://Stackoverflow.com/users/126537",
"pm_score": -1,
"selected": false,
"text": "^(?:[0-9a-f]{1,4}(?:::)?){0,7}::[0-9a-f]+$\n"
},
{
"answer_id": 17871737,
"author": "David M. Syzdek",
"author_id": 903194,
"author_profile": "https://Stackoverflow.com/users/903194",
"pm_score": 8,
"selected": false,
"text": "(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\n # IPv6 RegEx\n(\n([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}| # 1:2:3:4:5:6:7:8\n([0-9a-fA-F]{1,4}:){1,7}:| # 1:: 1:2:3:4:5:6:7::\n([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}| # 1::8 1:2:3:4:5:6::8 1:2:3:4:5:6::8\n([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}| # 1::7:8 1:2:3:4:5::7:8 1:2:3:4:5::8\n([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}| # 1::6:7:8 1:2:3:4::6:7:8 1:2:3:4::8\n([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}| # 1::5:6:7:8 1:2:3::5:6:7:8 1:2:3::8\n([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}| # 1::4:5:6:7:8 1:2::4:5:6:7:8 1:2::8\n[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})| # 1::3:4:5:6:7:8 1::3:4:5:6:7:8 1::8 \n:((:[0-9a-fA-F]{1,4}){1,7}|:)| # ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 :: \nfe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}| # fe80::7:8%eth0 fe80::7:8%1 (link-local IPv6 addresses with zone index)\n::(ffff(:0{1,4}){0,1}:){0,1}\n((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}\n(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])| # ::255.255.255.255 ::ffff:255.255.255.255 ::ffff:0:255.255.255.255 (IPv4-mapped IPv6 addresses and IPv4-translated addresses)\n([0-9a-fA-F]{1,4}:){1,4}:\n((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}\n(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]) # 2001:db8:3:4::192.0.2.33 64:ff9b::192.0.2.33 (IPv4-Embedded IPv6 Address)\n)\n\n# IPv4 RegEx\n((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\n IPV4SEG = (25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\nIPV4ADDR = (IPV4SEG\\.){3,3}IPV4SEG\nIPV6SEG = [0-9a-fA-F]{1,4}\nIPV6ADDR = (\n (IPV6SEG:){7,7}IPV6SEG| # 1:2:3:4:5:6:7:8\n (IPV6SEG:){1,7}:| # 1:: 1:2:3:4:5:6:7::\n (IPV6SEG:){1,6}:IPV6SEG| # 1::8 1:2:3:4:5:6::8 1:2:3:4:5:6::8\n (IPV6SEG:){1,5}(:IPV6SEG){1,2}| # 1::7:8 1:2:3:4:5::7:8 1:2:3:4:5::8\n (IPV6SEG:){1,4}(:IPV6SEG){1,3}| # 1::6:7:8 1:2:3:4::6:7:8 1:2:3:4::8\n (IPV6SEG:){1,3}(:IPV6SEG){1,4}| # 1::5:6:7:8 1:2:3::5:6:7:8 1:2:3::8\n (IPV6SEG:){1,2}(:IPV6SEG){1,5}| # 1::4:5:6:7:8 1:2::4:5:6:7:8 1:2::8\n IPV6SEG:((:IPV6SEG){1,6})| # 1::3:4:5:6:7:8 1::3:4:5:6:7:8 1::8\n :((:IPV6SEG){1,7}|:)| # ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 :: \n fe80:(:IPV6SEG){0,4}%[0-9a-zA-Z]{1,}| # fe80::7:8%eth0 fe80::7:8%1 (link-local IPv6 addresses with zone index)\n ::(ffff(:0{1,4}){0,1}:){0,1}IPV4ADDR| # ::255.255.255.255 ::ffff:255.255.255.255 ::ffff:0:255.255.255.255 (IPv4-mapped IPv6 addresses and IPv4-translated addresses)\n (IPV6SEG:){1,4}:IPV4ADDR # 2001:db8:3:4::192.0.2.33 64:ff9b::192.0.2.33 (IPv4-Embedded IPv6 Address)\n )\n"
},
{
"answer_id": 17895611,
"author": "user2623580",
"author_id": 2623580,
"author_profile": "https://Stackoverflow.com/users/2623580",
"pm_score": 3,
"selected": false,
"text": "S [0-9a-f]{1,4} I (?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2}) (\n(\n::(S:){0,5}|\nS::(S:){0,4}|\n(S:){2}:(S:){0,3}|\n(S:){3}:(S:){0,2}|\n(S:){4}:(S:)?|\n(S:){5}:|\n(S:){6}\n)\nI\n\n|\n\n:(:|(:S){1,7})|\nS:(:|(:S){1,6})|\n(S:){2}(:|(:S){1,5})|\n(S:){3}(:|(:S){1,4})|\n(S:){4}(:|(:S){1,3})|\n(S:){5}(:|(:S){1,2})|\n(S:){6}(:|(:S))|\n(S:){7}:|\n(S:){7}S\n)\n\n(?:%[0-9a-z]+)?\n (?:\n(?:\n::(?:[0-9a-f]{1,4}:){0,5}|\n[0-9a-f]{1,4}::(?:[0-9a-f]{1,4}:){0,4}|\n(?:[0-9a-f]{1,4}:){2}:(?:[0-9a-f]{1,4}:){0,3}|\n(?:[0-9a-f]{1,4}:){3}:(?:[0-9a-f]{1,4}:){0,2}|\n(?:[0-9a-f]{1,4}:){4}:(?:[0-9a-f]{1,4}:)?|\n(?:[0-9a-f]{1,4}:){5}:|\n(?:[0-9a-f]{1,4}:){6}\n)\n(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})\\.){3}\n(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]{1,2})|\n\n:(?::|(?::[0-9a-f]{1,4}){1,7})|\n[0-9a-f]{1,4}:(?::|(?::[0-9a-f]{1,4}){1,6})|\n(?:[0-9a-f]{1,4}:){2}(?::|(?::[0-9a-f]{1,4}){1,5})|\n(?:[0-9a-f]{1,4}:){3}(?::|(?::[0-9a-f]{1,4}){1,4})|\n(?:[0-9a-f]{1,4}:){4}(?::|(?::[0-9a-f]{1,4}){1,3})|\n(?:[0-9a-f]{1,4}:){5}(?::|(?::[0-9a-f]{1,4}){1,2})|\n(?:[0-9a-f]{1,4}:){6}(?::|(?::[0-9a-f]{1,4}))|\n(?:[0-9a-f]{1,4}:){7}:|\n(?:[0-9a-f]{1,4}:){7}[0-9a-f]{1,4}\n)\n\n(?:%[0-9a-z]+)?\n"
},
{
"answer_id": 20059655,
"author": "Wireblue",
"author_id": 367806,
"author_profile": "https://Stackoverflow.com/users/367806",
"pm_score": 0,
"selected": false,
"text": "filter_var $is_ip4address = (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== FALSE);\n$is_ip6address = (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE);\n"
},
{
"answer_id": 20423004,
"author": "Chris",
"author_id": 3074256,
"author_profile": "https://Stackoverflow.com/users/3074256",
"pm_score": -1,
"selected": false,
"text": "^(([0-9a-f]{0,4}:){1,7}[0-9a-f]{1,4}|([0-9]{1,3}\\.){3}[0-9]{1,3})$\n"
},
{
"answer_id": 21962114,
"author": "Phil L.",
"author_id": 3024786,
"author_profile": "https://Stackoverflow.com/users/3024786",
"pm_score": -1,
"selected": false,
"text": "$ ifconfig | ipextract6\nfe80::1%lo0\n::1\nfe80::7ed1:c3ff:feec:dee1%en0\n"
},
{
"answer_id": 22329731,
"author": "Steve Buzonas",
"author_id": 816584,
"author_profile": "https://Stackoverflow.com/users/816584",
"pm_score": 2,
"selected": false,
"text": "^(?<hgroup>(?<hex>[[:xdigit:]]{0,4}) # grab a sequence of up to 4 hex digits\n # and name this pattern for usage later\n (?<!:::):{1,2}) # match 1 or 2 ':' characters\n # as long as we can't match 3\n (?&hgroup){1,6} # match our hex group 1 to 6 more times\n (?:(?:\n # match an ipv4 address or\n (?<dgroup>2[0-5]|(?:2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3}(?&dgroup)\n # match our hex group one last time\n |(?&hex))$\n"
},
{
"answer_id": 26105334,
"author": "user1977022",
"author_id": 1977022,
"author_profile": "https://Stackoverflow.com/users/1977022",
"pm_score": 0,
"selected": false,
"text": "(?=([0-9a-f]+(:[0-9a-f])*)?(?P<wild>::)(?!([0-9a-f]+:)*:))(::)?([0-9a-f]{1,4}:{1,2}){0,6}(?(wild)[0-9a-f]{0,4}|[0-9a-f]{1,4}:[0-9a-f]{1,4})\n"
},
{
"answer_id": 28289439,
"author": "Nuh Metin Güler",
"author_id": 4506317,
"author_profile": "https://Stackoverflow.com/users/4506317",
"pm_score": 1,
"selected": false,
"text": "class IPv6\n{\n public List<string> FindIPv6InFile(string filePath)\n {\n Char ch;\n StringBuilder sbIPv6 = new StringBuilder();\n List<string> listIPv6 = new List<string>();\n StreamReader reader = new StreamReader(filePath);\n do\n {\n bool hasColon = false;\n int length = 0;\n\n do\n {\n ch = (char)reader.Read();\n\n if (IsEscapeChar(ch))\n break;\n\n //Check the first 5 chars, if it has colon, then continue appending to stringbuilder\n if (!hasColon && length < 5)\n {\n if (ch == ':')\n {\n hasColon = true;\n }\n sbIPv6.Append(ch.ToString());\n }\n else if (hasColon) //if no colon in first 5 chars, then dont append to stringbuilder\n {\n sbIPv6.Append(ch.ToString());\n }\n\n length++;\n\n } while (!reader.EndOfStream);\n\n if (hasColon && !listIPv6.Contains(sbIPv6.ToString()) && IsIPv6(sbIPv6.ToString()))\n {\n listIPv6.Add(sbIPv6.ToString());\n }\n\n sbIPv6.Clear();\n\n } while (!reader.EndOfStream);\n reader.Close();\n reader.Dispose();\n\n return listIPv6;\n }\n\n public List<string> FindIPv6InText(string text)\n {\n StringBuilder sbIPv6 = new StringBuilder();\n List<string> listIPv6 = new List<string>();\n\n for (int i = 0; i < text.Length; i++)\n {\n bool hasColon = false;\n int length = 0;\n\n do\n {\n if (IsEscapeChar(text[length + i]))\n break;\n\n //Check the first 5 chars, if it has colon, then continue appending to stringbuilder\n if (!hasColon && length < 5)\n {\n if (text[length + i] == ':')\n {\n hasColon = true;\n }\n sbIPv6.Append(text[length + i].ToString());\n }\n else if (hasColon) //if no colon in first 5 chars, then dont append to stringbuilder\n {\n sbIPv6.Append(text[length + i].ToString());\n }\n\n length++;\n\n } while (i + length != text.Length);\n\n if (hasColon && !listIPv6.Contains(sbIPv6.ToString()) && IsIPv6(sbIPv6.ToString()))\n {\n listIPv6.Add(sbIPv6.ToString());\n }\n\n i += length;\n sbIPv6.Clear();\n }\n\n return listIPv6;\n }\n\n bool IsEscapeChar(char ch)\n {\n if (ch != ' ' && ch != '\\r' && ch != '\\n' && ch!='\\t')\n {\n return false;\n }\n\n return true;\n }\n\n bool IsIPv6(string maybeIPv6)\n {\n IPAddress ip;\n if (IPAddress.TryParse(maybeIPv6, out ip))\n {\n return ip.AddressFamily == AddressFamily.InterNetworkV6;\n }\n else\n {\n return false;\n }\n }\n\n}\n"
},
{
"answer_id": 28711926,
"author": "user4604205",
"author_id": 4604205,
"author_profile": "https://Stackoverflow.com/users/4604205",
"pm_score": 1,
"selected": false,
"text": "InetAddressUtils private static final String IPV4_BASIC_PATTERN_STRING =\n \"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\\\.){3}\" + // initial 3 fields, 0-255 followed by .\n \"([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\"; // final field, 0-255\n\nprivate static final Pattern IPV4_PATTERN =\n Pattern.compile(\"^\" + IPV4_BASIC_PATTERN_STRING + \"$\");\n\nprivate static final Pattern IPV4_MAPPED_IPV6_PATTERN = // TODO does not allow for redundant leading zeros\n Pattern.compile(\"^::[fF]{4}:\" + IPV4_BASIC_PATTERN_STRING + \"$\");\n\nprivate static final Pattern IPV6_STD_PATTERN =\n Pattern.compile(\n \"^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}$\");\n\nprivate static final Pattern IPV6_HEX_COMPRESSED_PATTERN =\n Pattern.compile(\n \"^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)\" + // 0-6 hex fields\n \"::\" +\n \"(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$\"); // 0-6 hex fields \n"
},
{
"answer_id": 32970482,
"author": "OliverKK",
"author_id": 2717428,
"author_profile": "https://Stackoverflow.com/users/2717428",
"pm_score": 2,
"selected": false,
"text": "libraryDependencies += \"commons-validator\" % \"commons-validator\" % \"1.4.1\"\n\n\nimport org.apache.commons.validator.routines._\n\n/**\n * Validates if the passed ip is a valid IPv4 or IPv6 address.\n *\n * @param ip The IP address to validate.\n * @return True if the passed IP address is valid, false otherwise.\n */ \n def ip(ip: String) = InetAddressValidator.getInstance().isValid(ip)\n ip(ip: String) \"The `ip` validator\" should {\n \"return false if the IPv4 is invalid\" in {\n ip(\"123\") must beFalse\n ip(\"255.255.255.256\") must beFalse\n ip(\"127.1\") must beFalse\n ip(\"30.168.1.255.1\") must beFalse\n ip(\"-1.2.3.4\") must beFalse\n }\n\n \"return true if the IPv4 is valid\" in {\n ip(\"255.255.255.255\") must beTrue\n ip(\"127.0.0.1\") must beTrue\n ip(\"0.0.0.0\") must beTrue\n }\n\n //IPv6\n //@see: http://www.ronnutter.com/ipv6-cheatsheet-on-identifying-valid-ipv6-addresses/\n \"return false if the IPv6 is invalid\" in {\n ip(\"1200::AB00:1234::2552:7777:1313\") must beFalse\n }\n\n \"return true if the IPv6 is valid\" in {\n ip(\"1200:0000:AB00:1234:0000:2552:7777:1313\") must beTrue\n ip(\"21DA:D3:0:2F3B:2AA:FF:FE28:9C5A\") must beTrue\n }\n}\n"
},
{
"answer_id": 37355379,
"author": "Rohit Malgaonkar",
"author_id": 6336249,
"author_profile": "https://Stackoverflow.com/users/6336249",
"pm_score": 4,
"selected": false,
"text": "([a-f0-9:]+:+)+[a-f0-9]+\n ifconfig -a | egrep -o '([a-f0-9:]+:+)+[a-f0-9]+'\n ifconfig -a | egrep -o '([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}) | (([a-f0-9:]+:+)+[a-f0-9]+)'\n"
},
{
"answer_id": 37903336,
"author": "Carlos Velazquez",
"author_id": 6484333,
"author_profile": "https://Stackoverflow.com/users/6484333",
"pm_score": -1,
"selected": false,
"text": "/(?!.*::.*::)(?!.*:::.*)(?!:[a-f0-9])((([a-f0-9]{1,4})?[:](?!:)){7}|(?=(.*:[:a-f0-9]{1,4}::|^([:a-f0-9]{1,4})?::))(([a-f0-9]{1,4})?[:]{1,2}){1,6})[a-f0-9]{1,4}/\n"
},
{
"answer_id": 39237544,
"author": "Bill Lipa",
"author_id": 1825318,
"author_profile": "https://Stackoverflow.com/users/1825318",
"pm_score": 2,
"selected": false,
"text": "[0-9a-f:]+\n"
},
{
"answer_id": 39841307,
"author": "Mike Wilmes",
"author_id": 5140523,
"author_profile": "https://Stackoverflow.com/users/5140523",
"pm_score": 2,
"selected": false,
"text": "pattern = '^(?=\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$)(?:(?:25[0-5]|[12][0-4][0-9]|1[5-9][0-9]|[1-9]?[0-9])\\.?){4}$|(?=^(?:[0-9a-f]{0,4}:){2,7}[0-9a-f]{0,4}$)(?![^:]*::.+::[^:]*$)(?:(?=.*::.*)|(?=\\w+:\\w+:\\w+:\\w+:\\w+:\\w+:\\w+:\\w+))(?:(?:^|:)(?:[0-9a-f]{4}|[1-9a-f][0-9a-f]{0,3})){0,8}(?:::(?:[0-9a-f]{1,4}(?:$|:)){0,6})?$'\nresult = re.match(pattern, ip)\nif result: result.group(0)\n"
},
{
"answer_id": 43307289,
"author": "Master James",
"author_id": 4928388,
"author_profile": "https://Stackoverflow.com/users/4928388",
"pm_score": 0,
"selected": false,
"text": "^\\[([0-9a-fA-F]{1,4})(\\:{1,2})([0-9a-fA-F]{1,4})(\\:{1,2})([0-9a-fA-F]{1,4})(\\:{1,2})([0-9a-fA-F]{1,4})(\\:{1,2})([0-9a-fA-F]{1,4})\\]\n"
},
{
"answer_id": 45271143,
"author": "Alexandre Fenyo",
"author_id": 8334991,
"author_profile": "https://Stackoverflow.com/users/8334991",
"pm_score": 0,
"selected": false,
"text": "// IPv6 textual representation validating parser fully compliant with RFC-4291 and RFC-5952\n// BSD-licensed / Copyright 2015-2017 Alexandre Fenyo\n\n#include <string.h>\n#include <netinet/in.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <ctype.h>\n\ntypedef enum { false, true } bool;\n\nstatic const char hexdigits[] = \"0123456789abcdef\";\nstatic int digit2int(const char digit) {\n return strchr(hexdigits, digit) - hexdigits;\n}\n\n// This IPv6 address parser handles any valid textual representation according to RFC-4291 and RFC-5952.\n// Other representations will return -1.\n//\n// note that str input parameter has been modified when the function call returns\n//\n// parse_ipv6(char *str, struct in6_addr *retaddr)\n// parse textual representation of IPv6 addresses\n// str: input arg\n// retaddr: output arg\nint parse_ipv6(char *str, struct in6_addr *retaddr) {\n bool compressed_field_found = false;\n unsigned char *_retaddr = (unsigned char *) retaddr;\n char *_str = str;\n char *delim;\n\n bzero((void *) retaddr, sizeof(struct in6_addr));\n if (!strlen(str) || strchr(str, ':') == NULL || (str[0] == ':' && str[1] != ':') ||\n (strlen(str) >= 2 && str[strlen(str) - 1] == ':' && str[strlen(str) - 2] != ':')) return -1;\n\n // convert transitional to standard textual representation\n if (strchr(str, '.')) {\n int ipv4bytes[4];\n char *curp = strrchr(str, ':');\n if (curp == NULL) return -1;\n char *_curp = ++curp;\n int i;\n for (i = 0; i < 4; i++) {\n char *nextsep = strchr(_curp, '.');\n if (_curp[0] == '0' || (i < 3 && nextsep == NULL) || (i == 3 && nextsep != NULL)) return -1;\n if (nextsep != NULL) *nextsep = 0;\n int j;\n for (j = 0; j < strlen(_curp); j++) if (_curp[j] < '0' || _curp[j] > '9') return -1;\n if (strlen(_curp) > 3) return -1;\n const long val = strtol(_curp, NULL, 10);\n if (val < 0 || val > 255) return -1;\n ipv4bytes[i] = val;\n _curp = nextsep + 1;\n }\n sprintf(curp, \"%x%02x:%x%02x\", ipv4bytes[0], ipv4bytes[1], ipv4bytes[2], ipv4bytes[3]);\n }\n\n // parse standard textual representation\n do {\n if ((delim = strchr(_str, ':')) == _str || (delim == NULL && !strlen(_str))) {\n if (delim == str) _str++;\n else if (delim == NULL) return 0;\n else {\n if (compressed_field_found == true) return -1;\n if (delim == str + strlen(str) - 1 && _retaddr != (unsigned char *) (retaddr + 1)) return 0;\n compressed_field_found = true;\n _str++;\n int cnt = 0;\n char *__str;\n for (__str = _str; *__str; ) if (*(__str++) == ':') cnt++;\n unsigned char *__retaddr = - 2 * ++cnt + (unsigned char *) (retaddr + 1);\n if (__retaddr <= _retaddr) return -1;\n _retaddr = __retaddr;\n }\n } else {\n char hexnum[4] = \"0000\";\n if (delim == NULL) delim = str + strlen(str);\n if (delim - _str > 4) return -1;\n int i;\n for (i = 0; i < delim - _str; i++)\n if (!isxdigit(_str[i])) return -1;\n else hexnum[4 - (delim - _str) + i] = tolower(_str[i]);\n _str = delim + 1;\n *(_retaddr++) = (digit2int(hexnum[0]) << 4) + digit2int(hexnum[1]);\n *(_retaddr++) = (digit2int(hexnum[2]) << 4) + digit2int(hexnum[3]);\n }\n } while (_str < str + strlen(str));\n return 0;\n}\n"
},
{
"answer_id": 47861266,
"author": "Sean F",
"author_id": 6801443,
"author_profile": "https://Stackoverflow.com/users/6801443",
"pm_score": 2,
"selected": false,
"text": " try {\n IPAddressString str = new IPAddressString(\"::1\");\n IPAddress addr = str.toAddress();\n if(addr.isIPv6() || addr.isIPv6Convertible()) {\n IPv6Address ipv6Addr = addr.toIPv6();\n }\n //use address\n } catch(AddressStringException e) {\n //e.getMessage has validation error\n }\n"
},
{
"answer_id": 50385461,
"author": "Jitendra Gosavi",
"author_id": 5725705,
"author_profile": "https://Stackoverflow.com/users/5725705",
"pm_score": 3,
"selected": false,
"text": "(([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4})\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4883/"
] |
53,501 |
<p>I am developing console application in .Net and I want to change a behavior a little based on information that application was started from cmd.exe or from explorer.exe. Is it possible?</p>
|
[
{
"answer_id": 53526,
"author": "Factor Mystic",
"author_id": 1569,
"author_profile": "https://Stackoverflow.com/users/1569",
"pm_score": 4,
"selected": true,
"text": "Process this_process = Process.GetCurrentProcess();\nint parent_pid = 0;\nusing (ManagementObject MgmtObj = new ManagementObject(\"win32_process.handle='\" + this_process.Id.ToString() + \"'\"))\n{\n MgmtObj.Get();\n parent_pid = Convert.ToInt32(MgmtObj[\"ParentProcessId\"]);\n}\nstring parent_process_name = Process.GetProcessById(parent_pid).ProcessName;\n"
},
{
"answer_id": 53565,
"author": "Adam Mitz",
"author_id": 2574,
"author_profile": "https://Stackoverflow.com/users/2574",
"pm_score": 2,
"selected": false,
"text": "#define WIN32_LEAN_AND_MEAN\n#include <windows.h>\nint main()\n{\n STARTUPINFO si;\n GetStartupInfo(&si);\n MessageBox(NULL, si.lpTitle, NULL, MB_OK);\n return 0;\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53501",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2361/"
] |
53,511 |
<p>If I use restful_authentication in my ruby on rails app are passwords transfered between the broswer and the server in paintext? And if so how worried should I be about it?</p>
|
[
{
"answer_id": 232301,
"author": "two-bit-fool",
"author_id": 23899,
"author_profile": "https://Stackoverflow.com/users/23899",
"pm_score": 2,
"selected": false,
"text": "filter_parameter_logging :password\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4474/"
] |
53,513 |
<p>For example, if passed the following:</p>
<pre><code>a = []
</code></pre>
<p>How do I check to see if <code>a</code> is empty?</p>
|
[
{
"answer_id": 53522,
"author": "Patrick",
"author_id": 429,
"author_profile": "https://Stackoverflow.com/users/429",
"pm_score": 14,
"selected": true,
"text": "if not a:\n print(\"List is empty\")\n list"
},
{
"answer_id": 53525,
"author": "Peter Hoffmann",
"author_id": 720,
"author_profile": "https://Stackoverflow.com/users/720",
"pm_score": 7,
"selected": false,
"text": "a = []\nif a:\n print(\"not empty\")\n __nonzero__ __len__"
},
{
"answer_id": 53533,
"author": "verix",
"author_id": 5342,
"author_profile": "https://Stackoverflow.com/users/5342",
"pm_score": 5,
"selected": false,
"text": "if a == []:\n print \"The list is empty.\"\n"
},
{
"answer_id": 53752,
"author": "Harley Holcombe",
"author_id": 1057,
"author_profile": "https://Stackoverflow.com/users/1057",
"pm_score": 10,
"selected": false,
"text": "# Correct:\nif not seq:\nif seq:\n\n# Wrong:\nif len(seq):\nif not len(seq):\n"
},
{
"answer_id": 61918,
"author": "George V. Reilly",
"author_id": 6364,
"author_profile": "https://Stackoverflow.com/users/6364",
"pm_score": 6,
"selected": false,
"text": "len()"
},
{
"answer_id": 7302987,
"author": "Jabba",
"author_id": 232485,
"author_profile": "https://Stackoverflow.com/users/232485",
"pm_score": 10,
"selected": false,
"text": "if len(li) == 0:\n print('the list is empty')\n li if not li: ... li"
},
{
"answer_id": 9381545,
"author": "Mike",
"author_id": 1194883,
"author_profile": "https://Stackoverflow.com/users/1194883",
"pm_score": 9,
"selected": false,
"text": "list size bool if x bool ValueError >>> x = numpy.array([0,1])\n>>> if x: print(\"x\")\nValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()\n if 0 0.0 False if False >>> x = numpy.array([0,])\n>>> if x: print(\"x\")\n... else: print(\"No x\")\nNo x\n x len len( numpy.zeros((1,0)) )\n if x.size >>> x = numpy.array([0,1])\n>>> if x.size: print(\"x\")\nx\n\n>>> x = numpy.array([0,])\n>>> if x.size: print(\"x\")\n... else: print(\"No x\")\nx\n\n>>> x = numpy.zeros((1,0))\n>>> if x.size: print(\"x\")\n... else: print(\"No x\")\nNo x\n list numpy.asarray dtype x = numpy.asarray(x, dtype=numpy.double)\n x.size"
},
{
"answer_id": 10835703,
"author": "dubiousjim",
"author_id": 272427,
"author_profile": "https://Stackoverflow.com/users/272427",
"pm_score": 6,
"selected": false,
"text": "if isinstance(a, (list, some, other, types, i, accept)) and not a:\n do_stuff\n a False if not a: if isinstance(a, numpy.ndarray) and not a.size:\n do_stuff\nelif isinstance(a, collections.Sized) and not a:\n do_stuff\n elif isinstance(a, (list, tuple)) and not a:\n elif isinstance(a, (list, tuple)) and not len(a):\n a TypeError len len"
},
{
"answer_id": 27262598,
"author": "abarnert",
"author_id": 908494,
"author_profile": "https://Stackoverflow.com/users/908494",
"pm_score": 7,
"selected": false,
"text": "if not a: if not a: None if not a and a is not None: if len(a) != 0: if not a:"
},
{
"answer_id": 32978062,
"author": "MrWonderful",
"author_id": 2069807,
"author_profile": "https://Stackoverflow.com/users/2069807",
"pm_score": 7,
"selected": false,
"text": "a = []\n\nfor item in a:\n # <Do something with item>\n\n# <The rest of code>\n a = []\n\nif not a:\n # <React to empty list>\n\n# <The rest of code>\n"
},
{
"answer_id": 34558732,
"author": "Sнаđошƒаӽ",
"author_id": 3375713,
"author_profile": "https://Stackoverflow.com/users/3375713",
"pm_score": 5,
"selected": false,
"text": "True None False 0 0.0 0j '' () [] {} __bool__() __len__() False [] if not a:\n print('\"a\" is empty!')\n"
},
{
"answer_id": 36610301,
"author": "Tagar",
"author_id": 470583,
"author_profile": "https://Stackoverflow.com/users/470583",
"pm_score": 4,
"selected": false,
"text": "def list_test (L):\n if L is None : print('list is None')\n elif not L : print('list is empty')\n else: print('list has %d elements' % len(L))\n\nlist_test(None)\nlist_test([])\nlist_test([1,2,3])\n None list is None \nlist is empty \nlist has 3 elements\n None None def list_test2 (L):\n if not L : print('list is empty')\n else: print('list has %d elements' % len(L))\n\nlist_test2(None)\nlist_test2([])\nlist_test2([1,2,3])\n list is empty\nlist is empty\nlist has 3 elements\n"
},
{
"answer_id": 39469420,
"author": "Sunil Lulla",
"author_id": 5267848,
"author_profile": "https://Stackoverflow.com/users/5267848",
"pm_score": 5,
"selected": false,
"text": "bool() a = [1,2,3];\n print bool(a); # it will return True\n a = [];\n print bool(a); # it will return False\n"
},
{
"answer_id": 40846473,
"author": "Taufiq Rahman",
"author_id": 5401681,
"author_profile": "https://Stackoverflow.com/users/5401681",
"pm_score": 5,
"selected": false,
"text": "a = [] #the list\n if not a:\n print(\"a is empty\")\n False True len() 0 if len(a) == 0:\n print(\"a is empty\")\n if a == []:\n print(\"a is empty\")\n exception iter() try:\n next(iter(a))\n # list has elements\nexcept StopIteration:\n print(\"Error: a is empty\")\n"
},
{
"answer_id": 43083496,
"author": "AndreyS Scherbakov",
"author_id": 4819357,
"author_profile": "https://Stackoverflow.com/users/4819357",
"pm_score": 4,
"selected": false,
"text": "import collections\ndef is_empty(a):\n return not a and isinstance(a, collections.Iterable)\n and not isinstance(a,(str,unicode)) >>> is_empty('sss')\nFalse\n>>> is_empty(555)\nFalse\n>>> is_empty(0)\nFalse\n>>> is_empty('')\nTrue\n>>> is_empty([3])\nFalse\n>>> is_empty([])\nTrue\n>>> is_empty({})\nTrue\n>>> is_empty(())\nTrue\n"
},
{
"answer_id": 45778282,
"author": "Russia Must Remove Putin",
"author_id": 541136,
"author_profile": "https://Stackoverflow.com/users/541136",
"pm_score": 8,
"selected": false,
"text": "a = []\n if while False True if not a: # do this!\n print('a is an empty list')\n Yes: if not seq:\n if seq:\n\nNo: if len(seq):\n if not len(seq):\n if len(a) == 0: # Don't do this!\n print('a is an empty list')\n if a == []: # Don't do this!\n print('a is an empty list')\n [] __bool__() False __len__() None False 0 0.0 0j Decimal(0) Fraction(0, 1) '' () [] {} set() range(0) object.__bool__(self) bool() False True __len__() __len__() __bool__() object.__len__(self) len() __bool__() __len__() if len(a) == 0: # Don't do this!\n print('a is an empty list')\n if a == []: # Don't do this!\n print('a is an empty list')\n if not a:\n print('a is an empty list')\n >>> import timeit\n>>> min(timeit.repeat(lambda: len([]) == 0, repeat=100))\n0.13775854044661884\n>>> min(timeit.repeat(lambda: [] == [], repeat=100))\n0.0984637276455409\n>>> min(timeit.repeat(lambda: not [], repeat=100))\n0.07878462291455435\n >>> min(timeit.repeat(lambda: [], repeat=100))\n0.07074015751817342\n len 0 len(a) == 0 len 0 >>> import dis\n>>> dis.dis(lambda: len([]) == 0)\n 1 0 LOAD_GLOBAL 0 (len)\n 2 BUILD_LIST 0\n 4 CALL_FUNCTION 1\n 6 LOAD_CONST 1 (0)\n 8 COMPARE_OP 2 (==)\n 10 RETURN_VALUE\n [] == [] >>> dis.dis(lambda: [] == [])\n 1 0 BUILD_LIST 0\n 2 BUILD_LIST 0\n 4 COMPARE_OP 2 (==)\n 6 RETURN_VALUE\n >>> dis.dis(lambda: not [])\n 1 0 BUILD_LIST 0\n 2 UNARY_NOT\n 4 RETURN_VALUE\n PyVarObject PyObject ob_size PyObject_VAR_HEAD typedef struct {\n PyObject_VAR_HEAD\n /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */\n PyObject **ob_item;\n\n /* ob_item contains space for 'allocated' elements. The number\n * currently in use is ob_size.\n * Invariants:\n * 0 <= ob_size <= allocated\n * len(list) == ob_size\n l=[] %timeit len(l) != 0 %timeit l != [] %timeit not not l not not l if l: %timeit bool(l) %timeit l %timeit In [1]: l = [] \n\nIn [2]: %timeit l \n20 ns ± 0.155 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)\n\nIn [3]: %timeit not l \n24.4 ns ± 1.58 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [4]: %timeit not not l \n30.1 ns ± 2.16 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n not In [5]: %timeit if l: pass \n22.6 ns ± 0.963 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [6]: %timeit if not l: pass \n24.4 ns ± 0.796 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [7]: %timeit if not not l: pass \n23.4 ns ± 0.793 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n In [8]: l = [1] \n\nIn [9]: %timeit if l: pass \n23.7 ns ± 1.06 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [10]: %timeit if not l: pass \n23.6 ns ± 1.64 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n\nIn [11]: %timeit if not not l: pass \n26.3 ns ± 1 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)\n bool"
},
{
"answer_id": 45898755,
"author": "Vineet Jain",
"author_id": 6761181,
"author_profile": "https://Stackoverflow.com/users/6761181",
"pm_score": 3,
"selected": false,
"text": "def is_empty(any_structure):\n if any_structure:\n print('Structure is not empty.')\n return True\n else:\n print('Structure is empty.')\n return False \n is_empty(any_structure)"
},
{
"answer_id": 49109480,
"author": "Rahul",
"author_id": 5452365,
"author_profile": "https://Stackoverflow.com/users/5452365",
"pm_score": 4,
"selected": false,
"text": "l = []\nif l:\n # do your stuff.\n True l = [\"\", False, 0, '', [], {}, ()]\nif all(bool(x) for x in l):\n # do your stuff.\n def empty_list(lst):\n if len(lst) == 0:\n return False\n else:\n return all(bool(x) for x in l)\n if empty_list(lst):\n # do your stuff.\n"
},
{
"answer_id": 50362360,
"author": "Nitin Siwach",
"author_id": 6546694,
"author_profile": "https://Stackoverflow.com/users/6546694",
"pm_score": 3,
"selected": false,
"text": "False True"
},
{
"answer_id": 52771578,
"author": "Ashiq Imran",
"author_id": 7032887,
"author_profile": "https://Stackoverflow.com/users/7032887",
"pm_score": 3,
"selected": false,
"text": "if len(a) == 0:\n print(\"a is empty\")\n"
},
{
"answer_id": 52772082,
"author": "HackerBoss",
"author_id": 3081198,
"author_profile": "https://Stackoverflow.com/users/3081198",
"pm_score": 4,
"selected": false,
"text": "not a\n None if isinstance(a, list) and len(a)==0:\n print(\"Received an empty list\")\n"
},
{
"answer_id": 53127845,
"author": "Andrey Topoleov",
"author_id": 7306511,
"author_profile": "https://Stackoverflow.com/users/7306511",
"pm_score": 4,
"selected": false,
"text": "print('not empty' if a else 'empty')\n a.pop() if a else None\n if a: a.pop() \n"
},
{
"answer_id": 53169502,
"author": "Trect",
"author_id": 9789097,
"author_profile": "https://Stackoverflow.com/users/9789097",
"pm_score": 3,
"selected": false,
"text": "a == []\n"
},
{
"answer_id": 53926417,
"author": "Andy Jazz",
"author_id": 6599590,
"author_profile": "https://Stackoverflow.com/users/6599590",
"pm_score": 4,
"selected": false,
"text": "def enquiry(list1):\n return len(list1) == 0\n\n# ––––––––––––––––––––––––––––––––\n\nlist1 = []\n\nif enquiry(list1):\n print(\"The list isn't empty\")\nelse:\n print(\"The list is Empty\")\n\n# Result: \"The list is Empty\".\n def enquiry(list1):\n return not list1\n\n# ––––––––––––––––––––––––––––––––\n\nlist1 = []\n\nif enquiry(list1):\n print(\"The list is Empty\")\nelse:\n print(\"The list isn't empty\")\n\n# Result: \"The list is Empty\"\n"
},
{
"answer_id": 54065002,
"author": "l. zhang",
"author_id": 10874195,
"author_profile": "https://Stackoverflow.com/users/10874195",
"pm_score": 4,
"selected": false,
"text": "item_list=[]\nif len(item_list) == 0:\n print(\"list is empty\")\nelse:\n print(\"list is not empty\")\n"
},
{
"answer_id": 54612063,
"author": "Vikrant",
"author_id": 1302617,
"author_profile": "https://Stackoverflow.com/users/1302617",
"pm_score": 5,
"selected": false,
"text": "if not a:\n print (\"Empty\")\n if len(a) == 0:\n print(\"Empty\")\n if a == []:\n print (\"Empty\")\n"
},
{
"answer_id": 55833259,
"author": "Vedran Šego",
"author_id": 1667018,
"author_profile": "https://Stackoverflow.com/users/1667018",
"pm_score": 3,
"selected": false,
"text": "foo = itertools.takewhile(is_not_empty, (f(x) for x in itertools.count(1)))\n foo = itertools.takewhile(bool, (f(x) for x in itertools.count(1)))\n bool if if bool(L): bool"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4872/"
] |
53,532 |
<p>I have a bunch of servlets running under the Tomcat servlet container. I would like to separate test code from production code, so I considered using a test framework.
JUnit is nicely integrated into Eclipse, but I failed to make it run servlets using a running Tomcat server. Could you please recommend a unit testing framework that supports testing Tomcat servlets? Eclipse integration is nice but not necessary. </p>
|
[
{
"answer_id": 53535,
"author": "Will Sargent",
"author_id": 5266,
"author_profile": "https://Stackoverflow.com/users/5266",
"pm_score": 3,
"selected": false,
"text": "public void testPost() {\n mockRequest = createMock(HttpServletRequest.class);\n mockResponse = createMock(HttpServletResponse.class);\n replay(mockRequest, mockResponse);\n myServlet.doPost(mockRequest, mockResponse);\n verify(mockRequest, mockResponse);\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1702/"
] |
53,538 |
<p>Is it possible to order results in SQL Server 2005 by the relevance of a freetext match? In MySQL you can use the (roughly equivalent) MATCH function in the ORDER BY section, but I haven't found any equivalence in SQL Server.</p>
<p>From the <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-natural-language.html" rel="noreferrer">MySQL docs</a>:</p>
<blockquote>
<p>For each row in the table, MATCH() returns a relevance value; that is, a similarity measure between the search string and the text in that row in the columns named in the MATCH() list.</p>
</blockquote>
<p>So for example you could order by the number of votes, then this relevance, and finally by a creation date. Is this something that can be done, or am I stuck with just returning the matching values and not having this ordering ability?</p>
|
[
{
"answer_id": 53540,
"author": "Biri",
"author_id": 968,
"author_profile": "https://Stackoverflow.com/users/968",
"pm_score": 3,
"selected": true,
"text": "FREETEXTTABLE Rank order by Rank"
},
{
"answer_id": 58179,
"author": "Josef",
"author_id": 5581,
"author_profile": "https://Stackoverflow.com/users/5581",
"pm_score": 2,
"selected": false,
"text": "FREETEXTTABLE CONTAINSTABLE [RANK]"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1612/"
] |
53,543 |
<p>Having tries to target two of these environments at the same time I can safely say the if you have to use a database etc. you end up having to write unique code for that environment. Have you got a great way to handle this situation?</p>
|
[
{
"answer_id": 53549,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 4,
"selected": false,
"text": "import mymodule_jython as mymodule\n\nimport mymodule_cpython as mymodule\n from module_importer import mymodule\n module_importer.py"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] |
53,545 |
<p>I have an exe with an <code>App.Config</code> file. Now I want to create a wrapper dll around the exe in order to consume some of the functionalities.</p>
<p>The question is how can I access the app.config property in the exe from the wrapper dll?</p>
<p>Maybe I should be a little bit more in my questions, I have the following app.config content with the exe:</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="myKey" value="myValue"/>
</appSettings>
</configuration>
</code></pre>
<p>The question is how to how to get "myValue" out from the wrapper dll?</p>
<hr>
<p>thanks for your solution.</p>
<p>Actually my initial concept was to avoid XML file reading method or LINQ or whatever. My preferred solution was to use the <a href="http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx" rel="noreferrer">configuration manager libraries and the like</a>.</p>
<p>I'll appreciate any help that uses the classes that are normally associated with accessing app.config properties. </p>
|
[
{
"answer_id": 53553,
"author": "Espo",
"author_id": 2257,
"author_profile": "https://Stackoverflow.com/users/2257",
"pm_score": 5,
"selected": false,
"text": "static void GetMappedExeConfigurationSections()\n{\n // Get the machine.config file.\n ExeConfigurationFileMap fileMap =\n new ExeConfigurationFileMap();\n // You may want to map to your own exe.comfig file here.\n fileMap.ExeConfigFilename = \n @\"C:\\test\\ConfigurationManager.exe.config\";\n System.Configuration.Configuration config =\n ConfigurationManager.OpenMappedExeConfiguration(fileMap, \n ConfigurationUserLevel.None);\n\n // Loop to get the sections. Display basic information.\n Console.WriteLine(\"Name, Allow Definition\");\n int i = 0;\n foreach (ConfigurationSection section in config.Sections)\n {\n Console.WriteLine(\n section.SectionInformation.Name + \"\\t\" +\n section.SectionInformation.AllowExeDefinition);\n i += 1;\n\n }\n Console.WriteLine(\"[Total number of sections: {0}]\", i);\n\n // Display machine.config path.\n Console.WriteLine(\"[File path: {0}]\", config.FilePath);\n}\n ExeConfigurationFileMap fileMap =\n new ExeConfigurationFileMap();\nfileMap.ExeConfigFilename = \n @\"C:\\test\\ConfigurationManager.exe.config\";\nSystem.Configuration.Configuration config =\n ConfigurationManager.OpenMappedExeConfiguration(fileMap, \n ConfigurationUserLevel.None);\nConsole.WriteLine(config.AppSettings.Settings[\"MyKey\"].Value);\n"
},
{
"answer_id": 53642,
"author": "lomaxx",
"author_id": 493,
"author_profile": "https://Stackoverflow.com/users/493",
"pm_score": 2,
"selected": false,
"text": "System.Configuration.ConfigurationManager.OpenExeConfiguration(string path)\n"
},
{
"answer_id": 53776,
"author": "Graviton",
"author_id": 3834,
"author_profile": "https://Stackoverflow.com/users/3834",
"pm_score": 4,
"selected": true,
"text": "System.Configuration.ConfigurationManager.AppSettings[\"myKey\"]"
},
{
"answer_id": 53784,
"author": "tkrehbiel",
"author_id": 4925,
"author_profile": "https://Stackoverflow.com/users/4925",
"pm_score": -1,
"selected": false,
"text": "System.Configuration.ConfigurationManager.OpenExeConfiguration."
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] |
53,562 |
<p>What are the steps required to enable Hibernate's second-level cache, when using the Java Persistence API (annotated entities)? How do I check that it's working? I'm using JBoss 4.2.2.GA.</p>
<p>From the Hibernate documentation, it seems that I need to enable the cache and specify a cache provider in <em>persistence.xml</em>, like:</p>
<pre><code><property name="hibernate.cache.use_second_level_cache"
value="true" />
<property name="hibernate.cache.provider_class"
value="org.hibernate.cache.HashtableCacheProvider" />
</code></pre>
<p>What else is required? Do I need to add <em>@Cache</em> annotations to my JPA entities?</p>
<p>How can I tell if the cache is working? I have tried accessing cache statistics after running a Query, but <em>Statistics.getSecondLevelCacheStatistics</em> returns null, perhaps because I don't know what 'region' name to use.</p>
|
[
{
"answer_id": 54415,
"author": "Peter Hilton",
"author_id": 2670,
"author_profile": "https://Stackoverflow.com/users/2670",
"pm_score": 2,
"selected": false,
"text": "<property name=\"hibernate.cache.provider_class\" \n value=\"net.sf.ehcache.hibernate.EhCacheProvider\" />\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2670/"
] |
53,569 |
<p>What is the best way to get a log of commits on a branch since the time it was branched from the current branch? My solution so far is:</p>
<pre><code>git log $(git merge-base HEAD branch)..branch
</code></pre>
<p>The documentation for <a href="http://git-scm.com/docs/git-diff" rel="noreferrer">git-diff</a> indicates that <code>git diff A...B</code> is equivalent to <code>git diff $(git-merge-base A B) B</code>. On the other hand, the documentation for <a href="http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html" rel="noreferrer">git-rev-parse</a> indicates that <code>r1...r2</code> is defined as <code>r1 r2 --not $(git merge-base --all r1 r2)</code>.</p>
<p>Why are these different? Note that <code>git diff HEAD...branch</code> gives me the diffs I want, but the corresponding git log command gives me more than what I want.</p>
<p>In pictures, suppose this:</p>
<pre>
x---y---z---branch
/
---a---b---c---d---e---HEAD
</pre>
<p>I would like to get a log containing commits x, y, z.</p>
<ul>
<li><code>git diff HEAD...branch</code> gives these commits</li>
<li>however, <code>git log HEAD...branch</code> gives x, y, z, c, d, e.</li>
</ul>
|
[
{
"answer_id": 53573,
"author": "Lily Ballard",
"author_id": 582,
"author_profile": "https://Stackoverflow.com/users/582",
"pm_score": 9,
"selected": true,
"text": "A...B git-rev-parse git-diff A...B git-diff git-diff A...B git-rev-parse A...B git log HEAD..branch git log branch --not HEAD"
},
{
"answer_id": 273683,
"author": "skiphoppy",
"author_id": 18103,
"author_profile": "https://Stackoverflow.com/users/18103",
"pm_score": 6,
"selected": false,
"text": "git cherry branch [newbranch]\n master git diff --name-status branch [newbranch]\n"
},
{
"answer_id": 2831173,
"author": "Clintm",
"author_id": 3384609,
"author_profile": "https://Stackoverflow.com/users/3384609",
"pm_score": 5,
"selected": false,
"text": "function parse_git_branch {\n git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \\(.*\\)/\\1/'\n}\n\nfunction gbin {\n echo branch \\($1\\) has these commits and \\($(parse_git_branch)\\) does not\n git log ..$1 --no-merges --format='%h | Author:%an | Date:%ad | %s' --date=local\n}\n\nfunction gbout {\n echo branch \\($(parse_git_branch)\\) has these commits and \\($1\\) does not\n git log $1.. --no-merges --format='%h | Author:%an | Date:%ad | %s' --date=local\n}\n"
},
{
"answer_id": 11689964,
"author": "nopsoft",
"author_id": 1557959,
"author_profile": "https://Stackoverflow.com/users/1557959",
"pm_score": 2,
"selected": false,
"text": "git log --cherry-mark --oneline from_branch...to_branch\n"
},
{
"answer_id": 13465814,
"author": "Debajit",
"author_id": 2288585,
"author_profile": "https://Stackoverflow.com/users/2288585",
"pm_score": 5,
"selected": false,
"text": "git log master..branchName \n git log master..branchName --oneline\n git log branchName..master\n"
},
{
"answer_id": 18241536,
"author": "Alex V",
"author_id": 327934,
"author_profile": "https://Stackoverflow.com/users/327934",
"pm_score": 3,
"selected": false,
"text": "git log -p master..branch\n alias gbc=\"git branch --no-color | sed -e '/^[^\\*]/d' -e 's/* \\\\(.*\\\\)/\\1/'\"\n\nalias gbl='git log -p master..\\`gbc\\`'\n gbl\n"
},
{
"answer_id": 19315225,
"author": "Dominik Ehrenberg",
"author_id": 2410151,
"author_profile": "https://Stackoverflow.com/users/2410151",
"pm_score": 2,
"selected": false,
"text": "git diff <branch_with_changes> <branch_to_compare_to>\n git diff HEAD master\n"
},
{
"answer_id": 33091430,
"author": "NDavis",
"author_id": 1457295,
"author_profile": "https://Stackoverflow.com/users/1457295",
"pm_score": 3,
"selected": false,
"text": "git log master... git log ...other-branch"
},
{
"answer_id": 37115352,
"author": "Michael Durrant",
"author_id": 631619,
"author_profile": "https://Stackoverflow.com/users/631619",
"pm_score": 4,
"selected": false,
"text": "git diff master...\n"
},
{
"answer_id": 65117801,
"author": "Denton L",
"author_id": 4762298,
"author_profile": "https://Stackoverflow.com/users/4762298",
"pm_score": 0,
"selected": false,
"text": "git diff --merge-base <branch> HEAD git diff <branch>...HEAD"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/893/"
] |
53,599 |
<p>Ulimately I just wanted to extract strings from the .rc file so I could translate them, but anything that goes with .rc files works for me.</p>
|
[
{
"answer_id": 98442,
"author": "jussij",
"author_id": 14738,
"author_profile": "https://Stackoverflow.com/users/14738",
"pm_score": 0,
"selected": false,
"text": "# Run Script Using This Command Line\n#\n# sed.exe -n -f sed.txt test.rc\n#\n\n# Check for lines that contain strings\n/\\\".*\\\"/ {\n # print the string part of the line only\n s/\\(.*\\)\\(\\\".*\\\"\\)\\(.*\\)/\\2/ p\n}\n"
},
{
"answer_id": 13627025,
"author": "blackbada_cpp",
"author_id": 1220715,
"author_profile": "https://Stackoverflow.com/users/1220715",
"pm_score": 2,
"selected": false,
"text": "void ProcessLine(const char * str)\n{\n if (strstr(str, \" DIALOG\"))\n state = Scan;\n else if (strstr(str, \" MENU\"))\n state = Scan;\n else if (strstr(str, \" STRINGTABLE\"))\n state = Scan;\n else if (strstr(str, \"END\"))\n state = DontScan;\n\n if (state == Scan)\n {\n const char * cur = sLine;\n string hdr = ...// for example \"# file.rc:453\"\n string msgid;\n string msgid = \"\";\n while (ExtractString(sLine, cur, msgid))\n {\n if (msgid.empty())\n continue;\n if (IsPredefined(msgid))\n continue;\n if (msgid.find(\"IDB_\") == 0 || msgid.find(\"IDC_\") == 0)\n continue;\n WritePoString(hdr, msgid, msgstr);\n }\n }\n}\n LTEXT \"Mother has washed \"\"Sony\"\", then \\taquarium\\\\shelves\\r\\nand probably floors\",IDC_TEXT1,24,14,224,19\n Mother has washed \"Sony\", then aquarium\\shelves\nand probably floors\n int TranslateDialog(CWnd& wnd)\n{\n int i = 0;\n CWnd *pChild;\n CString text;\n\n //Translate Title\nwnd.GetWindowText(text);\nLPCTSTR translation = Translate(text);\n window.SetWindowText(translation);\n\n //Translate child windows\n pChild=wnd.GetWindow(GW_CHILD);\n while(pChild)\n {\n i++;\n Child->GetWindowText(Text);//including NULL\n translation = Translate(Text);\n pChild->SetWindowText(translation);\n pChild = pChild->GetWindow(GW_HWNDNEXT);\n }\n return i;\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4880/"
] |
53,609 |
<p>I hope this qualifies as a programming question, as in any programming tutorial, you eventually come across 'foo' in the code examples. (yeah, right?)</p>
<p>what does 'foo' really mean?</p>
<p>If it is meant to mean <strong>nothing</strong>, when did it begin to be used so?</p>
|
[
{
"answer_id": 58617,
"author": "Will Harris",
"author_id": 4702,
"author_profile": "https://Stackoverflow.com/users/4702",
"pm_score": 5,
"selected": false,
"text": "foo foo bar baz bundy spam eggs ham foo foo tmp foo"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/123/"
] |
53,623 |
<p>I want to get whois information of a domain name from my c#/java programs. Is there a simple way to do this? </p>
|
[
{
"answer_id": 53632,
"author": "Chris Bunch",
"author_id": 422,
"author_profile": "https://Stackoverflow.com/users/422",
"pm_score": -1,
"selected": false,
"text": "whois import java.io.*;\nimport java.util.*;\n\npublic class ExecTest2 {\n public static void main(String[] args) throws IOException {\n Process result = Runtime.getRuntime().exec(\"whois stackoverflow.com\");\n\n BufferedReader output = new BufferedReader(new InputStreamReader(result.getInputStream()));\n StringBuffer outputSB = new StringBuffer(40000);\n String s = null;\n\n while ((s = output.readLine()) != null) {\n outputSB.append(s + \"\\n\");\n System.out.println(s);\n }\n\n String whoisStr = output.toString();\n }\n}\n"
},
{
"answer_id": 177758,
"author": "Alnitak",
"author_id": 6782,
"author_profile": "https://Stackoverflow.com/users/6782",
"pm_score": 2,
"selected": false,
"text": "SRV _nicname._tcp SRV <tld>.whois-servers.net .uk .uk whois-servers.net .uk.com whois-servers.net CRLF LF"
},
{
"answer_id": 1067587,
"author": "Andrew Shepherd",
"author_id": 25216,
"author_profile": "https://Stackoverflow.com/users/25216",
"pm_score": 4,
"selected": true,
"text": "/// <summary>\n/// Gets the whois information.\n/// </summary>\n/// <param name=\"whoisServer\">The whois server.</param>\n/// <param name=\"url\">The URL.</param>\n/// <returns></returns>\nprivate string GetWhoisInformation(string whoisServer, string url)\n{\n StringBuilder stringBuilderResult = new StringBuilder();\n TcpClient tcpClinetWhois = new TcpClient(whoisServer, 43);\n NetworkStream networkStreamWhois = tcpClinetWhois.GetStream();\n BufferedStream bufferedStreamWhois = new BufferedStream(networkStreamWhois);\n StreamWriter streamWriter = new StreamWriter(bufferedStreamWhois);\n\n streamWriter.WriteLine(url);\n streamWriter.Flush();\n\n StreamReader streamReaderReceive = new StreamReader(bufferedStreamWhois);\n\n while (!streamReaderReceive.EndOfStream)\n stringBuilderResult.AppendLine(streamReaderReceive.ReadLine());\n\n return stringBuilderResult.ToString();\n}\n"
},
{
"answer_id": 16179401,
"author": "user2313093",
"author_id": 2313093,
"author_profile": "https://Stackoverflow.com/users/2313093",
"pm_score": 2,
"selected": false,
"text": "StringBuilder stringBuilderResult = new StringBuilder();\nusing(TcpClient tcpClinetWhois = new TcpClient(whoIsServer, 43))\n{\n using(NetworkStream networkStreamWhois = tcpClinetWhois.GetStream())\n {\n using(BufferedStream bufferedStreamWhois = new BufferedStream(networkStreamWhois))\n {\n using(StreamWriter streamWriter = new StreamWriter(bufferedStreamWhois))\n {\n streamWriter.WriteLine(url);\n streamWriter.Flush();\n using (StreamReader streamReaderReceive = new StreamReader(bufferedStreamWhois))\n {\n while (!streamReaderReceive.EndOfStream) stringBuilderResult.AppendLine(streamReaderReceive.ReadLine());\n }\n }\n }\n }\n}\n"
},
{
"answer_id": 72093332,
"author": "Erman Çetin",
"author_id": 4819851,
"author_profile": "https://Stackoverflow.com/users/4819851",
"pm_score": 0,
"selected": false,
"text": "leaveOpen: true StreamWriter StreamReader var stringBuilderResult = new StringBuilder();\n\nusing (var tcpClinetWhois = new TcpClient(whoIsServer, 43))\nusing (var networkStreamWhois = tcpClinetWhois.GetStream())\nusing (var bufferedStreamWhois = new BufferedStream(networkStreamWhois))\nusing (var streamWriter = new StreamWriter(networkStreamWhois, leaveOpen: true))\n{\n streamWriter.WriteLine(url);\n streamWriter.Flush();\n\n using (var streamReaderReceive = new StreamReader(networkStreamWhois, leaveOpen: true))\n {\n while (!streamReaderReceive.EndOfStream)\n {\n stringBuilderResult.AppendLine(streamReaderReceive.ReadLine());\n }\n }\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184/"
] |
53,629 |
<p>Is it possible to see the history of changes to a particular line of code in a Subversion repository?</p>
<p>I'd like, for instance, to be able to see when a particular statement was added or when that statement was changed, even if its line number is not the same any more.</p>
|
[
{
"answer_id": 53634,
"author": "Brad Wilson",
"author_id": 1554,
"author_profile": "https://Stackoverflow.com/users/1554",
"pm_score": -1,
"selected": false,
"text": "svn blame"
},
{
"answer_id": 53636,
"author": "Peter Hoffmann",
"author_id": 720,
"author_profile": "https://Stackoverflow.com/users/720",
"pm_score": 0,
"selected": false,
"text": " 4564 wiemann # $Id$\n 4564 wiemann # Author: David Goodger <[email protected]>\n 778 goodger # Copyright: This module has been placed in the public domain.\n 217 goodger \n"
},
{
"answer_id": 53640,
"author": "Marcio Aguiar",
"author_id": 4213,
"author_profile": "https://Stackoverflow.com/users/4213",
"pm_score": 1,
"selected": false,
"text": "svn annotate\n"
},
{
"answer_id": 53644,
"author": "morechilli",
"author_id": 5427,
"author_profile": "https://Stackoverflow.com/users/5427",
"pm_score": 7,
"selected": true,
"text": "svn blame svn blame svn blame TARGET[@REV]...\n"
},
{
"answer_id": 9137338,
"author": "atedja",
"author_id": 1015188,
"author_profile": "https://Stackoverflow.com/users/1015188",
"pm_score": 4,
"selected": false,
"text": "svn blame FILE -r svn blame FILE -r 1:REV\n"
},
{
"answer_id": 27187583,
"author": "Serge Kutny",
"author_id": 1766641,
"author_profile": "https://Stackoverflow.com/users/1766641",
"pm_score": 3,
"selected": false,
"text": "svn blame /path/to/your/file > blame.tmp grep \"your_line_of_text\" blame.tmp"
},
{
"answer_id": 37281937,
"author": "tniles",
"author_id": 1228878,
"author_profile": "https://Stackoverflow.com/users/1228878",
"pm_score": 2,
"selected": false,
"text": "svn blame svn help blame CLI svn log | grep -C 10 \"fileName.h\" | less blame annotate cd trunk\nsvn blame fileName.h@r35948 | less\n svn diff -r35948:PREV fileName.h\n"
},
{
"answer_id": 57630362,
"author": "Harrison Mc",
"author_id": 7343786,
"author_profile": "https://Stackoverflow.com/users/7343786",
"pm_score": 0,
"selected": false,
"text": "vc vc-annotate vc-annotate svn blame vc-annotate-revision-previous-to-line"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1428/"
] |
53,649 |
<p>Using reflection, I need to investigate a user DLL and create an object of a class in it.</p>
<p>What is the simple way of doing it?</p>
|
[
{
"answer_id": 53658,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stackoverflow.com/users/1908",
"pm_score": 2,
"selected": false,
"text": "System.Reflection.Assembly Assembly.GetTypes() Assembly.GetExportedTypes()"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/195/"
] |
53,652 |
<p>This might be a bit on the silly side of things but I need to send the contents of a DataTable (unknown columns, unknown contents) via a text e-mail. Basic idea is to loop over rows and columns and output all cell contents into a StringBuilder using .ToString(). </p>
<p>Formatting is a big issue though. Any tips/ideas on how to make this look "readable" in a text format ? </p>
<p>I'm thinking on "padding" each cell with empty spaces, but I also need to split some cells into multiple lines, and this makes the StringBuilder approach a bit messy ( because the second line of text from the first column comes after the first line of text in the last column,etc.)</p>
|
[
{
"answer_id": 53665,
"author": "Lukas Šalkauskas",
"author_id": 5369,
"author_profile": "https://Stackoverflow.com/users/5369",
"pm_score": -1,
"selected": false,
"text": "Dim Str As String = \"\"\n 'Create File if doesn't exist\n Dim FILE_NAME As String = \"C:\\temp\\Custom.txt\"\n If System.IO.File.Exists(FILE_NAME) = False Then\n System.IO.File.Create(FILE_NAME)\n End If\n\n Dim objWriter As System.IO.StreamWriter\n Try\n objWriter = New System.IO.StreamWriter(FILE_NAME)\n Catch ex As System.IO.IOException\n MsgBox(\"Please close the file: (C:\\temp\\Custom.txt) before proceeding\" & vbCrLf & ex.Message.ToString, MsgBoxStyle.Exclamation)\n objWriter = Nothing\n Err = True\n End Try\n\n\n'I assume you know how to write to text file.\n'Say my datagridview is named \"dgrid\"\n\nDim x,y as integer\n\nFor x = 0 to dgrid.rows.count -1\n For y = 0 to dgrid.columns.count - 1\n Str = dgrid.Rows(x).Cells(y).Values & \" \"\n Next y\nNext x\n\nobjWriter.Close()\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3263/"
] |
53,664 |
<p>I've started using Vim to develop Perl scripts and am starting to find it very powerful. </p>
<p>One thing I like is to be able to open multiple files at once with:</p>
<pre><code>vi main.pl maintenance.pl
</code></pre>
<p>and then hop between them with:</p>
<pre><code>:n
:prev
</code></pre>
<p>and see which file are open with:</p>
<pre><code>:args
</code></pre>
<p>And to add a file, I can say: </p>
<pre><code>:n test.pl
</code></pre>
<p>which I expect would then be added to my list of files, but instead it wipes out my current file list and when I type <code>:args</code> I only have <code>test.pl</code> open.</p>
<p>So how can I add and remove files in my args list?</p>
|
[
{
"answer_id": 53667,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": false,
"text": ":tabe [filename] gt gT"
},
{
"answer_id": 53668,
"author": "fijter",
"author_id": 3215,
"author_profile": "https://Stackoverflow.com/users/3215",
"pm_score": 11,
"selected": true,
"text": ":tabn :tabp :tabe <filepath> :q :wq :tabn :tabp :sp <filepath>"
},
{
"answer_id": 53701,
"author": "MarkB",
"author_id": 2996,
"author_profile": "https://Stackoverflow.com/users/2996",
"pm_score": 7,
"selected": false,
"text": "args :argadd\n args :argdelete\n :argedit args :help args"
},
{
"answer_id": 53702,
"author": "Rob Wells",
"author_id": 2974,
"author_profile": "https://Stackoverflow.com/users/2974",
"pm_score": 6,
"selected": false,
"text": ":ls 1 %a \"./checkin.pl\" line 1\n 2 # \"./grabakamailogs.pl\" line 1\n 3 \"./grabwmlogs.pl\" line 0\n etc.\n :ls :reg"
},
{
"answer_id": 53709,
"author": "Andy Whitfield",
"author_id": 4805,
"author_profile": "https://Stackoverflow.com/users/4805",
"pm_score": 6,
"selected": false,
"text": ":bn :bp :buffers :b<n> :bd :e <filename>"
},
{
"answer_id": 53714,
"author": "Sébastien RoccaSerra",
"author_id": 2797,
"author_profile": "https://Stackoverflow.com/users/2797",
"pm_score": 9,
"selected": false,
"text": ":ls\n :e ../myFile.pl\n set wildmenu .vimrc :find :b myfile\n set wildmenu :b# Ctrl-W s Ctrl-W v :split :vertical split :sp :vs Ctrl-W w Ctrl-W h j k l Ctrl-W c Ctrl-W o -o -O --remote-silent"
},
{
"answer_id": 64829,
"author": "zigdon",
"author_id": 4913,
"author_profile": "https://Stackoverflow.com/users/4913",
"pm_score": 4,
"selected": false,
"text": ":b <partial filename><tab> :bw :e <file path> pltags"
},
{
"answer_id": 65732,
"author": "shyam",
"author_id": 7616,
"author_profile": "https://Stackoverflow.com/users/7616",
"pm_score": 8,
"selected": false,
"text": ":ls\n :bp :bn :bn n :b <filename-part> bn bp bnext bprevious ^ :mksession! ~/today.ses\n ~/today.ses vim -S ~/today.ses\n"
},
{
"answer_id": 75793,
"author": "projecktzero",
"author_id": 13380,
"author_profile": "https://Stackoverflow.com/users/13380",
"pm_score": 2,
"selected": false,
"text": "~/.vimrc :b1 :b2"
},
{
"answer_id": 83984,
"author": "Max Cantor",
"author_id": 16034,
"author_profile": "https://Stackoverflow.com/users/16034",
"pm_score": 4,
"selected": false,
"text": "\" Movement between tabs OR buffers\nnnoremap L :call MyNext()<CR>\nnnoremap H :call MyPrev()<CR>\n\n\" MyNext() and MyPrev(): Movement between tabs OR buffers\nfunction! MyNext()\n if exists( '*tabpagenr' ) && tabpagenr('$') != 1\n \" Tab support && tabs open\n normal gt\n else\n \" No tab support, or no tabs open\n execute \":bnext\"\n endif\nendfunction\nfunction! MyPrev()\n if exists( '*tabpagenr' ) && tabpagenr('$') != '1'\n \" Tab support && tabs open\n normal gT\n else\n \" No tab support, or no tabs open\n execute \":bprev\"\n endif\nendfunction\n"
},
{
"answer_id": 8436685,
"author": "puk",
"author_id": 654789,
"author_profile": "https://Stackoverflow.com/users/654789",
"pm_score": 5,
"selected": false,
"text": ":e :badd :e foo.txt bar.txt\n:e /foo/bar/*.txt\n:badd /foo/bar/*\n arga[dd] :arga foo.txt bar.txt\n:arga /foo/bar/*.txt\n:argadd /foo/bar/*\n"
},
{
"answer_id": 17536403,
"author": "user2179522",
"author_id": 2179522,
"author_profile": "https://Stackoverflow.com/users/2179522",
"pm_score": 4,
"selected": false,
"text": "'C 'T mC mT"
},
{
"answer_id": 20964867,
"author": "user2663398",
"author_id": 2663398,
"author_profile": "https://Stackoverflow.com/users/2663398",
"pm_score": 2,
"selected": false,
"text": "nmap <leader>sh :leftabove vnew<CR> nmap <leader>sl :rightbelow vnew<CR> nmap <leader>sk :leftabove new<CR> nmap <leader>sj :rightbelow new<CR> nmap <C-j> <C-w>j nmap <C-k> <C-w>k nmap <C-l> <C-w>l nmap <C-h> <C-w>h"
},
{
"answer_id": 21220765,
"author": "Michael Durrant",
"author_id": 631619,
"author_profile": "https://Stackoverflow.com/users/631619",
"pm_score": 3,
"selected": false,
"text": "screen"
},
{
"answer_id": 24555993,
"author": "Jens",
"author_id": 925649,
"author_profile": "https://Stackoverflow.com/users/925649",
"pm_score": 2,
"selected": false,
"text": "alias gvim=\"gvim --servername \\$(git rev-parse --show-toplevel || echo 'default') --remote-tab\"\n nmap <C-p> :tabprevious<CR>\nnmap <C-n> :tabnext<CR>\n"
},
{
"answer_id": 29597152,
"author": "superarts.org",
"author_id": 772295,
"author_profile": "https://Stackoverflow.com/users/772295",
"pm_score": 1,
"selected": false,
"text": "map <S-h> :bprev<Return> map <S-l> :bnext<Return>"
},
{
"answer_id": 34109581,
"author": "fede1024",
"author_id": 1025899,
"author_profile": "https://Stackoverflow.com/users/1025899",
"pm_score": 2,
"selected": false,
"text": "nmap <CR> :CtrlPBuffer<CR>\n"
},
{
"answer_id": 35669509,
"author": "Dionysis",
"author_id": 1236333,
"author_profile": "https://Stackoverflow.com/users/1236333",
"pm_score": 1,
"selected": false,
"text": "<leader> <leader> nnoremap <leader><leader> <c-^>\n <leader>a 2 <leader>ff set winwidth=84\nset winheight=5\nset winminheight=5\nset winheight=999\n\nnnoremap <C-w>v :111vs<CR>\nnnoremap <C-w>s :rightbelow split<CR>\nset splitright\n nnoremap <C-J> <C-W><C-J>\nnnoremap <C-K> <C-W><C-K>\nnnoremap <C-L> <C-W><C-L>\nnnoremap <C-H> <C-W><C-H>\n"
},
{
"answer_id": 44647932,
"author": "qeatzy",
"author_id": 3625404,
"author_profile": "https://Stackoverflow.com/users/3625404",
"pm_score": 4,
"selected": false,
"text": "nnoremap <Leader>f :set nomore<Bar>:ls<Bar>:set more<CR>:b<Space>\n :ls :b <Leader>f 23 # <Tab> <C-i> <CR> <Esc> :set nomore|:ls|:set more\n 1 h \"script.py\" line 1\n 2 #h + \"file1.txt\" line 6 -- '#' for alternative buffer\n 3 %a \"README.md\" line 17 -- '%' for current buffer\n 4 \"file3.txt\" line 0 -- line 0 for hasn't switched to\n 5 + \"/etc/passwd\" line 42 -- '+' for modified\n:b '<Cursor> here'\n %a h # + set hidden :help 'hidden'"
},
{
"answer_id": 44935024,
"author": "dlmeetei",
"author_id": 1389898,
"author_profile": "https://Stackoverflow.com/users/1389898",
"pm_score": 4,
"selected": false,
"text": "tab :tab sball\n gt or :tabn \" go to next tab\ngT or :tabp or :tabN \" go to previous tab\n :help tab-page-commands vim -p file1 file2 alias vim='vim -p' ~/.vimrc au VimEnter * if !&diff | tab all | tabfirst | endif\n arga file argd pattern :help arglist"
},
{
"answer_id": 45770452,
"author": "icc97",
"author_id": 327074,
"author_profile": "https://Stackoverflow.com/users/327074",
"pm_score": 3,
"selected": false,
"text": ".vimrc let g:airline#extensions#tabline#enabled = 1 set wildmenu .vimrc :b <file part> :Explore - :cdo"
},
{
"answer_id": 46858244,
"author": "npit",
"author_id": 3532255,
"author_profile": "https://Stackoverflow.com/users/3532255",
"pm_score": 0,
"selected": false,
"text": "vim vim -p .bashrc alias vim=\"vim -p\"\n :tab ball"
},
{
"answer_id": 59810540,
"author": "Mou Sam Dahal",
"author_id": 10048518,
"author_profile": "https://Stackoverflow.com/users/10048518",
"pm_score": 3,
"selected": false,
"text": "<C-W><C-H/K/L/j>"
},
{
"answer_id": 66870832,
"author": "Aram Simonyan",
"author_id": 14274837,
"author_profile": "https://Stackoverflow.com/users/14274837",
"pm_score": 0,
"selected": false,
"text": "vim -p file1 file2 :tabnew file3 :new file3 ~/.vimrc let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'\n if empty(glob(data_dir . '/autoload/plug.vim'))\n silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs \n https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'\n autocmd VimEnter * PlugInstall --sync | source $MYVIMRC\n endif\n\n call plug#begin('~/.vim/plugged')\n Plug 'scrooloose/nerdtree'\n call plug#end()\n :wq :PlugInstall"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] |
53,666 |
<p>Say I have an interface IFoo which I am mocking. There are 3 methods on this interface. I need to test that the system under test calls at least one of the three methods. I don't care how many times, or with what arguments it does call, but the case where it ignores all the methods and does not touch the IFoo mock is the failure case.</p>
<p>I've been looking through the Expect.Call documentation but can't see an easy way to do it.</p>
<p>Any ideas?</p>
|
[
{
"answer_id": 58623,
"author": "Spoike",
"author_id": 3713,
"author_profile": "https://Stackoverflow.com/users/3713",
"pm_score": 0,
"selected": false,
"text": "[TestFixture]\npublic class MyTest {\n\n // The mocked interface\n public class MockedInterface implements MyInterface {\n int counter = 0;\n public method1() { counter++; }\n public method2() { counter++; }\n public method3() { counter++; }\n }\n\n // The actual test, I assume you have the ClassUnderTest\n // inject the interface through the constructor and\n // the methodToTest calls either of the three methods on \n // the interface.\n [TestMethod]\n public void testCallingAnyOfTheThreeMethods() {\n MockedInterface mockery = new MockedInterface();\n ClassUnderTest classToTest = new ClassUnderTest(mockery);\n\n classToTest.methodToTest();\n\n Assert.That(mockery.counter, Is.GreaterThan(1));\n }\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3024/"
] |
53,676 |
<p>When trying to connect to an <code>ORACLE</code> user via TOAD (Quest Software) or any other means (<code>Oracle Enterprise Manager</code>) I get this error:</p>
<blockquote>
<p><code>ORA-011033: ORACLE initialization or shutdown in progress</code></p>
</blockquote>
|
[
{
"answer_id": 53684,
"author": "rohancragg",
"author_id": 5351,
"author_profile": "https://Stackoverflow.com/users/5351",
"pm_score": 8,
"selected": true,
"text": "SQL> startup mount\n\nORACLE Instance started\n\nSQL> recover database \n\nMedia recovery complete\n\nSQL> alter database open;\n\nDatabase altered\n"
},
{
"answer_id": 21298642,
"author": "z atef",
"author_id": 2052097,
"author_profile": "https://Stackoverflow.com/users/2052097",
"pm_score": 5,
"selected": false,
"text": "SQL> Startup mount\nORA-01081: cannot start already-running ORACLE - shut it down first\nSQL> shutdown abort\nORACLE instance shut down.\nSQL>\nSQL> startup mount\nORACLE instance started.\n\nTotal System Global Area 1904054272 bytes\nFixed Size 2404024 bytes\nVariable Size 570425672 bytes\nDatabase Buffers 1325400064 bytes\nRedo Buffers 5824512 bytes\nDatabase mounted.\nSQL> Show parameter control_files\n\nNAME TYPE VALUE\n------------------------------------ ----------- ------------------------------\ncontrol_files string C:\\APP\\USER\\ORADATA\\ORACLEDB\\C\n ONTROL01.CTL, C:\\APP\\USER\\FAST\n _RECOVERY_AREA\\ORACLEDB\\CONTRO\n L02.CTL\nSQL> select a.member,a.group#,b.status from v$logfile a ,v$log b where a.group#=\nb.group# and b.status='CURRENT'\n 2\nSQL> select a.member,a.group#,b.status from v$logfile a ,v$log b where a.group#=\nb.group# and b.status='CURRENT';\n\nMEMBER\n--------------------------------------------------------------------------------\n\n GROUP# STATUS\n---------- ----------------\nC:\\APP\\USER\\ORADATA\\ORACLEDB\\REDO03.LOG\n 3 CURRENT\n\n\nSQL> shutdown abort\nORACLE instance shut down.\nSQL> startup mount\nORACLE instance started.\n\nTotal System Global Area 1904054272 bytes\nFixed Size 2404024 bytes\nVariable Size 570425672 bytes\nDatabase Buffers 1325400064 bytes\nRedo Buffers 5824512 bytes\nDatabase mounted.\nSQL> recover database using backup controlfile until cancel;\nORA-00279: change 4234808 generated at 01/21/2014 18:31:05 needed for thread 1\nORA-00289: suggestion :\nC:\\APP\\USER\\FAST_RECOVERY_AREA\\ORACLEDB\\ARCHIVELOG\\2014_01_22\\O1_MF_1_108_%U_.AR\n\nC\nORA-00280: change 4234808 for thread 1 is in sequence #108\n\n\nSpecify log: {<RET>=suggested | filename | AUTO | CANCEL}\nC:\\APP\\USER\\ORADATA\\ORACLEDB\\REDO03.LOG\nLog applied.\nMedia recovery complete.\nSQL> alter database open resetlogs;\n\nDatabase altered.\n"
},
{
"answer_id": 35026997,
"author": "gadildafissh",
"author_id": 811058,
"author_profile": "https://Stackoverflow.com/users/811058",
"pm_score": 2,
"selected": false,
"text": "C:\\>sqlplus sys/sys as sysdba\nSQL*Plus: Release 11.2.0.3.0 Production on Tue Apr 30 19:07:16 2013\nCopyright (c) 1982, 2011, Oracle. All rights reserved.\nConnected to an idle instance.\n\nSQL> startup\nORACLE instance started.\nTotal System Global Area 778387456 bytes\nFixed Size 1384856 bytes\nVariable Size 520097384 bytes\nDatabase Buffers 251658240 bytes\nRedo Buffers 5246976 bytes\nDatabase mounted.\nORA-01157: cannot identify/lock data file 11 – see DBWR trace file\nORA-01110: data file 16: 'E:\\oracle\\app\\nimish.garg\\oradata\\orcl\\test_ts.dbf'\n\nSQL> select NAME from v$datafile where file#=16;\nNAME\n--------------------------------------------------------------------------------\nE:\\ORACLE\\APP\\NIMISH.GARG\\ORADATA\\ORCL\\TEST_TS.DBF\n\nSQL> alter database datafile 16 OFFLINE DROP;\nDatabase altered.\n\nSQL> alter database open;\nDatabase altered.\n"
},
{
"answer_id": 43871217,
"author": "Witold Kaczurba",
"author_id": 6931119,
"author_profile": "https://Stackoverflow.com/users/6931119",
"pm_score": 5,
"selected": false,
"text": "sqlplus hr/hr@pdborcl ORACLE initialization or shutdown in progress SYSDBA sqlplus SYS/Oracle_1@pdborcl AS SYSDBA\n alter pluggable database pdborcl open read write;\n sqlplus hr/hr@pdborcl\n"
},
{
"answer_id": 54326242,
"author": "Goku",
"author_id": 10631120,
"author_profile": "https://Stackoverflow.com/users/10631120",
"pm_score": 2,
"selected": false,
"text": "alter database open alter database open resetlogs $ sqlplus / sysdba\n\nSQL> startup\nORACLE instance started.\n\nTotal System Global Area 1073741824 bytes\nFixed Size 8628936 bytes\nVariable Size 624952632 bytes\nDatabase Buffers 436207616 bytes\nRedo Buffers 3952640 bytes\nDatabase mounted.\nDatabase opened.\n\nSQL> conn user/pass123\nConnected.\n"
},
{
"answer_id": 64407006,
"author": "Ian Nato",
"author_id": 5841507,
"author_profile": "https://Stackoverflow.com/users/5841507",
"pm_score": 0,
"selected": false,
"text": "sqlplus / as sysdba show parameter local_listener ALTER SYSTEM SET LOCAL_LISTENER='<LISTENER_NAME_GOES_HERE>'"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5351/"
] |
53,715 |
<p>Does Delphi call inherited on overridden procedures if there is no explicit call in the code ie (inherited;), I have the following structure (from super to sub class)</p>
<p>TForm >> TBaseForm >> TAnyOtherForm</p>
<p>All the forms in the project will be derived from TBaseForm, as this will have all the standard set-up and destructive parts that are used for every form (security, validation ect). </p>
<p>TBaseForm has onCreate and onDestroy procedures with the code to do this, but if someone (ie me) forgot to add inherited to the onCreate on TAnyOtherForm would Delphi call it for me? I have found references on the web that say it is not required, but nowhere says if it gets called if it is omitted from the code.</p>
<p>Also if it does call inherited for me, when will it call it?</p>
|
[
{
"answer_id": 53785,
"author": "Frank",
"author_id": 4474,
"author_profile": "https://Stackoverflow.com/users/4474",
"pm_score": 2,
"selected": false,
"text": "// interface\n\nTBaseForm = Class(TForm)\n...\nProtected\n Procedure DoCreate(Sender : TObject); Override;\nEnd\n\n// implementation\n\nProcedure TBaseForm.DoCreate(Sender : TObject);\nBegin\n // do work here\n\n // let parent call the OnCreate property \n Inherited DoCreate(Sender);\nEnd;\n"
},
{
"answer_id": 57513,
"author": "Jody Dawkins",
"author_id": 1234,
"author_profile": "https://Stackoverflow.com/users/1234",
"pm_score": 1,
"selected": false,
"text": "procedure TMyCalcObject.SolveForX;\nbegin\n ResetCalcState;\n inherited SolveForX;\n PostProcessSolveForX;\nend;\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2098/"
] |
53,719 |
<p>It is obviously possible to hide individual data points in an Excel line chart.</p>
<ul>
<li>Select a data point. </li>
<li>Right click -> Format Data Point... </li>
<li>Select Patterns</li>
<li>Tab Set Line to None</li>
</ul>
<p>How do you accomplish the same thing in VBA? Intuition tells me there should be a property on the <a href="http://msdn.microsoft.com/en-us/library/aa174283(office.11).aspx" rel="nofollow noreferrer">Point object</a> <code>Chart.SeriesCollection(<index>).Points(<index></code> which deals with this...</p>
|
[
{
"answer_id": 67650,
"author": "SpyJournal",
"author_id": 10326,
"author_profile": "https://Stackoverflow.com/users/10326",
"pm_score": 2,
"selected": false,
"text": "IF #N/A =If(B2=0,\"#N/A\",B2)"
},
{
"answer_id": 471678,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "=IF(b2=0,NA(),b2) #N/A"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5085/"
] |
53,728 |
<p>I am not concerned about other kinds of attacks. Just want to know whether HTML Encode can prevent all kinds of XSS attacks.</p>
<p>Is there some way to do an XSS attack even if HTML Encode is used?</p>
|
[
{
"answer_id": 53739,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": -1,
"selected": false,
"text": "<script/>\n"
},
{
"answer_id": 53816,
"author": "metavida",
"author_id": 5539,
"author_profile": "https://Stackoverflow.com/users/5539",
"pm_score": 1,
"selected": false,
"text": "# Markup example\n[foo](javascript:alert\\('bar'\\);)\n"
},
{
"answer_id": 70222,
"author": "AviD",
"author_id": 10080,
"author_profile": "https://Stackoverflow.com/users/10080",
"pm_score": 8,
"selected": true,
"text": "<input value=<%= HtmlEncode(somevar) %> id=textbox>\n a onclick=alert(document.cookie)\n <input value=a onclick=alert(document.cookie) id=textbox>\n +ADw-script+AD4-alert(document.cookie)+ADw-/script+AD4-\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/184/"
] |
53,734 |
<p>If you're creating a temporary table within a stored procedure and want to add an index or two on it, to improve the performance of any additional statements made against it, what is the best approach? Sybase says <a href="http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.dc20020_1251/html/databases/databases644.htm" rel="noreferrer">this</a>:</p>
<p><em>"the table must contain data when the index is created. If you create the temporary table and create the index on an empty table, Adaptive Server does not create column statistics such as histograms and densities. If you insert data rows after creating the index, the optimizer has incomplete statistics."</em></p>
<p>but recently a colleague mentioned that if I create the temp table and indices in a different stored procedure to the one which actually uses the temporary table, then Adaptive Server optimiser <em>will</em> be able to make use of them.</p>
<p>On the whole, I'm not a big fan of wrapper procedures that add little value, so I've not actually got around to testing this, but I thought I'd put the question out there, to see if anyone had any other approaches or advice?</p>
|
[
{
"answer_id": 153680,
"author": "AJ.",
"author_id": 7211,
"author_profile": "https://Stackoverflow.com/users/7211",
"pm_score": 4,
"selected": true,
"text": "SELECT * \nFROM #table (index idIndex) \nWHERE id = @id\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53734",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1030/"
] |
53,744 |
<p>I would like to know how can i escape a # in velocity. Backslash seems to escape it but it prints itself as well</p>
<p>This: </p>
<pre><code>\#\#
</code></pre>
<p>prints: </p>
<pre><code>\#\#
</code></pre>
<p>I would like: </p>
<pre><code>##
</code></pre>
|
[
{
"answer_id": 64246,
"author": "Nathan Bubna",
"author_id": 8131,
"author_profile": "https://Stackoverflow.com/users/8131",
"pm_score": 6,
"selected": false,
"text": "#set( $H = '#' )\n$H$H\n"
},
{
"answer_id": 7093929,
"author": "alvi",
"author_id": 644958,
"author_profile": "https://Stackoverflow.com/users/644958",
"pm_score": 6,
"selected": false,
"text": "#[[\n##\n]]#\n ##\n"
},
{
"answer_id": 11053895,
"author": "gregm",
"author_id": 108495,
"author_profile": "https://Stackoverflow.com/users/108495",
"pm_score": 0,
"selected": false,
"text": "set ($n = '_lastname)\n $name$n\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] |
53,757 |
<p>Which compiles to faster code: "ans = n * 3" or "ans = n+(n*2)"?</p>
<p>Assuming that n is either an int or a long, and it is is running on a modern Win32 Intel box.</p>
<p>Would this be different if there was some dereferencing involved, that is, which of these would be faster?</p>
<pre>
long a;
long *pn;
long ans;
...
*pn = some_number;
ans = *pn * 3;
</pre>
<p>Or</p>
<pre>
ans = *pn+(*pn*2);
</pre>
<p>Or, is it something one need not worry about as optimizing compilers are likely to account for this in any case?</p>
|
[
{
"answer_id": 53763,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 0,
"selected": false,
"text": "* 2"
},
{
"answer_id": 53781,
"author": "Antti Kissaniemi",
"author_id": 2948,
"author_profile": "https://Stackoverflow.com/users/2948",
"pm_score": 3,
"selected": false,
"text": "gcc time /* test1.c */\nint main()\n{\n int result = 0;\n int times = 1000000000;\n while (--times)\n result = result * 3;\n return result;\n}\n\nmachine:~$ gcc -O2 test1.c -o test1\nmachine:~$ time ./test1.exe\n\nreal 0m0.673s\nuser 0m0.608s\nsys 0m0.000s\n gcc -S -O2 test1.c"
},
{
"answer_id": 53797,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 4,
"selected": false,
"text": "MUL EAX,3\n MOV EBX,EAX\nSHL EAX,1\nADD EAX,EBX\n"
},
{
"answer_id": 53815,
"author": "Skizz",
"author_id": 1898,
"author_profile": "https://Stackoverflow.com/users/1898",
"pm_score": 2,
"selected": false,
"text": "int i = 45, j, k;\nj = i * 3;\nk = i + (i * 2);\n"
},
{
"answer_id": 304053,
"author": "Artelius",
"author_id": 31945,
"author_profile": "https://Stackoverflow.com/users/31945",
"pm_score": 1,
"selected": false,
"text": "n * 3"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3137/"
] |
53,786 |
<p>I am trying to automate functional testing of a server using a realistic frequency distribution of requests. (sort of load testing, sort of simulation)</p>
<p>I've chosen the <a href="http://en.wikipedia.org/wiki/Weibull_distribution" rel="nofollow noreferrer">Weibull</a> distribution as it "sort of" matches the distribution I've observed (ramps up quickly, drops off quickly but not instantly)</p>
<p>I use this distribution to generate the number of requests that should be sent each day between a given start and end date</p>
<p>I've hacked together an algorithm in Python that sort of works but it feels kludgy:</p>
<pre><code>how_many_days = (end_date - start_date).days
freqs = defaultdict(int)
for x in xrange(how_many_responses):
freqs[int(how_many_days * weibullvariate(0.5, 2))] += 1
timeline = []
day = start_date
for i,freq in sorted(freqs.iteritems()):
timeline.append((day, freq))
day += timedelta(days=1)
return timeline
</code></pre>
<p>What better ways are there to do this? </p>
|
[
{
"answer_id": 56032,
"author": "Kai",
"author_id": 2963,
"author_profile": "https://Stackoverflow.com/users/2963",
"pm_score": 0,
"selected": false,
"text": "from datetime import *\nfrom random import *\n\ntimeline = []\nscaling = 10\nstart_date = date(2008, 5, 1)\nend_date = date(2008, 6, 1)\n\nnum_days = (end_date - start_date).days + 1\ndays = [start_date + timedelta(i) for i in range(num_days)]\nrequests = [int(scaling * weibullvariate(0.5, 2)) for i in range(num_days)]\ntimeline = zip(days, requests)\ntimeline\n"
},
{
"answer_id": 56102,
"author": "Jacob Rigby",
"author_id": 5357,
"author_profile": "https://Stackoverflow.com/users/5357",
"pm_score": 0,
"selected": false,
"text": "timeline = (start_date + timedelta(days=days) for days in count(0))\nhow_many_days = (end_date - start_date).days\npick_a_day = lambda _:int(how_many_days * weibullvariate(0.5, 2))\ndays = sorted(imap(pick_a_day, xrange(how_many_responses)))\nhistogram = zip(timeline, (len(list(responses)) for day, responses in groupby(days)))\nprint '\\n'.join((d.strftime('%Y-%m-%d ') + \"*\" * c) for d,c in histogram)\n"
},
{
"answer_id": 56247,
"author": "Kai",
"author_id": 2963,
"author_profile": "https://Stackoverflow.com/users/2963",
"pm_score": 1,
"selected": false,
"text": "samples = [0 for i in xrange(how_many_days + 1)]\nfor s in xrange(how_many_responses):\n samples[min(int(how_many_days * weibullvariate(0.5, 2)), how_many_days)] += 1\nhistogram = zip(timeline, samples)\nprint '\\n'.join((d.strftime('%Y-%m-%d ') + \"*\" * c) for d,c in histogram)\n"
},
{
"answer_id": 56548,
"author": "Kai",
"author_id": 2963,
"author_profile": "https://Stackoverflow.com/users/2963",
"pm_score": 2,
"selected": true,
"text": "dev import math\nfrom datetime import datetime, timedelta, date\nfrom random import gauss\n\nhow_many_responses = 1000\nstart_date = date(2008, 5, 1)\nend_date = date(2008, 6, 1)\nnum_days = (end_date - start_date).days + 1\ntimeline = [start_date + timedelta(i) for i in xrange(num_days)]\n\ndef weibull(x, k, l):\n return (k / l) * (x / l)**(k-1) * math.e**(-(x/l)**k)\n\ndev = 0.1\nsamples = [i * 1.25/(num_days-1) for i in range(num_days)]\nprobs = [weibull(i, 2, 0.5) for i in samples]\nnoise = [gauss(0, dev) for i in samples]\nsimdata = [max(0., e + n) for (e, n) in zip(probs, noise)]\nevents = [int(p * (how_many_responses / sum(probs))) for p in simdata]\n\nhistogram = zip(timeline, events)\n\nprint '\\n'.join((d.strftime('%Y-%m-%d ') + \"*\" * c) for d,c in histogram)\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5357/"
] |
53,796 |
<p>A GUI driven application needs to host some prebuilt WinForms based components.
These components provide high performance interactive views using a mixture of GDI+ and DirectX.
The views handle control input and display custom graphical renderings.
The components are tested in a WinForms harness by the supplier.</p>
<p>Can a commericial application use WPF for its GUI and rely on <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost.aspx" rel="noreferrer" title="WindowsFormsHost">WindowsFormsHost</a> to host the WinForms components or
have you experience of technical glitches e.g. input lags, update issues that would make you cautious?</p>
|
[
{
"answer_id": 53855,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 0,
"selected": false,
"text": "Application Application"
},
{
"answer_id": 70064,
"author": "AndyL",
"author_id": 9944,
"author_profile": "https://Stackoverflow.com/users/9944",
"pm_score": 2,
"selected": false,
"text": "<WindowsFormsHost Grid.Row=\"1\" Grid.Column=\"1\" Margin=\"8,0,0,0\"\n Visibility=\"{Binding ActualHeight, RelativeSource={RelativeSource\n Mode=FindAncestor, AncestorType=UserControl},\n Converter={StaticResource WinFormsControlVisibilityConverter}}\" >\n\n <winforms:DateTimePicker x:Name=\"datepickerOrderExpected\" Width=\"140\"\n Format=\"Custom\" CustomFormat=\"M/dd/yy h:mm tt\"\n ValueChanged=\"OnEditDateTimeOrderExpected\" />\n\n</WindowsFormsHost>\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5427/"
] |
53,803 |
<p>We're looking at moving from a check-out/edit/check-in style of version control system to Subversion, and during the evaluation we discovered that when you perform an Update action in TortoiseSVN (and presumably in any Subversion client?), if changes in the repository that need to be applied to files that you've been editing don't cause any conflicts then they'll be automatically/silently merged.</p>
<p>This scares us a little, as it's possible that this merge, while not producing any compile errors, could at least introduce some logic errors that may not be easily detected.</p>
<p>Very simple example: I'm working within a C# method changing some logic in the latter-part of the method, and somebody else changes the value that a variable gets initialised to at the start of the method. The other person's change isn't in the lines of code that I'm working on so there won't be a conflict; but it's possible to dramatically change the output of the method.</p>
<p>What we were hoping the situation would be is that if a merge needs to occur, then the two files would be shown and at least a simple accept/reject change option be presented, so that at least we're aware that something has changed and are given the option to see if it impacts our code.</p>
<p>Is there a way to do this with Subversion/TortoiseSVN? Or are we stuck in our present working ways too much and should just let it do it's thing...</p>
|
[
{
"answer_id": 53812,
"author": "aku",
"author_id": 1196,
"author_profile": "https://Stackoverflow.com/users/1196",
"pm_score": 3,
"selected": false,
"text": "svn --diff-cmd=/bin/false\n"
},
{
"answer_id": 7673033,
"author": "Nordic Mainframe",
"author_id": 385433,
"author_profile": "https://Stackoverflow.com/users/385433",
"pm_score": 4,
"selected": false,
"text": "[helpers] diff-cmd = \"C:\\\\false.bat\"\n @type %9\n @exit 1\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5517/"
] |
53,806 |
<p>What was the motivation for having the <code>reintroduce</code> keyword in Delphi?</p>
<p>If you have a child class that contains a function with the same name as a virtual function in the parent class and it is not declared with the override modifier then it is a compile error. Adding the reintroduce modifier in such situations fixes the error, but I have never grasped the reasoning for the compile error.</p>
|
[
{
"answer_id": 68154,
"author": "Francesca",
"author_id": 9842,
"author_profile": "https://Stackoverflow.com/users/9842",
"pm_score": 2,
"selected": false,
"text": "TDescendant.MyMethod ADescendant.MyMethod (ADescendant as TAncestor).MyMethod"
},
{
"answer_id": 142459,
"author": "Frank",
"author_id": 4474,
"author_profile": "https://Stackoverflow.com/users/4474",
"pm_score": 2,
"selected": false,
"text": "TParent = Class\nPublic\n Procedure Procedure1(I : Integer); Virtual;\n Procedure Procedure2(I : Integer);\n Procedure Procedure3(I : Integer); Virtual;\nEnd;\n\nTChild = Class(TParent)\nPublic\n Procedure Procedure1(I : Integer);\n Procedure Procedure2(I : Integer);\n Procedure Procedure3(I : Integer); Override;\n Procedure Setup(I : Integer);\nEnd;\n\nprocedure TParent.Procedure1(I: Integer);\nbegin\n WriteLn('TParent.Procedure1');\nend;\n\nprocedure TParent.Procedure2(I: Integer);\nbegin\n WriteLn('TParent.Procedure2');\nend;\n\nprocedure TChild.Procedure1(I: Integer);\nbegin\n WriteLn('TChild.Procedure1');\nend;\n\nprocedure TChild.Procedure2(I: Integer);\nbegin\n WriteLn('TChild.Procedure2');\nend;\n\nprocedure TChild.Setup(I : Integer);\nbegin\n WriteLn('TChild.Setup');\nend;\n\nProcedure Test;\nVar\n Child : TChild;\n Parent : TParent;\nBegin\n Child := TChild.Create;\n Child.Procedure1(1); // outputs TChild.Procedure1\n Child.Procedure2(1); // outputs TChild.Procedure2\n\n Parent := Child;\n Parent.Procedure1(1); // outputs TParent.Procedure1\n Parent.Procedure2(1); // outputs TParent.Procedure2\nEnd;\n // version 2.0\nTParent = Class\nPublic\n Procedure Procedure1(I : Integer); Virtual;\n Procedure Procedure2(I : Integer);\n Procedure Procedure3(I : Integer); Virtual;\n Procedure Setup(I : Integer); Virtual;\nEnd;\n\nprocedure TParent.Setup(I: Integer);\nbegin\n // important code\nend;\n Procedure TestClient;\nVar\n Child : TChild;\nBegin\n Child := TChild.Create;\n Child.Setup;\nEnd;\n // library version 2.0\nProcedure TestLibrary(Parent : TParent);\nBegin\n Parent.Setup;\nEnd;\n"
},
{
"answer_id": 4749516,
"author": "Ian Boyd",
"author_id": 12597,
"author_profile": "https://Stackoverflow.com/users/12597",
"pm_score": 2,
"selected": false,
"text": "reintroduce"
},
{
"answer_id": 4750135,
"author": "Jeroen Wiert Pluimers",
"author_id": 29290,
"author_profile": "https://Stackoverflow.com/users/29290",
"pm_score": 1,
"selected": false,
"text": "reintroduce reintroduce"
},
{
"answer_id": 31089509,
"author": "Rohit Gupta",
"author_id": 4779472,
"author_profile": "https://Stackoverflow.com/users/4779472",
"pm_score": 0,
"selected": false,
"text": "constructor Create (AOwner : TComponent; AParent : TComponent); reintroduce;\n constructor TClassname.Create (AOwner : TComponent; AParent : TComponent);\nbegin\n inherited Create (AOwner);\n Parent := AParent;\n ..\nend;\n"
},
{
"answer_id": 47268906,
"author": "Roman Krejci",
"author_id": 8933951,
"author_profile": "https://Stackoverflow.com/users/8933951",
"pm_score": 1,
"selected": false,
"text": "type \n tMyFooClass = class of tMyFoo;\n\n tMyFoo = class\n constructor Create; virtual;\n end;\n\n tMyFooDescendant = class(tMyFoo)\n constructor Create(a: Integer); reintroduce;\n end;\n\n\nprocedure .......\nvar\n tmp: tMyFooClass;\nbegin\n // Create tMyFooDescendant instance one way\n tmp := tMyFooDescendant;\n with tmp.Create do // please note no a: integer argument needed here\n try\n { do something }\n finally\n free;\n end;\n\n // Create tMyFooDescendant instance the other way\n with tMyFooDescendant.Create(20) do // a: integer argument IS needed here\n try\n { do something }\n finally\n free;\n end;\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53806",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4474/"
] |
53,808 |
<p>When interviewing college coops/interns or recent graduates it helps to have a Java programming question that they can do on a white board in 15 minutes. Does anyone have examples of good questions like this? A C++ question I was once asked in an interview was to write a string to integer function which is along the lines of the level of question I am looking for examples of.</p>
|
[
{
"answer_id": 53828,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 3,
"selected": false,
"text": "final protected"
},
{
"answer_id": 53830,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 4,
"selected": true,
"text": "echo cat int ArrayList"
},
{
"answer_id": 232326,
"author": "rich",
"author_id": 25502,
"author_profile": "https://Stackoverflow.com/users/25502",
"pm_score": 0,
"selected": false,
"text": "BSers"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3637/"
] |
53,811 |
<p>Do you normally set your compiler to optimize for maximum speed or smallest code size? or do you manually configure individual optimization settings? Why?</p>
<p>I notice most of the time people tend to just leave compiler optimization settings to their default state, which with visual c++ means max speed.
I've always felt that the default settings had more to do with looking good on benchmarks, which tend to be small programs that will fit entirely within the L2 cache than what's best for overall performance, so I normally set it optimize for smallest size.</p>
|
[
{
"answer_id": 53826,
"author": "Claes Mogren",
"author_id": 4992,
"author_profile": "https://Stackoverflow.com/users/4992",
"pm_score": 4,
"selected": true,
"text": "A relative graph of fitnesses:\n\n Acovea Best-of-the-Best: ************************************** (2.55366)\n Acovea Common Options: ******************************************* (2.86788)\n -O1: ********************************************** (3.0752)\n -O2: *********************************************** (3.12343)\n -O3: *********************************************** (3.1277)\n -O3 -ffast-math: ************************************************** (3.31539)\n -Os: ************************************************* (3.30573)\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4086/"
] |
53,820 |
<p>In the application I'm developping (in Java/swing), I have to show a full screen window on the <em>second</em> screen of the user.
I did this using a code similar to the one you'll find below...
Be, as soon as I click in a window opened by windows explorer, or as soon as I open windows explorer (i'm using windows XP), the full screen window is minimized...</p>
<p>Do you know any way or workaround to fix this problem, or is there something important I did not understand with full screen windows?</p>
<p>Thanks for the help,</p>
<pre><code>import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JWindow;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;
import javax.swing.JButton;
import javax.swing.JToggleButton;
import java.awt.Rectangle;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
public class FullScreenTest {
private JFrame jFrame = null; // @jve:decl-index=0:visual-constraint="94,35"
private JPanel jContentPane = null;
private JToggleButton jToggleButton = null;
private JPanel jFSPanel = null; // @jve:decl-index=0:visual-constraint="392,37"
private JLabel jLabel = null;
private Window window;
/**
* This method initializes jFrame
*
* @return javax.swing.JFrame
*/
private JFrame getJFrame() {
if (jFrame == null) {
jFrame = new JFrame();
jFrame.setSize(new Dimension(474, 105));
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.setContentPane(getJContentPane());
}
return jFrame;
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJToggleButton(), null);
}
return jContentPane;
}
/**
* This method initializes jToggleButton
*
* @return javax.swing.JToggleButton
*/
private JToggleButton getJToggleButton() {
if (jToggleButton == null) {
jToggleButton = new JToggleButton();
jToggleButton.setBounds(new Rectangle(50, 23, 360, 28));
jToggleButton.setText("Show Full Screen Window on 2nd screen");
jToggleButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
showFullScreenWindow(jToggleButton.isSelected());
}
});
}
return jToggleButton;
}
protected void showFullScreenWindow(boolean b) {
if(window==null){
window = initFullScreenWindow();
}
window.setVisible(b);
}
private Window initFullScreenWindow() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
GraphicsDevice gd = gds[1];
JWindow window = new JWindow(gd.getDefaultConfiguration());
window.setContentPane(getJFSPanel());
gd.setFullScreenWindow(window);
return window;
}
/**
* This method initializes jFSPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJFSPanel() {
if (jFSPanel == null) {
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(18, 19, 500, 66));
jLabel.setText("Hello ! Now, juste open windows explorer and see what happens...");
jFSPanel = new JPanel();
jFSPanel.setLayout(null);
jFSPanel.setSize(new Dimension(500, 107));
jFSPanel.add(jLabel, null);
}
return jFSPanel;
}
/**
* @param args
*/
public static void main(String[] args) {
FullScreenTest me = new FullScreenTest();
me.getJFrame().setVisible(true);
}
}
</code></pre>
|
[
{
"answer_id": 56166,
"author": "Laurent K",
"author_id": 2965,
"author_profile": "https://Stackoverflow.com/users/2965",
"pm_score": 0,
"selected": false,
"text": "private Window initFullScreenWindow() {\n GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();\n GraphicsDevice[] gds = ge.getScreenDevices();\n GraphicsDevice gd = gds[1];\n JWindow window = new JWindow(gd.getDefaultConfiguration());\n window.setContentPane(getJFSPanel());\n window.setLocation(1280, 0);\n window.setSize(gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight());\n window.setAlwaysOnTop(true);\n //gd.setFullScreenWindow(window);\n return window;\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2965/"
] |
53,827 |
<p>I'm using MinGW with GCC 3.4.5 (mingw-special vista r3).</p>
<p>My C application uses a lot of stack so I was wondering is there any way I can tell programatically how much stack is remaining so I can cleanly handle the situation if I find that I'm about to run out.</p>
<p>If not what other ways would you work around the problem of potentially running out of stack space?</p>
<p>I've no idea what size of stack I'll start with so would need to identify that programatically also.</p>
|
[
{
"answer_id": 53836,
"author": "Rob Walker",
"author_id": 3631,
"author_profile": "https://Stackoverflow.com/users/3631",
"pm_score": 4,
"selected": false,
"text": "size_t top_of_stack;\n\nvoid Main()\n{\n int x=0;\n top_of_stack = (size_t) &x;\n\n do_something_very_recursive(....)\n}\n\nsize_t SizeOfStack()\n{\n int x=0;\n return top_of_stack - (size_t) &x;\n} \n"
},
{
"answer_id": 53925,
"author": "mweerden",
"author_id": 4285,
"author_profile": "https://Stackoverflow.com/users/4285",
"pm_score": 3,
"selected": false,
"text": "/proc/<pid>/maps"
},
{
"answer_id": 5864773,
"author": "phoxis",
"author_id": 702361,
"author_profile": "https://Stackoverflow.com/users/702361",
"pm_score": 5,
"selected": false,
"text": "man getrusage getrlimit RLIMIT_STACK #include <sys/resource.h>\nint main (void)\n{\n struct rlimit limit;\n\n getrlimit (RLIMIT_STACK, &limit);\n printf (\"\\nStack Limit = %ld and %ld max\\n\", limit.rlim_cur, limit.rlim_max);\n}\n man getrlimit ulimit -s ulimit -a setrlimit"
},
{
"answer_id": 8716410,
"author": "Daniel James Bryars",
"author_id": 418246,
"author_profile": "https://Stackoverflow.com/users/418246",
"pm_score": 2,
"selected": false,
"text": "public static class StackManagement\n {\n [StructLayout(LayoutKind.Sequential)]\n struct MEMORY_BASIC_INFORMATION\n {\n public UIntPtr BaseAddress;\n public UIntPtr AllocationBase;\n public uint AllocationProtect;\n public UIntPtr RegionSize;\n public uint State;\n public uint Protect;\n public uint Type;\n };\n\n private const long STACK_RESERVED_SPACE = 4096 * 16;\n\n public unsafe static bool CheckForSufficientStack(UInt64 bytes)\n {\n MEMORY_BASIC_INFORMATION stackInfo = new MEMORY_BASIC_INFORMATION();\n UIntPtr currentAddr = new UIntPtr(&stackInfo);\n VirtualQuery(currentAddr, ref stackInfo, sizeof(MEMORY_BASIC_INFORMATION));\n\n UInt64 stackBytesLeft = currentAddr.ToUInt64() - stackInfo.AllocationBase.ToUInt64();\n\n return stackBytesLeft > (bytes + STACK_RESERVED_SPACE);\n }\n\n [DllImport(\"kernel32.dll\")]\n private static extern int VirtualQuery(UIntPtr lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, int dwLength);\n }\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5330/"
] |
53,844 |
<p>I would like to do the equivalent of:</p>
<pre><code>object result = Eval("1 + 3");
string now = Eval("System.DateTime.Now().ToString()") as string
</code></pre>
<p>Following Biri s <a href="http://www.codeproject.com/KB/cs/evalcscode.aspx" rel="noreferrer">link</a>, I got this snippet (modified to remove obsolete method <code>ICodeCompiler.CreateCompiler()</code>:</p>
<pre><code>private object Eval(string sExpression)
{
CSharpCodeProvider c = new CSharpCodeProvider();
CompilerParameters cp = new CompilerParameters();
cp.ReferencedAssemblies.Add("system.dll");
cp.CompilerOptions = "/t:library";
cp.GenerateInMemory = true;
StringBuilder sb = new StringBuilder("");
sb.Append("using System;\n");
sb.Append("namespace CSCodeEvaler{ \n");
sb.Append("public class CSCodeEvaler{ \n");
sb.Append("public object EvalCode(){\n");
sb.Append("return " + sExpression + "; \n");
sb.Append("} \n");
sb.Append("} \n");
sb.Append("}\n");
CompilerResults cr = c.CompileAssemblyFromSource(cp, sb.ToString());
if (cr.Errors.Count > 0)
{
throw new InvalidExpressionException(
string.Format("Error ({0}) evaluating: {1}",
cr.Errors[0].ErrorText, sExpression));
}
System.Reflection.Assembly a = cr.CompiledAssembly;
object o = a.CreateInstance("CSCodeEvaler.CSCodeEvaler");
Type t = o.GetType();
MethodInfo mi = t.GetMethod("EvalCode");
object s = mi.Invoke(o, null);
return s;
}
</code></pre>
|
[
{
"answer_id": 54339,
"author": "JJJ",
"author_id": 5547,
"author_profile": "https://Stackoverflow.com/users/5547",
"pm_score": 1,
"selected": false,
"text": "using System;\npublic class Test\n{\n static public void DoStuff( Scripting.IJob Job)\n {\n Console.WriteLine( \"Heps\" );\n }\n}\n"
},
{
"answer_id": 4050198,
"author": "Rudolf_Abel",
"author_id": 491038,
"author_profile": "https://Stackoverflow.com/users/491038",
"pm_score": 2,
"selected": false,
"text": "using System;\nusing Microsoft.JScript;\nusing Microsoft.JScript.Vsa;\nusing Convert = Microsoft.JScript.Convert;\n\nnamespace System\n{\n public class MathEvaluator : INeedEngine\n {\n private VsaEngine vsaEngine;\n\n public virtual String Evaluate(string expr)\n {\n var engine = (INeedEngine)this;\n var result = Eval.JScriptEvaluate(expr, engine.GetEngine());\n\n return Convert.ToString(result, true);\n }\n\n VsaEngine INeedEngine.GetEngine()\n {\n vsaEngine = vsaEngine ?? VsaEngine.CreateEngineWithType(this.GetType().TypeHandle);\n return vsaEngine;\n }\n\n void INeedEngine.SetEngine(VsaEngine engine)\n {\n vsaEngine = engine;\n }\n }\n}\n"
},
{
"answer_id": 14761604,
"author": "Davide Icardi",
"author_id": 209727,
"author_profile": "https://Stackoverflow.com/users/209727",
"pm_score": 5,
"selected": false,
"text": "var interpreter = new Interpreter();\nvar result = interpreter.Eval(\"8 / 2 + 2\");\n var interpreter = new Interpreter()\n .SetVariable(\"service\", new ServiceExample());\n\nstring expression = \"x > 4 ? service.aMethod() : service.AnotherMethod()\";\n\nLambda parsedExpression = interpreter.Parse(expression, \n new Parameter(\"x\", typeof(int)));\n\nparsedExpression.Invoke(5);\n"
},
{
"answer_id": 43630318,
"author": "Ridkuma",
"author_id": 5466644,
"author_profile": "https://Stackoverflow.com/users/5466644",
"pm_score": 5,
"selected": false,
"text": "var result = CSharpScript.EvaluateAsync(\"1 + 3\").Result;\n var now = CSharpScript.EvaluateAsync<string>(\"System.DateTime.Now.ToString()\").Result;\n"
},
{
"answer_id": 68767842,
"author": "Binh",
"author_id": 8046877,
"author_profile": "https://Stackoverflow.com/users/8046877",
"pm_score": 1,
"selected": false,
"text": "using System;\nusing org.matheval;\n \npublic class Program\n{\n public static void Main()\n {\n Expression expression = new Expression(\"IF(time>8, (HOUR_SALARY*8) + (HOUR_SALARY*1.25*(time-8)), HOUR_SALARY*time)\");\n //bind variable\n expression.Bind(\"HOUR_SALARY\", 10);\n expression.Bind(\"time\", 9);\n //eval\n Decimal salary = expression.Eval<Decimal>(); \n Console.WriteLine(salary);\n }\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2260/"
] |
53,849 |
<p>Java has a convenient split method:</p>
<pre><code>String str = "The quick brown fox";
String[] results = str.split(" ");
</code></pre>
<p>Is there an easy way to do this in C++?</p>
|
[
{
"answer_id": 53862,
"author": "vzczc",
"author_id": 224,
"author_profile": "https://Stackoverflow.com/users/224",
"pm_score": 5,
"selected": false,
"text": "//Header file\nclass Tokenizer \n{\n public:\n static const std::string DELIMITERS;\n Tokenizer(const std::string& str);\n Tokenizer(const std::string& str, const std::string& delimiters);\n bool NextToken();\n bool NextToken(const std::string& delimiters);\n const std::string GetToken() const;\n void Reset();\n protected:\n size_t m_offset;\n const std::string m_string;\n std::string m_token;\n std::string m_delimiters;\n};\n\n//CPP file\nconst std::string Tokenizer::DELIMITERS(\" \\t\\n\\r\");\n\nTokenizer::Tokenizer(const std::string& s) :\n m_string(s), \n m_offset(0), \n m_delimiters(DELIMITERS) {}\n\nTokenizer::Tokenizer(const std::string& s, const std::string& delimiters) :\n m_string(s), \n m_offset(0), \n m_delimiters(delimiters) {}\n\nbool Tokenizer::NextToken() \n{\n return NextToken(m_delimiters);\n}\n\nbool Tokenizer::NextToken(const std::string& delimiters) \n{\n size_t i = m_string.find_first_not_of(delimiters, m_offset);\n if (std::string::npos == i) \n {\n m_offset = m_string.length();\n return false;\n }\n\n size_t j = m_string.find_first_of(delimiters, i);\n if (std::string::npos == j) \n {\n m_token = m_string.substr(i);\n m_offset = m_string.length();\n return true;\n }\n\n m_token = m_string.substr(i, j - i);\n m_offset = j;\n return true;\n}\n std::vector <std::string> v;\nTokenizer s(\"split this string\", \" \");\nwhile (s.NextToken())\n{\n v.push_back(s.GetToken());\n}\n"
},
{
"answer_id": 53863,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 8,
"selected": true,
"text": "split std::vector<std::basic_string<…>> std::string::find std::string::npos std::string::substr std::istringstream auto iss = std::istringstream{\"The quick brown fox\"};\nauto str = std::string{};\n\nwhile (iss >> str) {\n process(str);\n}\n std::istream_iterator std::regex_token_iterator auto const str = \"The quick brown fox\"s;\nauto const re = std::regex{R\"(\\s+)\"};\nauto const vec = std::vector<std::string>(\n std::sregex_token_iterator{begin(str), end(str), re, -1},\n std::sregex_token_iterator{}\n);\n"
},
{
"answer_id": 53878,
"author": "Adam Pierce",
"author_id": 5324,
"author_profile": "https://Stackoverflow.com/users/5324",
"pm_score": 7,
"selected": false,
"text": "#include <vector>\n#include <string>\nusing namespace std;\n\nvector<string> split(const char *str, char c = ' ')\n{\n vector<string> result;\n\n do\n {\n const char *begin = str;\n\n while(*str != c && *str)\n str++;\n\n result.push_back(string(begin, str));\n } while (0 != *str++);\n\n return result;\n}\n"
},
{
"answer_id": 53915,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile": "https://Stackoverflow.com/users/2260",
"pm_score": 2,
"selected": false,
"text": ">> string word; sin >> word;\n"
},
{
"answer_id": 53921,
"author": "KeithB",
"author_id": 2298,
"author_profile": "https://Stackoverflow.com/users/2298",
"pm_score": 6,
"selected": false,
"text": "#include <string>\n#include <vector>\n#include <iostream>\n#include <istream>\n#include <ostream>\n#include <iterator>\n#include <sstream>\n#include <algorithm>\n\nint main()\n{\n std::string str = \"The quick brown fox\";\n\n // construct a stream from the string\n std::stringstream strstr(str);\n\n // use stream iterators to copy the stream to the vector as whitespace separated strings\n std::istream_iterator<std::string> it(strstr);\n std::istream_iterator<std::string> end;\n std::vector<std::string> results(it, end);\n\n // send the vector to stdout.\n std::ostream_iterator<std::string> oit(std::cout);\n std::copy(results.begin(), results.end(), oit);\n}\n"
},
{
"answer_id": 54048,
"author": "Mark",
"author_id": 4405,
"author_profile": "https://Stackoverflow.com/users/4405",
"pm_score": 7,
"selected": false,
"text": "char myString[] = \"The quick brown fox\";\nchar *p = strtok(myString, \" \");\nwhile (p) {\n printf (\"Token: %s\\n\", p);\n p = strtok(NULL, \" \");\n}\n"
},
{
"answer_id": 55680,
"author": "Ferruccio",
"author_id": 4086,
"author_profile": "https://Stackoverflow.com/users/4086",
"pm_score": 8,
"selected": false,
"text": "#include <iostream>\n#include <string>\n#include <boost/foreach.hpp>\n#include <boost/tokenizer.hpp>\n\nusing namespace std;\nusing namespace boost;\n\nint main(int, char**)\n{\n string text = \"token, test string\";\n\n char_separator<char> sep(\", \");\n tokenizer< char_separator<char> > tokens(text, sep);\n BOOST_FOREACH (const string& t, tokens) {\n cout << t << \".\" << endl;\n }\n}\n #include <iostream>\n#include <string>\n#include <boost/tokenizer.hpp>\n\nusing namespace std;\nusing namespace boost;\n\nint main(int, char**)\n{\n string text = \"token, test string\";\n\n char_separator<char> sep(\", \");\n tokenizer<char_separator<char>> tokens(text, sep);\n for (const auto& t : tokens) {\n cout << t << \".\" << endl;\n }\n}\n"
},
{
"answer_id": 59552,
"author": "Raz",
"author_id": 5661,
"author_profile": "https://Stackoverflow.com/users/5661",
"pm_score": 5,
"selected": false,
"text": "#include <vector>\n#include <boost/algorithm/string.hpp>\n\nint main() {\n auto s = \"a,b, c ,,e,f,\";\n std::vector<std::string> fields;\n boost::split(fields, s, boost::is_any_of(\",\"));\n for (const auto& field : fields)\n std::cout << \"\\\"\" << field << \"\\\"\\n\";\n return 0;\n}\n \"a\"\n\"b\"\n\" c \"\n\"\"\n\"e\"\n\"f\"\n\"\"\n"
},
{
"answer_id": 63946,
"author": "jilles de wit",
"author_id": 7531,
"author_profile": "https://Stackoverflow.com/users/7531",
"pm_score": 2,
"selected": false,
"text": "unsigned TokenizeString(const std::string& i_source,\n const std::string& i_seperators,\n bool i_discard_empty_tokens,\n std::vector<std::string>& o_tokens)\n{\n unsigned prev_pos = 0;\n unsigned pos = 0;\n unsigned number_of_tokens = 0;\n o_tokens.clear();\n pos = i_source.find_first_of(i_seperators, pos);\n while (pos != std::string::npos)\n {\n std::string token = i_source.substr(prev_pos, pos - prev_pos);\n if (!i_discard_empty_tokens || token != \"\")\n {\n o_tokens.push_back(i_source.substr(prev_pos, pos - prev_pos));\n number_of_tokens++;\n }\n\n pos++;\n prev_pos = pos;\n pos = i_source.find_first_of(i_seperators, pos);\n }\n\n if (prev_pos < i_source.length())\n {\n o_tokens.push_back(i_source.substr(prev_pos));\n number_of_tokens++;\n }\n\n return number_of_tokens;\n}\n"
},
{
"answer_id": 325000,
"author": "Mr.Ree",
"author_id": 37946,
"author_profile": "https://Stackoverflow.com/users/37946",
"pm_score": 6,
"selected": false,
"text": "void\nsplit( vector<string> & theStringVector, /* Altered/returned value */\n const string & theString,\n const string & theDelimiter)\n{\n UASSERT( theDelimiter.size(), >, 0); // My own ASSERT macro.\n\n size_t start = 0, end = 0;\n\n while ( end != string::npos)\n {\n end = theString.find( theDelimiter, start);\n\n // If at end, use length=maxLength. Else use length=end-start.\n theStringVector.push_back( theString.substr( start,\n (end == string::npos) ? string::npos : end - start));\n\n // If at end, use start=maxSize. Else use start=end+delimiter.\n start = ( ( end > (string::npos - theDelimiter.size()) )\n ? string::npos : end + theDelimiter.size());\n }\n}\n #define SHOW(I,X) cout << \"[\" << (I) << \"]\\t \" # X \" = \\\"\" << (X) << \"\\\"\" << endl\n\nint\nmain()\n{\n vector<string> v;\n\n split( v, \"A:PEP:909:Inventory Item\", \":\" );\n\n for (unsigned int i = 0; i < v.size(); i++)\n SHOW( i, v[i] );\n}\n"
},
{
"answer_id": 325042,
"author": "user35978",
"author_id": 35978,
"author_profile": "https://Stackoverflow.com/users/35978",
"pm_score": 7,
"selected": false,
"text": "getline stringstream ss(\"bla bla\");\nstring s;\n\nwhile (getline(ss, s, ' ')) {\n cout << s << endl;\n}\n split() vector<string>"
},
{
"answer_id": 670441,
"author": "Jim In Texas",
"author_id": 15079,
"author_profile": "https://Stackoverflow.com/users/15079",
"pm_score": 3,
"selected": false,
"text": "CAtlString str( \"%First Second#Third\" );\nCAtlString resToken;\nint curPos= 0;\n\nresToken= str.Tokenize(\"% #\",curPos);\nwhile (resToken != \"\")\n{\n printf(\"Resulting token: %s\\n\", resToken);\n resToken= str.Tokenize(\"% #\",curPos);\n};\n\nOutput\n\nResulting Token: First\nResulting Token: Second\nResulting Token: Third\n"
},
{
"answer_id": 3408134,
"author": "sivabudh",
"author_id": 65313,
"author_profile": "https://Stackoverflow.com/users/65313",
"pm_score": 5,
"selected": false,
"text": "#include <QString>\n\n...\n\nQString str = \"The quick brown fox\"; \nQStringList results = str.split(\" \"); \n"
},
{
"answer_id": 4489586,
"author": "sohesado",
"author_id": 548600,
"author_profile": "https://Stackoverflow.com/users/548600",
"pm_score": 3,
"selected": false,
"text": "#include <iostream>\n#include <sstream>\n\nusing namespace std;\n\nint main ()\n{\n string tmps;\n istringstream is (\"the dellimiter is the space\");\n while (is.good ()) {\n is >> tmps;\n cout << tmps << \"\\n\";\n }\n return 0;\n}\n"
},
{
"answer_id": 6011144,
"author": "Angel Sinigersky",
"author_id": 754396,
"author_profile": "https://Stackoverflow.com/users/754396",
"pm_score": 0,
"selected": false,
"text": "class TextLineSplitter\n{\npublic:\n\n TextLineSplitter( const size_t max_line_len );\n\n ~TextLineSplitter();\n\n void SplitLine( const char *line,\n const char sep_char = ',',\n );\n\n inline size_t NumTokens( void ) const\n {\n return mNumTokens;\n }\n\n const char * GetToken( const size_t token_idx ) const\n {\n assert( token_idx < mNumTokens );\n return mTokens[ token_idx ];\n }\n\nprivate:\n const size_t mStorageSize;\n\n char *mBuff;\n char **mTokens;\n size_t mNumTokens;\n\n inline void ResetContent( void )\n {\n memset( mBuff, 0, mStorageSize );\n // mark all items as empty:\n memset( mTokens, 0, mStorageSize * sizeof( char* ) );\n // reset counter for found items:\n mNumTokens = 0L;\n }\n};\n TextLineSplitter::TextLineSplitter( const size_t max_line_len ):\n mStorageSize ( max_line_len + 1L )\n{\n // allocate memory\n mBuff = new char [ mStorageSize ];\n mTokens = new char* [ mStorageSize ];\n\n ResetContent();\n}\n\nTextLineSplitter::~TextLineSplitter()\n{\n delete [] mBuff;\n delete [] mTokens;\n}\n\n\nvoid TextLineSplitter::SplitLine( const char *line,\n const char sep_char /* = ',' */,\n )\n{\n assert( sep_char != '\\0' );\n\n ResetContent();\n strncpy( mBuff, line, mMaxLineLen );\n\n size_t idx = 0L; // running index for characters\n\n do\n {\n assert( idx < mStorageSize );\n\n const char chr = line[ idx ]; // retrieve current character\n\n if( mTokens[ mNumTokens ] == NULL )\n {\n mTokens[ mNumTokens ] = &mBuff[ idx ];\n } // if\n\n if( chr == sep_char || chr == '\\0' )\n { // item or line finished\n // overwrite separator with a 0-terminating character:\n mBuff[ idx ] = '\\0';\n // count-up items:\n mNumTokens ++;\n } // if\n\n } while( line[ idx++ ] );\n}\n // create an instance capable of splitting strings up to 1000 chars long:\nTextLineSplitter spl( 1000 );\nspl.SplitLine( \"Item1,,Item2,Item3\" );\nfor( size_t i = 0; i < spl.NumTokens(); i++ )\n{\n printf( \"%s\\n\", spl.GetToken( i ) );\n}\n Item1\n\nItem2\nItem3\n"
},
{
"answer_id": 6922744,
"author": "Arash",
"author_id": 551537,
"author_profile": "https://Stackoverflow.com/users/551537",
"pm_score": 1,
"selected": false,
"text": "template<typename CH>\ninline vector< basic_string<CH> > tokenize(\n const basic_string<CH> &Input,\n const basic_string<CH> &Delimiter,\n bool remove_empty_token\n ) {\n\n typedef typename basic_string<CH>::const_iterator string_iterator_t;\n typedef boost::find_iterator< string_iterator_t > string_find_iterator_t;\n\n vector< basic_string<CH> > Result;\n string_iterator_t it = Input.begin();\n string_iterator_t it_end = Input.end();\n for(string_find_iterator_t i = boost::make_find_iterator(Input, boost::first_finder(Delimiter, boost::is_equal()));\n i != string_find_iterator_t();\n ++i) {\n if(remove_empty_token){\n if(it != i->begin())\n Result.push_back(basic_string<CH>(it,i->begin()));\n }\n else\n Result.push_back(basic_string<CH>(it,i->begin()));\n it = i->end();\n }\n if(it != it_end)\n Result.push_back(basic_string<CH>(it,it_end));\n\n return Result;\n}\n"
},
{
"answer_id": 8669587,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 4,
"selected": false,
"text": "#include <string>\n#include <vector>\n#include \"pystring.h\"\n\nstd::vector<std::string> chunks;\npystring::split(\"this string\", chunks);\n\n// also can specify a separator\npystring::split(\"this-string\", chunks, \"-\");\n"
},
{
"answer_id": 11497058,
"author": "jochenleidner",
"author_id": 1527677,
"author_profile": "https://Stackoverflow.com/users/1527677",
"pm_score": 0,
"selected": false,
"text": "boost::tokenizer wstring wchar_t string char #include <iostream>\n#include <boost/tokenizer.hpp>\n#include <string>\n\nusing namespace std;\nusing namespace boost;\n\ntypedef tokenizer<char_separator<wchar_t>,\n wstring::const_iterator, wstring> Tok;\n\nint main()\n{\n wstring s;\n while (getline(wcin, s)) {\n char_separator<wchar_t> sep(L\" \"); // list of separator characters\n Tok tok(s, sep);\n for (Tok::iterator beg = tok.begin(); beg != tok.end(); ++beg) {\n wcout << *beg << L\"\\t\"; // output (or store in vector)\n }\n wcout << L\"\\n\";\n }\n return 0;\n}\n"
},
{
"answer_id": 11753247,
"author": "David919",
"author_id": 1567655,
"author_profile": "https://Stackoverflow.com/users/1567655",
"pm_score": 2,
"selected": false,
"text": "using namespace std;\n\nstring someText = ...\n\nstring::size_type tokenOff = 0, sepOff = tokenOff;\nwhile (sepOff != string::npos)\n{\n sepOff = someText.find(' ', sepOff);\n string::size_type tokenLen = (sepOff == string::npos) ? sepOff : sepOff++ - tokenOff;\n string token = someText.substr(tokenOff, tokenLen);\n if (!token.empty())\n /* do something with token */;\n tokenOff = sepOff;\n}\n"
},
{
"answer_id": 13089627,
"author": "Darren Smith",
"author_id": 1776419,
"author_profile": "https://Stackoverflow.com/users/1776419",
"pm_score": 2,
"selected": false,
"text": "#include <string.h> // for strchr and strlen\n\n/*\n * want_empty_tokens==true : include empty tokens, like strsep()\n * want_empty_tokens==false : exclude empty tokens, like strtok()\n */\nstd::vector<std::string> tokenize(const char* src,\n char delim,\n bool want_empty_tokens)\n{\n std::vector<std::string> tokens;\n\n if (src and *src != '\\0') // defensive\n while( true ) {\n const char* d = strchr(src, delim);\n size_t len = (d)? d-src : strlen(src);\n\n if (len or want_empty_tokens)\n tokens.push_back( std::string(src, len) ); // capture token\n\n if (d) src += len+1; else break;\n }\n\n return tokens;\n}\n"
},
{
"answer_id": 16635277,
"author": "Karthik",
"author_id": 2398970,
"author_profile": "https://Stackoverflow.com/users/2398970",
"pm_score": -1,
"selected": false,
"text": "#include <iostream.h>\n#include <stdio.h>\n#include <string.h>\n#include <math.h>\n#include <conio.h>\nclass word\n {\n public:\n char w[20];\n word()\n {\n for(int j=0;j<=20;j++)\n {w[j]='\\0';\n }\n }\n\n\n\n};\n\nvoid main()\n {\n int i=1,n=0,j=0,k=0,m=1;\n char input[100];\n word ww[100];\n gets(input);\n\n n=strlen(input);\n\n\n for(i=0;i<=m;i++)\n {\n if(context[i]!=' ')\n {\n ww[k].w[j]=context[i];\n j++;\n\n }\n else\n {\n k++;\n j=0;\n m++;\n }\n\n }\n }\n"
},
{
"answer_id": 20590157,
"author": "vsoftco",
"author_id": 3093378,
"author_profile": "https://Stackoverflow.com/users/3093378",
"pm_score": 0,
"selected": false,
"text": "#include <iostream>\n#include <vector>\n#include <string>\n#include <stdexcept> \n\nstd::vector<std::string> \nsplit(const std::string& str, const std::string& delim){\n std::vector<std::string> result;\n if (str.empty())\n throw std::runtime_error(\"Can not tokenize an empty string!\");\n std::string::const_iterator begin, str_it;\n begin = str_it = str.begin(); \n do {\n while (delim.find(*str_it) == std::string::npos && str_it != str.end())\n str_it++; // find the position of the first delimiter in str\n std::string token = std::string(begin, str_it); // grab the token\n if (!token.empty()) // empty token only when str starts with a delimiter\n result.push_back(token); // push the token into a vector<string>\n while (delim.find(*str_it) != std::string::npos && str_it != str.end())\n str_it++; // ignore the additional consecutive delimiters\n begin = str_it; // process the remaining tokens\n } while (str_it != str.end());\n return result;\n}\n\nint main() {\n std::string test_string = \".this is.a.../.simple;;test;;;END\";\n std::string delim = \"; ./\"; // string containing the delimiters\n std::vector<std::string> tokens = split(test_string, delim); \n for (std::vector<std::string>::const_iterator it = tokens.begin(); \n it != tokens.end(); it++)\n std::cout << *it << std::endl;\n}\n"
},
{
"answer_id": 20981311,
"author": "DannyK",
"author_id": 969968,
"author_profile": "https://Stackoverflow.com/users/969968",
"pm_score": 4,
"selected": false,
"text": "#include <iostream>\n#include <vector>\n#include <string>\n#include <strtk.hpp>\n\nconst char *whitespace = \" \\t\\r\\n\\f\";\nconst char *whitespace_and_punctuation = \" \\t\\r\\n\\f;,=\";\n\nint main()\n{\n { // normal parsing of a string into a vector of strings\n std::string s(\"Somewhere down the road\");\n std::vector<std::string> result;\n if( strtk::parse( s, whitespace, result ) )\n {\n for(size_t i = 0; i < result.size(); ++i )\n std::cout << result[i] << std::endl;\n }\n }\n\n { // parsing a string into a vector of floats with other separators\n // besides spaces\n\n std::string s(\"3.0, 3.14; 4.0\");\n std::vector<float> values;\n if( strtk::parse( s, whitespace_and_punctuation, values ) )\n {\n for(size_t i = 0; i < values.size(); ++i )\n std::cout << values[i] << std::endl;\n }\n }\n\n { // parsing a string into specific variables\n\n std::string s(\"angle = 45; radius = 9.9\");\n std::string w1, w2;\n float v1, v2;\n if( strtk::parse( s, whitespace_and_punctuation, w1, v1, w2, v2) )\n {\n std::cout << \"word \" << w1 << \", value \" << v1 << std::endl;\n std::cout << \"word \" << w2 << \", value \" << v2 << std::endl;\n }\n }\n\n return 0;\n}\n"
},
{
"answer_id": 22006543,
"author": "Murphy78",
"author_id": 3331297,
"author_profile": "https://Stackoverflow.com/users/3331297",
"pm_score": 0,
"selected": false,
"text": "/// split a string into multiple sub strings, based on a separator string\n/// for example, if separator=\"::\",\n///\n/// s = \"abc\" -> \"abc\"\n///\n/// s = \"abc::def xy::st:\" -> \"abc\", \"def xy\" and \"st:\",\n///\n/// s = \"::abc::\" -> \"abc\"\n///\n/// s = \"::\" -> NO sub strings found\n///\n/// s = \"\" -> NO sub strings found\n///\n/// then append the sub-strings to the end of the vector v.\n/// \n/// the idea comes from the findUrls() function of \"Accelerated C++\", chapt7,\n/// findurls.cpp\n///\nvoid split(const string& s, const string& sep, vector<string>& v)\n{\n typedef string::const_iterator iter;\n iter b = s.begin(), e = s.end(), i;\n iter sep_b = sep.begin(), sep_e = sep.end();\n\n // search through s\n while (b != e){\n i = search(b, e, sep_b, sep_e);\n\n // no more separator found\n if (i == e){\n // it's not an empty string\n if (b != e)\n v.push_back(string(b, e));\n break;\n }\n else if (i == b){\n // the separator is found and right at the beginning\n // in this case, we need to move on and search for the\n // next separator\n b = i + sep.length();\n }\n else{\n // found the separator\n v.push_back(string(b, i));\n b = i;\n }\n }\n}\n"
},
{
"answer_id": 22460450,
"author": "robcsi",
"author_id": 3257292,
"author_profile": "https://Stackoverflow.com/users/3257292",
"pm_score": 0,
"selected": false,
"text": "//use like this\n//std::vector<std::wstring> vec = Split<std::wstring> (L\"Hello##world##!\", L\"##\");\n\ntemplate <typename valueType>\nstatic std::vector <valueType> Split (valueType text, const valueType& delimiter)\n{\n std::vector <valueType> tokens;\n size_t pos = 0;\n valueType token;\n\n while ((pos = text.find(delimiter)) != valueType::npos) \n {\n token = text.substr(0, pos);\n tokens.push_back (token);\n text.erase(0, pos + delimiter.length());\n }\n tokens.push_back (text);\n\n return tokens;\n}\n"
},
{
"answer_id": 24971386,
"author": "odinthenerd",
"author_id": 893819,
"author_profile": "https://Stackoverflow.com/users/893819",
"pm_score": 2,
"selected": false,
"text": "std::vector<std::string> split(std::string::const_iterator it, std::string::const_iterator end, std::regex e = std::regex{\"\\\\w+\"}){\n std::smatch m{};\n std::vector<std::string> ret{};\n while (std::regex_search (it,end,m,e)) {\n ret.emplace_back(m.str()); \n std::advance(it, m.position() + m.length()); //next start position = match position + match length\n }\n return ret;\n}\nstd::vector<std::string> split(const std::string &s, std::regex e = std::regex{\"\\\\w+\"}){ //comfort version calls flexible version\n return split(s.cbegin(), s.cend(), std::move(e));\n}\nint main ()\n{\n std::string str {\"Some people, excluding those present, have been compile time constants - since puberty.\"};\n auto v = split(str);\n for(const auto&s:v){\n std::cout << s << std::endl;\n }\n std::cout << \"crazy version:\" << std::endl;\n v = split(str, std::regex{\"[^e]+\"}); //using e as delim shows flexibility\n for(const auto&s:v){\n std::cout << s << std::endl;\n }\n return 0;\n}\n template<bool...> struct BoolSequence{}; //just here to hold bools\ntemplate<char...> struct CharSequence{}; //just here to hold chars\ntemplate<typename T, char C> struct Contains; //generic\ntemplate<char First, char... Cs, char Match> //not first specialization\nstruct Contains<CharSequence<First, Cs...>,Match> :\n Contains<CharSequence<Cs...>, Match>{}; //strip first and increase index\ntemplate<char First, char... Cs> //is first specialization\nstruct Contains<CharSequence<First, Cs...>,First>: std::true_type {}; \ntemplate<char Match> //not found specialization\nstruct Contains<CharSequence<>,Match>: std::false_type{};\n\ntemplate<int I, typename T, typename U> \nstruct MakeSequence; //generic\ntemplate<int I, bool... Bs, typename U> \nstruct MakeSequence<I,BoolSequence<Bs...>, U>: //not last\n MakeSequence<I-1, BoolSequence<Contains<U,I-1>::value,Bs...>, U>{};\ntemplate<bool... Bs, typename U> \nstruct MakeSequence<0,BoolSequence<Bs...>,U>{ //last \n using Type = BoolSequence<Bs...>;\n};\ntemplate<typename T> struct BoolASCIITable;\ntemplate<bool... Bs> struct BoolASCIITable<BoolSequence<Bs...>>{\n /* could be made constexpr but not yet supported by MSVC */\n static bool isDelim(const char c){\n static const bool table[256] = {Bs...};\n return table[static_cast<int>(c)];\n } \n};\nusing Delims = CharSequence<'.',',',' ',':','\\n'>; //list your custom delimiters here\nusing Table = BoolASCIITable<typename MakeSequence<256,BoolSequence<>,Delims>::Type>;\n getNextToken template<typename T_It>\nstd::pair<T_It,T_It> getNextToken(T_It begin,T_It end){\n begin = std::find_if(begin,end,std::not1(Table{})); //find first non delim or end\n auto second = std::find_if(begin,end,Table{}); //find first delim or end\n return std::make_pair(begin,second);\n}\n int main() {\n std::string s{\"Some people, excluding those present, have been compile time constants - since puberty.\"};\n auto it = std::begin(s);\n auto end = std::end(s);\n while(it != std::end(s)){\n auto token = getNextToken(it,end);\n std::cout << std::string(token.first,token.second) << std::endl;\n it = token.second;\n }\n return 0;\n}\n"
},
{
"answer_id": 27468529,
"author": "w.b",
"author_id": 2720372,
"author_profile": "https://Stackoverflow.com/users/2720372",
"pm_score": 6,
"selected": false,
"text": "regex_token_iterator #include <iostream>\n#include <regex>\n#include <string>\n\nusing namespace std;\n\nint main()\n{\n string str(\"The quick brown fox\");\n\n regex reg(\"\\\\s+\");\n\n sregex_token_iterator iter(str.begin(), str.end(), reg, -1);\n sregex_token_iterator end;\n\n vector<string> vec(iter, end);\n\n for (auto a : vec)\n {\n cout << a << endl;\n }\n}\n"
},
{
"answer_id": 27969097,
"author": "CATspellsDOG",
"author_id": 4308970,
"author_profile": "https://Stackoverflow.com/users/4308970",
"pm_score": 0,
"selected": false,
"text": "#include <iostream>\n#include <string>\n#include <vector>\n#include <sstream>\n\nusing namespace std;\n\nstring seps(string& s) {\n if (!s.size()) return \"\";\n stringstream ss;\n ss << s[0];\n for (int i = 1; i < s.size(); i++) {\n ss << '|' << s[i];\n }\n return ss.str();\n}\n\nvoid Tokenize(string& str, vector<string>& tokens, const string& delimiters = \" \")\n{\n seps(str);\n\n // Skip delimiters at beginning.\n string::size_type lastPos = str.find_first_not_of(delimiters, 0);\n // Find first \"non-delimiter\".\n string::size_type pos = str.find_first_of(delimiters, lastPos);\n\n while (string::npos != pos || string::npos != lastPos)\n {\n // Found a token, add it to the vector.\n tokens.push_back(str.substr(lastPos, pos - lastPos));\n // Skip delimiters. Note the \"not_of\"\n lastPos = str.find_first_not_of(delimiters, pos);\n // Find next \"non-delimiter\"\n pos = str.find_first_of(delimiters, lastPos);\n }\n}\n\nint main(int argc, char *argv[])\n{\n vector<string> t;\n string s = \"Tokens for everyone!\";\n\n Tokenize(s, t, \"|\");\n\n for (auto c : t)\n cout << c << endl;\n\n system(\"pause\");\n\n return 0;\n}\n"
},
{
"answer_id": 28788127,
"author": "Parham",
"author_id": 1357387,
"author_profile": "https://Stackoverflow.com/users/1357387",
"pm_score": 5,
"selected": false,
"text": "std::find std::find_first_not_of #include <string>\n#include <vector>\n\nvoid tokenize(std::string str, std::vector<string> &token_v){\n size_t start = str.find_first_not_of(DELIMITER), end=start;\n\n while (start != std::string::npos){\n // Find next occurence of delimiter\n end = str.find(DELIMITER, start);\n // Push back the token found into vector\n token_v.push_back(str.substr(start, end-start));\n // Skip all occurences of the delimiter to find new start\n start = str.find_first_not_of(DELIMITER, end);\n }\n}\n"
},
{
"answer_id": 38595708,
"author": "Jonathan Mee",
"author_id": 2642059,
"author_profile": "https://Stackoverflow.com/users/2642059",
"pm_score": 3,
"selected": false,
"text": "const char* string string str{ \"The quick brown fox\" } auto start = find(cbegin(str), cend(str), ' ');\nvector<string> tokens{ string(cbegin(str), start) };\n\nwhile (start != cend(str)) {\n const auto finish = find(++start, cend(str), ' ');\n\n tokens.push_back(string(start, finish));\n start = finish;\n}\n strtok vector<string> tokens;\n\nfor (auto i = strtok(data(str), \" \"); i != nullptr; i = strtok(nullptr, \" \")) tokens.push_back(i);\n data(str) strtok strtok strings nullptr string char* strtok_s strtok strtok string const string const char* strtok string str split_view vector const vector<string> tokens istream_iterator const string str{ \"The quick \\tbrown \\nfox\" } istringstream is{ str };\nconst vector<string> tokens{ istream_iterator<string>(is), istream_iterator<string>() };\n istringstream string regex_token_iterator string const string str{ \"The ,qu\\\\,ick ,\\tbrown, fox\" } const regex re{ \"\\\\s*((?:[^\\\\\\\\,]|\\\\\\\\.)*?)\\\\s*(?:,|$)\" };\nconst vector<string> tokens{ sregex_token_iterator(cbegin(str), cend(str), re, 1), sregex_token_iterator() };\n"
},
{
"answer_id": 50247503,
"author": "NutCracker",
"author_id": 5517378,
"author_profile": "https://Stackoverflow.com/users/5517378",
"pm_score": 2,
"selected": false,
"text": "vector<string> get_words(string const& text, string const& separator)\n{\n vector<string> result;\n string tmp = text;\n\n size_t first_pos = 0;\n size_t second_pos = tmp.find(separator);\n\n while (second_pos != string::npos)\n {\n if (first_pos != second_pos)\n {\n string word = tmp.substr(first_pos, second_pos - first_pos);\n result.push_back(word);\n }\n tmp = tmp.substr(second_pos + separator.length());\n second_pos = tmp.find(separator);\n }\n\n result.push_back(tmp);\n\n return result;\n}\n"
},
{
"answer_id": 52436170,
"author": "kayleeFrye_onDeck",
"author_id": 3543437,
"author_profile": "https://Stackoverflow.com/users/3543437",
"pm_score": 1,
"selected": false,
"text": "#include <string>\n#include <locale>\n#include <regex>\n\nstd::vector<std::wstring> tokenize_string(std::wstring string_to_tokenize) {\n std::vector<std::wstring> tokens;\n\n std::wregex re(LR\"((\"[^\"]*\"|'[^']*'|[^\"' ]+))\", std::regex_constants::collate);\n\n std::wsregex_iterator next( string_to_tokenize.begin(),\n string_to_tokenize.end(),\n re,\n std::regex_constants::match_not_null );\n\n std::wsregex_iterator end;\n const wchar_t single_quote = L'\\'';\n const wchar_t double_quote = L'\\\"';\n while ( next != end ) {\n std::wsmatch match = *next;\n const std::wstring token = match.str( 0 );\n next++;\n\n if (token.length() > 2 && (token.front() == double_quote || token.front() == single_quote))\n tokens.emplace_back( std::wstring(token.begin()+1, token.begin()+token.length()-1) );\n else\n tokens.emplace_back(token);\n }\n return tokens;\n}\n"
},
{
"answer_id": 63431488,
"author": "einpoklum",
"author_id": 1593077,
"author_profile": "https://Stackoverflow.com/users/1593077",
"pm_score": 3,
"selected": false,
"text": "auto results = str | ranges::views::tokenize(\" \",1);\n auto results = str | ranges::views::tokenize(\" \",1) | ranges::to<std::vector>();\n str"
},
{
"answer_id": 71564188,
"author": "Tanzer",
"author_id": 3976739,
"author_profile": "https://Stackoverflow.com/users/3976739",
"pm_score": 1,
"selected": false,
"text": "void StrTokenizer(string& source, const char* delimiter, vector<string>& Tokens)\n{ \n size_t new_index = 0;\n size_t old_index = 0;\n\n while (new_index != std::string::npos) \n {\n new_index = source.find(delimiter, old_index);\n Tokens.emplace_back(source.substr(old_index, new_index-old_index));\n\n if (new_index != std::string::npos)\n old_index = ++new_index;\n }\n}\n"
},
{
"answer_id": 74347767,
"author": "leanid.chaika",
"author_id": 955508,
"author_profile": "https://Stackoverflow.com/users/955508",
"pm_score": 0,
"selected": false,
"text": "#include <iomanip>\n#include <iostream>\n#include <iterator>\n#include <string_view>\n#include <utility>\n\nstruct split_by_spaces\n{\n std::string_view text;\n static constexpr char delim = ' ';\n\n struct iterator\n {\n const std::string_view& text;\n std::size_t cur_pos;\n std::size_t end_pos;\n\n std::string_view operator*() const\n {\n return { &text[cur_pos], end_pos - cur_pos };\n }\n bool operator==(const iterator& other) const\n {\n return cur_pos == other.cur_pos && end_pos == other.end_pos;\n }\n bool operator!=(const iterator& other) const\n {\n return !(*this == other);\n }\n iterator& operator++()\n {\n cur_pos = text.find_first_not_of(delim, end_pos);\n\n if (cur_pos == std::string_view::npos)\n {\n cur_pos = text.size();\n end_pos = cur_pos;\n return *this;\n }\n\n end_pos = text.find(delim, cur_pos);\n\n if (cur_pos == std::string_view::npos)\n {\n end_pos = text.size();\n }\n\n return *this;\n }\n };\n\n [[nodiscard]] iterator begin() const\n {\n auto start = text.find_first_not_of(delim);\n if (start == std::string_view::npos)\n {\n return iterator{ text, text.size(), text.size() };\n }\n auto end_word = text.find(delim, start);\n if (end_word == std::string_view::npos)\n {\n end_word = text.size();\n }\n return iterator{ text, start, end_word };\n }\n [[nodiscard]] iterator end() const\n {\n return iterator{ text, text.size(), text.size() };\n }\n};\n\nint main(int argc, char** argv)\n{\n using namespace std::literals;\n auto str = \" there should be no memory allocation during parsing\"\n \" into words this line and you should'n create any\"\n \" contaner for intermediate words \"sv;\n\n auto comma = \"\";\n for (std::string_view word : split_by_spaces{ str })\n {\n std::cout << std::exchange(comma, \",\") << std::quoted(word);\n }\n\n auto only_spaces = \" \"sv;\n for (std::string_view word : split_by_spaces{ only_spaces })\n {\n std::cout << \"you will not see this line in output\" << std::endl;\n }\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53849",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] |
53,911 |
<p>Programming in vim I often go search for something, yank it, then go back to where I was, insert it, modify it.</p>
<p>The problem is that after I search and find, I need to MANUALLY find my way back to where I was.</p>
<p>Is there an automatic way to go back to where I was when I initiated my last search?</p>
|
[
{
"answer_id": 53924,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 6,
"selected": false,
"text": ":marks :marks"
},
{
"answer_id": 53926,
"author": "Paul Tomblin",
"author_id": 3333,
"author_profile": "https://Stackoverflow.com/users/3333",
"pm_score": 3,
"selected": false,
"text": "m[letter] '[letter]"
},
{
"answer_id": 84117,
"author": "Max Cantor",
"author_id": 16034,
"author_profile": "https://Stackoverflow.com/users/16034",
"pm_score": 7,
"selected": false,
"text": "`` ''"
},
{
"answer_id": 138943,
"author": "André",
"author_id": 9683,
"author_profile": "https://Stackoverflow.com/users/9683",
"pm_score": 5,
"selected": false,
"text": ":help jumplist"
},
{
"answer_id": 10392263,
"author": "Ethan Zhang",
"author_id": 619292,
"author_profile": "https://Stackoverflow.com/users/619292",
"pm_score": 3,
"selected": false,
"text": "nnoremap / ms/\nnnoremap ? ms?\n / ? `s s"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] |
53,939 |
<p>I'm running Visual Studio 2008 with the stuff-of-nightmares awful MS test framework. Trouble is that it's sending my CPU to 100% (well 25% on a quad-core).</p>
<p>My question is why can't Visual Studio run on more than one core? Surely M$ must have a sufficient handle on threading to get this to work.</p>
|
[
{
"answer_id": 3357049,
"author": "Olivier Dagenais",
"author_id": 98903,
"author_profile": "https://Stackoverflow.com/users/98903",
"pm_score": 2,
"selected": false,
"text": "parallelTestCount .testsettings <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<TestSettings\n name=\"Release\"\n id=\"{GUID}\"\n xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\">\n <Description>\n These are default test settings for a local test run.\n </Description>\n <Execution parallelTestCount=\"0\">\n (...)\n </Execution>\n</TestSettings>\n parallelTestCount"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1122/"
] |
53,945 |
<p>I am currently loading a lightbox style popup that loads it's HTML from an XHR call. This content is then displayed in a 'modal' popup using <code>element.innerHTML = content</code> This works like a charm.</p>
<p>In another section of this website I use a Flickr 'badge' (<a href="http://www.elliotswan.com/2006/08/06/custom-flickr-badge-api-documentation/" rel="noreferrer">http://www.elliotswan.com/2006/08/06/custom-flickr-badge-api-documentation/</a>) to load flickr images dynamically. This is done including a script tag that loads a flickr javascript, which in turn does some <code>document.write</code> statments.</p>
<p>Both of them work perfectly when included in the HTML. Only when loading the flickr badge code <em>inside</em> the lightbox, no content is rendered at all. It seems that using <code>innerHTML</code> to write <code>document.write</code> statements is taking it a step too far, but I cannot find any clue in the javascript implementations (FF2&3, IE6&7) of this behavior.</p>
<p>Can anyone clarify if this should or shouldn't work? Thanks.</p>
|
[
{
"answer_id": 54002,
"author": "Jon Cram",
"author_id": 5343,
"author_profile": "https://Stackoverflow.com/users/5343",
"pm_score": 0,
"selected": false,
"text": "document.write document.write document.write document.write content element.innerHTML = content document.write innerHTML <script>\n var content = \"<p>1st para</p><script>document.write('<p>2nd para</p>');</script>\"\n element.innerHTML = content;\n</script>\n document.write innerHTML"
},
{
"answer_id": 54026,
"author": "Kamiel Wanrooij",
"author_id": 4174,
"author_profile": "https://Stackoverflow.com/users/4174",
"pm_score": 3,
"selected": false,
"text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html>\n <head>\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />\n <title>Document Write Testcase</title>\n </head>\n <body>\n <div id=\"container\">\n </div>\n <div id=\"container2\">\n </div>\n\n <script>\n // This doesn't work!\n var container = document.getElementById('container');\n container.innerHTML = \"<script type='text/javascript'>alert('foo');document.write('bar');<\\/script>\";\n\n // This does!\n var container2 = document.getElementById('container2');\n var script = document.createElement(\"script\");\n script.type = 'text/javascript';\n script.innerHTML = \"alert('bar');document.write('foo');\";\n container.appendChild(script);\n </script>\n </body>\n</html>\n script innerHTML script"
},
{
"answer_id": 54079,
"author": "Jon Cram",
"author_id": 5343,
"author_profile": "https://Stackoverflow.com/users/5343",
"pm_score": 0,
"selected": false,
"text": "script script"
},
{
"answer_id": 54110,
"author": "Kamiel Wanrooij",
"author_id": 4174,
"author_profile": "https://Stackoverflow.com/users/4174",
"pm_score": 0,
"selected": false,
"text": "script container script"
},
{
"answer_id": 54114,
"author": "Mo.",
"author_id": 5560,
"author_profile": "https://Stackoverflow.com/users/5560",
"pm_score": 1,
"selected": false,
"text": "document.write write document innerHTML"
},
{
"answer_id": 1863308,
"author": "noah",
"author_id": 12034,
"author_profile": "https://Stackoverflow.com/users/12034",
"pm_score": 5,
"selected": true,
"text": "document.write document.write var content = '';\ndocument.write = function(s) {\n content += s;\n};\n// execute the script\n$('#foo').html(markupWithScriptInIt);\n$('#foo .whereverTheDocumentWriteContentGoes').html(content);\n"
},
{
"answer_id": 7175202,
"author": "David Refoua",
"author_id": 1454514,
"author_profile": "https://Stackoverflow.com/users/1454514",
"pm_score": 2,
"selected": false,
"text": "document.writeln(content); document.write(content) innerHTML element.innerHTML += content;\n element.innerHTML = content; += element.innerHTML += content document.write"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4174/"
] |
53,961 |
<p>I'm working with a large (270+ project) VS.Net solution. Yes, I know this is pushing the friendship with VS but it's inherited and blah blah. Anyway, to speed up the solution load and compile time I've removed all projects that I'm not currently working on... which in turn has removed those project references from the projects I want to retain. So now I'm going through a mind numbing process of adding binary references to the retained projects so that the referenced Types can be found.</p>
<p>Here's how I'm working at present;</p>
<ul>
<li>Attempt to compile, get thousands of
errors, 'type or namespace missing'</li>
<li>Copy the first line of the error
list to the clipboard</li>
<li>Using a perl script hooked up to a
hotkey (AHK) I extract the type name from
the error message and store it in the windows clipboard</li>
<li>I paste the type name into source
insight symbol browser and note the
assembly containing the Type</li>
<li>I go back to VS and add that
assembly as a binary reference to
the relevant project</li>
</ul>
<p>So now, after about 30 mins I'm thinking there's just got to be a quicker way...</p>
|
[
{
"answer_id": 54063,
"author": "Gulzar Nazim",
"author_id": 4337,
"author_profile": "https://Stackoverflow.com/users/4337",
"pm_score": 1,
"selected": false,
"text": " <ItemGroup>\n <ProjectReference Include=\"..\\WindowsApplication2\\WindowsApplication2.csproj\">\n <Project>{7CE93073-D1E3-49B0-949E-89C73F3EC282}</Project>\n <Name>WindowsApplication2</Name>\n </ProjectReference>\n </ItemGroup>\n <ItemGroup>\n <Reference Include=\"WindowsApplication2, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL\">\n <SpecificVersion>False</SpecificVersion>\n <ExecutableExtension>.dll</ExecutableExtension>\n <HintPath>..\\WindowsApplication2\\bin\\Release\\WindowsApplication2.dll</HintPath>\n </Reference> </ItemGroup>\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53961",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4200/"
] |
53,965 |
<pre><code>$output = preg_replace("|(/D)(/s+)(/d+)(;)|", "//1,//3;", $output);
</code></pre>
<p>I'm trying to replace all alphabetical character followed by one or more whitespace characters (tabs and/or spaces) followed by one or more numerical characters followed by a semicolon with the alphabetical character followed by a comma followed by the numerical digits and then the semicolon.</p>
<p>I'll provide an example:</p>
<p>Start:</p>
<pre><code>hello world 1007;
</code></pre>
<p>End:</p>
<pre><code>hello world,1007;
</code></pre>
|
[
{
"answer_id": 53993,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stackoverflow.com/users/1908",
"pm_score": 4,
"selected": true,
"text": "| $n $output = preg_replace(\"/(\\\\D)\\\\s+(\\\\d+;)/\", \"$1,$2\", $output);\n $output = preg_replace('/(\\D)\\s+(\\d+;)/', '$1,$2', $output);\n"
},
{
"answer_id": 54018,
"author": "Alan Storm",
"author_id": 4668,
"author_profile": "https://Stackoverflow.com/users/4668",
"pm_score": 1,
"selected": false,
"text": "$x = \"hello world 1007;\"; \necho preg_replace('|(\\D)(\\s+)(\\d+)(;)|','$1,$3',$x);\necho preg_replace('/(\\D)(\\s+)(\\d+)(;)/','$1,$3',$x);\necho preg_replace('{(\\D)(\\s+)(\\d+)(;)}','$1,$3',$x);\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] |
53,967 |
<p>I have a class that map objects to objects, but unlike dictionary it maps them both ways. I am now trying to implement a custom <code>IEnumerator</code> interface that iterates through the values.</p>
<pre><code>public class Mapper<K,T> : IEnumerable<T>, IEnumerator<T>
{
C5.TreeDictionary<K,T> KToTMap = new TreeDictionary<K,T>();
C5.HashDictionary<T,K> TToKMap = new HashDictionary<T,K>();
public void Add(K key, T value)
{
KToTMap.Add(key, value);
TToKMap.Add(value, key);
}
public int Count
{
get { return KToTMap.Count; }
}
public K this[T obj]
{
get
{
return TToKMap[obj];
}
}
public T this[K obj]
{
get
{
return KToTMap[obj];
}
}
public IEnumerator<T> GetEnumerator()
{
return KToTMap.Values.GetEnumerator();
}
public T Current
{
get { throw new NotImplementedException(); }
}
public void Dispose()
{
throw new NotImplementedException();
}
object System.Collections.IEnumerator.Current
{
get { throw new NotImplementedException(); }
}
public bool MoveNext()
{
;
}
public void Reset()
{
throw new NotImplementedException();
}
}
</code></pre>
|
[
{
"answer_id": 53999,
"author": "Pop Catalin",
"author_id": 4685,
"author_profile": "https://Stackoverflow.com/users/4685",
"pm_score": 3,
"selected": false,
"text": "IEnumerable<T> IEnumerator<T> public class Mapper<K,T> : IEnumerable<T> {\n public IEnumerator<T> GetEnumerator()\n {\n return KToTMap.Values.GetEnumerator();\n }\n}\n"
},
{
"answer_id": 14999790,
"author": "Jack",
"author_id": 794594,
"author_profile": "https://Stackoverflow.com/users/794594",
"pm_score": 3,
"selected": false,
"text": "CreateEnumerable() IEnumerable GetEnumerator() public class EasyEnumerable : IEnumerable<int> {\n\n IEnumerable<int> CreateEnumerable() {\n yield return 123;\n yield return 456;\n for (int i = 0; i < 6; i++) {\n yield return i;\n }//for\n }//method\n\n public IEnumerator<int> GetEnumerator() {\n return CreateEnumerable().GetEnumerator();\n }//method\n\n IEnumerator IEnumerable.GetEnumerator() {\n return CreateEnumerable().GetEnumerator();\n }//method\n\n}//class\n"
},
{
"answer_id": 23442029,
"author": "Rezo Megrelidze",
"author_id": 2204040,
"author_profile": "https://Stackoverflow.com/users/2204040",
"pm_score": 2,
"selected": false,
"text": "public class Stack<T> : IEnumerable<T>\n{\n private T[] array;\n\n public Stack(int n)\n {\n array = new T[n];\n }\n\n public Stack()\n {\n array = new T[16];\n }\n\n public void Push(T item)\n {\n if (Count == array.Length)\n {\n Grow(array.Length * 2);\n }\n\n array[Count++] = item;\n }\n\n public T Pop()\n {\n if (Count == array.Length/4)\n {\n Shrink(array.Length/2);\n }\n\n return array[--Count];\n }\n\n private void Grow(int size)\n {\n var temp = array;\n array = new T[size];\n Array.Copy(temp, array, temp.Length);\n }\n\n private void Shrink(int size)\n {\n Array temp = array;\n array = new T[size];\n Array.Copy(temp,0,array,0,size);\n }\n\n public int Count { get; private set; }\n public IEnumerator<T> GetEnumerator()\n {\n return new ReverseArrayIterator(Count,array);\n }\n\n IEnumerator IEnumerable.GetEnumerator()\n {\n return GetEnumerator();\n }\n\n\n // IEnumerator implementation\n private class ReverseArrayIterator : IEnumerator<T>\n {\n private int i;\n\n private readonly T[] array;\n\n public ReverseArrayIterator(int count,T[] array)\n {\n i = count;\n this.array = array;\n }\n\n public void Dispose()\n {\n\n }\n\n public bool MoveNext()\n {\n return i > 0;\n }\n\n public void Reset()\n {\n\n }\n\n public T Current { get { return array[--i]; } }\n\n object IEnumerator.Current\n {\n get { return Current; }\n }\n }\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4694/"
] |
53,989 |
<p>Usually Flash and Flex applications are embedded on in HTML using either a combination of <code>object</code> and <code>embed</code> tags, or more commonly using JavaScript. However, if you link directly to a SWF file it will open in the browser window and without looking in the address bar you can't tell that it wasn't embedded in HTML with the size set to 100% width and height.</p>
<p>Considering the overhead of the HTML, CSS and JavaScript needed to embed a Flash or Flex application filling 100% of the browser window, what are the downsides of linking directly to the SWF file instead? What are the upsides?</p>
<p>I can think of one upside and three downsides: you don't need the 100+ lines of HTML, JavaScript and CSS that are otherwise required, but you have no plugin detection, no version checking and you lose your best SEO option (progressive enhancement).</p>
<p><em>Update</em> don't get hung up on the 100+ lines, I simply mean that the the amount of code needed to embed a SWF is quite a lot (and I mean including libraries like SWFObject), and it's just for displaying the SWF, which can be done without a single line by linking to it directly.</p>
|
[
{
"answer_id": 54155,
"author": "hasseg",
"author_id": 4111,
"author_profile": "https://Stackoverflow.com/users/4111",
"pm_score": 1,
"selected": false,
"text": "Application.application.parameters"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1109/"
] |
53,997 |
<p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
|
[
{
"answer_id": 605156,
"author": "mahmoud",
"author_id": 72931,
"author_profile": "https://Stackoverflow.com/users/72931",
"pm_score": 2,
"selected": false,
"text": "def Get(self, user):\n self.handleRequest()\n\ndef Post(self, user):\n self.handleRequest()\n\n\ndef handleRequest(self): \n '''\n A dictionary that maps an operation name to a command.\n aka: a dispatcher map.\n '''\n operationMap = {'getfriends': [GetFriendsCommand],\n 'requestfriend': [RequestFriendCommand, [self.request.get('id')]],\n 'confirmfriend': [ConfirmFriendCommand, [self.request.get('id')]],\n 'ignorefriendrequest': [IgnoreFriendRequestCommand, [self.request.get('id')]],\n 'deletefriend': [DeleteFriendCommand, [self.request.get('id')]]}\n\n # Delegate the request to the matching command class here.\n class Command():\n \"\"\" A simple command pattern.\n \"\"\"\n _valid = False\n def validate(self):\n \"\"\" Validates input. Sanitize user input here.\n \"\"\"\n self._valid = True\n\n def _do_execute(self):\n \"\"\" Executes the command. \n Override this in subclasses.\n \"\"\"\n pass\n\n @property\n def valid(self):\n return self._valid\n\n def execute(self):\n \"\"\" Override _do_execute rather than this.\n \"\"\" \n try:\n self.validate()\n except:\n raise\n return self._do_execute()\n\n # Make it easy to invoke commands:\n # So command() is equivalent to command.execute()\n __call__ = execute\n /** \n * Ajax API\n *\n * You should create a new instance for every call.\n */\nvar AjaxAPI = Class.create({\n /* Service URL */\n url: HOME_PATH+\"ajax/\",\n\n /* Function to call on results */\n resultCallback: null,\n\n /* Function to call on faults. Implementation not shown */\n faultCallback: null,\n\n /* Constructor/Initializer */\n initialize: function(resultCallback, faultCallback){\n this.resultCallback = resultCallback;\n this.faultCallback = faultCallback;\n },\n\n requestFriend: function(friendId){\n return new Ajax.Request(this.url + '?op=requestFriend', \n {method: 'post',\n parameters: {'id': friendId},\n onComplete: this.resultCallback\n }); \n },\n\n getFriends: function(){\n return new Ajax.Request(this.url + '?op=getfriends', \n {method: 'get',\n onComplete: this.resultCallback\n }); \n }\n\n});\n new AjaxApi(resultHandlerFunction, faultHandlerFunction).getFriends()\n"
},
{
"answer_id": 800037,
"author": "Scott Kirkwood",
"author_id": 95818,
"author_profile": "https://Stackoverflow.com/users/95818",
"pm_score": 3,
"selected": false,
"text": "/static/ google.load(\"jquery\", \"1.3.2\");\n google.load(google.load(\"dojo\", \"1.3.0\");\n <script src=\"http://www.google.com/jsapi?key=your-key-here\"></script>\n"
},
{
"answer_id": 994994,
"author": "dfa",
"author_id": 89266,
"author_profile": "https://Stackoverflow.com/users/89266",
"pm_score": 2,
"selected": false,
"text": "public void onModuleLoad() { \n $(\"div\").css(\"color\", \"red\").click(new Function() { \n public void f(Element e) { \n Window.alert(\"Hello\"); \n $(e).as(Effects).fadeOut(); \n } \n }); \n} \n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/53997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3834/"
] |
54,001 |
<p>Migrating a project from ASP.NET 1.1 to ASP.NET 2.0 and I keep hitting this error. </p>
<p>I don't actually need Global because I am not adding anything to it, but after I remove it I get more errors.</p>
|
[
{
"answer_id": 228209,
"author": "Mark Glorie",
"author_id": 952,
"author_profile": "https://Stackoverflow.com/users/952",
"pm_score": 3,
"selected": false,
"text": "Public Class [Global]\n Inherits System.Web.HttpApplication\n ...\n"
},
{
"answer_id": 8938480,
"author": "Pieter van Ginkel",
"author_id": 446261,
"author_profile": "https://Stackoverflow.com/users/446261",
"pm_score": 6,
"selected": false,
"text": "x86 bin\\x86\\Debug bin bin"
},
{
"answer_id": 11553579,
"author": "MitchellKrenz",
"author_id": 361783,
"author_profile": "https://Stackoverflow.com/users/361783",
"pm_score": 2,
"selected": false,
"text": "<clear /> <assemblies>"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54001",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3208/"
] |
54,010 |
<p>I've recently been working on a beginner's project in Scala, and have a beginner question about Scala's Lists.</p>
<p>Say I have a list of tuples ( <code>List[Tuple2[String, String]]</code>, for example). Is there a convenience method to return the first occurence of a specified tuple from the List, or is it necessary to iterate through the list by hand?</p>
|
[
{
"answer_id": 66489,
"author": "Daniel Spiewak",
"author_id": 9815,
"author_profile": "https://Stackoverflow.com/users/9815",
"pm_score": 2,
"selected": false,
"text": "find true false"
},
{
"answer_id": 392351,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "list find { case (x,y,_) => x == \"C\" && y == \"D\" }\n for ( (x,y,z) <- list if x == \"C\" && y == \"D\") yield (x,y,z)\n"
},
{
"answer_id": 13305849,
"author": "akauppi",
"author_id": 14455,
"author_profile": "https://Stackoverflow.com/users/14455",
"pm_score": 1,
"selected": false,
"text": "A B class A\n\ncase class B(val name: String) extends A\n\nobject TestX extends App {\n val states: List[A] = List( B(\"aa\"), new A, B(\"ccc\") )\n\n def findByName( name: String ): Option[B] = {\n states.find{\n case x: B if x.name == name => return Some(x)\n case _ => false\n }\n None\n }\n\n println( findByName(\"ccc\") ) // \"Some(B(ccc))\"\n}\n findByName Option[A] Option[B] B"
},
{
"answer_id": 32812857,
"author": "elm",
"author_id": 3189923,
"author_profile": "https://Stackoverflow.com/users/3189923",
"pm_score": 1,
"selected": false,
"text": "collectFirst Some[(String,String)] None xs collectFirst { case t@(a,_) if a == \"existing\" => t }\nSome((existing,str))\n\nscala> xs collectFirst { case t@(a,_) if a == \"nonExisting\" => t }\nNone\n @ t"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
54,036 |
<p>how can i create an application to read all my browser (firefox) history?
i noticed that i have in </p>
<p>C:\Users\user.name\AppData\Local\Mozilla\Firefox\Profiles\646vwtnu.default</p>
<p>what looks like a sqlite database (urlclassifier3.sqlite) but i don't know if its really what is used to store de history information.
i searched for examples on how to do this but didn't find anything.</p>
<p>ps: although the title is similar i believe this question is not the same as <a href="https://stackoverflow.com/questions/48805/how-do-you-access-browser-history">"How do you access browser history?"</a></p>
|
[
{
"answer_id": 54074,
"author": "hasseg",
"author_id": 4111,
"author_profile": "https://Stackoverflow.com/users/4111",
"pm_score": 4,
"selected": true,
"text": "places.sqlite history.dat"
},
{
"answer_id": 56201,
"author": "Vitor Silva",
"author_id": 1842864,
"author_profile": "https://Stackoverflow.com/users/1842864",
"pm_score": 2,
"selected": false,
"text": "cnn = New SQLiteConnection(\"data source=c:\\Users\\user.name\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\646vwtnu.default\\places.sqlite\")\ncnn.Open()\n"
},
{
"answer_id": 58235057,
"author": "amirouche",
"author_id": 140837,
"author_profile": "https://Stackoverflow.com/users/140837",
"pm_score": 1,
"selected": false,
"text": "places.sqlite $ pwd\n/home/amirouche/.mozilla/firefox/p4x432.default\n$ ls -l *sqlite\n-rw-r--r-- 1 amirouche amirouche 229376 Oct 4 12:39 content-prefs.sqlite\n-rw-r--r-- 1 amirouche amirouche 1572864 Oct 4 12:51 cookies.sqlite\n-rw-r--r-- 1 amirouche amirouche 40501248 Oct 4 12:47 favicons.sqlite\n-rw-r--r-- 1 amirouche amirouche 294912 Oct 4 12:46 formhistory.sqlite\n-rw-r--r-- 1 amirouche amirouche 196608 Oct 4 12:50 permissions.sqlite\n-rw-r--r-- 1 amirouche amirouche 36700160 Oct 4 12:50 places.sqlite\n-rw-r--r-- 1 amirouche amirouche 65536 Oct 4 11:50 protections.sqlite\n-rw-r--r-- 1 amirouche amirouche 512 Jul 24 23:41 storage.sqlite\n-rw-r--r-- 1 amirouche amirouche 131072 Oct 4 12:05 storage-sync.sqlite\n-rw-r--r-- 1 amirouche amirouche 15892480 Oct 4 12:51 webappsstore.sqlite\n\n$ sqlite3 places.sqlite \nSQLite version 3.27.2 2019-02-25 16:06:06\nEnter \".help\" for usage hints.\nsqlite> .schema\nError: database is locked\nsqlite> \n\n$ cp places.sqlite places.backup.sqlite\n\n$ sqlite3 places.backup.sqlite \nSQLite version 3.27.2 2019-02-25 16:06:06\nEnter \".help\" for usage hints.\nsqlite> .schema\n moz_places CREATE TABLE moz_origins ( id INTEGER PRIMARY KEY, prefix TEXT NOT NULL, host TEXT NOT NULL, frecency INTEGER NOT NULL, UNIQUE (prefix, host) );\nCREATE TABLE moz_places ( id INTEGER PRIMARY KEY, url LONGVARCHAR, title LONGVARCHAR, rev_host LONGVARCHAR, visit_count INTEGER DEFAULT 0, hidden INTEGER DEFAULT 0 NOT NULL, typed INTEGER DEFAULT 0 NOT NULL, frecency INTEGER DEFAULT -1 NOT NULL, last_visit_date INTEGER , guid TEXT, foreign_count INTEGER DEFAULT 0 NOT NULL, url_hash INTEGER DEFAULT 0 NOT NULL , description TEXT, preview_image_url TEXT, origin_id INTEGER REFERENCES moz_origins(id));\nCREATE TABLE moz_historyvisits ( id INTEGER PRIMARY KEY, from_visit INTEGER, place_id INTEGER, visit_date INTEGER, visit_type INTEGER, session INTEGER);\nCREATE TABLE moz_inputhistory ( place_id INTEGER NOT NULL, input LONGVARCHAR NOT NULL, use_count INTEGER, PRIMARY KEY (place_id, input));\nCREATE TABLE moz_bookmarks ( id INTEGER PRIMARY KEY, type INTEGER, fk INTEGER DEFAULT NULL, parent INTEGER, position INTEGER, title LONGVARCHAR, keyword_id INTEGER, folder_type TEXT, dateAdded INTEGER, lastModified INTEGER, guid TEXT, syncStatus INTEGER NOT NULL DEFAULT 0, syncChangeCounter INTEGER NOT NULL DEFAULT 1);\nCREATE TABLE moz_bookmarks_deleted ( guid TEXT PRIMARY KEY, dateRemoved INTEGER NOT NULL DEFAULT 0);\nCREATE TABLE moz_keywords ( id INTEGER PRIMARY KEY AUTOINCREMENT, keyword TEXT UNIQUE, place_id INTEGER, post_data TEXT);\nCREATE TABLE sqlite_sequence(name,seq);\nCREATE TABLE moz_anno_attributes ( id INTEGER PRIMARY KEY, name VARCHAR(32) UNIQUE NOT NULL);\nCREATE TABLE moz_annos ( id INTEGER PRIMARY KEY, place_id INTEGER NOT NULL, anno_attribute_id INTEGER, content LONGVARCHAR, flags INTEGER DEFAULT 0, expiration INTEGER DEFAULT 0, type INTEGER DEFAULT 0, dateAdded INTEGER DEFAULT 0, lastModified INTEGER DEFAULT 0);\nCREATE TABLE moz_items_annos ( id INTEGER PRIMARY KEY, item_id INTEGER NOT NULL, anno_attribute_id INTEGER, content LONGVARCHAR, flags INTEGER DEFAULT 0, expiration INTEGER DEFAULT 0, type INTEGER DEFAULT 0, dateAdded INTEGER DEFAULT 0, lastModified INTEGER DEFAULT 0);\nCREATE TABLE moz_meta (key TEXT PRIMARY KEY, value NOT NULL) WITHOUT ROWID ;\nCREATE TABLE sqlite_stat1(tbl,idx,stat);\nCREATE INDEX moz_places_url_hashindex ON moz_places (url_hash);\nCREATE INDEX moz_places_hostindex ON moz_places (rev_host);\nCREATE INDEX moz_places_visitcount ON moz_places (visit_count);\nCREATE INDEX moz_places_frecencyindex ON moz_places (frecency);\nCREATE INDEX moz_places_lastvisitdateindex ON moz_places (last_visit_date);\nCREATE UNIQUE INDEX moz_places_guid_uniqueindex ON moz_places (guid);\nCREATE INDEX moz_places_originidindex ON moz_places (origin_id);\nCREATE INDEX moz_historyvisits_placedateindex ON moz_historyvisits (place_id, visit_date);\nCREATE INDEX moz_historyvisits_fromindex ON moz_historyvisits (from_visit);\nCREATE INDEX moz_historyvisits_dateindex ON moz_historyvisits (visit_date);\nCREATE INDEX moz_bookmarks_itemindex ON moz_bookmarks (fk, type);\nCREATE INDEX moz_bookmarks_parentindex ON moz_bookmarks (parent, position);\nCREATE INDEX moz_bookmarks_itemlastmodifiedindex ON moz_bookmarks (fk, lastModified);\nCREATE INDEX moz_bookmarks_dateaddedindex ON moz_bookmarks (dateAdded);\nCREATE UNIQUE INDEX moz_bookmarks_guid_uniqueindex ON moz_bookmarks (guid);\nCREATE UNIQUE INDEX moz_keywords_placepostdata_uniqueindex ON moz_keywords (place_id, post_data);\nCREATE UNIQUE INDEX moz_annos_placeattributeindex ON moz_annos (place_id, anno_attribute_id);\nCREATE UNIQUE INDEX moz_items_annos_itemattributeindex ON moz_items_annos (item_id, anno_attribute_id);\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1842864/"
] |
54,037 |
<p>Say you've got a credit card number with an expiration date of 05/08 - i.e. May 2008.</p>
<p>Does that mean the card expires on the morning of the 1st of May 2008, or the night of the 31st of May 2008?</p>
|
[
{
"answer_id": 54041,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 4,
"selected": false,
"text": "EXPIRES END VALID THRU"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] |
54,047 |
<p>I've been trying to figure out a regex to allow me to search for a particular string while automatically skipping comments. Anyone have an RE like this or know of one? It doesn't even need to be sophisticated enough to skip <code>#if 0</code> blocks; I just want it to skip over <code>//</code> and <code>/*</code> blocks. The converse, that is only search inside comment blocks, would be very useful too. </p>
<p>Environment: VS 2003</p>
|
[
{
"answer_id": 54148,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 2,
"selected": false,
"text": "\"This is \\\"a test\\\"\""
},
{
"answer_id": 55604,
"author": "jfs",
"author_id": 4279,
"author_profile": "https://Stackoverflow.com/users/4279",
"pm_score": 2,
"selected": false,
"text": "#!/usr/bin/perl\n$/ = undef;\n$_ = <>; \n\ns#/\\*[^*]*\\*+([^/*][^*]*\\*+)*/|([^/\"']*(\"[^\"\\\\]*(\\\\[\\d\\D][^\"\\\\]*)*\"[^/\"']*|'[^'\\\\]*(\\\\[\\d\\D][^'\\\\]*)*'[^/\"']*|/+[^*/][^/\"']*)*)#$2#g;\nprint; \n #!/usr/local/bin/perl\n$/ = undef;\n$_ = <>;\n\ns#//(.*)|/\\*[^*]*\\*+([^/*][^*]*\\*+)*/|\"(\\\\.|[^\"\\\\])*\"|'(\\\\.|[^'\\\\])*'|[^/\"']+# $1 ? \"/*$1 */\" : $& #ge;\nprint;\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54047",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2820/"
] |
54,050 |
<p>We have an ASP.NET application that manages it's own User, Roles and Permission database and we have recently added a field to the User table to hold the Windows domain account. </p>
<p>I would like to make it so that the user doesn't have to <strong>physically</strong> log in to our application, but rather would be automatically logged in based on the currently logged in Windows domain account DOMAIN\username. We want to authenticate the Windows domain account against our own User table. </p>
<p>This is a piece of cake to do in Windows Forms, is it possible to do this in Web Forms?</p>
<p>I don't want the user to be prompted with a Windows challenge screen, I want our system to handle the log in.</p>
<p><strong>Clarification</strong>: We are using our own custom Principal object.</p>
<p><strong>Clarification</strong>: Not sure if it makes a difference or not, but we are using IIS7.</p>
|
[
{
"answer_id": 54065,
"author": "Biri",
"author_id": 968,
"author_profile": "https://Stackoverflow.com/users/968",
"pm_score": 1,
"selected": false,
"text": "using System.Security.Principal;\n...\nWindowsPrincipal wp = (WindowsPrincipal)HttpContext.Current.User;\n"
},
{
"answer_id": 54081,
"author": "Eric Z Beard",
"author_id": 1219,
"author_profile": "https://Stackoverflow.com/users/1219",
"pm_score": 1,
"selected": false,
"text": "WindowsIdentity myIdentity = WindowsIdentity.GetCurrent();\n\nWindowsPrincipal myPrincipal = new WindowsPrincipal(myIdentity);\n\nstring name = myPrincipal.Identity.Name;\nstring authType = myPrincipal.Identity.AuthenticationType;\nstring isAuth = myPrincipal.Identity.IsAuthenticated.ToString();\n\nstring identName = myIdentity.Name;\nstring identType = myIdentity.AuthenticationType;\nstring identIsAuth = myIdentity.IsAuthenticated.ToString();\nstring iSAnon = myIdentity.IsAnonymous.ToString();\nstring isG = myIdentity.IsGuest.ToString();\nstring isSys = myIdentity.IsSystem.ToString();\nstring token = myIdentity.Token.ToString();\n"
},
{
"answer_id": 54160,
"author": "Omer van Kloeten",
"author_id": 4979,
"author_profile": "https://Stackoverflow.com/users/4979",
"pm_score": 0,
"selected": false,
"text": "System.Threading.Thread.CurrentPrincipal"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1768/"
] |
54,052 |
<p>Are there any free tools available to view the contents of the solution user options file (the .suo file that accompanies solution files)?</p>
<p>I know it's basically formatted as a file system within the file, but I'd like to be able to view the contents so that I can figure out which aspects of my solution and customizations are causing it grow very large over time.</p>
|
[
{
"answer_id": 59385061,
"author": "Drew Noakes",
"author_id": 24874,
"author_profile": "https://Stackoverflow.com/users/24874",
"pm_score": 1,
"selected": false,
"text": "dotnet install --global suo\nsuo view <path-to-suo-file>\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/507/"
] |
54,059 |
<p>Say I have a linked list of numbers of length <code>N</code>. <code>N</code> is very large and I don’t know in advance the exact value of <code>N</code>. </p>
<p>How can I most efficiently write a function that will return <code>k</code> completely <em>random numbers</em> from the list?</p>
|
[
{
"answer_id": 54072,
"author": "Christian Oudard",
"author_id": 3757,
"author_profile": "https://Stackoverflow.com/users/3757",
"pm_score": -1,
"selected": false,
"text": "O(N*k)"
},
{
"answer_id": 54083,
"author": "George Mauer",
"author_id": 5056,
"author_profile": "https://Stackoverflow.com/users/5056",
"pm_score": -1,
"selected": false,
"text": "List GetKRandomFromList(List input, int k)\n List ret = new List();\n for(i=0;i<k;i++)\n ret.Add(input[Math.Rand(0,input.Length)]);\n return ret;\n"
},
{
"answer_id": 54174,
"author": "mweerden",
"author_id": 4285,
"author_profile": "https://Stackoverflow.com/users/4285",
"pm_score": 1,
"selected": false,
"text": "k k k/i i m m > k m k/m m+1 k/(m+1) k/(m+1) k/m * (k/(m+1)*(1-1/k) + (1-k/(m+1))) k/(m+1)"
},
{
"answer_id": 21201378,
"author": "Richard",
"author_id": 752843,
"author_profile": "https://Stackoverflow.com/users/752843",
"pm_score": 6,
"selected": true,
"text": "Let R be the result array of size s\nLet I be an input queue\n\n> Fill the reservoir array\nfor j in the range [1,s]:\n R[j]=I.pop()\n\nelements_seen=s\nwhile I is not empty:\n elements_seen+=1\n j=random(1,elements_seen) > This is inclusive\n if j<=s:\n R[j]=I.pop()\n else:\n I.pop()\n R R s n>s s s/n n+1 s/(n+1) 1/s n n+1 (1/s)*s/(n+1)=1/(n+1) 1-1/(n+1)=n/(n+1) n+1 n (s/n)*n/(n+1)=s/(n+1) s/(n+1) s n=s n-seen s/n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] |
54,068 |
<p>I'm looking at a new computer which will probably have vista on it. But there are so many editions of vista; are there any weird restrictions on what you can run on the various editions? For instance you couldn't run IIS on Windows ME. Can you still run IIS on the home editions of vista? </p>
|
[
{
"answer_id": 54072,
"author": "Christian Oudard",
"author_id": 3757,
"author_profile": "https://Stackoverflow.com/users/3757",
"pm_score": -1,
"selected": false,
"text": "O(N*k)"
},
{
"answer_id": 54083,
"author": "George Mauer",
"author_id": 5056,
"author_profile": "https://Stackoverflow.com/users/5056",
"pm_score": -1,
"selected": false,
"text": "List GetKRandomFromList(List input, int k)\n List ret = new List();\n for(i=0;i<k;i++)\n ret.Add(input[Math.Rand(0,input.Length)]);\n return ret;\n"
},
{
"answer_id": 54174,
"author": "mweerden",
"author_id": 4285,
"author_profile": "https://Stackoverflow.com/users/4285",
"pm_score": 1,
"selected": false,
"text": "k k k/i i m m > k m k/m m+1 k/(m+1) k/(m+1) k/m * (k/(m+1)*(1-1/k) + (1-k/(m+1))) k/(m+1)"
},
{
"answer_id": 21201378,
"author": "Richard",
"author_id": 752843,
"author_profile": "https://Stackoverflow.com/users/752843",
"pm_score": 6,
"selected": true,
"text": "Let R be the result array of size s\nLet I be an input queue\n\n> Fill the reservoir array\nfor j in the range [1,s]:\n R[j]=I.pop()\n\nelements_seen=s\nwhile I is not empty:\n elements_seen+=1\n j=random(1,elements_seen) > This is inclusive\n if j<=s:\n R[j]=I.pop()\n else:\n I.pop()\n R R s n>s s s/n n+1 s/(n+1) 1/s n n+1 (1/s)*s/(n+1)=1/(n+1) 1-1/(n+1)=n/(n+1) n+1 n (s/n)*n/(n+1)=s/(n+1) s/(n+1) s n=s n-seen s/n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/361/"
] |
54,092 |
<p><br />
I need to send MMS thought a C# application. I have already found 2 interesting components:
<a href="http://www.winwap.com" rel="nofollow noreferrer">http://www.winwap.com</a><br />
<a href="http://www.nowsms.com" rel="nofollow noreferrer">http://www.nowsms.com</a></p>
<p>Does anyone have experience with other third party components?<br />
Could someone explain what kind of server I need to send those MMS? Is it a classic SMTP Server? </p>
|
[
{
"answer_id": 32959714,
"author": "rickyrobinett",
"author_id": 3037626,
"author_profile": "https://Stackoverflow.com/users/3037626",
"pm_score": 0,
"selected": false,
"text": " // Send a new outgoing MMS by POSTing to the Messages resource */\n client.SendMessage(\n \"YYY-YYY-YYYY\", // From number, must be an SMS-enabled Twilio number\n person.Key, // To number, if using Sandbox see note above\n // message content\n string.Format(\"Hey {0}, Monkey Party at 6PM. Bring Bananas!\", person.Value),\n // media url of the image\n new string[] {\"https://demo.twilio.com/owl.png\" }\n );\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/296/"
] |
54,096 |
<p>I got a little curious after reading <a href="http://it.slashdot.org/it/08/09/09/1558218.shtml" rel="noreferrer">this /. article</a> over hijacking HTTPS cookies. I tracked it down a bit, and a good resource I stumbled across lists a few ways to secure cookies <a href="http://casabasecurity.com/content/using-aspnet-session-handling-secure-sites-set-secure-flag" rel="noreferrer">here</a>. Must I use adsutil, or will setting requireSSL in the httpCookies section of web.config cover session cookies in addition to all others (<a href="http://msdn2.microsoft.com/en-us/library/ms228262.aspx" rel="noreferrer">covered here</a>)? Is there anything else I should be considering to harden sessions further?</p>
|
[
{
"answer_id": 32959714,
"author": "rickyrobinett",
"author_id": 3037626,
"author_profile": "https://Stackoverflow.com/users/3037626",
"pm_score": 0,
"selected": false,
"text": " // Send a new outgoing MMS by POSTing to the Messages resource */\n client.SendMessage(\n \"YYY-YYY-YYYY\", // From number, must be an SMS-enabled Twilio number\n person.Key, // To number, if using Sandbox see note above\n // message content\n string.Format(\"Hey {0}, Monkey Party at 6PM. Bring Bananas!\", person.Value),\n // media url of the image\n new string[] {\"https://demo.twilio.com/owl.png\" }\n );\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54096",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212/"
] |
54,104 |
<p>Surprisingly as you get good at vim, you can code even faster than standard IDEs such as Eclipse. But one thing I really miss is code completion, especially for long variable names and functions.</p>
<p>Is there any way to enable code completion for Perl in vim?</p>
|
[
{
"answer_id": 54116,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 3,
"selected": false,
"text": "autocmd FileType php set omnifunc=phpcomplete#CompletePHP\n"
},
{
"answer_id": 72727,
"author": "Matt Siegman",
"author_id": 12299,
"author_profile": "https://Stackoverflow.com/users/12299",
"pm_score": 2,
"selected": false,
"text": "inoremap <tab> <c-r>=InsertTabWrapper()<cr>\n\nfunction! InsertTabWrapper()\n let col = col('.') - 1\n if !col || getline('.')[col - 1] !~ '\\k'\n return \"\\<tab>\"\n else\n return \"\\<c-p>\"\n endif\nendfunction\n"
},
{
"answer_id": 75131,
"author": "Mark Grimes",
"author_id": 13233,
"author_profile": "https://Stackoverflow.com/users/13233",
"pm_score": 3,
"selected": false,
"text": "~/.vim/ftplugin/perl.vim set iskeyword+=:\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54104",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] |
54,118 |
<p>Database? Page variables? Enum?</p>
<p>I'm looking for opinions here. </p>
|
[
{
"answer_id": 57722,
"author": "Zack Peterson",
"author_id": 83,
"author_profile": "https://Stackoverflow.com/users/83",
"pm_score": 1,
"selected": false,
"text": "<asp:SiteMapPath ID=\"SiteMapPath1\" runat=\"server\" />\n<asp:Menu ID=\"Menu1\" runat=\"server\" DataSourceID=\"SiteMapDataSource2\" />\n<asp:TreeView ID=\"TreeView1\" runat=\"server\" DataSourceID=\"SiteMapDataSource1\" />\n<asp:SiteMapDataSource ID=\"SiteMapDataSource1\" runat=\"server\" />\n<asp:SiteMapDataSource ID=\"SiteMapDataSource2\" runat=\"server\" ShowStartingNode=\"False\" />\n <?xml version=\"1.0\"?>\n<configuration>\n ...\n <system.web>\n ...\n <siteMap defaultProvider=\"default\">\n <providers>\n <clear/>\n <add name=\"default\"\n type=\"System.Web.XmlSiteMapProvider\"\n siteMapFile=\"web.sitemap\"\n securityTrimmingEnabled=\"true\"/>\n </providers>\n </siteMap>\n ...\n </system.web>\n ...\n</configuration>\n Protected Sub TreeView1_DataBound( ByVal sender As Object, ByVal e As EventArgs ) Handles TreeView1.DataBound\n\n 'Collapse unnecessary menu items...\n If TreeView1.SelectedNode IsNot Nothing Then\n Dim n As TreeNode = TreeView1.SelectedNode\n TreeView1.CollapseAll()\n n.Expand()\n Do Until n.Parent Is Nothing\n n = n.Parent\n n.Expand()\n Loop\n Else\n TreeView1.ExpandAll()\n End If\n\nEnd Sub\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4140/"
] |
54,138 |
<p>I have a third-party app that creates HTML-based reports that I need to display. I have <em>some</em> control over how they look, but in general it's pretty primitive. I <em>can</em> inject some javascript, though. I'd like to try to inject some jQuery goodness into it to tidy it up some. One specific thing I would like to do is to take a table (an actual HTML <table>) that always contains one row and a variable number of columns and magically convert that into a tabbed view where the contents (always one <div> that I can supply an ID if necessary) of each original table cell represents a sheet in the tabbed view. I haven't found any good (read: simple) examples of re-parenting items like this, so I'm not sure where to begin. Can someone provide some hints on how I might try this?</p>
|
[
{
"answer_id": 54190,
"author": "samjudson",
"author_id": 1908,
"author_profile": "https://Stackoverflow.com/users/1908",
"pm_score": 0,
"selected": false,
"text": "<ul> <div>'s"
},
{
"answer_id": 76943,
"author": "Rich McCollister",
"author_id": 9306,
"author_profile": "https://Stackoverflow.com/users/9306",
"pm_score": 3,
"selected": true,
"text": "<body><br/>\n <table id=\"my-table\">`<br/>\n <tr><br/>\n <td><div>This is the contents of Column One</div></td><br/>\n <td><div>This is the contents of Column Two</div></td><br/>\n <td><div>This is the contents of Column Three</div></td><br/>\n <td><div>Contents of Column Four blah blah</div></td><br/>\n <td><div>Column Five is here</div></td><br/>\n </tr><br/>\n </table><br/>\n</body><br/>\n $(document).ready(function() {\n var tabCounter = 1;\n $(\"#my-table\").after(\"<div id='tab-container' class='flora'><ul id='tab-list'></ul></div>\");\n $(\"#my-table div\").appendTo(\"#tab-container\").each(function() { \n var id = \"fragment-\" + tabCounter;\n $(this).attr(\"id\", id);\n $(\"#tab-list\").append(\"<li><span><a href='#\" + id + \"'>Tab \" + tabCounter + \"</a></span></li>\");\n tabCounter++;\n });\n $(\"#tab-container > ul\").tabs();\n});\n"
},
{
"answer_id": 1091573,
"author": "fbuchinger",
"author_id": 113936,
"author_profile": "https://Stackoverflow.com/users/113936",
"pm_score": 0,
"selected": false,
"text": "var mycontent = $('table tr[:first-child]').find('td[:first-child]').html()\n $('body').append($('<div></div>').attr('id','mytabs'));\n$('#mytabs').tabs({}); //specify tab preferences here\n$('#mytabs').tabs('add',mycontent);\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/404/"
] |
54,142 |
<p>How does the comma operator work in C++?</p>
<p>For instance, if I do:</p>
<pre><code>a = b, c;
</code></pre>
<p>Does a end up equaling b or c? </p>
<p>(Yes, I know this is easy to test - just documenting on here for someone to find the answer quickly.)</p>
<p><strong>Update:</strong> This question has exposed a nuance when using the comma operator. Just to document this:</p>
<pre><code>a = b, c; // a is set to the value of b!
a = (b, c); // a is set to the value of c!
</code></pre>
<p>This question was actually inspired by a typo in code. What was intended to be</p>
<pre><code>a = b;
c = d;
</code></pre>
<p>Turned into</p>
<pre><code>a = b, // <- Note comma typo!
c = d;
</code></pre>
|
[
{
"answer_id": 54146,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 7,
"selected": true,
"text": "b"
},
{
"answer_id": 54172,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 7,
"selected": false,
"text": "keywords = \"and\", \"or\", \"not\", \"xor\";\n (((keywords = \"and\"), \"or\"), \"not\"), \"xor\";\n keywords.operator =(\"and\") operator, keywords.operator =(\"and\").operator ,(\"or\").operator ,(\"not\").operator ,(\"xor\");\n"
},
{
"answer_id": 65438,
"author": "MobyDX",
"author_id": 3923,
"author_profile": "https://Stackoverflow.com/users/3923",
"pm_score": 5,
"selected": false,
"text": "a b c d = (a = b, c);\n a b d c"
},
{
"answer_id": 114404,
"author": "efotinis",
"author_id": 12320,
"author_profile": "https://Stackoverflow.com/users/12320",
"pm_score": 7,
"selected": false,
"text": "a = b, c;\n (a = b), c;\n a+b, c(), d\n someFunc(arg1, arg2, arg3)\n"
},
{
"answer_id": 15861440,
"author": "Quonux",
"author_id": 388614,
"author_profile": "https://Stackoverflow.com/users/388614",
"pm_score": -1,
"selected": false,
"text": "class Example {\n Foo<int, char*> ContentA;\n}\n < > , for(a=5,b=0;a<42;a++,b--)\n ...\n for a = b, c;\n (a = b), c;\n = , a = b;\nc;\n"
},
{
"answer_id": 19198977,
"author": "CygnusX1",
"author_id": 635654,
"author_profile": "https://Stackoverflow.com/users/635654",
"pm_score": 6,
"selected": false,
"text": "exprA , exprB exprA exprA exprB exprB false && foo() foo if( HERE ) for for ( HERE ; ; ) if (foo) HERE ; (foo, if (foo) bar) if a=b, c; a=b; c; a a = b, c = d; a=b; c=d; a int a, b; int a=5, b=3; foo(x,y) x y FOO(x,y) foo<a,b> int foo(int a, int b) Foo::Foo() : a(5), b(3) {}"
},
{
"answer_id": 31221185,
"author": "Roopam",
"author_id": 3529776,
"author_profile": "https://Stackoverflow.com/users/3529776",
"pm_score": 2,
"selected": false,
"text": "#include<stdio.h>\nint main()\n{\n int i;\n i = (1,2,3);\n printf(\"i:%d\\n\",i);\n return 0;\n}\n int main()\n{\n int i;\n i = 1,2,3;\n printf(\"i:%d\\n\",i);\n return 0;\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1541/"
] |
54,147 |
<p>I want to insert some special characters at the caret inside textboxes using javascript on a button. How can this be done?</p>
<p>The script needs to find the active textbox and insert the character at the caret in that textbox. The script also needs to work in IE and Firefox.</p>
<p><strong>EDIT:</strong> It is also ok to insert the character "last" in the previously active textbox.</p>
|
[
{
"answer_id": 54167,
"author": "Brian Warshaw",
"author_id": 1344,
"author_profile": "https://Stackoverflow.com/users/1344",
"pm_score": 0,
"selected": false,
"text": "onblur"
},
{
"answer_id": 54269,
"author": "Brian Warshaw",
"author_id": 1344,
"author_profile": "https://Stackoverflow.com/users/1344",
"pm_score": 1,
"selected": false,
"text": "var inputs = document.getElementsByTagName('input');\nvar lastTextBox = null;\n\nfor(var i = 0; i < inputs.length; i++)\n{\n if(inputs[i].getAttribute('type') == 'text')\n {\n inputs[i].onfocus = function() {\n lastTextBox = this;\n }\n }\n}\n\nvar button = document.getElementById(\"YOURBUTTONID\");\nbutton.onclick = function() {\n lastTextBox.value += 'PUTYOURTEXTHERE';\n}\n"
},
{
"answer_id": 58369,
"author": "bmb",
"author_id": 5298,
"author_profile": "https://Stackoverflow.com/users/5298",
"pm_score": 2,
"selected": false,
"text": "<html><head></head><body>\n\n<script language=\"JavaScript\">\n<!--\n\nvar lasttext;\n\nfunction doinsert_ie() {\n var oldtext = lasttext.value;\n var marker = \"##MARKER##\";\n lasttext.focus();\n var sel = document.selection.createRange();\n sel.text = marker;\n var tmptext = lasttext.value;\n var curpos = tmptext.indexOf(marker);\n pretext = oldtext.substring(0,curpos);\n posttest = oldtext.substring(curpos,oldtext.length);\n lasttext.value = pretext + \"|\" + posttest;\n}\n\nfunction doinsert_ff() {\n var oldtext = lasttext.value;\n var curpos = lasttext.selectionStart;\n pretext = oldtext.substring(0,curpos);\n posttest = oldtext.substring(curpos,oldtext.length);\n lasttext.value = pretext + \"|\" + posttest;\n}\n\n-->\n</script>\n\n\n<form name=\"testform\">\n<input type=\"text\" name=\"testtext1\" onBlur=\"lasttext=this;\">\n<input type=\"text\" name=\"testtext2\" onBlur=\"lasttext=this;\">\n<input type=\"text\" name=\"testtext3\" onBlur=\"lasttext=this;\">\n\n</form>\n<a href=\"#\" onClick=\"doinsert_ie();\">Insert IE</a>\n<br>\n<a href=\"#\" onClick=\"doinsert_ff();\">Insert FF</a>\n</body></html>\n"
},
{
"answer_id": 14401812,
"author": "CraigDub",
"author_id": 1983541,
"author_profile": "https://Stackoverflow.com/users/1983541",
"pm_score": 0,
"selected": false,
"text": "var lasttext;\n\nfunction doinsert_ie() {\n var ttInsert = \"bla\";\n lasttext.focus();\n var sel = document.selection.createRange();\n sel.text = ttInsert;\n sel.select();\n}\n\nfunction doinsert_ff() {\n var oldtext = lasttext.value;\n var curposS = lasttext.selectionStart;\n var curposF = lasttext.selectionEnd;\n pretext = oldtext.substring(0,curposS);\n posttest = oldtext.substring(curposF,oldtext.length);\n var ttInsert='bla';\n lasttext.value = pretext + ttInsert + posttest;\n lasttext.selectionStart=curposS+ttInsert.length;\n lasttext.selectionEnd=curposS+ttInsert.length;\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1523/"
] |
54,176 |
<p>I'm looking at improving the performance of some SQL, currently CTEs are being used and referenced multiple times in the script. Would I get improvements using a table variable instead? (Can't use a temporary table as the code is within functions).</p>
|
[
{
"answer_id": 73371261,
"author": "Shnugo",
"author_id": 5089204,
"author_profile": "https://Stackoverflow.com/users/5089204",
"pm_score": 3,
"selected": false,
"text": "WITH() USE master; --in my case the master database has just 5 \"user tables\", you can use any other DB of course\nGO\n \n--simple join, first the small set joining to the large set\nSELECT o.name AS TableName\n ,c.name AS ColumnName\nFROM sys.objects o\nINNER JOIN sys.columns c ON c.object_id=o.object_id \nWHERE o.type='U';\nGO\n\n--simple join \"the other way round\" with the filter as part of the ON-clause\nSELECT o.name AS TableName\n ,c.name AS ColumnName\nFROM sys.columns c\nINNER JOIN sys.objects o ON c.object_id=o.object_id AND o.type='U';\nGO\n\n--join from the large set with a sub-query to the small set\nSELECT o.name AS TableName\n ,c.name AS ColumnName\nFROM sys.columns c\nINNER JOIN (\n SELECT o.* \n FROM sys.objects o\n WHERE o.type='U' --user tables \n) o ON c.object_id=o.object_id;\nGO\n\n--join for large to small with a row-wise APPLY\nSELECT o.name AS TableName\n ,c.name AS ColumnName\nFROM sys.columns c\nCROSS APPLY (\n SELECT o.* \n FROM sys.objects o\n WHERE o.type='U' --user tables \n AND o.object_id=c.object_id\n) o;\nGO\n\n--use a CTE to \"pre-filter\" the small set\nWITH cte AS\n(\n SELECT o.* \n FROM sys.objects o\n WHERE o.type='U' --user tables \n)\nSELECT cte.name AS TableName\n ,c.name AS ColumnName\nFROM sys.columns c\nINNER JOIN cte ON c.object_id=cte.object_id;\nGO\n VIEW CTE TRY_CAST JOIN CROSS JOIN DELETE FORCE ORDER wrong syntax ; ;WITH"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5556/"
] |
54,188 |
<p>I have two threads, one updating an int and one reading it. This is a statistic value where the order of the reads and writes is irrelevant.</p>
<p>My question is, do I need to synchronize access to this multi-byte value anyway? Or, put another way, can part of the write be complete and get interrupted, and then the read happen.</p>
<p>For example, think of a value = 0x0000FFFF that gets incremented value of 0x00010000.</p>
<p>Is there a time where the value looks like 0x0001FFFF that I should be worried about? Certainly the larger the type, the more possible something like this to happen.</p>
<p>I've always synchronized these types of accesses, but was curious what the community thinks.</p>
|
[
{
"answer_id": 3378960,
"author": "siddhusingh",
"author_id": 306819,
"author_profile": "https://Stackoverflow.com/users/306819",
"pm_score": 0,
"selected": false,
"text": "int x;\nx++;\nx=x+5;\n x=5;\n"
},
{
"answer_id": 9903090,
"author": "etham",
"author_id": 806286,
"author_profile": "https://Stackoverflow.com/users/806286",
"pm_score": 0,
"selected": false,
"text": "movl cpt.1586(%rip), %eax\naddl $1, %eax\nmovl %eax, cpt.1586(%rip)\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2167252/"
] |
54,199 |
<p>How to implement Repository pattern withe LinqToEntities
how to implement the interface </p>
|
[
{
"answer_id": 3378960,
"author": "siddhusingh",
"author_id": 306819,
"author_profile": "https://Stackoverflow.com/users/306819",
"pm_score": 0,
"selected": false,
"text": "int x;\nx++;\nx=x+5;\n x=5;\n"
},
{
"answer_id": 9903090,
"author": "etham",
"author_id": 806286,
"author_profile": "https://Stackoverflow.com/users/806286",
"pm_score": 0,
"selected": false,
"text": "movl cpt.1586(%rip), %eax\naddl $1, %eax\nmovl %eax, cpt.1586(%rip)\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2442689/"
] |
54,200 |
<p>I am developing a web app which requires a username and password to be stored in the web.Config, it also refers to some URLs which will be requested by the web app itself and never the client.</p>
<p>I know the .Net framework will not allow a web.config file to be served, however I still think its bad practice to leave this sort of information in plain text. </p>
<p>Everything I have read so far requires me to use a command line switch or to store values in the registry of the server. I have access to neither of these as the host is online and I have only FTP and Control Panel (helm) access.</p>
<p>Can anyone recommend any good, free encryption DLL's or methods which I can use? I'd rather not develop my own!</p>
<p>Thanks for the feedback so far guys but I am not able to issue commands and and not able to edit the registry. Its going to have to be an encryption util/helper but just wondering which one!</p>
|
[
{
"answer_id": 40489084,
"author": "Matt",
"author_id": 1016343,
"author_profile": "https://Stackoverflow.com/users/1016343",
"pm_score": 2,
"selected": false,
"text": "C: D:\\Apps\\myApp cd \"C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\" Framework Framework64 cd /D \"D:\\Apps\\myApp\" /D D:\\Apps\\myApp c:aspnet_regiis -pef appConfig . -pdf -pef aspnet_regiis -pe \"connectionStrings\" -app \"/SampleApplication\"\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2208/"
] |
54,207 |
<p>I have an internal enterprise app that currently consumes 10 different web services. They're consumed via old style "Web References" instead of using WCF.</p>
<p>The problem I'm having is trying to work with the other teams in the company who are authoring the services I'm consuming. I found I needed to capture the exact SOAP messages that I'm sending and receiving. I did this by creating a new attribute that extends SoapExtensionAttribute. I then just add that attribute to the service method in the generated Reference.cs file. This works, but is painful for two reasons. First, it's a generated file so anything I do in there can be overwritten. Second, I have to remember to remove the attribute before checking in the file.</p>
<p><strong>Is There a better way to capture the exact SOAP messages that I am sending and receiving?</strong></p>
|
[
{
"answer_id": 54306,
"author": "NotMyself",
"author_id": 303,
"author_profile": "https://Stackoverflow.com/users/303",
"pm_score": 0,
"selected": false,
"text": "<System.Diagnostics.Conditional(\"DEBUG\")> _\n Private Sub CheckHTTPRequest(ByVal functionName As String)\n Dim e As New UTF8Encoding()\n\n Dim bytes As Long = Me.Context.Request.InputStream.Length\n Dim stream(bytes) As Byte\n Me.Context.Request.InputStream.Seek(0, IO.SeekOrigin.Begin)\n Me.Context.Request.InputStream.Read(stream, 0, CInt(bytes))\n\n Dim thishttpRequest As String = e.GetString(stream)\n\n My.Computer.FileSystem.WriteAllText(\"D:\\SoapRequests\\\" & functionName & \".xml\", thishttpRequest, False)\n\n End Sub\n"
},
{
"answer_id": 307039,
"author": "David Chappelle",
"author_id": 7475,
"author_profile": "https://Stackoverflow.com/users/7475",
"pm_score": 3,
"selected": true,
"text": "Reference.cs app.config"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2595/"
] |
54,219 |
<p>I'm working on an editor for files that are used by an important internal testing tool we use. The tool itself is large, complicated, and refactoring or rewriting would take more resources than we are able to devote to it for the forseeable future, so my hands are tied when it comes to large modifications. I must use a .NET language.</p>
<p>The files are XML serialized versions of four classes that are used by the tool (let's call them A, B, C, and D). The classes form a tree structure when all is well. Our editor works by loading a set of files, deserializing them, working out the relationships between them, and keeping track of any bad states it can find. The idea is for us to move away from hand-editing these files, which introduces tons of errors.</p>
<p>For a particular type of error, I'd like to maintain a collection of all files that have the problem. All four classes can have the problem, and I'd like to reduce duplication of code as much as possible. An important requirement is the user needs to be able to get the items in sets; for example, they need to get all A objects with an error, and telling them to iterate over the whole collection and pick out what they want is unacceptable compared to a <code>GetAs()</code> method. So, my first thought was to make a generic item that related the deserialized object and some metadata to indicate the error:</p>
<pre><code>public class ErrorItem<T>
{
public T Item { get; set; }
public Metadata Metadata { get; set; }
}
</code></pre>
<p>Then, I'd have a collection class that could hold all of the error items, with helper methods to extract the items of a specific class when the user needs them. This is where the trouble starts.</p>
<p>None of the classes inherit from a common ancestor (other than <code>Object</code>). This was probably a mistake of the initial design, but I've spent a few days thinking about it and the classes really don't have much in common other than a GUID property that uniquely identifies each item so I can see why the original designer did not relate them through inheritance. This means that the unified error collection would need to store <code>ErrorItem<Object></code> objects, since I don't have a base class or interface to restrict what comes in. However, this makes the idea of this unified collection a little sketchy to me:</p>
<pre><code>Public Class ErrorCollection
{
public ErrorItem<Object> AllItems { get; set; }
}
</code></pre>
<p>However, this has consequences on the public interface. What I really want is to return the appropriate <code>ErrorItem</code> generic type like this:</p>
<pre><code>public ErrorItem<A>[] GetA()
</code></pre>
<p>This is impossible because I can only store <code>ErrorItem<Object></code>! I've gone over some workarounds in my head; mostly they include creating a new <code>ErrorItem</code> of the appropriate type on-the-fly, but it just feels kind of ugly. Another thought has been using a <code>Dictionary</code> to keep items organized by type, but it still doesn't seem right.</p>
<p>Is there some kind of pattern that might help me here? I know the easiest way to solve this is to add a base class that A, B, C, and D derive from, but I'm trying to have as small an impact on the original tool as possible. Is the cost of any workaround great enough that I should push to change the initial tool?</p>
|
[
{
"answer_id": 54287,
"author": "fryguybob",
"author_id": 4592,
"author_profile": "https://Stackoverflow.com/users/4592",
"pm_score": 1,
"selected": false,
"text": "private List<ErrorItem<object>> _allObjects = new List<ErrorItem<object>>();\n\npublic IEnumerable<ErrorItem<A>> ItemsOfA\n{\n get\n {\n foreach (ErrorItem<object> obj in _allObjects)\n {\n if (obj.Item is A)\n yield return new ErrorItem<A>((A)obj.Item, obj.MetaData);\n }\n }\n}\n ItemsOfA private List<ErrorItem<A>> _itemsOfA = null;\n\npublic IEnumerable<ErrorItem<A>> ItemsOfACached\n{\n if (_itemsOfA == null)\n _itemsOfA = new List<ErrorItem<A>>(ItemsOfA);\n return _itemsOfA;\n}\n"
},
{
"answer_id": 54649,
"author": "OwenP",
"author_id": 2547,
"author_profile": "https://Stackoverflow.com/users/2547",
"pm_score": 1,
"selected": false,
"text": "ErrorItem<BaseClass> yield return"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2547/"
] |
54,227 |
<p>I have an asp.net url path which is being generated in a web form, and is coming out something like "/foo/bar/../bar/path.aspx", and is coming out in the generated html like this too. It should be shortened to "/foo/bar/path.aspx". </p>
<p>Path.Combine didn't fix it. Is there a function to clean this path up? </p>
|
[
{
"answer_id": 54273,
"author": "Compile This",
"author_id": 4048,
"author_profile": "https://Stackoverflow.com/users/4048",
"pm_score": 3,
"selected": true,
"text": "public static class UriHelper\n{ \n public static string NormalizeRelativePath(string path)\n {\n UriBuilder _builder = new UriBuilder(\"http://localhost\");\n builder.Path = path;\n return builder.Uri.AbsolutePath;\n }\n}\n string url = \"foo/bar/../bar/path.aspx\";\nConsole.WriteLine(UriHelper.NormalizeRelativePath(url));\n"
},
{
"answer_id": 54289,
"author": "Ishmaeel",
"author_id": 227,
"author_profile": "https://Stackoverflow.com/users/227",
"pm_score": 0,
"selected": false,
"text": "myPath = System.IO.Path.GetFullPath(myPath);\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5599/"
] |
54,237 |
<p>I want to link to bookmark on a page (mysite.com/mypage.htm#bookmark) AND visually highlight the item that was bookmarked (maybe having a red border). Naturally, there would be multiple items bookmarked. So that if someone clicked on #bookmark2 then <em>that</em> other area would be highlighted). </p>
<p>I can see how to do that with .asp or .aspx but I'd like to do it more simply than that. I thought maybe there was a clever way to do it with CSS.</p>
<p>WHY I'm interested:
- I want to have our programs link to a shopping page that lists all the programs on it. I'm using a bookmark so they're jumping to the particular program area (site.com/shoppingpage#Programx) but just to make it <em>obvious</em> I'd like to actually highlight the page being linked to.</p>
|
[
{
"answer_id": 54278,
"author": "Kevin",
"author_id": 2678,
"author_profile": "https://Stackoverflow.com/users/2678",
"pm_score": 2,
"selected": false,
"text": "jQuery(location.hash).addClass('highlight');\n"
},
{
"answer_id": 54326,
"author": "Pat",
"author_id": 238,
"author_profile": "https://Stackoverflow.com/users/238",
"pm_score": 4,
"selected": true,
"text": "a.highlight {border:1px solid red;}\n $(document).ready ( function () { //Work as soon as the DOM is ready for parsing\n var id = location.hash.substr(1); //Get the word after the hash from the url\n if (id) $('#'+id).addClass('highlight'); // add class highlight to element whose id is the word after the hash\n});\n $(\"a[href^='#']\")\n .mouseover(function() {\n var id = $(this).attr('href').substr(1);\n $('#'+id).addClass('highlight');\n })\n .mouseout(function() {\n var id = $(this).attr('href').substr(1);\n $('#'+id).removeClass('highlight');\n });\n"
},
{
"answer_id": 55530,
"author": "chrisofspades",
"author_id": 2614,
"author_profile": "https://Stackoverflow.com/users/2614",
"pm_score": 3,
"selected": false,
"text": "target <html>\n<head>\n\n<style type=\"text/css\">\ndiv#test:target {\n background-color: yellow;\n}\n</style>\n\n</head>\n<body>\n\n<p><b><a href=\"#test\">Link</a></b></p>\n\n<div id=\"test\">\nTarget\n</div>\n\n</body>\n</html>\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54237",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4906/"
] |
54,255 |
<p>Using Vim I often want to replace a block of code with a block that I just yanked.</p>
<p>But when I delete the block of code that is to be replaced, that block itself goes into the register which erases the block I just yanked. So I've got in the habit of yanking, then inserting, then deleting what I didn't want, but with large blocks of code this gets messy trying to keep the inserted block and the block to delete separate.</p>
<p>So what is the slickest and quickest way to replace text in Vim?</p>
<ul>
<li>is there a way to delete text without putting it into the register?</li>
<li>is there a way to say e.g. "replace next word" or "replace up to next paragraph"</li>
<li>or is the best way to somehow use the multi-register feature?</li>
</ul>
|
[
{
"answer_id": 54265,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 3,
"selected": false,
"text": ":h d\n"
},
{
"answer_id": 54272,
"author": "EBGreen",
"author_id": 1358,
"author_profile": "https://Stackoverflow.com/users/1358",
"pm_score": 5,
"selected": false,
"text": "*Highlight what you want to put somewhere else\n*delete (d)\n*Highlight the code that you want it to replace\n*paste (p)\n"
},
{
"answer_id": 54422,
"author": "maeghith",
"author_id": 5614,
"author_profile": "https://Stackoverflow.com/users/5614",
"pm_score": 3,
"selected": false,
"text": "ggVjyGVkp gg V j y G V k p \"ay \"ap :he mark"
},
{
"answer_id": 54434,
"author": "Christian Berg",
"author_id": 5035,
"author_profile": "https://Stackoverflow.com/users/5035",
"pm_score": 10,
"selected": true,
"text": "\"_d\n"
},
{
"answer_id": 58607,
"author": "Swaroop C H",
"author_id": 4869,
"author_profile": "https://Stackoverflow.com/users/4869",
"pm_score": 3,
"selected": false,
"text": "cw cap"
},
{
"answer_id": 58637,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 7,
"selected": false,
"text": "line1\nline2\nline3\nline4\n\nold1\nold2\nold3\nold4\n \"2p\n \"3p line1\nline2\nline3\nline4\n"
},
{
"answer_id": 62959,
"author": "JayG",
"author_id": 5823,
"author_profile": "https://Stackoverflow.com/users/5823",
"pm_score": 2,
"selected": false,
"text": "\"*y \"*p"
},
{
"answer_id": 509557,
"author": "alex2k8",
"author_id": 62192,
"author_profile": "https://Stackoverflow.com/users/62192",
"pm_score": 6,
"selected": false,
"text": "\"0p"
},
{
"answer_id": 920139,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": "\" it's a capital 'p' at the end\nvmap r \"_dP\n vmap - mapping for visual mode\n\"_d - delete current selection into \"black hole register\"\nP - paste\n"
},
{
"answer_id": 1290230,
"author": "Magnus",
"author_id": 136815,
"author_profile": "https://Stackoverflow.com/users/136815",
"pm_score": 5,
"selected": false,
"text": "noremap y \"*y\nnoremap Y \"*Y\nnoremap p \"*p\nnoremap P \"*P\nvnoremap y \"*y\nvnoremap Y \"*Y\nvnoremap p \"*p\nvnoremap P \"*P\n"
},
{
"answer_id": 2557670,
"author": "idbrii",
"author_id": 79125,
"author_profile": "https://Stackoverflow.com/users/79125",
"pm_score": 4,
"selected": false,
"text": "\"0p :registers\n :help registers cW cW W"
},
{
"answer_id": 5370718,
"author": "expelledboy",
"author_id": 644945,
"author_profile": "https://Stackoverflow.com/users/644945",
"pm_score": 2,
"selected": false,
"text": "VISUAL yiw \" yank the whole word\nviwp \" replace any word with the default register\n <ctrl>+<p> <C-P>"
},
{
"answer_id": 28726374,
"author": "Hieu Nguyen",
"author_id": 1087430,
"author_profile": "https://Stackoverflow.com/users/1087430",
"pm_score": 2,
"selected": false,
"text": "xnoremap p \"_dP\n"
},
{
"answer_id": 32488853,
"author": "Torben",
"author_id": 398844,
"author_profile": "https://Stackoverflow.com/users/398844",
"pm_score": 4,
"selected": false,
"text": "0 0 p \"0 .vimrc noremap p \"0p\nnoremap P \"0P\nfor s:i in ['\"','*','+','-','.',':','%','/','=','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\n execute 'noremap \"'.s:i.'p \"'.s:i.'p'\n execute 'noremap \"'.s:i.'P \"'.s:i.'P'\nendfor\n p \"0p p p P p P 0 \"0d d noremap <LEADER>d \"0d\nnoremap <LEADER>D \"0D\n \\ \\d \\D :help timeoutlen set timeout timeoutlen=3000 ttimeoutlen=100\n"
},
{
"answer_id": 32954215,
"author": "Wayne",
"author_id": 592746,
"author_profile": "https://Stackoverflow.com/users/592746",
"pm_score": 5,
"selected": false,
"text": "0 1-9 1 0 \"_dd \"0p\n"
},
{
"answer_id": 50424088,
"author": "snap",
"author_id": 8578684,
"author_profile": "https://Stackoverflow.com/users/8578684",
"pm_score": 1,
"selected": false,
"text": "xnoremap <expr> p 'pgv\"'.v:register.'y' vnoremap p pgvy"
},
{
"answer_id": 52913326,
"author": "Adrien Vakili",
"author_id": 9033536,
"author_profile": "https://Stackoverflow.com/users/9033536",
"pm_score": 2,
"selected": false,
"text": "(evil-paste-pop) <C-p> p <C-p>"
},
{
"answer_id": 53872985,
"author": "Victoria Stuart",
"author_id": 1904943,
"author_profile": "https://Stackoverflow.com/users/1904943",
"pm_score": 3,
"selected": false,
"text": "Normal x x \"_d ~/.vimrc nnoremap x \"_x\n y d p x"
},
{
"answer_id": 58026614,
"author": "Eduard Kolosovskyi",
"author_id": 5385623,
"author_profile": "https://Stackoverflow.com/users/5385623",
"pm_score": 2,
"selected": false,
"text": "nnoremap d \"_d dd nnoremap dd \"_dd"
},
{
"answer_id": 60119781,
"author": "gregory",
"author_id": 2057509,
"author_profile": "https://Stackoverflow.com/users/2057509",
"pm_score": 3,
"selected": false,
"text": "nnoremap d \"dd \"send latest delete to d register\nnnoremap D \"dD \"send latest delete to d register \nnnoremap dd \"ddd \"send latest delete to d register\nnnoremap x \"_x \"send char deletes to black hole, not worth saving\nnnoremap <leader>p \"dp \"paste what was deleted\nnnoremap <leader>P \"dP \"paste what was deleted\n"
},
{
"answer_id": 62951993,
"author": "mohammadreza berneti",
"author_id": 3464834,
"author_profile": "https://Stackoverflow.com/users/3464834",
"pm_score": 2,
"selected": false,
"text": "{\n \"vim.normalModeKeyBindingsNonRecursive\": [\n {\n \"before\": [\"d\"],\n \"after\": [ \"\\\"\", \"_\", \"d\" ]\n }\n ]\n}\n"
},
{
"answer_id": 64529113,
"author": "sebtheiler",
"author_id": 10226703,
"author_profile": "https://Stackoverflow.com/users/10226703",
"pm_score": 0,
"selected": false,
"text": "q\"_dwq @d"
},
{
"answer_id": 64641073,
"author": "ZhiyuanLck",
"author_id": 9514052,
"author_profile": "https://Stackoverflow.com/users/9514052",
"pm_score": 0,
"selected": false,
"text": "p function! MyPaste(ex)\n let save_reg = @\"\n let reg = v:register\n let l:count = v:count1\n let save_map = maparg('_', 'v', 0, 1)\n exec 'vnoremap _ '.a:ex\n exec 'normal gv\"'.reg.l:count.'_'\n call mapset('v', 0, save_map)\n let @\" = save_reg\nendfunction\n\nvmap p :<c-u>call MyPaste('p')<cr>\nvmap P :<c-u>call MyPaste('P')<cr>\n"
},
{
"answer_id": 65785248,
"author": "Jacob Vanus",
"author_id": 1249891,
"author_profile": "https://Stackoverflow.com/users/1249891",
"pm_score": 0,
"selected": false,
"text": "# highlight text you want to copy, then:\n\"py\n # delete or highlight the text you want to replace, then:\n\"pp\n \"pp"
},
{
"answer_id": 66926326,
"author": "WalksB",
"author_id": 6382242,
"author_profile": "https://Stackoverflow.com/users/6382242",
"pm_score": 0,
"selected": false,
"text": "noremap mm m noremap mx \"_x"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] |
54,295 |
<p>I'd like to store a properties file as XML. Is there a way to sort the keys when doing this so that the generated XML file will be in alphabetical order? </p>
<pre><code>String propFile = "/path/to/file";
Properties props = new Properties();
/*set some properties here*/
try {
FileOutputStream xmlStream = new FileOutputStream(propFile);
/*this comes out unsorted*/
props.storeToXML(xmlStream,"");
} catch (IOException e) {
e.printStackTrace();
}
</code></pre>
|
[
{
"answer_id": 54316,
"author": "ScArcher2",
"author_id": 1310,
"author_profile": "https://Stackoverflow.com/users/1310",
"pm_score": 2,
"selected": false,
"text": "public static void main(String[] args){\n String propFile = \"/tmp/test2.xml\";\n Properties props = new Properties();\n props.setProperty(\"key\", \"value\");\n props.setProperty(\"key1\", \"value1\");\n props.setProperty(\"key2\", \"value2\");\n props.setProperty(\"key3\", \"value3\");\n props.setProperty(\"key4\", \"value4\");\n\n try {\n BufferedWriter out = new BufferedWriter(new FileWriter(propFile));\n List<String> list = new ArrayList<String>();\n for(Object o : props.keySet()){\n list.add((String)o);\n }\n Collections.sort(list);\n out.write(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\");\n out.write(\"<!DOCTYPE properties SYSTEM \\\"http://java.sun.com/dtd/properties.dtd\\\">\\n\");\n out.write(\"<properties>\\n\");\n out.write(\"<comment/>\\n\");\n for(String s : list){\n out.write(\"<entry key=\\\"\" + s + \"\\\">\" + props.getProperty(s) + \"</entry>\\n\");\n }\n out.write(\"</properties>\\n\");\n out.flush();\n out.close();\n } catch (IOException e) {\n e.printStackTrace();\n }\n }\n"
},
{
"answer_id": 54382,
"author": "Jay R.",
"author_id": 5074,
"author_profile": "https://Stackoverflow.com/users/5074",
"pm_score": 0,
"selected": false,
"text": "Set keys = props.keySet();\nIterator i = keys.iterator();\n Set keys = props.keySet();\nList<String> newKeys = new ArrayList<String>();\nfor(Object key : keys)\n{\n newKeys.add(key.toString());\n}\nCollections.sort(newKeys);\nIterator i = newKeys.iterator();\n"
},
{
"answer_id": 54402,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 2,
"selected": false,
"text": "new Properties() {\n @Override Set<Object> keySet() {\n return new TreeSet<Object>(super.keySet());\n }\n}\n"
},
{
"answer_id": 54454,
"author": "erickson",
"author_id": 3474,
"author_profile": "https://Stackoverflow.com/users/3474",
"pm_score": 6,
"selected": true,
"text": "String propFile = \"/path/to/file\";\nProperties props = new Properties();\n\n/* Set some properties here */\n\nProperties tmp = new Properties() {\n @Override\n public Set<Object> keySet() {\n return Collections.unmodifiableSet(new TreeSet<Object>(super.keySet()));\n }\n};\n\ntmp.putAll(props);\n\ntry {\n FileOutputStream xmlStream = new FileOutputStream(propFile);\n /* This comes out SORTED! */\n tmp.storeToXML(xmlStream,\"\");\n} catch (IOException e) {\n e.printStackTrace();\n}\n keySet keys() Hashtable keySet"
},
{
"answer_id": 3253071,
"author": "Espen",
"author_id": 392356,
"author_profile": "https://Stackoverflow.com/users/392356",
"pm_score": 4,
"selected": false,
"text": "Properties.store(OutputStream out, String comments) Properties.storeToXML(OutputStream os, String comment) Properties props = new Properties() {\n @Override\n public Set<Object> keySet(){\n return Collections.unmodifiableSet(new TreeSet<Object>(super.keySet()));\n }\n\n @Override\n public synchronized Enumeration<Object> keys() {\n return Collections.enumeration(new TreeSet<Object>(super.keySet()));\n }\n};\nprops.put(\"B\", \"Should come second\");\nprops.put(\"A\", \"Should come first\");\nprops.storeToXML(new FileOutputStream(new File(\"sortedProps.xml\")), null);\nprops.store(new FileOutputStream(new File(\"sortedProps.properties\")), null);\n"
},
{
"answer_id": 17982586,
"author": "Serg",
"author_id": 105037,
"author_profile": "https://Stackoverflow.com/users/105037",
"pm_score": 0,
"selected": false,
"text": "public static void save_sorted(Properties props, String filename) throws Throwable {\n FileOutputStream fos = new FileOutputStream(filename);\n Properties prop_sorted = new Properties() {\n @Override\n public Set<String> stringPropertyNames() {\n TreeSet<String> set = new TreeSet<String>();\n for (Object o : keySet()) {\n set.add((String) o);\n }\n return set;\n }\n };\n prop_sorted.putAll(props);\n prop_sorted.storeToXML(fos, \"test xml\");\n}\n"
},
{
"answer_id": 23092108,
"author": "trevorsky",
"author_id": 3203998,
"author_profile": "https://Stackoverflow.com/users/3203998",
"pm_score": 2,
"selected": false,
"text": "store entrySet public static void saveSorted(Properties props, FileWriter fw, String comment) throws IOException {\n Properties tmp = new Properties() {\n @Override\n public Set<Object> keySet() {\n return Collections.unmodifiableSet(new TreeSet<Object>(super.keySet()));\n }\n\n @Override\n public Set<java.util.Map.Entry<Object,Object>> entrySet() {\n TreeSet<java.util.Map.Entry<Object,Object>> tmp = new TreeSet<java.util.Map.Entry<Object,Object>>(new Comparator<java.util.Map.Entry<Object,Object>>() {\n @Override\n public int compare(java.util.Map.Entry<Object, Object> entry1, java.util.Map.Entry<Object, Object> entry2) {\n String key1 = entry1.getKey().toString();\n String key2 = entry2.getKey().toString();\n return key1.compareTo(key2);\n }\n });\n\n tmp.addAll(super.entrySet());\n\n return Collections.unmodifiableSet(tmp);\n }\n\n @Override\n public synchronized Enumeration<Object> keys() {\n return Collections.enumeration(new TreeSet<Object>(super.keySet()));\n }\n\n @Override\n public Set<String> stringPropertyNames() {\n TreeSet<String> set = new TreeSet<String>();\n for(Object o : keySet()) {\n set.add((String)o);\n }\n return set;\n }\n };\n\n tmp.putAll(props);\n tmp.store(fw, comment);\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5084/"
] |
54,318 |
<p>I'm looking for any tools that can give you code churn metrics (graphs and charts would be even better) for a Subversion repository.</p>
<p>One tool I know of is <a href="http://www.statsvn.org/" rel="noreferrer">statsvn</a> - a Java tool that creates some HTML reports and some code churn metrics. Statsvn reports the number of lines modified (churned) by user over time, some descriptive stats on LOC per file and folder/subfolder, etc.</p>
<p>I would like to know code churn in order to get a better idea of the state of the project. Idea behind this inspired by the MS research: <a href="http://research.microsoft.com/research/pubs/view.aspx?type=Publication&id=1359" rel="noreferrer">Use of Relative Code Churn Measures to Predict System Defect Density</a></p>
<p>In a nutshell, the more that source code is churning (changing, whether adding new lines, deleting, changing,etc) the higher the probability that defects are being introduced into the system. The MS research paper says that the number of defects produced can be predicted based on a number of relative code churn measures.</p>
<p>I wanted to know if there are any others that are maybe open source, extensible, etc.</p>
|
[
{
"answer_id": 78183,
"author": "James A. N. Stauffer",
"author_id": 6770,
"author_profile": "https://Stackoverflow.com/users/6770",
"pm_score": 0,
"selected": false,
"text": "svn blame sed sort uniq -c"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1341/"
] |
54,334 |
<p>The following SQL:</p>
<pre><code>SELECT notes + 'SomeText'
FROM NotesTable a
</code></pre>
<p>Give the error:</p>
<blockquote>
<p>The data types nvarchar and text are incompatible in the add operator.</p>
</blockquote>
|
[
{
"answer_id": 54343,
"author": "GateKiller",
"author_id": 383,
"author_profile": "https://Stackoverflow.com/users/383",
"pm_score": 7,
"selected": true,
"text": "Select Cast(notes as nvarchar(4000)) + 'SomeText'\nFrom NotesTable a\n"
},
{
"answer_id": 57061,
"author": "Scott Nichols",
"author_id": 4299,
"author_profile": "https://Stackoverflow.com/users/4299",
"pm_score": 4,
"selected": false,
"text": "Select Cast(notes as nvarchar(max)) + 'SomeText' From NotesTable a\n"
},
{
"answer_id": 77130,
"author": "Chris Wuestefeld",
"author_id": 10082,
"author_profile": "https://Stackoverflow.com/users/10082",
"pm_score": 5,
"selected": false,
"text": "Select IsNull(Cast(notes as nvarchar(4000)),'') + 'SomeText' From NotesTable a\n"
},
{
"answer_id": 48540394,
"author": "David Gausmann",
"author_id": 1800813,
"author_profile": "https://Stackoverflow.com/users/1800813",
"pm_score": 2,
"selected": false,
"text": "SELECT CONCAT(MyTable.TextColumn, 'Text') FROM MyTable\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2017/"
] |
54,365 |
<p>This is probably <a href="http://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/x13320.html" rel="noreferrer">a complex solution</a>.</p>
<p>I am looking for a simple operator like ">>", but for prepending.</p>
<p>I am afraid it does not exist. I'll have to do something like </p>
<pre>
mv myfile tmp
cat myheader tmp > myfile
</pre>
<p>Anything smarter?</p>
|
[
{
"answer_id": 54381,
"author": "Jason Navarrete",
"author_id": 3920,
"author_profile": "https://Stackoverflow.com/users/3920",
"pm_score": 7,
"selected": false,
"text": "echo \"text\" | cat - yourfile > /tmp/out && mv /tmp/out yourfile\n"
},
{
"answer_id": 54384,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 4,
"selected": false,
"text": "{ echo foo; cat oldfile; } > newfile && mv newfile oldfile\n"
},
{
"answer_id": 59504,
"author": "Eric Hansander",
"author_id": 5039,
"author_profile": "https://Stackoverflow.com/users/5039",
"pm_score": 4,
"selected": false,
"text": "(tmpfile=`mktemp` && { echo \"prepended text\" | cat - yourfile > $tmpfile && mv $tmpfile yourfile; } )\n"
},
{
"answer_id": 61713,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 3,
"selected": false,
"text": "cat blah.txt | grep something > blah.txt sponge cat blah.txt | grep something | sponge blah.txt"
},
{
"answer_id": 621786,
"author": "John Mee",
"author_id": 75033,
"author_profile": "https://Stackoverflow.com/users/75033",
"pm_score": 6,
"selected": true,
"text": "(echo 'foo' && cat yourfile) | sponge yourfile exec 3<> yourfile >&3 -v TEXT=\"$text\" #!/bin/bash\ntext=\"Hello world\nWhat's up?\"\n\nexec 3<> yourfile && awk -v TEXT=\"$text\" 'BEGIN {print TEXT}{print}' yourfile >&3\n"
},
{
"answer_id": 1137872,
"author": "cb0",
"author_id": 85737,
"author_profile": "https://Stackoverflow.com/users/85737",
"pm_score": 3,
"selected": false,
"text": "$cat my.txt \nthis is the regular file\n $ cat header\nthis is the header\n $cat header <(cat my.txt) > my.txt\n $ cat my.txt\nthis is the header\nthis is the regular file\n"
},
{
"answer_id": 2362886,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "echo \"text to prepend\" | cat - file_to_be_modified | ( cat > file_to_be_modified ) \n"
},
{
"answer_id": 2652178,
"author": "user318396",
"author_id": 318396,
"author_profile": "https://Stackoverflow.com/users/318396",
"pm_score": -1,
"selected": false,
"text": "endor@grid ~ $ tac --help\nUsage: tac [OPTION]... [FILE]...\nWrite each FILE to standard output, last line first.\nWith no FILE, or when FILE is -, read standard input.\n\nMandatory arguments to long options are mandatory for short options too.\n -b, --before attach the separator before instead of after\n -r, --regex interpret the separator as a regular expression\n -s, --separator=STRING use STRING as the separator instead of newline\n --help display this help and exit\n --version output version information and exit\n\nReport tac bugs to [email protected]\nGNU coreutils home page: <http://www.gnu.org/software/coreutils/>\nGeneral help using GNU software: <http://www.gnu.org/gethelp/>\nReport tac translation bugs to <http://translationproject.org/team/>\n"
},
{
"answer_id": 2731521,
"author": "vinyll",
"author_id": 328117,
"author_profile": "https://Stackoverflow.com/users/328117",
"pm_score": 0,
"selected": false,
"text": "current=`cat my_file` && echo 'my_string' > my_file && echo $current >> my_file\n"
},
{
"answer_id": 2754039,
"author": "anonymous",
"author_id": 330877,
"author_profile": "https://Stackoverflow.com/users/330877",
"pm_score": 4,
"selected": false,
"text": "exec 3<>myfile && awk 'BEGIN{for(i=1;i<=1100;i++)print i}{print}' myfile >&3\n"
},
{
"answer_id": 3272296,
"author": "fluffle",
"author_id": 394737,
"author_profile": "https://Stackoverflow.com/users/394737",
"pm_score": 5,
"selected": false,
"text": "echo '0a\nyour text here\n.\nw' | ed some_file\n"
},
{
"answer_id": 3835300,
"author": "shixilun",
"author_id": 463357,
"author_profile": "https://Stackoverflow.com/users/463357",
"pm_score": 3,
"selected": false,
"text": "sed -i -e \"1s/^/new first line\\n/\" old_file.txt\n"
},
{
"answer_id": 4027421,
"author": "Daniel",
"author_id": 243238,
"author_profile": "https://Stackoverflow.com/users/243238",
"pm_score": 3,
"selected": false,
"text": "tee cat header main | tee main > /dev/null\n"
},
{
"answer_id": 5209427,
"author": "hobs",
"author_id": 623735,
"author_profile": "https://Stackoverflow.com/users/623735",
"pm_score": 2,
"selected": false,
"text": "vis cat sed -i -e \"1s/^/$(cat file_with_header.txt)/\" file_to_be_prepended.txt\n sed"
},
{
"answer_id": 5593088,
"author": "torf",
"author_id": 698365,
"author_profile": "https://Stackoverflow.com/users/698365",
"pm_score": 2,
"selected": false,
"text": "# cf. \"Editing files with the ed text editor from scripts.\",\n# http://wiki.bash-hackers.org/doku.php?id=howto:edit-ed\n\nprepend() {\n printf '%s\\n' H 1i \"${1}\" . wq | ed -s \"${2}\"\n}\n\necho 'Hello, world!' > myfile\nprepend 'line to prepend' myfile\n echo cat > manipulate.txt\nexec 3<manipulate.txt\n# Prevent open file from being truncated:\nrm manipulate.txt\nsed 's/cat/dog/' <&3 > manipulate.txt\n"
},
{
"answer_id": 6108287,
"author": "nemisj",
"author_id": 219703,
"author_profile": "https://Stackoverflow.com/users/219703",
"pm_score": 2,
"selected": false,
"text": "echo -e \"TEXTFIRSt\\n$(< header)\\n$(< my.txt)\" > my.txt\n"
},
{
"answer_id": 7050051,
"author": "lkraav",
"author_id": 35946,
"author_profile": "https://Stackoverflow.com/users/35946",
"pm_score": 0,
"selected": false,
"text": ".git/hooks/prepare-commit-msg .gitmessage echo -e \"1r $PWD/.gitmessage\\n.\\nw\" | ed -s \"$1\"\n .gitmessage # Commit message formatting samples:\n# runlevels: boot +consolekit -zfs-fuse\n#\n 1r 0r .gitmessage -s [core]\n editor = vim -c ':normal gg'\n"
},
{
"answer_id": 7091228,
"author": "Jayen",
"author_id": 192798,
"author_profile": "https://Stackoverflow.com/users/192798",
"pm_score": 0,
"selected": false,
"text": "NEWFILE=$(echo deb http://mirror.csesoc.unsw.edu.au/ubuntu/ $(lsb_release -cs) main universe restricted multiverse && cat /etc/apt/sources.list)\necho \"$NEWFILE\" | sudo tee /etc/apt/sources.list\n"
},
{
"answer_id": 8208478,
"author": "Hammad Akhwand",
"author_id": 1057325,
"author_profile": "https://Stackoverflow.com/users/1057325",
"pm_score": 2,
"selected": false,
"text": "echo -e \"header \\n$(cat file)\" >file\n"
},
{
"answer_id": 9485338,
"author": "Max Tsepkov",
"author_id": 1035328,
"author_profile": "https://Stackoverflow.com/users/1035328",
"pm_score": 3,
"selected": false,
"text": "{ echo foo; cat bar; } | tee bar > /dev/null\n"
},
{
"answer_id": 10471758,
"author": "weakish",
"author_id": 222893,
"author_profile": "https://Stackoverflow.com/users/222893",
"pm_score": 2,
"selected": false,
"text": "sed -i -e '1rmyheader' -e '1{h;d}' -e '2{x;G}' myfile\n"
},
{
"answer_id": 14077361,
"author": "Dave Butler",
"author_id": 693869,
"author_profile": "https://Stackoverflow.com/users/693869",
"pm_score": 0,
"selected": false,
"text": "cat myheader | { echo '0a'; cat ; echo -e \".\\nw\";} | ed myfile\n function prepend() { { echo '0a'; cat ; echo -e \".\\nw\";} | ed $1; }\n\ncat myheader | prepend myfile\n"
},
{
"answer_id": 15721194,
"author": "user2227573",
"author_id": 2227573,
"author_profile": "https://Stackoverflow.com/users/2227573",
"pm_score": 4,
"selected": false,
"text": "cat header myfile | sponge myfile\n"
},
{
"answer_id": 17532487,
"author": "benjwadams",
"author_id": 1914300,
"author_profile": "https://Stackoverflow.com/users/1914300",
"pm_score": 2,
"selected": false,
"text": "ex -c '0r myheader|x' myfile\n"
},
{
"answer_id": 20931105,
"author": "JuSchu",
"author_id": 1738535,
"author_profile": "https://Stackoverflow.com/users/1738535",
"pm_score": 2,
"selected": false,
"text": "originalContent=$(cat targetfile) && echo \"text to prepend\" > targetfile && echo \"$originalContent\" >> targetfile\n"
},
{
"answer_id": 25340907,
"author": "jaybee",
"author_id": 837676,
"author_profile": "https://Stackoverflow.com/users/837676",
"pm_score": 0,
"selected": false,
"text": "myheader myfile exec 3<>myfile tee myfile myheader EOF myheader myfile"
},
{
"answer_id": 26330293,
"author": "crizCraig",
"author_id": 134077,
"author_profile": "https://Stackoverflow.com/users/134077",
"pm_score": 1,
"selected": false,
"text": "cat python -c 'f = \"filename\"; t = open(f).read(); open(f, \"w\").write(\"text to prepend \" + t)'"
},
{
"answer_id": 28504431,
"author": "Eric Woodruff",
"author_id": 1139784,
"author_profile": "https://Stackoverflow.com/users/1139784",
"pm_score": 4,
"selected": false,
"text": "cat <<-EOF > myfile\n $(echo this is prepended)\n $(cat myfile)\nEOF\n"
},
{
"answer_id": 30663695,
"author": "jozxyqk",
"author_id": 1888983,
"author_profile": "https://Stackoverflow.com/users/1888983",
"pm_score": 0,
"selected": false,
"text": "$ echo two > file\n$ echo one | python -c \"import sys; f=open(sys.argv[1]).read(); open(sys.argv[1],'w').write(sys.stdin.read()+f)\" file\n$ cat file\none\ntwo\n$ # or creating a shortcut...\n$ alias prepend='python -c \"import sys; f=open(sys.argv[1]).read(); open(sys.argv[1],\\\"w\\\").write(sys.stdin.read()+f)\"'\n$ echo zero | prepend file\n$ cat file\nzero\none\ntwo\n"
},
{
"answer_id": 31106873,
"author": "user137369",
"author_id": 1661012,
"author_profile": "https://Stackoverflow.com/users/1661012",
"pm_score": 1,
"selected": false,
"text": "printf new_line='the line you want to add'\ntarget_file='/file you/want to/write to'\n\nprintf \"%s\\n$(cat ${target_file})\" \"${new_line}\" > \"${target_file}\"\n printf \"${new_line}\\n$(cat ${target_file})\" > \"${target_file}\"\n %"
},
{
"answer_id": 34645273,
"author": "user5704481",
"author_id": 5704481,
"author_profile": "https://Stackoverflow.com/users/5704481",
"pm_score": 2,
"selected": false,
"text": "perl -i -0777 -pe 's/^/my_header/' tmp\n perl -i -0777 -pe 's/^/`cat my_header`/e' tmp\n"
},
{
"answer_id": 69520112,
"author": "123",
"author_id": 5563327,
"author_profile": "https://Stackoverflow.com/users/5563327",
"pm_score": 0,
"selected": false,
"text": "echo \"hello\\n$(cat myfile)\" > myfile\n $ echo \"line\" > myfile\n$ cat myfile\nline\n$ echo \"line1\\n$(cat myfile)\" > myfile\n$ cat myfile\nline1\nline\n"
},
{
"answer_id": 70582884,
"author": "Murilo Perrone",
"author_id": 7626061,
"author_profile": "https://Stackoverflow.com/users/7626061",
"pm_score": 1,
"selected": false,
"text": "cat myHeader myFile | tee myFile\n echo \"<line to add>\" | cat - myFile | tee myFile\n echo -n &> /dev/null # make it executable (use u+x to allow only current user)\nchmod +x cropImage.ts\n# append the shebang\necho '#''!'/usr/bin/env ts-node | cat - cropImage.ts | tee cropImage.ts &> /dev/null\n# execute it\n./cropImage.ts myImage.png\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1277510/"
] |
54,380 |
<p>I am adding a ADO.Net Data Service lookup feature to an existing web page. Everything works great when running from visual studio, but when I roll it out to IIS, I get the following error:</p>
<blockquote>
<p><strong>Request Error</strong><br>The server encountered an error processing the request. See server logs for more details.</p>
</blockquote>
<p>I get this even when trying to display the default page, i.e.:</p>
<blockquote>
<p><a href="http://server/FFLookup.svc" rel="noreferrer">http://server/FFLookup.svc</a></p>
</blockquote>
<p>I have 3.5 SP1 installed on the server.</p>
<p>What am I missing, and which "Server Logs" is it refering to? I can't find any further error messages.</p>
<p>There is nothing in the Event Viewer logs (System or Application), and nothing in the IIS logs other than the GET:</p>
<blockquote>
<p>2008-09-10 15:20:19 10.7.131.71 GET /FFLookup.svc - 8082 - 10.7.131.86 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US)+AppleWebKit/525.13+(KHTML,+like+Gecko)+Chrome/0.2.149.29+Safari/525.13 401 2 2148074254</p>
</blockquote>
<p>There is no stack trace returned. The only response I get is the "Request Error" as noted above.</p>
<p>Thanks</p>
<p>Patrick</p>
|
[
{
"answer_id": 55557,
"author": "Patrick Connelly",
"author_id": 5431,
"author_profile": "https://Stackoverflow.com/users/5431",
"pm_score": 4,
"selected": false,
"text": " <system.diagnostics>\n <sources>\n <source name=\"System.ServiceModel.MessageLogging\" switchValue=\"Warning, ActivityTracing\" >\n <listeners>\n <add name=\"ServiceModelTraceListener\"/>\n </listeners>\n </source>\n\n <source name=\"System.ServiceModel\" switchValue=\"Verbose,ActivityTracing\" >\n <listeners>\n <add name=\"ServiceModelTraceListener\"/>\n </listeners>\n </source>\n <source name=\"System.Runtime.Serialization\" switchValue=\"Verbose,ActivityTracing\">\n <listeners>\n <add name=\"ServiceModelTraceListener\"/>\n </listeners>\n </source>\n </sources>\n <sharedListeners>\n <add initializeData=\"App_tracelog.svclog\" \n type=\"System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"\n name=\"ServiceModelTraceListener\" traceOutputOptions=\"Timestamp\"/>\n </sharedListeners>\n</system.diagnostics>\n"
},
{
"answer_id": 277112,
"author": "James_2195",
"author_id": 36086,
"author_profile": "https://Stackoverflow.com/users/36086",
"pm_score": 5,
"selected": false,
"text": "[System.ServiceModel.ServiceBehavior(IncludeExceptionDetailInFaults = true)] \n protected override void HandleException(HandleExceptionArgs e)\n{\n try\n {\n e.UseVerboseErrors = true;\n }\n catch (Exception ex)\n {\n Console.WriteLine(ex.Message);\n }\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5431/"
] |
54,401 |
<p>As I develop more with vim, I find myself wanting to copy in blocks of useful code, similar to "templates" in Eclipse. </p>
<p>I was thinking of making a separate file for each code chunk and just reading them in with</p>
<pre><code>:r code-fornext
</code></pre>
<p>but that just seems kind of primitive. Googling around I find vim macros mentioned and something about "maps" but nothing that seems straightforward.</p>
<p>What I am looking for are e.g. something like Eclipse's "Templates" so I pop in a code chunk with the cursor sitting in the middle of it.
Or JEdit's "Macros" which I can record doing complicated deletes and renaming on one line, then I can play it again on 10 other lines so it does the same to them.</p>
<p>Does vim have anything like these two functionalities?</p>
|
[
{
"answer_id": 54527,
"author": "brian newman",
"author_id": 3210,
"author_profile": "https://Stackoverflow.com/users/3210",
"pm_score": 4,
"selected": true,
"text": "q qq q q @q @@ 10@q 20@q +----------------------------------+-------------------------------------+\n| start recording a macro | qX (X = key to assign macro to) |\n+----------------------------------+-------------------------------------+\n| stop recording a macro | q | \n+----------------------------------+-------------------------------------+\n| playback macro | @X (X = key macro was assigned to) |\n+----------------------------------+-------------------------------------+\n| replay previously played macro | @@ |\n+----------------------------------+-------------------------------------+\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] |
54,418 |
<p>I need to retrieve all rows from a table where 2 columns combined are all different. So I want all the sales that do not have any other sales that happened on the same day for the same price. The sales that are unique based on day and price will get updated to an active status.</p>
<p>So I'm thinking:</p>
<pre><code>UPDATE sales
SET status = 'ACTIVE'
WHERE id IN (SELECT DISTINCT (saleprice, saledate), id, count(id)
FROM sales
HAVING count = 1)
</code></pre>
<p>But my brain hurts going any farther than that.</p>
|
[
{
"answer_id": 54430,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 10,
"selected": true,
"text": "SELECT DISTINCT a,b,c FROM t\n SELECT a,b,c FROM t GROUP BY a,b,c\n UPDATE sales\nSET status='ACTIVE'\nWHERE id IN\n(\n SELECT id\n FROM sales S\n INNER JOIN\n (\n SELECT saleprice, saledate\n FROM sales\n GROUP BY saleprice, saledate\n HAVING COUNT(*) = 1 \n ) T\n ON S.saleprice=T.saleprice AND s.saledate=T.saledate\n )\n"
},
{
"answer_id": 54557,
"author": "Christian Berg",
"author_id": 5035,
"author_profile": "https://Stackoverflow.com/users/5035",
"pm_score": 5,
"selected": false,
"text": "UPDATE sales\nSET status='ACTIVE'\nWHERE id IN (\n SELECT MIN(id) FROM sales\n GROUP BY saleprice, saledate\n HAVING COUNT(id) = 1\n)\n"
},
{
"answer_id": 12632129,
"author": "Erwin Brandstetter",
"author_id": 939860,
"author_profile": "https://Stackoverflow.com/users/939860",
"pm_score": 9,
"selected": false,
"text": "UPDATE sales\nSET status = 'ACTIVE'\nWHERE (saleprice, saledate) IN (\n SELECT saleprice, saledate\n FROM sales\n GROUP BY saleprice, saledate\n HAVING count(*) = 1 \n );\n NOT EXISTS EXISTS UPDATE sales s\nSET status = 'ACTIVE'\nWHERE NOT EXISTS (\n SELECT FROM sales s1 -- SELECT list can be empty for EXISTS\n WHERE s.saleprice = s1.saleprice\n AND s.saledate = s1.saledate\n AND s.id <> s1.id -- except for row itself\n )\nAND s.status IS DISTINCT FROM 'ACTIVE'; -- avoid empty updates. see below\n id ctid AND s1.ctid <> s.ctid\n serial IDENTITY EXISTS status = 'ACTIVE' WHERE status NOT NULL AND status <> 'ACTIVE';\n <> json (saleprice, saledate) (123, NULL)\n(123, NULL)\n GROUP BY DISTINCT DISTINCT ON () IS NOT DISTINCT FROM = NOT NULL"
},
{
"answer_id": 48238006,
"author": "frans eilering",
"author_id": 4962958,
"author_profile": "https://Stackoverflow.com/users/4962958",
"pm_score": 2,
"selected": false,
"text": "Select distinct GrondOfLucht,sortering\nfrom CorWijzeVanAanleg\norder by sortering\n SELECT GrondOfLucht\nFROM dbo.CorWijzeVanAanleg\nGROUP BY GrondOfLucht, sortering\nORDER BY MIN(sortering)\n"
},
{
"answer_id": 54456645,
"author": "Abdulhafeth Sartawi",
"author_id": 4385453,
"author_profile": "https://Stackoverflow.com/users/4385453",
"pm_score": 3,
"selected": false,
"text": "select distinct(col1, col2) from table\n select distinct * from (select col1, col2 from table ) as x\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4915/"
] |
54,419 |
<p>I have a WCF application that has two Services that I am trying to host in a single Windows Service using net.tcp. I can run either of the services just fine, but as soon as I try to put them both in the Windows Service only the first one loads up. I have determined that the second services ctor is being called but the OnStart never fires. This tells me that WCF is finding something wrong with loading up that second service.</p>
<p>Using net.tcp I know I need to turn on port sharing and start the port sharing service on the server. This all seems to be working properly. I have tried putting the services on different tcp ports and still no success.</p>
<p>My service installer class looks like this:</p>
<pre><code> [RunInstaller(true)]
public class ProjectInstaller : Installer
{
private ServiceProcessInstaller _process;
private ServiceInstaller _serviceAdmin;
private ServiceInstaller _servicePrint;
public ProjectInstaller()
{
_process = new ServiceProcessInstaller();
_process.Account = ServiceAccount.LocalSystem;
_servicePrint = new ServiceInstaller();
_servicePrint.ServiceName = "PrintingService";
_servicePrint.StartType = ServiceStartMode.Automatic;
_serviceAdmin = new ServiceInstaller();
_serviceAdmin.ServiceName = "PrintingAdminService";
_serviceAdmin.StartType = ServiceStartMode.Automatic;
Installers.AddRange(new Installer[] { _process, _servicePrint, _serviceAdmin });
}
}
</code></pre>
<p>and both services looking very similar</p>
<pre><code> class PrintService : ServiceBase
{
public ServiceHost _host = null;
public PrintService()
{
ServiceName = "PCTSPrintingService";
CanStop = true;
AutoLog = true;
}
protected override void OnStart(string[] args)
{
if (_host != null) _host.Close();
_host = new ServiceHost(typeof(Printing.ServiceImplementation.PrintingService));
_host.Faulted += host_Faulted;
_host.Open();
}
}
</code></pre>
|
[
{
"answer_id": 90870,
"author": "Wiren",
"author_id": 2538222,
"author_profile": "https://Stackoverflow.com/users/2538222",
"pm_score": 5,
"selected": true,
"text": "internal class MyWCFService1\n{\n internal static System.ServiceModel.ServiceHost serviceHost = null;\n\n internal static void StartService()\n {\n if (serviceHost != null)\n {\n serviceHost.Close();\n }\n\n // Instantiate new ServiceHost.\n serviceHost = new System.ServiceModel.ServiceHost(typeof(MyService1));\n // Open myServiceHost.\n serviceHost.Open();\n }\n\n internal static void StopService()\n {\n if (serviceHost != null)\n {\n serviceHost.Close();\n serviceHost = null;\n }\n }\n};\n // Start the Windows service.\n protected override void OnStart( string[] args )\n {\n // Call all the set up WCF services...\n MyWCFService1.StartService();\n //MyWCFService2.StartService();\n //MyWCFService3.StartService();\n\n\n }\n"
},
{
"answer_id": 9159152,
"author": "Eswararao",
"author_id": 1192102,
"author_profile": "https://Stackoverflow.com/users/1192102",
"pm_score": 2,
"selected": false,
"text": " Type serviceAServiceType = typeof(AfwConfigure);\n Type serviceAContractType = typeof(IAfwConfigure);\n\n Type serviceBServiceType = typeof(ConfigurationConsole);\n Type serviceBContractType = typeof(IConfigurationConsole);\n\n Type serviceCServiceType = typeof(ConfigurationAgent);\n Type serviceCContractType = typeof(IConfigurationAgent);\n\n ServiceHost serviceAHost = new ServiceHost(serviceAServiceType);\n ServiceHost serviceBHost = new ServiceHost(serviceBServiceType);\n ServiceHost serviceCHost = new ServiceHost(serviceCServiceType);\n Debug.WriteLine(\"Enter1\");\n serviceAHost.Open();\n Debug.WriteLine(\"Enter2\");\n serviceBHost.Open();\n Debug.WriteLine(\"Enter3\");\n serviceCHost.Open();\n Debug.WriteLine(\"Opened!!!!!!!!!\");\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5408/"
] |
54,421 |
<p>If you are writing a program that is executable from the command line, you often want to offer the user several options or flags, along with possibly more than one argument. I have stumbled my way through this many times, but is there some sort of design pattern for looping through args and calling the appropriate handler functions?</p>
<p>Consider:</p>
<pre><code>myprogram -f filename -d directory -r regex
</code></pre>
<p>How do you organize the handler functions after you retrieve the arguments using whatever built-ins for your language? (language-specific answers welcomed, if that helps you articulate an answer)</p>
|
[
{
"answer_id": 54690,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 2,
"selected": false,
"text": "while (current_argument = cli_parser_next()) {\n switch(current_argument) {\n case \"f\": //Parser strips the dashes\n case \"force\":\n config->force = true;\n break;\n case \"d\":\n case \"delete\":\n config->delete = true;\n break;\n //So on and so forth\n default:\n printUsage();\n exit;\n }\n}\n"
},
{
"answer_id": 54883,
"author": "Martin Del Vecchio",
"author_id": 5397,
"author_profile": "https://Stackoverflow.com/users/5397",
"pm_score": 2,
"selected": false,
"text": "int main (int argc, char *argv[])\n { int i;\n char *Arg;\n int ParamX, ParamY;\n char *Text, *Primary;\n\n // Initialize...\n ParamX = 1;\n ParamY = 0;\n Text = NULL;\n Primary = NULL;\n\n // For each argument...\n for (i = 0; i < argc; i++)\n {\n // Get the next argument and see what it is\n Arg = argv[i];\n switch (Arg[0])\n {\n case '-':\n case '/':\n // It's an argument; which one?\n switch (Arg[1])\n {\n case '?':\n case 'h':\n case 'H':\n // A cry for help\n printf (\"Usage: whatever...\\n\\n\");\n return (0);\n break;\n\n case 't':\n case 'T':\n // Param T requires a value; is it there?\n i++;\n if (i >= argc)\n {\n printf (\"Error: missing value after '%s'.\\n\\n\", Arg);\n return (1);\n }\n\n // Just remember this\n Text = Arg;\n\n break;\n\n case 'x':\n case 'X':\n // Param X requires a value; is it there?\n i++;\n if (i >= argc)\n {\n printf (\"Error: missing value after '%s'.\\n\\n\", Arg);\n return (1);\n }\n\n // The value is there; get it and convert it to an int (1..10)\n Arg = argv[i];\n ParamX = atoi (Arg);\n if ((ParamX == 0) || (ParamX > 10))\n {\n printf (\"Error: invalid value for '%s'; must be between 1 and 10.\\n\\n\", Arg);\n return (1);\n }\n\n break;\n\n case 'y':\n case 'Y':\n // Param Y doesn't expect a value after it\n ParamY = 1;\n break;\n\n default:\n // Unexpected argument\n printf (\"Error: unexpected parameter '%s'; type 'command -?' for help.\\n\\n\", Arg);\n return (1);\n break;\n }\n\n break;\n\n default:\n // It's not a switch that begins with '-' or '/', so it's the primary option\n Primary = Arg;\n\n break;\n }\n }\n\n // Done\n return (0);\n }\n"
},
{
"answer_id": 78034,
"author": "mes5k",
"author_id": 1359466,
"author_profile": "https://Stackoverflow.com/users/1359466",
"pm_score": 2,
"selected": false,
"text": "TCLAP"
},
{
"answer_id": 7529952,
"author": "Lindsay Morsillo",
"author_id": 945525,
"author_profile": "https://Stackoverflow.com/users/945525",
"pm_score": 4,
"selected": false,
"text": "If the arguments to the program are valid then\n Do necessary pre-processing\n For every line in the input\n Do necessary input processing\n Do necessary post-processing\nOtherwise\n Show the user a friendly usage message\n PreProcess()\nProcessLine()\nPostProcess()\nUsage()\nMain()\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/577/"
] |
54,426 |
<p>Like the Delicious submission bookmark-let, I'd like to have some standard JavaScript I can use to submit any visited URL to a 3rd party site when that's possible by URL. Suggestions?</p>
<p>For example, I've been using </p>
<pre><code>javascript:void(location.href="http://www.yacktrack.com/home?query="+encodeURI(location.href))
</code></pre>
<p>so far but wonder if there's something more sophisticated I could use or better practice.</p>
|
[
{
"answer_id": 54446,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 1,
"selected": false,
"text": "document.location = \"http://url_submitting_to.com?query_string_param=\" + window.location;\n"
},
{
"answer_id": 54470,
"author": "Justin Voss",
"author_id": 5616,
"author_profile": "https://Stackoverflow.com/users/5616",
"pm_score": 3,
"selected": true,
"text": "javascript:(function(){\n location.href='http://example.com/your-script.php?url='+\n encodeURIComponent(window.location.href)+\n '&title='+encodeURIComponent(document.title)\n})()\n iframe"
},
{
"answer_id": 54531,
"author": "Hafthor",
"author_id": 4489,
"author_profile": "https://Stackoverflow.com/users/4489",
"pm_score": 0,
"selected": false,
"text": "<form action=\"http://www.yacktrack.com/home\" method=\"get\" name=\"f\">\n <input type=\"hidden\" name=\"query\" />\n</form>\n f.query.value=location.href; f.submit();\n <form action=\"http://www.yacktrack.com/home\" method=\"get\" name=\"f\" onsubmit=\"f.query.value=location.href;\">\n <input type=\"hidden\" name=\"query\" />\n <input type=\"submit\" name=\"Save Link\" />\n</form>\n <form action=\"http://www.yacktrack.com/home\" method=\"get\" name=\"f\">\n <input type=\"hidden\" name=\"query\" value=\"<%=Response.Url%>\" />\n <input type=\"submit\" name=\"Save Link\" />\n</form>\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5613/"
] |
54,440 |
<p>I want to add the selected item from the <code>TreeView</code> to the <code>ListBox</code> control using <code>DataBinding</code> (If it can work with <code>DataBinding</code>). </p>
<pre><code><TreeView HorizontalAlignment="Left"
Margin="30,32,0,83"
Name="treeView1"
Width="133" >
</TreeView>
<ListBox VerticalAlignment="Top"
Margin="208,36,93,0"
Name="listBox1"
Height="196" >
</ListBox>
</code></pre>
<p><code>TreeView</code> is populated from the code behind page with some dummy data. </p>
|
[
{
"answer_id": 55830,
"author": "Dylan",
"author_id": 4580,
"author_profile": "https://Stackoverflow.com/users/4580",
"pm_score": 1,
"selected": false,
"text": "ItemsSource=\"{Binding SelectedItem, ElementName=treeView1}\"\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3797/"
] |
54,475 |
<p>I've run into a problem where I make changes to a few JavaScript files that are referenced in an HTML file, but the browser doesn't see the changes. It holds onto the copy cached in the browser, even though the web server has a newer version.</p>
<p>Not until I force the browser to clear the cache do I see the changes.</p>
<p>Is this a web-server configuration? Do I need to set my JavaScript files to never cache? I've seen some interesting techniques in the <a href="http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=FAQ_GWTApplicationFiles" rel="noreferrer">Google Web Toolkit</a> where they actually create a <strong>new</strong> JavaScript file name any time an update is made. I believe this is to prevent proxies and browsers from keeping old versions of the JavaScript files with the same names.</p>
<p>Is there a list of best practices somewhere?</p>
|
[
{
"answer_id": 54486,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 6,
"selected": true,
"text": "<script src=\"MyScript.js?4.0.8243\">\n"
},
{
"answer_id": 54506,
"author": "Chris Marasti-Georg",
"author_id": 96,
"author_profile": "https://Stackoverflow.com/users/96",
"pm_score": 3,
"selected": false,
"text": "<script src=\"/js/version/MyScript.js\"/>\n"
},
{
"answer_id": 71866372,
"author": "Stephen Duffy",
"author_id": 12894605,
"author_profile": "https://Stackoverflow.com/users/12894605",
"pm_score": 0,
"selected": false,
"text": "<script src='script.js' max-age=0 nocache />\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5079/"
] |
54,482 |
<p>I need to enumerate all the user defined types created in a <code>SQL Server</code> database with <code>CREATE TYPE</code>, and/or find out whether they have already been defined.</p>
<p>With tables or stored procedures I'd do something like this:</p>
<pre><code>if exists (select * from dbo.sysobjects where name='foobar' and xtype='U')
drop table foobar
</code></pre>
<p>However I can't find the equivalent (or a suitable alternative) for user defined types! I definitely can't see them anywhere in <code>sysobjects</code>. </p>
<p>Can anyone enlighten me?</p>
|
[
{
"answer_id": 54496,
"author": "jwolly2",
"author_id": 5202,
"author_profile": "https://Stackoverflow.com/users/5202",
"pm_score": 7,
"selected": true,
"text": "select * from sys.types\nwhere is_user_defined = 1\n"
},
{
"answer_id": 31549846,
"author": "Ron Sanderson",
"author_id": 3034283,
"author_profile": "https://Stackoverflow.com/users/3034283",
"pm_score": 4,
"selected": false,
"text": "SELECT USER_NAME(TYPE.schema_id) + '.' + TYPE.name AS \"Type Name\",\n COL.column_id,\n SUBSTRING(CAST(COL.column_id + 100 AS char(3)), 2, 2) + ': ' + COL.name AS \"Column\",\n ST.name AS \"Data Type\",\n CASE COL.Is_Nullable\n WHEN 1 THEN ''\n ELSE 'NOT NULL' \n END AS \"Nullable\",\n COL.max_length AS \"Length\",\n COL.[precision] AS \"Precision\",\n COL.scale AS \"Scale\",\n ST.collation AS \"Collation\"\nFROM sys.table_types TYPE\nJOIN sys.columns COL\n ON TYPE.type_table_object_id = COL.object_id\nJOIN sys.systypes AS ST \n ON ST.xtype = COL.system_type_id\nwhere TYPE.is_user_defined = 1\nORDER BY \"Type Name\",\n COL.column_id\n"
},
{
"answer_id": 48426414,
"author": "Ton Plooij",
"author_id": 4490706,
"author_profile": "https://Stackoverflow.com/users/4490706",
"pm_score": 3,
"selected": false,
"text": "-- User Defined Type definitions TP 20180124\nselect t1.name, t2.name, t1.precision, t1.scale, t1.max_length as bytes, t1.is_nullable\nfrom sys.types t1\njoin sys.types t2 on t2.system_type_id = t1.system_type_id and t2.is_user_defined = 0\nwhere t1.is_user_defined = 1 and t2.name <> 'sysname'\norder by t1.name\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/886/"
] |
54,487 |
<p>How can I format Floats in Java so that the float component is displayed only if it's not zero? For example:</p>
<pre>
123.45 -> 123.45
99.0 -> 99
23.2 -> 23.2
45.0 -> 45
</pre>
<p>Edit: I forgot to mention - I'm still on Java 1.4 - sorry!</p>
|
[
{
"answer_id": 54502,
"author": "ScArcher2",
"author_id": 1310,
"author_profile": "https://Stackoverflow.com/users/1310",
"pm_score": 4,
"selected": true,
"text": " DecimalFormat format = new DecimalFormat(\"###.##\");\n\n double[] doubles = {123.45, 99.0, 23.2, 45.0};\n for(int i=0;i<doubles.length;i++){\n System.out.println(format.format(doubles[i]));\n }\n"
},
{
"answer_id": 54511,
"author": "Jason Cohen",
"author_id": 4926,
"author_profile": "https://Stackoverflow.com/users/4926",
"pm_score": 0,
"selected": false,
"text": "new Formatter().format( \"%f\", myFloat )\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
54,500 |
<p>Alright, so I'm working on an application which will use a Linux back-end running PostgreSQL to serve up images to a Windows box with the front end written in C#.NET, though the front-end should hardly matter. My question is:</p>
<ul>
<li><strong>What is the best way to deal with storing images in Postgres?</strong></li>
</ul>
<p>The images are around 4-6 megapixels each, and we're storing upwards of 3000. It might also be good to note: this is not a web application, there will at most be about two front-ends accessing the database at once.</p>
|
[
{
"answer_id": 54561,
"author": "Kris Erickson",
"author_id": 3798,
"author_profile": "https://Stackoverflow.com/users/3798",
"pm_score": 5,
"selected": false,
"text": "//linuxserver/images/imagexxx.jpg\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145/"
] |
54,503 |
<p>I'm working on a .net post-commit hook to feed data into OnTime via their Soap SDK. My hook works on Windows fine, but on our production RHEL4 subversion server, it won't work when called from a shell script.</p>
<pre>
#!/bin/sh
/usr/bin/mono $1/hooks/post-commit.exe "$@"
</pre>
<p>When I execute it with parameters from the command line, it works properly. When executed via the shell script, I get the following error: (looks like there is some problem with the process execution of SVN that I use to get the log data for the revision):</p>
<pre>
Unhandled Exception: System.InvalidOperationException: The process must exit before getting the requested information.
at System.Diagnostics.Process.get_ExitCode () [0x0003f] in /tmp/monobuild/build/BUILD/mono-1.9.1/mcs/class/System/System.Diagnostics/Process.cs:149
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ExitCode ()
at SVNLib.SVN.Execute (System.String sCMD, System.String sParams, System.String sComment, System.String sUserPwd, SVNLib.SVNCallback callback) [0x00000]
at SVNLib.SVN.Log (System.String sUrl, Int32 nRevLow, Int32 nRevHigh, SVNLib.SVNCallback callback) [0x00000]
at SVNLib.SVN.LogAsString (System.String sUrl, Int32 nRevLow, Int32 nRevHigh) [0x00000]
at SVNCommit2OnTime.Program.Main (System.String[] args) [0x00000]
</pre>
<p>I've tried using <code>mkbundle</code> and <code>mkbundle2</code> to make a stand alone that could be named <code>post-commit</code>, but I get a different error message:</p>
<pre>
Unhandled Exception: System.ArgumentNullException: Argument cannot be null.
Parameter name: Value cannot be null.
at System.Guid.CheckNull (System.Object o) [0x00000]
at System.Guid..ctor (System.String g) [0x00000]
at SVNCommit2OnTime.Program.Main (System.String[] args) [0x00000]
</pre>
<p>Any ideas why it might be failing from a shell script or what might be wrong with the bundled version?</p>
<p><b>Edit:</b> <a href="https://stackoverflow.com/questions/54503/problem-with-net-app-under-linux-doesnt-work-from-shell-script#54537">@Herms</a>, I've already tried it with an echo, and it looks right. As for the <code>$1/hooks/post-commit.exe</code>, I've tried the script with and without a full path to the .net assembly with the same results.</p>
<p><b>Edit:</b> <a href="https://stackoverflow.com/questions/54503/problem-with-net-app-under-linux-doesnt-work-from-shell-script#54545">@Leon</a>, I've tried both <code>$1 $2</code> and <code>"$@"</code> with the same results. It is a subversion post commit hook, and it takes two parameters, so those need to be passed along to the .net assembly. The <code>"$@"</code> was what was recommended at the mono site for calling a .net assembly from a shell script. The shell script <i>is</i> executing the .net assembly and with the correct parameters, but it is throwing an exception that does not get thrown when run directly from the command line.</p>
<p><b>Edit:</b> <a href="https://stackoverflow.com/questions/54503/problem-with-net-app-under-linux-doesnt-work-from-shell-script#54568">@Vinko</a>, I don't see any differences in the environment other than things like <code>BASH_LINENO</code> and <code>BASH_SOURCE</code></p>
<p><b>Edit:</b> <a href="https://stackoverflow.com/questions/54503/problem-with-net-app-under-linux-doesnt-work-from-shell-script#54818">@Luke</a>, I tired it, but that makes no difference either. I first noticed the problem when testing from TortoiseSVN on my machine (when it runs as a sub-process of the subversion daemon), but also found that I get the same results when executing the script from the hooks directory (i.e. <code>./post-commit REPOS REV</code>, where <code>post-commit</code> is the above sh script. Doing <code>mono post-commit.exe REPOS REV</code> works fine. The main problem is that to execute, I need to have something of the name <code>post-commit</code> so that it will be called. But it does not work from a shell script, and as noted above, the <code>mkbundle</code> is not working with a different problem.</p>
|
[
{
"answer_id": 54537,
"author": "Herms",
"author_id": 1409,
"author_profile": "https://Stackoverflow.com/users/1409",
"pm_score": 0,
"selected": false,
"text": "#!/bin/sh\necho /usr/bin/mono $1/hooks/post-commit.exe \"$@\"\n"
},
{
"answer_id": 54545,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 0,
"selected": false,
"text": "/usr/bin/mono $1/hooks/post-commit.exe \"$@\""
},
{
"answer_id": 55119,
"author": "crashmstr",
"author_id": 1441,
"author_profile": "https://Stackoverflow.com/users/1441",
"pm_score": 0,
"selected": false,
"text": "proc.ExitCode"
},
{
"answer_id": 65070,
"author": "apenwarr",
"author_id": 42219,
"author_profile": "https://Stackoverflow.com/users/42219",
"pm_score": 3,
"selected": true,
"text": "proc.WaitForExit()"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1441/"
] |
54,512 |
<p>varchar(255), varchar(256), nvarchar(255), nvarchar(256), nvarchar(max), etc?</p>
<p>256 seems like a nice, round, space-efficient number. But I've seen 255 used a lot. Why?</p>
<p>What's the difference between varchar and nvarchar?</p>
|
[
{
"answer_id": 54533,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 2,
"selected": false,
"text": "0 1 2 3 4 5 ... 255\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] |
54,522 |
<p>I need to print out data into a pre-printed A6 form (1/4 the size of a landsacpe A4). I do not need to print paragraphs of text, just short lines scattered about on the page.</p>
<p>All the stuff on MSDN is about priting paragraphs of text. </p>
<p>Thanks for any help you can give,
Roberto</p>
|
[
{
"answer_id": 54533,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 2,
"selected": false,
"text": "0 1 2 3 4 5 ... 255\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5648/"
] |
54,536 |
<p>How do I create a windows application that does the following:</p>
<ul>
<li>it's a regular GUI app when invoked with no command line arguments</li>
<li>specifying the optional "--help" command line argument causes the app to write usage text to stdout then terminate</li>
<li>it must be a single executable. No cheating by making a console app exec a 2nd executable.</li>
<li>assume the main application code is written in C/C++</li>
<li>bonus points if no GUI window is created when "--help" is specified. (i.e., no flicker from a short-lived window)</li>
</ul>
<p>In my experience the standard visual studio template for console app has no GUI capability, and the normal win32 template does not send its stdout to the parent cmd shell.</p>
|
[
{
"answer_id": 113032,
"author": "Hugh Allen",
"author_id": 15069,
"author_profile": "https://Stackoverflow.com/users/15069",
"pm_score": 5,
"selected": false,
"text": "cmd.exe C:\\> cmd cmd #include <stdio.h>\n#include <windows.h>\n\nint main(int argc, char *argv[])\n{\n if (GetStdHandle(STD_OUTPUT_HANDLE) == 0) // no console, we must be the child process\n {\n MessageBox(0, \"Hello GUI world!\", \"\", 0);\n }\n else if (argc > 1) // we have command line args\n {\n printf(\"Hello console world!\\n\");\n }\n else // no command line args but a console - launch child process\n {\n DWORD dwCreationFlags = CREATE_DEFAULT_ERROR_MODE | DETACHED_PROCESS;\n STARTUPINFO startinfo;\n PROCESS_INFORMATION procinfo;\n ZeroMemory(&startinfo, sizeof(startinfo));\n startinfo.cb = sizeof(startinfo);\n if (!CreateProcess(NULL, argv[0], NULL, NULL, FALSE, dwCreationFlags, NULL, NULL, &startinfo, &procinfo))\n MessageBox(0, \"CreateProcess() failed :(\", \"\", 0);\n }\n exit(0);\n}\n"
},
{
"answer_id": 26087606,
"author": "Dmitry Markin",
"author_id": 1675481,
"author_profile": "https://Stackoverflow.com/users/1675481",
"pm_score": 4,
"selected": false,
"text": "AllocConsole() AttachConsole() stdout stderr if(AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole()){\n freopen(\"CONOUT$\", \"w\", stdout);\n freopen(\"CONOUT$\", \"w\", stderr);\n}\n WinMain()"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5429/"
] |
54,539 |
<p>So the SMEs at my current place of employment want to try and disable the back button for certain pages. We have a page where the user makes some selections and submits them to be processed. In some instances they have to enter a comment on another page. </p>
<p>What the users have figured out is that they don't have to enter a comment if they submit the information and go to the page with the comment and then hit the back button to return to the previous page. </p>
<p>I know there are several different solutions to this (and many of them are far more elegant then disabling the back button), but this is what I'm left with. Is it possible to prevent someone from going back to the previous page through altering the behavior of the back button. (like a submit -> return false sorta thing). </p>
<p>Due to double posting information I can't have it return to the previous page and then move to the current one. I can only have it not direct away from the current page. I Googled it, but I only saw posts saying that it will always return to the previous page. I was hoping that someone has some mad kung foo js skills that can make this possible.</p>
<p>I understand that everyone says this is a bad idea, and I agree, but sometimes you just have to do what you're told.</p>
|
[
{
"answer_id": 54571,
"author": "David Mohundro",
"author_id": 4570,
"author_profile": "https://Stackoverflow.com/users/4570",
"pm_score": 2,
"selected": false,
"text": "window.onBack = history.forward();\n"
},
{
"answer_id": 5881224,
"author": "Yossi Shasho",
"author_id": 437019,
"author_profile": "https://Stackoverflow.com/users/437019",
"pm_score": 2,
"selected": false,
"text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" >\n<title>Untitled Page</title>\n<script type = \"text/javascript\" >\nfunction changeHashOnLoad() {\n window.location.href += \"#\";\n setTimeout(\"changeHashAgain()\", \"50\"); \n}\n\nfunction changeHashAgain() {\n window.location.href += \"1\";\n}\n// If you want to skip the auto-positioning at the top of browser window,you can add the below code:\nwindow.location.hash=' ';\nvar storedHash = window.location.hash;\nwindow.setInterval(function () {\n if (window.location.hash != storedHash) {\n window.location.hash = storedHash;\n }\n}, 50);\n\n\n</script>\n</head>\n<body onload=\"changeHashOnLoad(); \">\nTry to hit the back button!\n</body>\n</html>\n"
},
{
"answer_id": 11268009,
"author": "Webveloper",
"author_id": 424671,
"author_profile": "https://Stackoverflow.com/users/424671",
"pm_score": 0,
"selected": false,
"text": "location.replace() location.replace('page3.html');"
},
{
"answer_id": 33186526,
"author": "Denis Chenu",
"author_id": 2239406,
"author_profile": "https://Stackoverflow.com/users/2239406",
"pm_score": 0,
"selected": false,
"text": "function removeBack(){\n window.location.hash=\"nbb\";\n window.location.hash=\"\";\n window.onhashchange=function(){window.location.hash=\"\";}\n}"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1942/"
] |
54,546 |
<p>Assemblies A and B are privately deployed and strongly named. Assembly A contains references to Assembly B. There are two versions of Assembly B: B1 and B2. I want to be able to indicate for Assembly A that it may bind to either B1 or B2 -- ideally, by incorporating this information into the assembly itself. What are my options?</p>
<p>I'm somewhat familiar with versioning policy and the way it applies to the GAC, but I don't want to be dependent on these assemblies being in the GAC.</p>
|
[
{
"answer_id": 54553,
"author": "Aaron Fischer",
"author_id": 5618,
"author_profile": "https://Stackoverflow.com/users/5618",
"pm_score": 1,
"selected": false,
"text": "Assembly.LoadFrom()"
},
{
"answer_id": 55560,
"author": "Adrian Clark",
"author_id": 148,
"author_profile": "https://Stackoverflow.com/users/148",
"pm_score": 3,
"selected": true,
"text": "<assemblyBinding>\n <dependantAssembly>\n <assemblyIdentity name=\"foo\" publicKeyToken=\"00000000000\" culture=\"neutral\" />\n <bindingRedirect oldVersion=\"0.0.0.0 - 2.0.0.0\" newVersion=\"2.5.0.0\" />\n </dependantAssembly>\n</assemblyBinding>\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/533/"
] |
54,566 |
<p>So I'm refactoring my code to implement more OOP. I set up a class to hold page attributes.</p>
<pre><code>class PageAtrributes
{
private $db_connection;
private $page_title;
public function __construct($db_connection)
{
$this->db_connection = $db_connection;
$this->page_title = '';
}
public function get_page_title()
{
return $this->page_title;
}
public function set_page_title($page_title)
{
$this->page_title = $page_title;
}
}
</code></pre>
<p>Later on I call the set_page_title() function like so</p>
<pre><code>function page_properties($objPortal) {
$objPage->set_page_title($myrow['title']);
}
</code></pre>
<p>When I do I receive the error message:</p>
<blockquote>
<p>Call to a member function set_page_title() on a non-object</p>
</blockquote>
<p>So what am I missing?</p>
|
[
{
"answer_id": 54572,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 7,
"selected": true,
"text": "$objPage function page_properties(PageAtrributes $objPortal) { \n ...\n $objPage->set_page_title($myrow['title']);\n}\n PageAtrributes"
},
{
"answer_id": 9621419,
"author": "Steve Breese",
"author_id": 1257523,
"author_profile": "https://Stackoverflow.com/users/1257523",
"pm_score": 2,
"selected": false,
"text": "$objPage = new PageAtrributes;\n\nfunction page_properties() {\n global $objPage;\n $objPage->set_page_title($myrow['title']);\n}\n"
},
{
"answer_id": 11807579,
"author": "Ahmad",
"author_id": 800816,
"author_profile": "https://Stackoverflow.com/users/800816",
"pm_score": 0,
"selected": false,
"text": "function page_properties($objPortal) use($objPage){ \n $objPage->set_page_title($myrow['title']);\n}\n"
},
{
"answer_id": 13055964,
"author": "David Urry",
"author_id": 511554,
"author_profile": "https://Stackoverflow.com/users/511554",
"pm_score": 5,
"selected": false,
"text": " $joe = null;\n $joe->anything();\n anything() anything() $joe"
},
{
"answer_id": 13668122,
"author": "dipole_moment",
"author_id": 1869326,
"author_profile": "https://Stackoverflow.com/users/1869326",
"pm_score": 3,
"selected": false,
"text": "$objPage $objPage PageAttributes"
},
{
"answer_id": 19642992,
"author": "Gui Lui",
"author_id": 2923742,
"author_profile": "https://Stackoverflow.com/users/2923742",
"pm_score": 2,
"selected": false,
"text": "$game = new game;\n\n$game->doGameStuff($gameReturn);\n\nforeach($gameArray as $game)\n{\n $game['STUFF']; // No longer an object and is now a standard variable pointer for $game.\n}\n\n\n\n$game->doGameStuff($gameReturn); // Wont work because $game is declared as a standard variable. You need to be careful when using common variable names and were they are declared in your code.\n"
},
{
"answer_id": 20092552,
"author": "Falc",
"author_id": 3012422,
"author_profile": "https://Stackoverflow.com/users/3012422",
"pm_score": 2,
"selected": false,
"text": "function page_properties($objPortal) { \n $objPage->set_page_title($myrow['title']);\n}\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54566",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2863/"
] |
54,567 |
<p>I've got an <code>JComboBox</code> with a custom <code>inputVerifyer</code> set to limit MaxLength when it's set to editable.</p>
<p>The verify method never seems to get called.<br>
The same verifyer gets invoked on a <code>JTextField</code> fine.</p>
<p>What might I be doing wrong?</p>
|
[
{
"answer_id": 54614,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 1,
"selected": false,
"text": "package inputverifier;\n\nimport javax.swing.*;\n\n class Go {\n public static void main(String[] args) {\n java.awt.EventQueue.invokeLater(new Runnable() { public void run() {\n runEDT();\n }});\n }\n private static void runEDT() {\n new JFrame(\"combo thing\") {{\n setLayout(new java.awt.GridLayout(2, 1));\n add(new JComboBox() {{\n setEditable(true);\n setInputVerifier(new InputVerifier() {\n @Override public boolean verify(JComponent input) {\n System.err.println(\"Hi!\");\n return true;\n }\n });\n }});\n add(new JTextField());\n setDefaultCloseOperation(EXIT_ON_CLOSE);\n pack();\n setVisible(true);\n }};\n } \n}\n"
},
{
"answer_id": 54799,
"author": "Allain Lalonde",
"author_id": 2443,
"author_profile": "https://Stackoverflow.com/users/2443",
"pm_score": 4,
"selected": true,
"text": "JComboBox combo = new JComboBox();\nJTextField tf = (JTextField)(combo.getEditor().getEditorComponent());\ntf.setInputVerifier(verifyer);\n"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2443/"
] |
54,578 |
<p>How do I capture the output of "%windir%/system32/pnputil.exe -e"?
(assume windows vista 32-bit)</p>
<p>Bonus for technical explanation of why the app normally writes output to the cmd shell, but when stdout and/or stderr are redirected then the app writes nothing to the console or to stdout/stderr?</p>
<pre>
C:\Windows\System32>PnPutil.exe --help
Microsoft PnP Utility {...}
C:\Windows\System32>pnputil -e > c:\foo.txt
C:\Windows\System32>type c:\foo.txt
C:\Windows\System32>dir c:\foo.txt
Volume in drive C has no label.
Volume Serial Number is XXXX-XXXX
Directory of c:\
09/10/2008 12:10 PM 0 foo.txt
1 File(s) 0 bytes
</pre>
|
[
{
"answer_id": 54588,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 0,
"selected": false,
"text": "svn status | find \"? \"\n svn status find \"? \" >"
},
{
"answer_id": 46796987,
"author": "Tim LaGrange",
"author_id": 8791813,
"author_profile": "https://Stackoverflow.com/users/8791813",
"pm_score": 0,
"selected": false,
"text": "pnputil.exe -e > c:\\driveroutput.txt\n driveroutput.txt C:"
}
] |
2008/09/10
|
[
"https://Stackoverflow.com/questions/54578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5429/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.