qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
276,575
|
<p>I am trying to migrate my .net remoting code to wcf but I'm finding it difficult. Can someone help me migrate this simple Remoting based program below to use WCF? The program implements a simple publisher/subscriber pattern where we have a single TemperatureProviderProgram that publishers to many TemperatureSubcriberPrograms that subcribe to the TemperatureProvider.</p>
<p>To run the programs:</p>
<ol>
<li>Copy the TemperatureProviderProgram and TemperatureSubcriberProgram into seperate console application projects.</li>
<li>Copying to remaining classes and interfaces into a common Class Library project then add a reference to System.Runtime.Remoting library</li>
<li>Add a reference to the Class Library project from the console app projects.</li>
<li>Complie and run 1 TemperatureProviderProgram and multiple TemperatureSubcriberProgram.</li>
</ol>
<p>Please note no IIS or xml should be used. Thanks in advance.</p>
<pre><code>public interface ITemperatureProvider
{
void Subcribe(ObjRef temperatureSubcriber);
}
[Serializable]
public sealed class TemperatureProvider : MarshalByRefObject, ITemperatureProvider
{
private readonly List<ITemperatureSubcriber> _temperatureSubcribers = new List<ITemperatureSubcriber>();
private readonly Random randomTemperature = new Random();
public void Subcribe(ObjRef temperatureSubcriber)
{
ITemperatureSubcriber tempSubcriber = (ITemperatureSubcriber)RemotingServices.Unmarshal(temperatureSubcriber);
lock (_temperatureSubcribers)
{
_temperatureSubcribers.Add(tempSubcriber);
}
}
public void Start()
{
Console.WriteLine("TemperatureProvider started...");
BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
TcpServerChannel tcpChannel = new TcpServerChannel("TemperatureProviderChannel", 5001, provider);
ChannelServices.RegisterChannel(tcpChannel, false);
RemotingServices.Marshal(this, "TemperatureProvider", typeof(ITemperatureProvider));
while (true)
{
double nextTemp = randomTemperature.NextDouble();
lock (_temperatureSubcribers)
{
foreach (var item in _temperatureSubcribers)
{
try
{
item.OnTemperature(nextTemp);
}
catch (SocketException)
{}
catch(RemotingException)
{}
}
}
Thread.Sleep(200);
}
}
}
public interface ITemperatureSubcriber
{
void OnTemperature(double temperature);
}
[Serializable]
public sealed class TemperatureSubcriber : MarshalByRefObject, ITemperatureSubcriber
{
private ObjRef _clientRef;
private readonly Random portGen = new Random();
public void OnTemperature(double temperature)
{
Console.WriteLine(temperature);
}
public override object InitializeLifetimeService()
{
return null;
}
public void Start()
{
BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
int port = portGen.Next(1, 65535);
TcpServerChannel tcpChannel = new TcpServerChannel(string.Format("TemperatureSubcriber_{0}", Guid.NewGuid()), port, provider);
ChannelServices.RegisterChannel(tcpChannel, false);
ITemperatureProvider p1 = (ITemperatureProvider)RemotingServices.Connect(typeof(ITemperatureProvider), "tcp://localhost:5001/TemperatureProvider");
_clientRef = RemotingServices.Marshal(this, string.Format("TemperatureSubcriber_{0}_{1}.rem", Environment.MachineName, Guid.NewGuid()));
p1.Subcribe(_clientRef);
}
}
public class TemperatureProviderProgram
{
static void Main(string[] args)
{
TemperatureProvider tp = new TemperatureProvider();
tp.Start();
}
}
public class TemperatureSubcriberProgram
{
static void Main(string[] args)
{
Console.WriteLine("Press any key to start TemperatureSubcriber.");
Console.ReadLine();
TemperatureSubcriber ts = new TemperatureSubcriber();
ts.Start();
Console.ReadLine();
}
}
</code></pre>
|
[
{
"answer_id": 277405,
"author": "Alexandre Brisebois",
"author_id": 18619,
"author_profile": "https://Stackoverflow.com/users/18619",
"pm_score": 1,
"selected": false,
"text": "WCF WCF"
},
{
"answer_id": 277406,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 1,
"selected": false,
"text": "MarshalByRefObject NetDataContractSerializer DataContractSerializer"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
276,585
|
<p>In vs2008, is it possible to write an extension methods which would apply to any enumeration.</p>
<p>I know you can write extension methods against a specific enumeration, but I want to be able to every enumeration using a single extension method. Is this possible?</p>
|
[
{
"answer_id": 276589,
"author": "Greg Beech",
"author_id": 13552,
"author_profile": "https://Stackoverflow.com/users/13552",
"pm_score": 7,
"selected": true,
"text": "Enum public static void Something(this Enum e)\n{\n // code here\n}\n Enum.GetUnderlyingType IsOneOf IsCombinationOf float double"
},
{
"answer_id": 276600,
"author": "Scott Dorman",
"author_id": 1559,
"author_profile": "https://Stackoverflow.com/users/1559",
"pm_score": 4,
"selected": false,
"text": "Enum public static void EnumExtension(this Enum e)\n{\n}\n <Extension()> _\nPublic Sub EnumExtension(ByVal s As Enum)\nEnd Sub\n"
},
{
"answer_id": 1010107,
"author": "Michael La Voie",
"author_id": 65843,
"author_profile": "https://Stackoverflow.com/users/65843",
"pm_score": 4,
"selected": false,
"text": "public static class ExtensionMethods\n{\n public static bool TryParse<T>(this Enum theEnum, string strType, \n out T result)\n {\n string strTypeFixed = strType.Replace(' ', '_');\n if (Enum.IsDefined(typeof(T), strTypeFixed))\n {\n result = (T)Enum.Parse(typeof(T), strTypeFixed, true);\n return true;\n }\n else\n {\n foreach (string value in Enum.GetNames(typeof(T)))\n {\n if (value.Equals(strTypeFixed, \n StringComparison.OrdinalIgnoreCase))\n {\n result = (T)Enum.Parse(typeof(T), value);\n return true;\n }\n }\n result = default(T);\n return false;\n }\n }\n}\n public enum TestEnum\n{\n A,\n B,\n C\n}\n\npublic void TestMethod(string StringOfEnum)\n{\n TestEnum myEnum;\n myEnum.TryParse(StringOfEnum, out myEnum);\n}\n"
},
{
"answer_id": 8830545,
"author": "Adriaan de Beer",
"author_id": 1144750,
"author_profile": "https://Stackoverflow.com/users/1144750",
"pm_score": 3,
"selected": false,
"text": "public static class ExtensionMethods \n{\n public static void ForEach(this Enum enumType, Action<Enum> action)\n {\n foreach (var type in Enum.GetValues(enumType.GetType()))\n {\n action((Enum)type);\n }\n }\n}\n\npublic enum TestEnum { A,B,C } \npublic void TestMethod() \n{\n default(TestEnum).ForEach(Console.WriteLine); \n} \n"
},
{
"answer_id": 11191138,
"author": "Koray Bayram",
"author_id": 846384,
"author_profile": "https://Stackoverflow.com/users/846384",
"pm_score": 2,
"selected": false,
"text": "public static class Extensions\n{\n public static ConvertType Convert<ConvertType>(this Enum e)\n {\n object o = null;\n Type type = typeof(ConvertType);\n\n if (type == typeof(int))\n {\n o = Convert.ToInt32(e);\n }\n else if (type == typeof(long))\n {\n o = Convert.ToInt64(e);\n }\n else if (type == typeof(short))\n {\n o = Convert.ToInt16(e);\n }\n else\n {\n o = Convert.ToString(e);\n }\n\n return (ConvertType)o;\n }\n}\n int a = MyEnum.A.Convert<int>();\n"
},
{
"answer_id": 19707946,
"author": "Esge",
"author_id": 2190520,
"author_profile": "https://Stackoverflow.com/users/2190520",
"pm_score": 2,
"selected": false,
"text": "enum Enum1 { One = 1, Two = 2, Three = 3 };\nenum Enum2 { Due = 2, Uno = 1 };\nenum Enum3 { Two, One };\n\nEnum2 e2 = Enum1.One.ConvertByValue<Enum2>();\nEnum3 e3 = Enum1.One.ConvertByName<Enum3>();\nEnum3 x2 = Enum1.Three.ConvertByValue<Enum3>();\n\npublic static class EnumConversionExtensions\n{\n public static T ConvertByName<T>(this Enum value)\n {\n return (T)Enum.Parse(typeof(T), Enum.GetName(value.GetType(), value));\n }\n\n public static T ConvertByValue<T>(this Enum value)\n {\n return (T)((dynamic)((int)((object)value)));\n }\n}\n"
},
{
"answer_id": 31527513,
"author": "Bronek",
"author_id": 769465,
"author_profile": "https://Stackoverflow.com/users/769465",
"pm_score": 1,
"selected": false,
"text": "public static IEnumerable<T> toElementsCollection<T>(this T value) where T : struct, IConvertible\n {\n if (typeof(T).IsEnum == false) throw new Exception(\"typeof(T).IsEnum == false\");\n\n return Enum.GetValues(typeof(T)).Cast<T>();\n }\n public enum TestEnum { A,B,C };\n\nTestEnum.A.toElementsCollection();\n"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/100/"
] |
276,601
|
<p>Can Emacs support the concept of projects? That would be where several configuration options varies depending on what project you are working on.</p>
|
[
{
"answer_id": 276618,
"author": "dmckee --- ex-moderator kitten",
"author_id": 2509,
"author_profile": "https://Stackoverflow.com/users/2509",
"pm_score": 3,
"selected": true,
"text": "yourproject.el M-x load-file"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6068/"
] |
276,602
|
<p>In php I need to get the contents of a url (source) search for a string "maybe baby love you" and if it does not contain this then do x.</p>
|
[
{
"answer_id": 276611,
"author": "okoman",
"author_id": 35903,
"author_profile": "https://Stackoverflow.com/users/35903",
"pm_score": 4,
"selected": true,
"text": "$url = 'http://my.url.com/';\n$data = file_get_contents( $url );\n\nif ( strpos( 'maybe baby love you', $data ) === false )\n{\n\n // do something\n\n}\n"
},
{
"answer_id": 276614,
"author": "Alan Storm",
"author_id": 4668,
"author_profile": "https://Stackoverflow.com/users/4668",
"pm_score": 0,
"selected": false,
"text": "$string = file_get_contents('http://example.com/file.html');\nif(strpos ('maybe baby love you', $string) === false){ \n //do X\n}\n"
},
{
"answer_id": 2040523,
"author": "Tarek Ahmed",
"author_id": 247871,
"author_profile": "https://Stackoverflow.com/users/247871",
"pm_score": 3,
"selected": false,
"text": "//The Answer No 3 Is good But a small Mistake in the function strpos() I have correction the code bellow.\n\n$url = 'http://my.url.com/';\n$data = file_get_contents( $url );\n\nif ( strpos($data,'maybe baby love you' ) === false )\n{\n // do something\n}\n"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26823/"
] |
276,610
|
<p>I am in the process of designing a daily build routine for my project. We are using Flex 3 and SQL Server 2005. I am unsure to what degree I should be rebuilding the database on a daily build. Should I be dropping all tables and stored procedures and adding them back in? Then I would have to have a script that put all the default data back into the tables.</p>
<p>Or should I have the DBA write Alter scripts that only run when changes are made and concentrate on building the code on a daily basis?</p>
|
[
{
"answer_id": 276633,
"author": "Todd",
"author_id": 31940,
"author_profile": "https://Stackoverflow.com/users/31940",
"pm_score": 2,
"selected": true,
"text": "sp_ generate_inserts"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36014/"
] |
276,612
|
<p>Given a pointer to some variable.. is there a way to check whether it was statically or dynamically allocated?? </p>
|
[
{
"answer_id": 276676,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 5,
"selected": true,
"text": "malloc() alloca() malloc() new new[] malloc() new mmap LocalAlloc GlobalAlloc HeapAlloc"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276612",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25990/"
] |
276,656
|
<p>So let's say I'm using Python 2.5's built-in default sqlite3 and I have a Django model class with the following code:</p>
<pre><code>class SomeEntity(models.Model):
some_field = models.CharField(max_length=50, db_index=True, unique=True)
</code></pre>
<p>I've got the admin interface setup and everything appears to be working fine except that I can create two SomeEntity records, one with some_field='some value' and one with some_field='Some Value' because the unique constraint on some_field appears to be case sensitive.</p>
<p>Is there some way to force sqlite to perform a case <em>in</em>sensitive comparison when checking for uniqueness?</p>
<p>I can't seem to find an option for this in Django's docs and I'm wondering if there's something that I can do directly to sqlite to get it to behave the way I want. :-)</p>
|
[
{
"answer_id": 471066,
"author": "Noah",
"author_id": 12113,
"author_profile": "https://Stackoverflow.com/users/12113",
"pm_score": 5,
"selected": true,
"text": "import sqlite3\n\ndef collate_reverse(string1, string2):\n return -cmp(string1, string2)\n\ncon = sqlite3.connect(\":memory:\")\ncon.create_collation(\"reverse\", collate_reverse)\n\ncur = con.cursor()\ncur.execute(\"create table test(x)\")\ncur.executemany(\"insert into test(x) values (?)\", [(\"a\",), (\"b\",)])\ncur.execute(\"select x from test order by x collate reverse\")\nfor row in cur:\n print row\ncon.close()\n"
},
{
"answer_id": 70322810,
"author": "Alireza Farahani",
"author_id": 1660013,
"author_profile": "https://Stackoverflow.com/users/1660013",
"pm_score": 2,
"selected": false,
"text": "class Meta:\n constraints = [\n models.UniqueConstraint(\n Lower('<field name>'),\n name='<constraint name>'\n ),\n ]\n"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29123/"
] |
276,660
|
<p>I need to warn users about unsaved changes before they leave a page (a pretty common problem).</p>
<pre><code>window.onbeforeunload = handler
</code></pre>
<p>This works but it raises a default dialog with an irritating standard message that wraps my own text. I need to either completely replace the standard message, so my text is clear, or (even better) replace the entire dialog with a modal dialog using jQuery.</p>
<p>So far I have failed and I haven't found anyone else who seems to have an answer. Is it even possible?</p>
<p>Javascript in my page:</p>
<pre><code><script type="text/javascript">
window.onbeforeunload = closeIt;
</script>
</code></pre>
<p>The closeIt() function:</p>
<pre><code>function closeIt()
{
if (changes == "true" || files == "true")
{
return "Here you can append a custom message to the default dialog.";
}
}
</code></pre>
<p>Using jQuery and jqModal I have tried this kind of thing (using a custom confirm dialog):</p>
<pre><code>$(window).beforeunload(function () {
confirm('new message: ' + this.href + ' !', this.href);
return false;
});
</code></pre>
<p>which also doesn't work - I cannot seem to bind to the <code>beforeunload</code> event.</p>
|
[
{
"answer_id": 276739,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 9,
"selected": true,
"text": "onbeforeunload window.onbeforeunload = function() {\n return 'You have unsaved changes!';\n}\n onbeforeunload window.event.returnValue false true false false onbeforeunload onbeforeunload onbeforeunload bind $(window).bind('beforeunload', function() {} );\n"
},
{
"answer_id": 3532762,
"author": "Ricardo stands with Ukraine",
"author_id": 364568,
"author_profile": "https://Stackoverflow.com/users/364568",
"pm_score": 1,
"selected": false,
"text": "$(window).one(\"beforeunload\", BeforeUnload);\n"
},
{
"answer_id": 4991688,
"author": "grebe",
"author_id": 616120,
"author_profile": "https://Stackoverflow.com/users/616120",
"pm_score": 5,
"selected": false,
"text": "$(window).bind(\"beforeunload\",function(event) {\n if(hasChanged) return \"You have unsaved changes\";\n});\n"
},
{
"answer_id": 6305669,
"author": "Imran Rizvi",
"author_id": 252975,
"author_profile": "https://Stackoverflow.com/users/252975",
"pm_score": 2,
"selected": false,
"text": "function closeMe(evt) {\n if (typeof evt == 'undefined') {\n evt = window.event; }\n if (evt && evt.clientX >= (window.event.screenX - 150) &&\n evt.clientY >= -150 && evt.clientY <= 0) {\n return \"Do you want to log out of your current session?\";\n }\n}\nwindow.onbeforeunload = closeMe;\n"
},
{
"answer_id": 9546411,
"author": "Tamas Cseh",
"author_id": 1246818,
"author_profile": "https://Stackoverflow.com/users/1246818",
"pm_score": 2,
"selected": false,
"text": "function onunload = (){\n window.open('logout.php');\n}\n window.close();\n"
},
{
"answer_id": 9735315,
"author": "Krishna Patel",
"author_id": 1273745,
"author_profile": "https://Stackoverflow.com/users/1273745",
"pm_score": 1,
"selected": false,
"text": " <script type=\"text/javascript\">\n window.onbeforeunload = function(evt) {\n var message = 'Are you sure you want to leave?';\n if (typeof evt == 'undefined') {\n evt = window.event;\n } \n if (evt) {\n evt.returnValue = message;\n }\n return message;\n } \n </script>\n"
},
{
"answer_id": 11445108,
"author": "Dan Power",
"author_id": 1118863,
"author_profile": "https://Stackoverflow.com/users/1118863",
"pm_score": 5,
"selected": false,
"text": "$(':input').change(function() {\n if(!is_dirty){\n // When the user changes a field on this page, set our is_dirty flag.\n is_dirty = true;\n }\n});\n\n$('a').mousedown(function(e) {\n if(is_dirty) {\n // if the user navigates away from this page via an anchor link, \n // popup a new boxy confirmation.\n answer = Boxy.confirm(\"You have made some changes which you might want to save.\");\n }\n});\n\nwindow.onbeforeunload = function() {\nif((is_dirty)&&(!answer)){\n // call this if the box wasn't shown.\n return 'You have made some changes which you might want to save.';\n }\n};\n"
},
{
"answer_id": 15005467,
"author": "Donald Powell",
"author_id": 1735037,
"author_profile": "https://Stackoverflow.com/users/1735037",
"pm_score": 2,
"selected": false,
"text": "return; window.onbeforeunload = function(evt) { \n //Your Extra Code\n return;\n}\n"
},
{
"answer_id": 61478410,
"author": "Istvan Dembrovszky",
"author_id": 7751106,
"author_profile": "https://Stackoverflow.com/users/7751106",
"pm_score": 3,
"selected": false,
"text": "constructor() {\n window.addEventListener('beforeunload', (event: BeforeUnloadEvent) => {\n if (this.generatedBarcodeIndex) {\n event.preventDefault(); // for Firefox\n event.returnValue = ''; // for Chrome\n return '';\n }\n return false;\n });\n }\n"
},
{
"answer_id": 71094846,
"author": "Muhwezi Jerald basasa",
"author_id": 6682117,
"author_profile": "https://Stackoverflow.com/users/6682117",
"pm_score": 0,
"selected": false,
"text": "$(window).bind('beforeunload', function (event) {\n setTimeout(function () {\n var retVal = confirm(\"Do you want to continue ?\");\n if (retVal == true) {\n alert(\"User wants to continue!\");\n return true;\n }\n else {\n window.stop();\n return false;\n }\n });\n return;\n });\n"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27805/"
] |
276,666
|
<p>I have got 3 text files (A, B and C), each with several hundred email addresses. I want to merge list A and list B into a single file, ignoring differences in case and white space. Then I want to remove all emails in the new list that are in list C, again ignoring differences in case and white space.</p>
<p>My programming language of choice is normally C++, but it seems poorly suited for this task. Is there a scripting language that could do this (and similar tasks) in relatively few lines?</p>
<p>Or is there software already out there (free or commercial) that would allow me to do it? Is it possible to do it in Excel, for example?</p>
|
[
{
"answer_id": 276687,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 2,
"selected": false,
"text": "set list to empty\nforeach line in file one:\n key = unwhitespace(tolowercase(line))\n list{key} = line\nforeach line in file two:\n key = unwhitespace(tolowercase(line))\n list{key} = line\nforeach line in file three:\n key = unwhitespace(tolowercase(line))\n if exists(list{key})\n delete list{key}\nforeach key in list:\n print list{key}\n"
},
{
"answer_id": 276700,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 1,
"selected": false,
"text": "def read_file(filename):\n with file(filename, \"r\") as f:\n while True:\n line = f.readline();\n if not line:\n break;\n line = line.rstrip();\n if line:\n yield line;\n\ndef write_file(filename, lines):\n with file(filename, \"w\") as f:\n for line in lines:\n f.write(line + \"\\n\");\n\nset_a = set((line.lower() for line in read_file(\"file_a.txt\")));\nset_b = set((line.lower() for line in read_file(\"file_b.txt\")));\nset_c = set((line.lower() for line in read_file(\"file_c.txt\")));\n\n# Calculate (a + b) - c\nwrite_file(\"result.txt\", set_a.union(set_b).difference(set_c));\n"
},
{
"answer_id": 276723,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 2,
"selected": false,
"text": "Set cn = CreateObject(\"ADODB.Connection\")\nstrCon = \"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Docs\\;\" _\n& \"Extended Properties=\"\"text;HDR=No;FMT=Delimited\"\";\"\n\ncn.Open strCon\n\nstrSQL = \"SELECT F1 Into New.txt From EmailsA.txt \" _\n & \"WHERE UCase(F1) Not IN (SELECT UCase(F1) From EmailsC.txt)\"\ncn.Execute strSQL\n\nstrSQL = \"INSERT INTO New.txt ( F1 ) SELECT F1 FROM EmailsB.txt \" _\n & \"WHERE UCase(F1) Not IN (SELECT UCase(F1) From EmailsC.txt)\"\ncn.Execute strSQL\n"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
276,677
|
<p>I'm a self-taught developer and my experience is all in small applications that I've developed.</p>
<p>I'm currently working on an application that I've made public, and I've realized that I need to start doing good unit testing to catch regressions and generally make sure everything works.</p>
<p>I've read up on a <a href="https://stackoverflow.com/questions/205566/comprehensive-introduction-to-unit-testing">previous question</a>. I would like to know if there are any resources online specifically dealing with C# unit testing in Visual Studio 2008, preferably with examples.</p>
<p>EDIT: I'm using Visual Studio 2008 Professional for Windows applications, no web development.</p>
|
[
{
"answer_id": 277253,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 4,
"selected": true,
"text": "[TestFixture]\npublic class Foo {\n [Test]\n public void Bar() {\n Assert.AreEqual(2, 1+1);\n }\n}\n"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5982/"
] |
276,678
|
<p>C#: What is the proper way to change the font style (underline) from a Label at runtime?</p>
<p>So far I understand that if you want to change font related properties at runtime from a label, mainly all font properties, you would have to use,</p>
<pre><code> lblName.Font = new Font(... etc. etc.
</code></pre>
<p>Is there a shortcut to the above but only assign nothing but a new Font style such FontStyle.Underline? </p>
<p>or </p>
<p>Would I have to proceed with using the "new Font()" method and assign all fields along with it too just to underline my label?</p>
|
[
{
"answer_id": 276686,
"author": "wonderchook",
"author_id": 32113,
"author_profile": "https://Stackoverflow.com/users/32113",
"pm_score": 0,
"selected": false,
"text": " //\n // Summary:\n // Gets or sets a value that indicates whether the font is underlined.\n //\n // Returns:\n // true if the font is underlined; otherwise, false. The default value is false.\n [DefaultValue(false)]\n [NotifyParentProperty(true)]\n public bool Underline { get; set; }\n"
},
{
"answer_id": 276785,
"author": "denis phillips",
"author_id": 748,
"author_profile": "https://Stackoverflow.com/users/748",
"pm_score": 4,
"selected": false,
"text": "this.Font = new Font(this.Font, FontStyle.Underline);\n"
},
{
"answer_id": 9751280,
"author": "Syed Baqar Hassan",
"author_id": 1271468,
"author_profile": "https://Stackoverflow.com/users/1271468",
"pm_score": 1,
"selected": false,
"text": "//Bold.\n label1.Font = new Font(label1.Font.Name, 12, FontStyle.Bold); \n\n//Bold With Underline.\n label1.Font = new Font(label1.Font.Name, 12, FontStyle.Bold | FontStyle.Underline); \n\n//Bold with Underline with Italic.\n label1.Font = new Font(label1.Font.Name, 12, FontStyle.Bold | FontStyle.Underline | FontStyle.Italic); \n"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
276,679
|
<p>Is it possible to import a python file more than once in a python script because i run a loop back to my driver file in a function by using the import command but it only works once? thanks</p>
<p><strong>edit:</strong> Resolved myself thanks</p>
|
[
{
"answer_id": 276692,
"author": "Tom Leys",
"author_id": 11440,
"author_profile": "https://Stackoverflow.com/users/11440",
"pm_score": 2,
"selected": false,
"text": "def main():\n # All the code that currently does work goes in here \n # rather than just in the module\n import your_module #used to do the work\n\nyour_module.main() # now does the work (and you can call it multiple times)\n# some other code\nyour_module.main() # do the work again\n"
},
{
"answer_id": 276694,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "execfile() eval()"
},
{
"answer_id": 277463,
"author": "Matthew Trevor",
"author_id": 11265,
"author_profile": "https://Stackoverflow.com/users/11265",
"pm_score": 1,
"selected": false,
"text": "module.py:\nprint \"imported!\"\n\n>>> import module\nimported!\n>>> reload(module)\nimported!\n<module 'module' from 'module.pyc'>\n"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
276,693
|
<p>What is the best way to change the height and width of an ASP.NET control from a client-side Javascript function?</p>
<p>Thanks,
Jeff</p>
|
[
{
"answer_id": 276789,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 1,
"selected": true,
"text": "example usage:\n\n<input type='button' value='Expand' onclick='setSize(\"myDiv\", 500, 500);' />\n\n...\n\nfunction setSize(ctlName, height, width ) {\n var ctl = asp$( ctlName, 'div' );\n if (ctl) {\n ctl.style.height = height + 'px';\n ctl.style.width = width + 'px';\n }\n}\n\n\nfunction asp$( id, tagName ) {\n var idRegexp = new RegExp( id + '$', 'i' );\n var tags = new Array();\n if (tagName) {\n tags = document.getElementsByTagName( tagName );\n }\n else {\n tags = document.getElementsByName( id );\n }\n var control = null;\n for (var i = 0; i < tags.length; ++i) {\n var ctl = tags[i];\n if (idRegexp.test(ctl.id)) {\n control = ctl;\n break;\n }\n }\n\n if (control) {\n return $(control.id);\n }\n else {\n return null;\n }\n}\n"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12172/"
] |
276,706
|
<p>I'm someone who writes code just for fun and haven't really delved into it in either an academic or professional setting, so stuff like these bitwise operators really escapes me.</p>
<p>I was reading an article about JavaScript, which apparently supports bitwise operations. I keep seeing this operation mentioned in places, and I've tried reading about to figure out what exactly it is, but I just don't seem to get it at all. So what are they? Clear examples would be great! :D</p>
<p>Just a few more questions - what are some practical applications of bitwise operations? When might you use them?</p>
|
[
{
"answer_id": 276711,
"author": "Jeff Hillman",
"author_id": 3950,
"author_profile": "https://Stackoverflow.com/users/3950",
"pm_score": 4,
"selected": false,
"text": "op1 & op2 AND op1 | op2 OR op1 ^ op2 EXCLUSIVE-OR ~op1 COMPLEMENT op1 << op2 SHIFT LEFT op1 >> op2 SHIFT RIGHT op1 >>> op2 SHIFT RIGHT ZERO FILL"
},
{
"answer_id": 276715,
"author": "paxdiablo",
"author_id": 14860,
"author_profile": "https://Stackoverflow.com/users/14860",
"pm_score": 5,
"selected": false,
"text": "AND|0 1 OR|0 1\n---+---- ---+----\n 0|0 0 0|0 1\n 1|0 1 1|1 1\n\nXOR|0 1 NOT|0 1\n---+---- ---+---\n 0|0 1 |1 0\n 1|1 0\n 203: 1100 1011\nAND 15: 0000 1111\n------------------\n IS 11: 0000 1011\n"
},
{
"answer_id": 276724,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": false,
"text": "int x = 5 & 6;\n 5 = 0 0 0 0 0 1 0 1\n& 6 = 0 0 0 0 0 1 1 0\n---------------------\n 0 0 0 0 0 1 0 0\n"
},
{
"answer_id": 276750,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 2,
"selected": false,
"text": "a = \"Cat\" && \"Dog\" // t && t returns Dog\na = 2 && 4 // t && t returns 4\n <html>\n<body>\n<script>\n alert(\"\\\"Cat\\\" && \\\"Dog\\\" = \" + (\"Cat\" && \"Dog\") + \"\\n\"\n + \"2 && 4 = \" + (2 && 4) + \"\\n\"\n + \"2 & 4 = \" + (2 & 4));\n</script>\n"
},
{
"answer_id": 276771,
"author": "Ed Marty",
"author_id": 36007,
"author_profile": "https://Stackoverflow.com/users/36007",
"pm_score": 9,
"selected": true,
"text": "File.Open() Read: 00000001\nWrite: 00000010\n 00000011\n if ((flag & Read) != 0) { //...\n 00000011 &\n00000001\n 00000001\n Up: 00000001\n Down: 00000010\n Left: 00000100\n Right: 00001000\nCurrent: 00000100\n x << y\n int val = (A << 24) | (B << 16) | (C << 8) | D;\n A = 01000000\nB = 00000101\nC = 00101011\nD = 11100011\nval = 01000000 00000101 00101011 11100011\n A = 255 = 11111111\nR = 21 = 00010101\nG = 255 = 11111111\nB = 0 = 00000000\nColor = 11111111 00010101 11111111 00000000\n Int Alpha = Color >> 24\nInt Red = Color >> 16 & 0xFF\nInt Green = Color >> 8 & 0xFF\nInt Blue = Color & 0xFF\n 0xFF 11111111 Color >> 16 = (filled in 00000000 00000000)11111111 00010101 (removed 11111111 00000000)\n00000000 00000000 11111111 00010101 &\n00000000 00000000 00000000 11111111 =\n00000000 00000000 00000000 00010101 (The original value)\n"
},
{
"answer_id": 24329660,
"author": "user3677963",
"author_id": 3677963,
"author_profile": "https://Stackoverflow.com/users/3677963",
"pm_score": 0,
"selected": false,
"text": " 5: 00000101\n 3: 00000011\n"
},
{
"answer_id": 36762031,
"author": "Prashant",
"author_id": 3404480,
"author_profile": "https://Stackoverflow.com/users/3404480",
"pm_score": 2,
"selected": false,
"text": " AND|0 1 OR|0 1 \n ---+---- ---+---- \n 0|0 0 0|0 1 \n 1|0 1 1|1 1 \n\n XOR|0 1 NOT|0 1 \n ---+---- ---+--- \n 0|0 1 |1 0 \n 1|1 0\n 203: 1100 1011\nAND 15: 0000 1111\n------------------\n = 11: 0000 1011\n int main()\n{\n int x = 19;\n printf (\"x << 1 = %d\\n\" , x <<1);\n printf (\"x >> 1 = %d\\n\", x >>1);\n return 0;\n}\n// Output: 38 9\n int main()\n{\n int x = 19;\n (x & 1)? printf(\"Odd\"): printf(\"Even\");\n return 0;\n }\n// Output: Odd\n if else int min(int x, int y)\n{\n return y ^ ((x ^ y) & - (x < y))\n}\n #include <stdio.h>\nint main ()\n{\n int n , c , k ;\n printf(\"Enter an integer in decimal number system\\n \" ) ;\n scanf( \"%d\" , & n );\n printf(\"%d in binary number\n system is: \\n \" , n ) ;\n for ( c = 31; c >= 0 ; c -- )\n {\n k = n >> c ;\n if ( k & 1 )\n printf(\"1\" ) ;\n else\n printf(\"0\" ) ;\n }\n printf(\" \\n \" );\n return 0 ;\n}\n"
}
] |
2008/11/09
|
[
"https://Stackoverflow.com/questions/276706",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36032/"
] |
276,732
|
<p>I have a CSS like this</p>
<pre><code>ul {
list-style-image:url(images/bulletArrow.gif);
}
ul li {
background: url(images/hr.gif) no-repeat left bottom;
padding: 5px 0 7px 0;
}
</code></pre>
<p>But the bullet image doesn't align properly in IE (it's fine in Firefox).
I already have a background image for li, so I can't use the bullet image as a background.
Is there any solution to this?</p>
<p>Thanks in advance.</p>
|
[
{
"answer_id": 276820,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 5,
"selected": false,
"text": "list-style-image"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276732",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36036/"
] |
276,737
|
<p>I have one large access database that I need to normalize into five tables and a lookup table. I understand the theory behind normalization and have already sketched out the look of the tables but I am lost on how to transform my table to get the database normalized. The table analyzers doesn't offer the the breakdown that I want. </p>
|
[
{
"answer_id": 276953,
"author": "David-W-Fenton",
"author_id": 9787,
"author_profile": "https://Stackoverflow.com/users/9787",
"pm_score": 3,
"selected": false,
"text": " tblPerson\n LastName, FirstName, WorkPhone, HomePhone\n tblPhone\n PhoneID, PersonID, PhoneNumber, Type\n INSERT INTO tblPhone (PersonID, PhoneNumber, Type)\n SELECT tblPerson.PersonID, tblPerson.WorkPhone, \"Work\"\n FROM tblPerson\n WHERE tblPerson.WorkPhone Is Not Null;\n INSERT INTO tblPhone (PersonID, PhoneNumber, Type)\n SELECT tblPerson.PersonID, tblPerson.HomePhone, \"Home\"\n FROM tblPerson\n WHERE tblPerson.HomePhone Is Not Null;\n SELECT tblPerson.PersonID, tblPerson.WorkPhone, \"Work\" As Type\n FROM tblPerson\n WHERE tblPerson.WorkPhone Is Not Null\n UNION ALL \n SELECT tblPerson.PersonID, tblPerson.HomePhone, \"Home\" As Type\n FROM tblPerson\n WHERE tblPerson.HomePhone Is Not Null;\n INSERT INTO tblPhone (PersonID, PhoneNumber, Type)\n SELECT qryPhones.PersonID, qryPhones.WorkPhone, qryPhones.Type\n FROM qryPhones;\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
276,740
|
<p>I want to retrieve a list of the files that has been added or deleted from our Subversion repository over, for example, the last month.</p>
<p>I'd prefer to have the file names, and not just a count.</p>
<p>Is this possible from the Subversion command line, or would I need to use a script to trawl the log?</p>
|
[
{
"answer_id": 276755,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 4,
"selected": true,
"text": "svn log -v --xml | grep 'action=\"[A|D]\"'\n"
},
{
"answer_id": 19625050,
"author": "M0les",
"author_id": 2060068,
"author_profile": "https://Stackoverflow.com/users/2060068",
"pm_score": 2,
"selected": false,
"text": "% svn log -v -r \\{2013-09-01\\}:\\{2013-10-31\\}|grep ' D'\n"
},
{
"answer_id": 33172450,
"author": "Danny Parker",
"author_id": 164089,
"author_profile": "https://Stackoverflow.com/users/164089",
"pm_score": 2,
"selected": false,
"text": "svn diff -r 14311:HEAD --summarize | findstr \"^A\" > AddedFiles.txt\nsvn diff -r 14311:HEAD --summarize | findstr \"^D\" > DeletedFiles.txt\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6340/"
] |
276,757
|
<p>I need to create an API that will allow my customer's developers to use a proprietary C module that will be released as a library (think <code>.lib</code> or <code>.so</code> -- not source).</p>
<p>I'd like to make the header as developer-friendly as possible (so I won't need to be), following best practices and providing comments with descriptions, examples, caveats, <em>etc</em>.</p>
<p>What else should I consider from business, technical, and plain common-sense perspectives?</p>
<p>Thanks!</p>
|
[
{
"answer_id": 276777,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 3,
"selected": true,
"text": "#include \"your-header.h\""
},
{
"answer_id": 278386,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 2,
"selected": false,
"text": "FILENAME_20081110_H_ CONFIG_H_ #ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* your stuff */\n\n#ifdef __cplusplus\n}\n#endif\n"
},
{
"answer_id": 282263,
"author": "Krunch",
"author_id": 35831,
"author_profile": "https://Stackoverflow.com/users/35831",
"pm_score": 2,
"selected": false,
"text": "typedef unsigned short uchar;\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29157/"
] |
276,758
|
<p>I have a fairly large database with with a column that has strings that are for the most part really just ints, e.g. "1234" or "345". However some of them have strings prepended to them (of varying length), so e.g. "a123" or "abc123".</p>
<p>Is there a smart way to create a new column with just the integer values? Thus, "abc123" would become "123"? I know I can read all of the rows in PHP and then use a regex to do it pretty easily but I wanted to see if there was a way to let SQL do this for me.</p>
|
[
{
"answer_id": 276777,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 3,
"selected": true,
"text": "#include \"your-header.h\""
},
{
"answer_id": 278386,
"author": "Evan Teran",
"author_id": 13430,
"author_profile": "https://Stackoverflow.com/users/13430",
"pm_score": 2,
"selected": false,
"text": "FILENAME_20081110_H_ CONFIG_H_ #ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* your stuff */\n\n#ifdef __cplusplus\n}\n#endif\n"
},
{
"answer_id": 282263,
"author": "Krunch",
"author_id": 35831,
"author_profile": "https://Stackoverflow.com/users/35831",
"pm_score": 2,
"selected": false,
"text": "typedef unsigned short uchar;\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
276,769
|
<p>I'm trying to expose this function to Python using SWIG:</p>
<pre><code>std::vector<int> get_match_stats();
</code></pre>
<p>And I want SWIG to generate wrapping code for Python so I can see it as a list of integers.</p>
<p>Adding this to the .i file:</p>
<pre>
%include "typemaps.i"
%include "std_vector.i"
namespace std
{
%template(IntVector) vector<int>;
}
</pre>
<p>I'm running <code>SWIG Version 1.3.36</code> and calling swig with <code>-Wall</code> and I get no warnings.</p>
<p>I'm able to get access to a list but I get a bunch of warnings when compiling with <code>-Wall</code> (with <code>g++ (GCC) 4.2.4</code> ) the generated C++ code that say:</p>
<pre>
warning: dereferencing type-punned pointer will break strict-aliasing rules
</pre>
<p>Am I exposing the function correctly? If so, what does the warning mean?</p>
<hr>
<p>These are the lines before the offending line in the same function:</p>
<pre>
SWIGINTERN PyObject *_wrap_IntVector_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
std::vector *arg1 = (std::vector *) 0 ;
std::vector::iterator arg2 ;
std::vector::iterator result;
void *argp1 = 0 ;
int res1 = 0 ;
swig::PySwigIterator *iter2 = 0 ;
int res2 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OO:IntVector_erase",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_erase" "', argument " "1"" of type '" "std::vector *""'");
}
arg1 = reinterpret_cast * >(argp1);
</pre>
<p>And this is the offending line:</p>
<pre>
res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
</pre>
<p>More code follows that.</p>
<p>The warning generated when compiling with g++ 4.2.4 is:</p>
<pre>
swig_iss_wrap.cxx: In function ‘PyObject* _wrap_IntVector_erase__SWIG_0(PyObject*, PyObject*)’:
swig_iss_wrap.cxx:5885: warning: dereferencing type-punned pointer will break strict-aliasing rules
</pre>
|
[
{
"answer_id": 277687,
"author": "Mr Fooz",
"author_id": 25050,
"author_profile": "https://Stackoverflow.com/users/25050",
"pm_score": 5,
"selected": true,
"text": "%template(IntVector) vector<int>;\n"
},
{
"answer_id": 368961,
"author": "Fergal",
"author_id": 46407,
"author_profile": "https://Stackoverflow.com/users/46407",
"pm_score": 0,
"selected": false,
"text": "%include \"myvector.h\"\n\n\n%{\n# include \"myvector.h\"\n%}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30626/"
] |
276,780
|
<p>My mission is to create a little app where you can upload a picture, and the app will turn it into ASCII art. I'm sure these exist already but I want to prove that I can do it myself.</p>
<p>This would involve taking an image, making it greyscale and then matching each pixel with a character depending on how dark the picture is and how full the character is.</p>
<p>So my question is, Using the GD Library (or i guess some other means if necessary) how do I make an image black and white?</p>
|
[
{
"answer_id": 277354,
"author": "Stefan Gehrig",
"author_id": 11354,
"author_profile": "https://Stackoverflow.com/users/11354",
"pm_score": 5,
"selected": false,
"text": "(pixel.r + pixel.g + pixel.b) / 3 imagefilter() $im = imagecreatefrompng('dave.png');\nimagefilter($im, IMG_FILTER_GRAYSCALE);\nimagepng($im, 'dave.png');\n"
},
{
"answer_id": 3551573,
"author": "Mark Lalor",
"author_id": 1246275,
"author_profile": "https://Stackoverflow.com/users/1246275",
"pm_score": 3,
"selected": false,
"text": "imagefilter($im, IMG_FILTER_GRAYSCALE);\nimagefilter($im, IMG_FILTER_CONTRAST, -1000);\n"
},
{
"answer_id": 3552025,
"author": "Jive Dadson",
"author_id": 445296,
"author_profile": "https://Stackoverflow.com/users/445296",
"pm_score": 3,
"selected": false,
"text": "// sRGB luminance(Y) values\nconst double rY = 0.212655;\nconst double gY = 0.715158;\nconst double bY = 0.072187;\n\n// Inverse of sRGB \"gamma\" function. (approx 2.2)\ndouble inv_gam_sRGB(int ic) {\n double c = ic/255.0;\n if ( c <= 0.04045 )\n return c/12.92;\n else \n return pow(((c+0.055)/(1.055)),2.4);\n}\n\n// sRGB \"gamma\" function (approx 2.2)\nint gam_sRGB(double v) {\n if(v<=0.0031308)\n v *= 12.92;\n else \n v = 1.055*pow(v,1.0/2.4)-0.055;\n return int(v*255+.5);\n}\n\n// GRAY VALUE\nint gray(int r, int g, int b) {\n return gam_sRGB(\n rY*inv_gam_sRGB(r) +\n gY*inv_gam_sRGB(g) +\n bY*inv_gam_sRGB(b)\n );\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2128/"
] |
276,790
|
<pre><code>(define (repeated f n)
if (= n 0)
f
((compose repeated f) (lambda (x) (- n 1))))
</code></pre>
<p>I wrote this function, but how would I express this more clearly, using simple recursion with repeated?</p>
<p>I'm sorry, I forgot to define my compose function.</p>
<pre><code>(define (compose f g) (lambda (x) (f (g x))))
</code></pre>
<p>And the function takes as inputs a procedure that computes f and a positive integer n and returns the procedure that computes the nth repeated application of f.</p>
|
[
{
"answer_id": 276885,
"author": "C. K. Young",
"author_id": 13,
"author_profile": "https://Stackoverflow.com/users/13",
"pm_score": 0,
"selected": false,
"text": "f n (define (repeated f n)\n (for-each (lambda (i) (f)) (iota n)))\n"
},
{
"answer_id": 276967,
"author": "Kyle Cronin",
"author_id": 658,
"author_profile": "https://Stackoverflow.com/users/658",
"pm_score": 1,
"selected": false,
"text": "(define (repeated f n)\n (lambda (x)\n (if (= n 0)\n x\n ((repeated f (- n 1)) (f x))))) \n\n(define (square x)\n (* x x))\n\n(define y (repeated square 3))\n\n(y 2) ; returns 256, which is (square (square (square 2)))\n"
},
{
"answer_id": 276972,
"author": "Nathan Shively-Sanders",
"author_id": 7851,
"author_profile": "https://Stackoverflow.com/users/7851",
"pm_score": 1,
"selected": false,
"text": "(define (repeated f n)\n (lambda (x)\n (let recur ((x x) (n n))\n (if (= n 0)\n args\n (recur (f x) (sub1 n))))))\n repeated (define repeated (lambda (f n) (lambda (x) \n (define (recur x n)\n (if (= n 0)\n x\n (recur (f x) (sub1 n))))\n (recur x n))))\n > (define foonly (repeat sub1 10))\n> (foonly 11)\n1\n> (foonly 9)\n-1\n repeated _ 0 x = x\nrepeated f n x = repeated f (pred n) (f x)\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
276,807
|
<p>The last week on the ACM ICPC Mexico competition, I missed a "return 0" on a C++ program. For this reason we got punished with 20 minutes.</p>
<p>I had read that the standard does not oblige us to write it at the end of a main function. It is implicit, isn't it? How can I prove it? </p>
<p>We were using a Fedora system with a G++ compiler. </p>
|
[
{
"answer_id": 276814,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 6,
"selected": true,
"text": "return 0;"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27211/"
] |
276,808
|
<p>I have a 2-dimensional array of objects and I basically want to databind each one to a cell in a WPF grid. Currently I have this working but I am doing most of it procedurally. I create the correct number of row and column definitions, then I loop through the cells and create the controls and set up the correct bindings for each one. </p>
<p>At a minimum I would like to be able to use a template to specify the controls and bindings in xaml. Ideally I would like to get rid of the procedural code and just do it all with databinding, but I'm not sure that's possible.</p>
<p>Here is the code I am currently using:</p>
<pre><code>public void BindGrid()
{
m_Grid.Children.Clear();
m_Grid.ColumnDefinitions.Clear();
m_Grid.RowDefinitions.Clear();
for (int x = 0; x < MefGrid.Width; x++)
{
m_Grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star), });
}
for (int y = 0; y < MefGrid.Height; y++)
{
m_Grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star), });
}
for (int x = 0; x < MefGrid.Width; x++)
{
for (int y = 0; y < MefGrid.Height; y++)
{
Cell cell = (Cell)MefGrid[x, y];
SolidColorBrush brush = new SolidColorBrush();
var binding = new Binding("On");
binding.Converter = new BoolColorConverter();
binding.Mode = BindingMode.OneWay;
BindingOperations.SetBinding(brush, SolidColorBrush.ColorProperty, binding);
var rect = new Rectangle();
rect.DataContext = cell;
rect.Fill = brush;
rect.SetValue(Grid.RowProperty, y);
rect.SetValue(Grid.ColumnProperty, x);
m_Grid.Children.Add(rect);
}
}
}
</code></pre>
|
[
{
"answer_id": 276868,
"author": "Jobi Joy",
"author_id": 8091,
"author_profile": "https://Stackoverflow.com/users/8091",
"pm_score": 7,
"selected": true,
"text": "<Window.Resources>\n <DataTemplate x:Key=\"DataTemplate_Level2\">\n <Button Content=\"{Binding}\" Height=\"40\" Width=\"50\" Margin=\"4,4,4,4\"/>\n </DataTemplate>\n\n <DataTemplate x:Key=\"DataTemplate_Level1\">\n <ItemsControl ItemsSource=\"{Binding}\" ItemTemplate=\"{DynamicResource DataTemplate_Level2}\">\n <ItemsControl.ItemsPanel>\n <ItemsPanelTemplate>\n <StackPanel Orientation=\"Horizontal\"/>\n </ItemsPanelTemplate>\n </ItemsControl.ItemsPanel>\n </ItemsControl>\n </DataTemplate>\n\n</Window.Resources>\n<Grid>\n <ItemsControl x:Name=\"lst\" ItemTemplate=\"{DynamicResource DataTemplate_Level1}\"/>\n</Grid>\n public Window1()\n {\n List<List<int>> lsts = new List<List<int>>();\n\n for (int i = 0; i < 5; i++)\n {\n lsts.Add(new List<int>());\n\n for (int j = 0; j < 5; j++)\n {\n lsts[i].Add(i * 10 + j);\n }\n }\n\n InitializeComponent();\n\n lst.ItemsSource = lsts;\n }\n"
},
{
"answer_id": 4002409,
"author": "Fredrik Hedblad",
"author_id": 318425,
"author_profile": "https://Stackoverflow.com/users/318425",
"pm_score": 5,
"selected": false,
"text": "DataGrid2D IList DataGrid ItemsSource2D xmlns:dg2d=\"clr-namespace:DataGrid2DLibrary;assembly=DataGrid2DLibrary\"\n <dg2d:DataGrid2D Name=\"dataGrid2D\"\n ItemsSource2D=\"{Binding Int2DList}\"/>\n private int[,] m_intArray = new int[5, 5];\n...\nfor (int i = 0; i < 5; i++)\n{\n for (int j = 0; j < 5; j++)\n {\n m_intArray[i,j] = (i * 10 + j);\n }\n}\n public class Ref<T> \n{ \n private readonly Func<T> getter; \n private readonly Action<T> setter; \n public Ref(Func<T> getter, Action<T> setter) \n { \n this.getter = getter; \n this.setter = setter; \n } \n public T Value { get { return getter(); } set { setter(value); } } \n} \n public static DataView GetBindable2DArray<T>(T[,] array)\n{\n DataTable dataTable = new DataTable();\n for (int i = 0; i < array.GetLength(1); i++)\n {\n dataTable.Columns.Add(i.ToString(), typeof(Ref<T>));\n }\n for (int i = 0; i < array.GetLength(0); i++)\n {\n DataRow dataRow = dataTable.NewRow();\n dataTable.Rows.Add(dataRow);\n }\n DataView dataView = new DataView(dataTable);\n for (int i = 0; i < array.GetLength(0); i++)\n {\n for (int j = 0; j < array.GetLength(1); j++)\n {\n int a = i;\n int b = j;\n Ref<T> refT = new Ref<T>(() => array[a, b], z => { array[a, b] = z; });\n dataView[i][j] = refT;\n }\n }\n return dataView;\n}\n <DataGrid Name=\"c_dataGrid\"\n RowHeaderWidth=\"0\"\n ColumnHeaderHeight=\"0\"\n AutoGenerateColumns=\"True\"\n AutoGeneratingColumn=\"c_dataGrid_AutoGeneratingColumn\"/>\n\nprivate void c_dataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)\n{\n DataGridTextColumn column = e.Column as DataGridTextColumn;\n Binding binding = column.Binding as Binding;\n binding.Path = new PropertyPath(binding.Path.Path + \".Value\");\n}\n c_dataGrid.ItemsSource = BindingHelper.GetBindable2DArray<int>(m_intArray);\n DataGrid"
},
{
"answer_id": 8326875,
"author": "CitizenInsane",
"author_id": 684399,
"author_profile": "https://Stackoverflow.com/users/684399",
"pm_score": 1,
"selected": false,
"text": "AutoGeneratingColumn DataGrid public static DataView GetBindable2DArray<T>(T[,] array)\n{\n var table = new DataTable();\n for (var i = 0; i < array.GetLength(1); i++)\n {\n table.Columns.Add(i+1, typeof(bool))\n .ExtendedProperties.Add(\"idx\", i); // Save original column index\n }\n for (var i = 0; i < array.GetLength(0); i++)\n {\n table.Rows.Add(table.NewRow());\n }\n\n var view = new DataView(table);\n for (var ri = 0; ri < array.GetLength(0); ri++)\n {\n for (var ci = 0; ci < array.GetLength(1); ci++)\n {\n view[ri][ci] = array[ri, ci];\n }\n }\n\n // Avoids writing an 'AutogeneratingColumn' handler\n table.ColumnChanged += (s, e) => \n {\n var ci = (int)e.Column.ExtendedProperties[\"idx\"]; // Retrieve original column index\n var ri = e.Row.Table.Rows.IndexOf(e.Row); // Retrieve row index\n\n array[ri, ci] = (T)view[ri][ci];\n };\n\n return view;\n}\n"
},
{
"answer_id": 31103075,
"author": "Johan Larsson",
"author_id": 1069200,
"author_profile": "https://Stackoverflow.com/users/1069200",
"pm_score": 3,
"selected": false,
"text": "DataGrid int[,] <DataGrid HeadersVisibility=\"None\"\n dataGrid2D:Source2D.ItemsSource2D=\"{Binding Data2D}\" />\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1509/"
] |
276,816
|
<p>It's not obvious to me..</p>
|
[
{
"answer_id": 8210219,
"author": "Nicola Musatti",
"author_id": 838975,
"author_profile": "https://Stackoverflow.com/users/838975",
"pm_score": 4,
"selected": false,
"text": "TSVNCache.exe bin C:\\Program Files\\TortoiseSVN\\bin"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/209/"
] |
276,827
|
<p>I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000".</p>
<pre><code>char *StringPadRight(char *string, int padded_len, char *pad) {
int len = (int) strlen(string);
if (len >= padded_len) {
return string;
}
int i;
for (i = 0; i < padded_len - len; i++) {
strcat(string, pad);
}
return string;
}
</code></pre>
<p>It works but has some weird side effects... some of the other variables get changed. How can I fix this?</p>
|
[
{
"answer_id": 276835,
"author": "Eugene Yokota",
"author_id": 3827,
"author_profile": "https://Stackoverflow.com/users/3827",
"pm_score": 1,
"selected": false,
"text": "char buffer[1024];\nmemset(buffer, 0, sizeof(buffer));\nstrncpy(buffer, \"Hello\", sizeof(buffer));\nStringPadRight(buffer, 10, \"0\");\n"
},
{
"answer_id": 276836,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "char hello[11] = \"Hello\";\nStringPadRight(hello, 10, \"0\");\n hello"
},
{
"answer_id": 276837,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": 0,
"selected": false,
"text": "size_of_string"
},
{
"answer_id": 276851,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": " char foo[10] = \"hello\";\n char padded[16];\n strcpy(padded, foo);\n printf(\"%s\", StringPadRight(padded, 15, \" \"));\n"
},
{
"answer_id": 276869,
"author": "Tom Leys",
"author_id": 11440,
"author_profile": "https://Stackoverflow.com/users/11440",
"pm_score": 9,
"selected": true,
"text": "printf(\"|%-10s|\", \"Hello\");\n |Hello |\n"
},
{
"answer_id": 9741091,
"author": "J Jorgenson",
"author_id": 310231,
"author_profile": "https://Stackoverflow.com/users/310231",
"pm_score": 6,
"selected": false,
"text": "int targetStrLen = 10; // Target output length \nconst char *myString=\"Monkey\"; // String for output \nconst char *padding=\"#####################################################\";\n\nint padLen = targetStrLen - strlen(myString); // Calc Padding length\nif(padLen < 0) padLen = 0; // Avoid negative length\n\nprintf(\"[%*.*s%s]\", padLen, padLen, padding, myString); // LEFT Padding \nprintf(\"[%s%*.*s]\", myString, padLen, padLen, padding); // RIGHT Padding \n [####Monkey] <-- Left padded, \"%*.*s%s\" [Monkey####] <-- Right padded, \"%s%*.*s\" printf(\"[%'#10s]\\n\", $s); // use the custom padding character '#' [####monkey]"
},
{
"answer_id": 38697789,
"author": "Naga",
"author_id": 5036010,
"author_profile": "https://Stackoverflow.com/users/5036010",
"pm_score": 1,
"selected": false,
"text": "#include <iostream>\n#include<stdio.h>\n#include<stdlib.h>\n#include<string.h>\n\nusing namespace std;\n\nint main() {\n // your code goes here\n int pi_length=11; //Total length \n char *str1;\n const char *padding=\"0000000000000000000000000000000000000000\";\n const char *myString=\"Monkey\";\n\n int padLen = pi_length - strlen(myString); //length of padding to apply\n\n if(padLen < 0) padLen = 0; \n\n str1= (char *)malloc(100*sizeof(char));\n\n sprintf(str1,\"%*.*s%s\", padLen, padLen, padding, myString);\n\n printf(\"%s --> %d \\n\",str1,strlen(str1));\n\n return 0;\n}\n"
},
{
"answer_id": 49163578,
"author": "Izya Budman",
"author_id": 9120297,
"author_profile": "https://Stackoverflow.com/users/9120297",
"pm_score": 3,
"selected": false,
"text": "#include <stdio.h>\n#include <string.h>\n\nint main(void) {\n char buf[BUFSIZ] = { 0 };\n char str[] = \"Hello\";\n char fill = '#';\n int width = 20; /* or whatever you need but less than BUFSIZ ;) */\n\n printf(\"%s%s\\n\", (char*)memset(buf, fill, width - strlen(str)), str);\n\n return 0;\n}\n $ gcc -Wall -ansi -pedantic padding.c\n$ ./a.out \n###############Hello\n"
},
{
"answer_id": 52043319,
"author": "Ayodeji",
"author_id": 7499394,
"author_profile": "https://Stackoverflow.com/users/7499394",
"pm_score": 0,
"selected": false,
"text": "#include<stdio.h>\n#include <string.h>\n\n\nvoid padLeft(int length, char pad, char* inStr,char* outStr) {\n int minLength = length * sizeof(char);\n if (minLength < sizeof(outStr)) {\n return;\n }\n\n int padLen = length - strlen(inStr);\n padLen = padLen < 0 ? 0 : padLen;\n\n memset(outStr, 0, sizeof(outStr));\n memset(outStr, pad,padLen);\n memcpy(outStr+padLen, inStr, minLength - padLen);\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
276,843
|
<p>Is there a way short of writing a seperate batch file or adding a system call to pause or getch or a breakpoint right before the end of the main function to keep a command window open after a command line application has finished running?</p>
<p>Put differently, is there a way in the project properties to run another command after running the target path? If my program is "foo.exe", something equivalent to a batch file containing</p>
<pre><code>@foo
@pause
</code></pre>
<p>Edit: added "or a getch or a breakpoint"</p>
|
[
{
"answer_id": 276849,
"author": "Tom Leys",
"author_id": 11440,
"author_profile": "https://Stackoverflow.com/users/11440",
"pm_score": 0,
"selected": false,
"text": "#include <conio.h>\n\n// .. Your code\n\nint main()\n{\n // More of your code\n\n // Tell the user to press a key \n getch(); // Get one character from the user (i.e a keypress)\n\n return 0;\n\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34799/"
] |
276,853
|
<p>Or should they always be a function when business logic is invloved ?</p>
<p>Example: Order.RequiresPayment </p>
<p>property or function ?
There are business rules as for when it is true or not</p>
<p>IS there a pattern that may determine this?</p>
|
[
{
"answer_id": 276870,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 2,
"selected": false,
"text": "OrderRequiresPayment true false"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25997/"
] |
276,856
|
<p>I have a lot of assignments where I have to continually update a Makefile as I add more subsequently numbered C programs. Is there a way to do this with a loop which iterates over the values 1.1, 1.2, 1.3, etc.?</p>
<pre><code>all: 1.1 1.2 1.3 1.4 1.5 1.6 1.7. 1.8 1.9
1.1: 1.1.o
gcc -o 1.1 $(FLAGS) 1.1.o
1.1.o: 1.1.c
gcc -c $(FLAGS) 1.1.c
1.2: 1.2.o
gcc -o 1.2 $(FLAGS) 1.2.o
1.2.o: 1.2.c
gcc -c $(FLAGS) 1.2.c
1.3: 1.3.o
gcc -o 1.3 $(FLAGS) 1.3.o
1.3.o: 1.3.c
gcc -c $(FLAGS) 1.3.c
1.4: 1.4.o
gcc -o 1.4 $(FLAGS) 1.4.o
1.4.o: 1.4.c
gcc -c $(FLAGS) 1.4.c
1.5: 1.5.o
gcc -o 1.5 $(FLAGS) 1.5.o
1.5.o: 1.5.c
gcc -c $(FLAGS) 1.5.c
1.6: 1.6.o
gcc -o 1.6 $(FLAGS) 1.6.o
1.6.o: 1.6.c
gcc -c $(FLAGS) 1.6.c
1.7: 1.7.o
gcc -o 1.7 $(FLAGS) 1.7.o
1.7.o: 1.7.c
gcc -c $(FLAGS) 1.7.c
1.8: 1.8.o
gcc -o 1.8 $(FLAGS) 1.8.o
1.8.o: 1.8.c
gcc -c $(FLAGS) 1.8.c
1.9: 1.9.o
gcc -o 1.9 $(FLAGS) 1.9.o
1.9.o: 1.9.c
gcc -c $(FLAGS) 1.9.c
clean:
rm -f *.o
rm -f 1.1 1.2 1.3 1.4 1.5 1.6 1.7. 1.8 1.9</code></pre>
|
[
{
"answer_id": 276860,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 0,
"selected": false,
"text": "gcc"
},
{
"answer_id": 276873,
"author": "David Martin",
"author_id": 34879,
"author_profile": "https://Stackoverflow.com/users/34879",
"pm_score": 2,
"selected": false,
"text": "OBJECTS = 1.1.o 1.2.o 1.3.o\n\nall: $(OBJECTS)\n\n%.o: %.c\n gcc $(FLAGS) %< -o $*\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18091/"
] |
276,861
|
<p>I would like to dynamically hide a button in one of my views depending on a certain condition.</p>
<p>I tried adding some code to the view controller's <code>-viewWillAppear</code> method, to make the button hidden before displaying the actual view, but I still don't know how to do that.</p>
<p>I have a reference to the button through an IBOutlet, but I'm not sure how to move forward from here. For reference, this is a UIBarButtonItem instance.</p>
|
[
{
"answer_id": 276890,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": -1,
"selected": false,
"text": "myButton.hidden = YES;\n"
},
{
"answer_id": 277052,
"author": "Ben Gottlieb",
"author_id": 6694,
"author_profile": "https://Stackoverflow.com/users/6694",
"pm_score": 7,
"selected": true,
"text": "NSMutableArray *items = [[myToolbar.items mutableCopy] autorelease];\n[items removeObject: myButton];\nmyToolbar.items = items;\n"
},
{
"answer_id": 1209938,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "self.navigationItem.leftBarButtonItem = nil;\n"
},
{
"answer_id": 1912277,
"author": "Gary Riley",
"author_id": 232642,
"author_profile": "https://Stackoverflow.com/users/232642",
"pm_score": 1,
"selected": false,
"text": "theButton.enabled = NO;\ntheButton.image = [UIImage imageNamed: @\"Blank.png\"];\n"
},
{
"answer_id": 2640609,
"author": "Heather Shoemaker",
"author_id": 316896,
"author_profile": "https://Stackoverflow.com/users/316896",
"pm_score": 4,
"selected": false,
"text": "barButtonItemDone = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done:)];\n self.navigationItem.rightBarButtonItem=[self barButtonItemDone];\n self.navigationItem.rightBarButtonItem=nil;\n"
},
{
"answer_id": 3550375,
"author": "Sara",
"author_id": 402150,
"author_profile": "https://Stackoverflow.com/users/402150",
"pm_score": 3,
"selected": false,
"text": "self.navigationItem.hidesBackButton = YES;\n"
},
{
"answer_id": 3945625,
"author": "Marius",
"author_id": 174650,
"author_profile": "https://Stackoverflow.com/users/174650",
"pm_score": 2,
"selected": false,
"text": "hidden = YES"
},
{
"answer_id": 7290517,
"author": "Jon",
"author_id": 463059,
"author_profile": "https://Stackoverflow.com/users/463059",
"pm_score": 1,
"selected": false,
"text": "[filterBarButton.customView setHidden:YES];\n"
},
{
"answer_id": 8298969,
"author": "Michael",
"author_id": 1031265,
"author_profile": "https://Stackoverflow.com/users/1031265",
"pm_score": 3,
"selected": false,
"text": "myButton.width = 0.1;\n myButton.width = 0.0;\n"
},
{
"answer_id": 8331436,
"author": "Christopher Shortt",
"author_id": 1074063,
"author_profile": "https://Stackoverflow.com/users/1074063",
"pm_score": 1,
"selected": false,
"text": "UIButton UIBarButtonItem UIBarButtonItem UIButton.hidden TRUE YES UIBarButtonItem"
},
{
"answer_id": 8949434,
"author": "jonnysamps",
"author_id": 201134,
"author_profile": "https://Stackoverflow.com/users/201134",
"pm_score": 3,
"selected": false,
"text": "myButton.customView = [[UIView alloc] init];\n"
},
{
"answer_id": 20509232,
"author": "Michael DiStefano",
"author_id": 2533208,
"author_profile": "https://Stackoverflow.com/users/2533208",
"pm_score": 2,
"selected": false,
"text": "if (shouldShowMyBarButtonItem) {\n self.myBarButtonItem.title = nil;\n self.myBarButtonItem.action = nil;\n} else if (!shouldShowMyBarButtonItem) {\n self.myBarButtonItem.title = @\"Title\";\n self.myBarButtonItem.action = @selector(mySelector:);\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35478/"
] |
276,867
|
<p>In this <a href="https://stackoverflow.com/questions/275545/does-aspnet-mvc-framework-support-asynchronous-page-execution">question & answer</a>, I found one way to make ASP.NET MVC support asynchronous processing. However, I cannot make it work.</p>
<p>Basically, the idea is to create a new implementation of IRouteHandler which has only one method <strong><em>GetHttpHandler</em></strong>. The <strong><em>GetHttpHandler</em></strong> method should return an <code>IHttpAsyncHandler</code> implementation instead of just <code>IHttpHandler</code>, because <code>IHttpAsyncHandler</code> has Begin/EndXXXX pattern API.</p>
<pre><code>public class AsyncMvcRouteHandler : IRouteHandler
{
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
return new AsyncMvcHandler(requestContext);
}
class AsyncMvcHandler : IHttpAsyncHandler, IRequiresSessionState
{
public AsyncMvcHandler(RequestContext context)
{
}
// IHttpHandler members
public bool IsReusable { get { return false; } }
public void ProcessRequest(HttpContext httpContext) { throw new NotImplementedException(); }
// IHttpAsyncHandler members
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
{
throw new NotImplementedException();
}
public void EndProcessRequest(IAsyncResult result)
{
throw new NotImplementedException();
}
}
}
</code></pre>
<p>Then, in the RegisterRoutes method of file Global.asax.cs, register this class <strong><em>AsyncMvcRouteHandler</em></strong>.</p>
<pre><code>public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.Add(new Route("{controller}/{action}/{id}", new AsyncMvcRouteHandler())
{
Defaults = new RouteValueDictionary(new { controller = "Home", action = "Index", id = "" }),
});
}
</code></pre>
<p>I set breakpoint at <strong><em>ProcessRequest</em></strong>, <strong><em>BeginProcessRequest</em></strong> and <strong><em>EndProcessRequest</em></strong>. Only <strong><em>ProcessRequest</em></strong> is executed. In another word, even though <strong><em>AsyncMvcHandler</em></strong> implements <strong><em>IHttpAsyncHandler</em></strong>. ASP.NET MVC doesn't know that and just handle it as an <code>IHttpHandler</code> implementation.</p>
<p>How to make ASP.NET MVC treat <strong><em>AsyncMvcHandler</em></strong> as <strong><em>IHttpAsyncHandler</em></strong> so we can have asynchronous page processing?</p>
|
[
{
"answer_id": 490003,
"author": "LaserJesus",
"author_id": 45207,
"author_profile": "https://Stackoverflow.com/users/45207",
"pm_score": 2,
"selected": false,
"text": "routes.MapRoute(\n \"Default\", \n \"{controller}/{action}\", \n new { controller = \"Home\", action = \"Index\" } \n);\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26349/"
] |
276,891
|
<p>I'm trying to figure out how to drop/discard a request, I'm basically trying to implement a blocked list of IPs in my app to block spammers and I don't want to return any response (just ignore the request), is this possible in ASP.NET?</p>
<p>Edit: Some of the answers suggest that I could add them in the firewall, while this will certainly be better it's not suitable in my case. To make a long story short, I'm adding a moderation section to my website where moderators will check the posts awaiting moderation for spam (filtered by a spam fitler), I want the IP of the sender of some post to be added to the list of blocked IPs once a post is marked as spam by the moderator, this is why I wan to do it in the application.</p>
<p>Edit: Calling Response.End() returns a response to the user (even though it's empty), the whole purpose of my question was how not to return any response. Is this possible (even out of curiosity)? There's also Response.Close() which closes the socket but it sends notification (in TCP/IP) when it does this, I just wan to ignore as it if was never received (i.e. send nothing to the user)</p>
<p>Thanks</p>
|
[
{
"answer_id": 276894,
"author": "John Boker",
"author_id": 2847,
"author_profile": "https://Stackoverflow.com/users/2847",
"pm_score": 2,
"selected": false,
"text": "Response.Clear();\nResponse.End();\n"
},
{
"answer_id": 276939,
"author": "Kyle Trauberman",
"author_id": 21461,
"author_profile": "https://Stackoverflow.com/users/21461",
"pm_score": 2,
"selected": false,
"text": "class IgnoreHandler : IHttpHandler\n{\n #region IHttpHandler Members\n\n public bool IsReusable\n {\n get { return true; }\n }\n\n public void ProcessRequest(HttpContext context)\n {\n context.Response.Clear();\n context.Response.StatusCode = 401;\n context.Response.Status = \"Unauthorized\";\n context.Response.End();\n }\n\n #endregion\n}\n <httpHandlers>\n <add verb=\"*\" \n path=\"*\" \n validate=\"false\" \n type=\"MyNamespace.IgnoreHandler, MyAssembly\" />\n</httpHandlers>\n"
},
{
"answer_id": 277005,
"author": "JackCorn",
"author_id": 14919,
"author_profile": "https://Stackoverflow.com/users/14919",
"pm_score": 0,
"selected": false,
"text": "throw new HttpException(404, \"File not found - \" + Request.AppRelativeCurrentExecutionFilePath);"
},
{
"answer_id": 42387199,
"author": "Matas Vaitkevicius",
"author_id": 1509764,
"author_profile": "https://Stackoverflow.com/users/1509764",
"pm_score": 2,
"selected": false,
"text": "public class RequestDropper : IHttpModule\n{\n public void Dispose()\n {\n throw new NotImplementedException();\n }\n\n public void Init(HttpApplication context)\n {\n context.BeginRequest += Context_BeginRequest;\n }\n\n public void Context_BeginRequest(object sender, EventArgs e)\n {\n var request = ((HttpApplication)sender).Context.Request;\n\n if (todayIAmNotInAMoodToProcessRequests)\n {\n request.Abort();\n }\n }\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/676066/"
] |
276,905
|
<p>When a user clicks in certain places in my control, I want to change the color of some rows and columns in my grid, then fade it back to the normal color, within say 500ms or so. I haven't decided whether to use Winforms or WPF yet, so advice in either of those technologies would work. Thank you.</p>
<p>Edit: I understand I could do this by just calling Paint in a loop within the click event, properly setting the drawing parameters. However I believe that would block the UI, and I would like to be more responsive than that.</p>
|
[
{
"answer_id": 277200,
"author": "Jeff Hillman",
"author_id": 3950,
"author_profile": "https://Stackoverflow.com/users/3950",
"pm_score": 1,
"selected": false,
"text": "using System;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace WindowsApplication1\n{\n public class FadeForm : Form\n {\n private Timer fadeTimer;\n private Panel fadePanel;\n private Button fadeButton;\n /// <summary>\n /// Required designer variable.\n /// </summary>\n private System.ComponentModel.IContainer components = null;\n\n /// <summary>\n /// Clean up any resources being used.\n /// </summary>\n /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n protected override void Dispose( bool disposing )\n {\n if ( disposing && ( components != null ) )\n {\n components.Dispose();\n }\n base.Dispose( disposing );\n }\n\n #region Windows Form Designer generated code\n\n /// <summary>\n /// Required method for Designer support - do not modify\n /// the contents of this method with the code editor.\n /// </summary>\n private void InitializeComponent()\n {\n this.fadePanel = new System.Windows.Forms.Panel();\n this.fadeButton = new System.Windows.Forms.Button();\n this.SuspendLayout();\n // \n // fadePanel\n // \n this.fadePanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\n this.fadePanel.Location = new System.Drawing.Point( 4, 8 );\n this.fadePanel.Name = \"fadePanel\";\n this.fadePanel.Size = new System.Drawing.Size( 276, 104 );\n this.fadePanel.TabIndex = 0;\n // \n // fadeButton\n // \n this.fadeButton.Location = new System.Drawing.Point( 104, 116 );\n this.fadeButton.Name = \"fadeButton\";\n this.fadeButton.Size = new System.Drawing.Size( 75, 23 );\n this.fadeButton.TabIndex = 1;\n this.fadeButton.Text = \"Fade\";\n this.fadeButton.UseVisualStyleBackColor = true;\n this.fadeButton.Click += new System.EventHandler( this.HandleFadeButtonClick );\n // \n // FadeForm\n // \n this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 13F );\n this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n this.ClientSize = new System.Drawing.Size( 284, 142 );\n this.Controls.Add( this.fadeButton );\n this.Controls.Add( this.fadePanel );\n this.Name = \"FadeForm\";\n this.Text = \"Fade Form\";\n this.ResumeLayout( false );\n\n }\n\n #endregion\n\n public FadeForm()\n {\n InitializeComponent();\n\n this.fadeTimer = new Timer();\n }\n\n private void HandleFadeButtonClick( object sender, EventArgs e )\n {\n this.fadeTimer.Tick += new EventHandler( HandleFadeTimerTick );\n this.fadePanel.BackColor = Color.Red;\n this.fadeTimer.Interval = 100;\n this.fadeTimer.Start();\n }\n\n void HandleFadeTimerTick( object sender, EventArgs e )\n {\n Color panelColor = this.fadePanel.BackColor;\n\n if ( panelColor.A > 0 )\n {\n this.fadePanel.BackColor = \n Color.FromArgb( \n Math.Max( panelColor.A - 20, 0 ), \n panelColor.R, panelColor.G, panelColor.B );\n }\n else\n {\n this.fadeTimer.Stop();\n }\n }\n }\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
276,906
|
<p>I'm looking at using CompositeWPF (<a href="http://www.codeplex.com/CompositeWPF" rel="nofollow noreferrer">http://www.codeplex.com/CompositeWPF</a>) - aka Prism, to build an application I am working on.</p>
<p>The application isn't a traditional LOB application, however it does present data and state information to the user.</p>
<p>One thing which I am unsure of is if CompositeWPF supports more than one Window or Shell. I would like to have my application notify users with a border-less window which appears in the lower RHS of the screen (think MSN notification) but still use the idea of views being injected into the region etc.</p>
<p>In addition to this I would like to be able to react to a user action (e.g. double click on something), hide the main window and present a progress dialog while work is being performed.</p>
<p>So, is this possible?</p>
|
[
{
"answer_id": 277200,
"author": "Jeff Hillman",
"author_id": 3950,
"author_profile": "https://Stackoverflow.com/users/3950",
"pm_score": 1,
"selected": false,
"text": "using System;\nusing System.ComponentModel;\nusing System.Drawing;\nusing System.Windows.Forms;\n\nnamespace WindowsApplication1\n{\n public class FadeForm : Form\n {\n private Timer fadeTimer;\n private Panel fadePanel;\n private Button fadeButton;\n /// <summary>\n /// Required designer variable.\n /// </summary>\n private System.ComponentModel.IContainer components = null;\n\n /// <summary>\n /// Clean up any resources being used.\n /// </summary>\n /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param>\n protected override void Dispose( bool disposing )\n {\n if ( disposing && ( components != null ) )\n {\n components.Dispose();\n }\n base.Dispose( disposing );\n }\n\n #region Windows Form Designer generated code\n\n /// <summary>\n /// Required method for Designer support - do not modify\n /// the contents of this method with the code editor.\n /// </summary>\n private void InitializeComponent()\n {\n this.fadePanel = new System.Windows.Forms.Panel();\n this.fadeButton = new System.Windows.Forms.Button();\n this.SuspendLayout();\n // \n // fadePanel\n // \n this.fadePanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\n this.fadePanel.Location = new System.Drawing.Point( 4, 8 );\n this.fadePanel.Name = \"fadePanel\";\n this.fadePanel.Size = new System.Drawing.Size( 276, 104 );\n this.fadePanel.TabIndex = 0;\n // \n // fadeButton\n // \n this.fadeButton.Location = new System.Drawing.Point( 104, 116 );\n this.fadeButton.Name = \"fadeButton\";\n this.fadeButton.Size = new System.Drawing.Size( 75, 23 );\n this.fadeButton.TabIndex = 1;\n this.fadeButton.Text = \"Fade\";\n this.fadeButton.UseVisualStyleBackColor = true;\n this.fadeButton.Click += new System.EventHandler( this.HandleFadeButtonClick );\n // \n // FadeForm\n // \n this.AutoScaleDimensions = new System.Drawing.SizeF( 6F, 13F );\n this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\n this.ClientSize = new System.Drawing.Size( 284, 142 );\n this.Controls.Add( this.fadeButton );\n this.Controls.Add( this.fadePanel );\n this.Name = \"FadeForm\";\n this.Text = \"Fade Form\";\n this.ResumeLayout( false );\n\n }\n\n #endregion\n\n public FadeForm()\n {\n InitializeComponent();\n\n this.fadeTimer = new Timer();\n }\n\n private void HandleFadeButtonClick( object sender, EventArgs e )\n {\n this.fadeTimer.Tick += new EventHandler( HandleFadeTimerTick );\n this.fadePanel.BackColor = Color.Red;\n this.fadeTimer.Interval = 100;\n this.fadeTimer.Start();\n }\n\n void HandleFadeTimerTick( object sender, EventArgs e )\n {\n Color panelColor = this.fadePanel.BackColor;\n\n if ( panelColor.A > 0 )\n {\n this.fadePanel.BackColor = \n Color.FromArgb( \n Math.Max( panelColor.A - 20, 0 ), \n panelColor.R, panelColor.G, panelColor.B );\n }\n else\n {\n this.fadeTimer.Stop();\n }\n }\n }\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18434/"
] |
276,909
|
<p>How can I write a function that takes an array of integers and returns true if their exists a pair of numbers whose product is odd?</p>
<p>What are the properties of odd integers? And of course, how do you write this function in Java? Also, maybe a short explanation of how you went about formulating an algorithm for the actual implementation.</p>
<p>Yes, this is a function out of a textbook. No, this is not homework—I'm just trying to learn, so please no "do your own homework comments."</p>
|
[
{
"answer_id": 277047,
"author": "Alan",
"author_id": 17205,
"author_profile": "https://Stackoverflow.com/users/17205",
"pm_score": 0,
"selected": false,
"text": "public static boolean hasAtLeastTwoOdds(int[] args) {\n int[] target = args; // make defensive copy\n int oddsFound;\n int numberOddsSought = 2;\n\n for (int i = 0; i < target.length; i++) {\n if (target[i] % 2 != 0) {\n if (oddsFound== numberOddsSought) {\n return true;\n }\n oddsFound++;\n }\n }\n\n return false;\n}\n"
},
{
"answer_id": 278820,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": " protected boolean isOdd(int i) {\n return ( (i&1) == 1);\n\n}\n protected boolean isOddProduct(int[] arr) {\n int oddCount = 0;\n if (arr.length < 2) \n throw new IllegalArgumentException();\n for (int i = 0; i <= arr.length-1; i++) {\n if (isOdd(arr[i]))\n oddCount++; \n }\n return oddCount > 1;\n }\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276909",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
276,927
|
<p>Using <code>MySQL</code>, I can do something like:</p>
<pre><code>SELECT hobbies FROM peoples_hobbies WHERE person_id = 5;
</code></pre>
<p><strong>My Output:</strong></p>
<pre><code>shopping
fishing
coding
</code></pre>
<p>but instead I just want 1 row, 1 col:</p>
<p><strong>Expected Output:</strong></p>
<pre><code>shopping, fishing, coding
</code></pre>
<p>The reason is that I'm selecting multiple values from multiple tables, and after all the joins I've got a lot more rows than I'd like.</p>
<p>I've looked for a function on <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat-ws" rel="noreferrer">MySQL Doc</a> and it doesn't look like the <code>CONCAT</code> or <code>CONCAT_WS</code> functions accept result sets.</p>
<p>So does anyone here know how to do this?</p>
|
[
{
"answer_id": 276949,
"author": "che",
"author_id": 7806,
"author_profile": "https://Stackoverflow.com/users/7806",
"pm_score": 12,
"selected": true,
"text": "GROUP_CONCAT SELECT person_id,\n GROUP_CONCAT(hobbies SEPARATOR ', ')\nFROM peoples_hobbies\nGROUP BY person_id;\n DISTINCT SELECT person_id,\n GROUP_CONCAT(DISTINCT hobbies SEPARATOR ', ')\nFROM peoples_hobbies\nGROUP BY person_id;\n ORDER BY SELECT person_id, \n GROUP_CONCAT(hobbies ORDER BY hobbies ASC SEPARATOR ', ')\nFROM peoples_hobbies\nGROUP BY person_id;\n SET group_concat_max_len = 2048;\n 2048 SET group_concat_max_len = CAST(\n (SELECT SUM(LENGTH(hobbies)) + COUNT(*) * LENGTH(', ')\n FROM peoples_hobbies\n GROUP BY person_id) AS UNSIGNED);\n"
},
{
"answer_id": 276951,
"author": "lpfavreau",
"author_id": 35935,
"author_profile": "https://Stackoverflow.com/users/35935",
"pm_score": 7,
"selected": false,
"text": "GROUP_CONCAT SELECT GROUP_CONCAT(hobbies SEPARATOR ', ') \n FROM peoples_hobbies \n WHERE person_id = 5 \n GROUP BY 'all';\n"
},
{
"answer_id": 2599426,
"author": "pau.moreno",
"author_id": 154922,
"author_profile": "https://Stackoverflow.com/users/154922",
"pm_score": 5,
"selected": false,
"text": "GROUP_CONCAT group_concat_max_len"
},
{
"answer_id": 19057956,
"author": "Shen liang",
"author_id": 1765981,
"author_profile": "https://Stackoverflow.com/users/1765981",
"pm_score": 4,
"selected": false,
"text": "SELECT @logmsg := CONCAT_ws(',',@logmsg,items) FROM temp_SplitFields a;\n test1,test11\n"
},
{
"answer_id": 24137378,
"author": "Fedir RYKHTIK",
"author_id": 634275,
"author_profile": "https://Stackoverflow.com/users/634275",
"pm_score": 5,
"selected": false,
"text": "SELECT CAST(GROUP_CONCAT(field SEPARATOR ',') AS CHAR) FROM table\n"
},
{
"answer_id": 26004156,
"author": "elbowlobstercowstand",
"author_id": 3965565,
"author_profile": "https://Stackoverflow.com/users/3965565",
"pm_score": 6,
"selected": false,
"text": "+------------+--------------------+-------+\n| product_id | name | price |\n+------------+--------------------+-------+\n| 13 | Double Double | 5 |\n| 14 | Neapolitan Shake | 2 |\n| 15 | Animal Style Fries | 3 |\n| 16 | Root Beer | 2 |\n| 17 | Lame T-Shirt | 15 |\n+------------+--------------------+-------+\n 13, 15, 16 GROUP_CONCAT IN mysql> SELECT GROUP_CONCAT(name SEPARATOR ' + ') AS order_summary FROM product WHERE product_id IN (13, 15, 16);\n +------------------------------------------------+\n| order_summary |\n+------------------------------------------------+\n| Double Double + Animal Style Fries + Root Beer |\n+------------------------------------------------+\n SUM() mysql> SELECT GROUP_CONCAT(name SEPARATOR ' + ') AS order_summary, SUM(price) AS total FROM product WHERE product_id IN (13, 15, 16);\n+------------------------------------------------+-------+\n| order_summary | total |\n+------------------------------------------------+-------+\n| Double Double + Animal Style Fries + Root Beer | 10 |\n+------------------------------------------------+-------+\n"
},
{
"answer_id": 28746324,
"author": "thejustv",
"author_id": 2466310,
"author_profile": "https://Stackoverflow.com/users/2466310",
"pm_score": 3,
"selected": false,
"text": "DECLARE @Hobbies NVARCHAR(200) = ' '\n\nSELECT @Hobbies = @Hobbies + hobbies + ',' FROM peoples_hobbies WHERE person_id = 5;\n set @sql='';\nset @result='';\nset @separator=' union \\r\\n';\nSELECT \n@sql:=concat('select ''',INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME ,''' as col_name,',\nINFORMATION_SCHEMA.COLUMNS.CHARACTER_MAXIMUM_LENGTH ,' as def_len ,' ,\n'MAX(CHAR_LENGTH(',INFORMATION_SCHEMA.COLUMNS.COLUMN_NAME , '))as max_char_len',\n' FROM ',\nINFORMATION_SCHEMA.COLUMNS.TABLE_NAME\n) as sql_piece, if(@result:=if(@result='',@sql,concat(@result,@separator,@sql)),'','') as dummy\nFROM INFORMATION_SCHEMA.COLUMNS \nWHERE \nINFORMATION_SCHEMA.COLUMNS.DATA_TYPE like '%char%'\nand INFORMATION_SCHEMA.COLUMNS.TABLE_SCHEMA='xxx' \nand INFORMATION_SCHEMA.COLUMNS.TABLE_NAME='yyy';\nselect @result;\n"
},
{
"answer_id": 29949607,
"author": "Alex Bowyer",
"author_id": 971500,
"author_profile": "https://Stackoverflow.com/users/971500",
"pm_score": 4,
"selected": false,
"text": "GROUP_CONCAT SELECT DISTINCT userID \nFROM event GROUP BY userID \nHAVING count(distinct(cohort))=2);\n SELECT GROUP_CONCAT(sub.userID SEPARATOR ', ') \nFROM (SELECT DISTINCT userID FROM event \nGROUP BY userID HAVING count(distinct(cohort))=2) as sub;\n"
},
{
"answer_id": 53282268,
"author": "raghavendra",
"author_id": 2648000,
"author_profile": "https://Stackoverflow.com/users/2648000",
"pm_score": 2,
"selected": false,
"text": "select concat(hobbies) as `Hobbies` from people_hobbies where 1\n select group_concat(hobbies) as `Hobbies` from people_hobbies where 1\n"
},
{
"answer_id": 55864579,
"author": "Oleg Abrazhaev",
"author_id": 1074834,
"author_profile": "https://Stackoverflow.com/users/1074834",
"pm_score": 4,
"selected": false,
"text": "GROUP_CONCAT SELECT i.*,\n(SELECT GROUP_CONCAT(userid) FROM favourites f WHERE f.itemid = i.id) AS idlist\nFROM items i\nWHERE i.id = $someid\n GROUP_CONCAT"
},
{
"answer_id": 68357409,
"author": "Muhammad Shahzad",
"author_id": 2138791,
"author_profile": "https://Stackoverflow.com/users/2138791",
"pm_score": 2,
"selected": false,
"text": "SELECT pm.id, pm.name, GROUP_CONCAT(c.name) as channel_names\nFROM payment_methods pm\nLEFT JOIN payment_methods_channels_pivot pmcp ON pmcp.payment_method_id = pm.id\nLEFT JOIN channels c ON c.id = pmcp.channel_id\nGROUP BY pm.id\n payment_methods \n id | name\n 1 | PayPal\n\nchannels\n id | name\n 1 | Google\n 2 | Faceook\n\npayment_methods_channels_pivot\n payment_method_id | channel_id\n 1 | 1\n 1 | 2\n"
},
{
"answer_id": 68776458,
"author": "Golden Lion",
"author_id": 4001177,
"author_profile": "https://Stackoverflow.com/users/4001177",
"pm_score": 0,
"selected": false,
"text": "select string_agg(field1, ', ') a FROM mytable \n\nor\n\nselect string_agg(field1, ', ') within group (order by field1 dsc) a FROM mytable group by field2\n"
},
{
"answer_id": 69433740,
"author": "Payel Senapati",
"author_id": 12118888,
"author_profile": "https://Stackoverflow.com/users/12118888",
"pm_score": 0,
"selected": false,
"text": "people_hobbies DESCRIBE people_hobbies;\n+---------+--------------+------+-----+---------+----------------+\n| Field | Type | Null | Key | Default | Extra |\n+---------+--------------+------+-----+---------+----------------+\n| id | int unsigned | NO | PRI | NULL | auto_increment |\n| ppl_id | int unsigned | YES | MUL | NULL | |\n| name | varchar(200) | YES | | NULL | |\n| hby_id | int unsigned | YES | MUL | NULL | |\n| hobbies | varchar(50) | YES | | NULL | |\n+---------+--------------+------+-----+---------+----------------+\n\n SELECT * FROM people_hobbies;\n+----+--------+-----------------+--------+-----------+\n| id | ppl_id | name | hby_id | hobbies |\n+----+--------+-----------------+--------+-----------+\n| 1 | 1 | Shriya Jain | 1 | reading |\n| 2 | 4 | Shirley Setia | 4 | coding |\n| 3 | 2 | Varsha Tripathi | 7 | gardening |\n| 4 | 3 | Diya Ghosh | 2 | fishing |\n| 5 | 4 | Shirley Setia | 3 | gaming |\n| 6 | 1 | Shriya Jain | 6 | cycling |\n| 7 | 2 | Varsha Tripathi | 1 | reading |\n| 8 | 3 | Diya Ghosh | 5 | shopping |\n| 9 | 3 | Diya Ghosh | 4 | coding |\n| 10 | 4 | Shirley Setia | 1 | reading |\n| 11 | 1 | Shriya Jain | 4 | coding |\n| 12 | 1 | Shriya Jain | 3 | gaming |\n| 13 | 4 | Shirley Setia | 2 | fishing |\n| 14 | 4 | Shirley Setia | 7 | gardening |\n| 15 | 2 | Varsha Tripathi | 3 | gaming |\n| 16 | 2 | Varsha Tripathi | 2 | fishing |\n| 17 | 1 | Shriya Jain | 5 | shopping |\n| 18 | 1 | Shriya Jain | 7 | gardening |\n| 19 | 3 | Diya Ghosh | 1 | reading |\n| 20 | 4 | Shirley Setia | 5 | shopping |\n+----+--------+-----------------+--------+-----------+\n hobby_list CREATE TABLE hobby_list AS\n -> SELECT ppl_id, name,\n -> GROUP_CONCAT(hobbies ORDER BY hby_id SEPARATOR \"\\n\")\n -> AS hobbies\n -> FROM people_hobbies\n -> GROUP BY ppl_id\n -> ORDER BY ppl_id;\n SELECT * FROM hobby_list;\n"
},
{
"answer_id": 69888644,
"author": "Md. Tarikul Islam Soikot",
"author_id": 15078671,
"author_profile": "https://Stackoverflow.com/users/15078671",
"pm_score": 2,
"selected": false,
"text": "Set @concatHobbies = '';\nSELECT TRIM(LEADING ', ' FROM T.hobbies ) FROM \n(\n select \n Id, @concatHobbies := concat_ws(', ',@concatHobbies,hobbies) as hobbies\n from peoples_hobbies\n)T\nOrder by Id DESC\nLIMIT 1\n select \n Id, @concatHobbies := concat_ws(', ',@concatHobbies,hobbies) as hobbies\n from peoples_hobbies\n Id hobbies\n 1 , shopping\n 2 , shopping, fishing\n 3 , shopping, fishing, coding\n Order by Id DESC \n LIMIT 1\n \n TRIM(LEADING ', ' FROM T.hobbies )\n"
},
{
"answer_id": 72904124,
"author": "Haddock-san",
"author_id": 1499769,
"author_profile": "https://Stackoverflow.com/users/1499769",
"pm_score": 0,
"selected": false,
"text": "SELECT GROUP_CONCAT(hobbies) FROM peoples_hobbies WHERE person_id = 5;\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14966/"
] |
276,931
|
<p>recently I downloaded this open source project and I am trying to compile it.</p>
<p>However, one of the line is giving me an error.</p>
<p>"import com.sun.org.apache.xpath.internal.functions.WrongNumberArgsException;"</p>
<p>Seems that i am missing a library.... is there a way to know WHICH library do I need?</p>
<p>I tried searching on google for com.sun.org.apache.xpath.internal.functions,
while there seem to be a result on kickjava.com/src containing the source code.</p>
<p>I think i need the Jar file right?</p>
<p>I tried downloading xalan from apache and it didn't work.
I tried to see if there's a xpath library, but I dont think there's a xpath library?
searching for xpath led me to xalan.
I have also tried Xerces-J-bin.2.9.1 .</p>
<p>Thanks!</p>
<hr>
|
[
{
"answer_id": 276964,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 3,
"selected": true,
"text": "org.apache.xpath.functions"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17085/"
] |
276,955
|
<p>Scanner can only get input from system console? not be able to get from any dialog window?</p>
<p>Thanks.</p>
|
[
{
"answer_id": 276970,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 3,
"selected": false,
"text": "BufferedReader CharArrayReader CharBuffer FileReader FilterReader InputStreamReader LineNumberReader PipedReader PushbackReader StringReader Readable Scanner Scanner String Scanner"
},
{
"answer_id": 277388,
"author": "PhiLho",
"author_id": 15459,
"author_profile": "https://Stackoverflow.com/users/15459",
"pm_score": 0,
"selected": false,
"text": "new File(\"my-text-file.txt\")"
},
{
"answer_id": 30011522,
"author": "Peter Lawrey",
"author_id": 57695,
"author_profile": "https://Stackoverflow.com/users/57695",
"pm_score": 1,
"selected": false,
"text": "String text = input.getText();\nScanner scan = new Scanner(text);\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36064/"
] |
276,965
|
<p>I have noticed that our VMWare VMs often have the incorrect time on them. No matter how many times I reset the time they keep on desyncing.</p>
<p>Has anyone else noticed this? What do other people do to keep their VM time in sync?</p>
<p><strong>Edit:</strong> These are CLI linux VMs btw..</p>
|
[
{
"answer_id": 278125,
"author": "bernie",
"author_id": 21141,
"author_profile": "https://Stackoverflow.com/users/21141",
"pm_score": 7,
"selected": true,
"text": "tools.syncTime = true\n tools.syncTime.period = 60\n"
},
{
"answer_id": 7157566,
"author": "Nirav Shah",
"author_id": 907216,
"author_profile": "https://Stackoverflow.com/users/907216",
"pm_score": 1,
"selected": false,
"text": " VMwareService.exe –cmd “vmx.set_option synctime 0 1″\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1666/"
] |
276,986
|
<p>When the program runs, there is a series of ListView forms. We populated one of them with items (as strings) and we check whether the state of selection has changed. Once it's changed, we grab the text of the selected item using FocusedItem.Text. The first time works just fine but when another selection is made, the selected item returns as null.</p>
<p>The only way we can temporarily get around this issue is to clear and repopulate the form. The disadvantage is that we lose the highlighted item. There got to be another way around this. Maybe we're not clear on how ListView really works?</p>
<p>Any ideas?</p>
|
[
{
"answer_id": 277179,
"author": "chakrit",
"author_id": 3055,
"author_profile": "https://Stackoverflow.com/users/3055",
"pm_score": 0,
"selected": false,
"text": "ItemSelectionChanged\n Item : ListViewItem: {a}\n IsSelected : True\n SelectedItem : ListViewItem: {a}\n FocusedItem : ListViewItem: {a}\nSelectedIndexChanged\n SelectedItem : ListViewItem: {a}\n FocusedItem : ListViewItem: {a}\nItemSelectionChanged\n Item : ListViewItem: {a}\n IsSelected : False\n SelectedItem : null\n FocusedItem : ListViewItem: {a}\nSelectedIndexChanged\n SelectedItem : null\n FocusedItem : ListViewItem: {a}\nItemSelectionChanged\n Item : ListViewItem: {b}\n IsSelected : True\n SelectedItem : ListViewItem: {b}\n FocusedItem : ListViewItem: {b}\nSelectedIndexChanged\n SelectedItem : ListViewItem: {b}\n FocusedItem : ListViewItem: {b}\nItemSelectionChanged\n Item : ListViewItem: {b}\n IsSelected : False\n SelectedItem : null\n FocusedItem : ListViewItem: {b}\nSelectedIndexChanged\n SelectedItem : null\n FocusedItem : ListViewItem: {b}\n FocusedItem if (listView.FocusedItem == null)"
},
{
"answer_id": 277553,
"author": "Sunlight",
"author_id": 33650,
"author_profile": "https://Stackoverflow.com/users/33650",
"pm_score": 1,
"selected": false,
"text": "SelectedItems FocusedItem"
},
{
"answer_id": 2473723,
"author": "mukunda",
"author_id": 296969,
"author_profile": "https://Stackoverflow.com/users/296969",
"pm_score": 0,
"selected": false,
"text": "SelectedIndexChanged ItemActivate SelectedIndexChanged this.TaskslistView.SelectedIndexChanged\n += new System.EventHandler(TaskslistView_SelectedIndexChanged);\n TaskslistView_SelectedIndexChanged this.TaskslistView.ItemActivate\n += new System.EventHandler(this.TaskslistView_ItemActivate);\n TaskslistView_SelectedIndexChanged TaskslistView_ItemActivate"
},
{
"answer_id": 4548830,
"author": "Nana Kofi",
"author_id": 555109,
"author_profile": "https://Stackoverflow.com/users/555109",
"pm_score": 2,
"selected": false,
"text": "OnSelectedIndexHandler if(listViewObject.SelectedItems!=null&& listViewObject.SelectedItems.Count>0)\n{\n //....your code here\n}\n"
},
{
"answer_id": 41473298,
"author": "dubucha",
"author_id": 2754828,
"author_profile": "https://Stackoverflow.com/users/2754828",
"pm_score": 0,
"selected": false,
"text": "ListView.ItemSelectionChanged += \nnew ListViewItemSelectionChangedEventHandler(ListView_ItemSelectionChanged);\n\nprivate void ListView_ItemSelectionChanged(Object sender, ListViewItemSelectionChangedEventArgs e)\n{\n var x = e.IsSelected;\n}\n if (e.IsSelected == true)\n ListView.Select();\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/276986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
277,007
|
<p>I need to load a bunch of words (about 70,000) from a text file, add it to a hashtable (using soundex as a key) and sort the values. While doing all these I want to show a progress bar using JProgressBar. Articles such as <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html" rel="noreferrer">this</a> and <a href="http://www.dreamincode.net/forums/showtopic27952.htm" rel="noreferrer">this</a>, only gives a non-real example (a while loop). Can anyone suggest me how should I proceed. How can I get a number from above condition to set the value for the progress bar? Also it seems that there are different ways to do it - using thread, timer etc. Which could be the best method for the situation such as above?</p>
|
[
{
"answer_id": 277048,
"author": "Zach Scrivena",
"author_id": 20029,
"author_profile": "https://Stackoverflow.com/users/20029",
"pm_score": 3,
"selected": false,
"text": "// INITIALIZATION ON EDT \n\n// JProgressBar progress = new JProgressBar();\n// progress.setStringPainted(true);\n\n// PREPROCESSING\n\n// update progress bar (indeterminate mode)\nSwingUtilities.invokeLater(new Runnable()\n{\n @Override\n public void run()\n {\n progress.setIndeterminate(true);\n progress.setString(\"Preprocessing...\");\n }\n});\n\n// perform preprocessing (open input file, determine total number of words, etc)\n\n// PROCESSING \n\n// update progress bar (switch to determinate mode)\nSwingUtilities.invokeLater(new Runnable()\n{\n @Override\n public void run()\n {\n progress.setIndeterminate(false);\n }\n});\n\nint count = 0;\n\nwhile (true)\n{\n // read a word from the input file; exit loop if EOF\n\n // compute soundex representation\n\n // add entry to map (hash table)\n\n // compute percentage completed\n count++;\n final int percent = count * 100 / total;\n\n // update progress bar on the EDT\n SwingUtilities.invokeLater(new Runnable()\n {\n @Override\n public void run()\n {\n progress.setString(\"Processing \" + percent + \"%\");\n progress.setValue(percent);\n }\n });\n}\n\n// POSTPROCESSING \n\n// update progress bar (switch to indeterminate mode)\nSwingUtilities.invokeLater(new Runnable()\n{\n @Override\n public void run()\n {\n progress.setIndeterminate(true);\n progress.setString(\"Postprocessing...\");\n }\n});\n\n// perform postprocessing (close input file, etc)\n\n// DONE! \n\nSwingUtilities.invokeLater(new Runnable()\n{\n @Override\n public void run()\n {\n progress.setIndeterminate(false);\n progress.setString(\"Done!\");\n progress.setValue(100);\n }\n});\n SwingUtilities.invokeLater... public void run()..."
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35307/"
] |
277,010
|
<p>What are the benefits of having a member variable declared as read only? Is it just protecting against someone changing its value during the lifecycle of the class or does using this keyword result in any speed or efficiency improvements?</p>
|
[
{
"answer_id": 277023,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 9,
"selected": true,
"text": "readonly const readonly"
},
{
"answer_id": 277075,
"author": "Xiaofu",
"author_id": 31967,
"author_profile": "https://Stackoverflow.com/users/31967",
"pm_score": 6,
"selected": false,
"text": "readonly readonly internal private readonly"
},
{
"answer_id": 14491251,
"author": "Adam Naylor",
"author_id": 17540,
"author_profile": "https://Stackoverflow.com/users/17540",
"pm_score": 2,
"selected": false,
"text": "readonly out private readonly int _someNumber;\nprivate readonly string _someText;\n\npublic MyClass(int someNumber) : this(data, null)\n{ }\n\npublic MyClass(int someNumber, string someText)\n{\n Initialise(out _someNumber, someNumber, out _someText, someText);\n}\n\nprivate void Initialise(out int _someNumber, int someNumber, out string _someText, string someText)\n{\n //some logic\n}\n"
},
{
"answer_id": 37733928,
"author": "Yuriy Zaletskyy",
"author_id": 677824,
"author_profile": "https://Stackoverflow.com/users/677824",
"pm_score": 0,
"selected": false,
"text": "public sealed class Singleton\n{\n private static readonly Lazy<Singleton> lazy =\n new Lazy<Singleton>(() => new Singleton());\n\n public static Singleton Instance { get { return lazy.Value; } }\n\n private Singleton()\n {\n }\n}\n"
},
{
"answer_id": 43941195,
"author": "Mina Gabriel",
"author_id": 1410185,
"author_profile": "https://Stackoverflow.com/users/1410185",
"pm_score": 0,
"selected": false,
"text": "readonly const readonly const using System;\n\nclass MainClass {\n public static void Main (string[] args) {\n\n Console.WriteLine(new Test().c);\n Console.WriteLine(new Test(\"Constructor\").c);\n Console.WriteLine(new Test().ChangeC()); //Error A readonly field \n // `MainClass.Test.c' cannot be assigned to (except in a constructor or a \n // variable initializer)\n }\n\n\n public class Test {\n public readonly string c = \"Hello World\";\n public Test() {\n\n }\n\n public Test(string val) {\n c = val;\n }\n\n public string ChangeC() {\n c = \"Method\";\n return c ;\n }\n }\n}\n"
},
{
"answer_id": 50897195,
"author": "code14214",
"author_id": 9775301,
"author_profile": "https://Stackoverflow.com/users/9775301",
"pm_score": 1,
"selected": false,
"text": "set readonly public int Foo { get; } // a readonly property\n readonly public readonly int Foo; // a readonly field\n readonly set"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4653/"
] |
277,016
|
<p>I'm having major rendering issues in Safari with the web application I'm working on. Most of the design is done with divs using absolute positioning. This renders fine on Internet Explorer, Firefox, Chrome, Opera, Netscape, and konqueror. In Safari, it's just a jumbled mess. </p>
<p>Does Safari lack support for absolute positioning of div elements? </p>
<p>What is the best way to trouble shoot and find out what is going on with the safari browser?
<a href="https://i.stack.imgur.com/gtgCi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gtgCi.jpg" alt="alt text"></a></p>
<p>UPDATE: I'd like to note I did find the issue, and I would like to thank everyone that gave suggestions. It was the WebKit's "Inspect Element" that gave the most useful information. It appears that their were conflicts with inline styles and styles from the CSS. While safari grabed the styles from the .css file, the rest of the browsers were using the inline styles. i was able to see those conflicts with the information in the tool that was suggested. </p>
|
[
{
"answer_id": 277023,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 9,
"selected": true,
"text": "readonly const readonly"
},
{
"answer_id": 277075,
"author": "Xiaofu",
"author_id": 31967,
"author_profile": "https://Stackoverflow.com/users/31967",
"pm_score": 6,
"selected": false,
"text": "readonly readonly internal private readonly"
},
{
"answer_id": 14491251,
"author": "Adam Naylor",
"author_id": 17540,
"author_profile": "https://Stackoverflow.com/users/17540",
"pm_score": 2,
"selected": false,
"text": "readonly out private readonly int _someNumber;\nprivate readonly string _someText;\n\npublic MyClass(int someNumber) : this(data, null)\n{ }\n\npublic MyClass(int someNumber, string someText)\n{\n Initialise(out _someNumber, someNumber, out _someText, someText);\n}\n\nprivate void Initialise(out int _someNumber, int someNumber, out string _someText, string someText)\n{\n //some logic\n}\n"
},
{
"answer_id": 37733928,
"author": "Yuriy Zaletskyy",
"author_id": 677824,
"author_profile": "https://Stackoverflow.com/users/677824",
"pm_score": 0,
"selected": false,
"text": "public sealed class Singleton\n{\n private static readonly Lazy<Singleton> lazy =\n new Lazy<Singleton>(() => new Singleton());\n\n public static Singleton Instance { get { return lazy.Value; } }\n\n private Singleton()\n {\n }\n}\n"
},
{
"answer_id": 43941195,
"author": "Mina Gabriel",
"author_id": 1410185,
"author_profile": "https://Stackoverflow.com/users/1410185",
"pm_score": 0,
"selected": false,
"text": "readonly const readonly const using System;\n\nclass MainClass {\n public static void Main (string[] args) {\n\n Console.WriteLine(new Test().c);\n Console.WriteLine(new Test(\"Constructor\").c);\n Console.WriteLine(new Test().ChangeC()); //Error A readonly field \n // `MainClass.Test.c' cannot be assigned to (except in a constructor or a \n // variable initializer)\n }\n\n\n public class Test {\n public readonly string c = \"Hello World\";\n public Test() {\n\n }\n\n public Test(string val) {\n c = val;\n }\n\n public string ChangeC() {\n c = \"Method\";\n return c ;\n }\n }\n}\n"
},
{
"answer_id": 50897195,
"author": "code14214",
"author_id": 9775301,
"author_profile": "https://Stackoverflow.com/users/9775301",
"pm_score": 1,
"selected": false,
"text": "set readonly public int Foo { get; } // a readonly property\n readonly public readonly int Foo; // a readonly field\n readonly set"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18893/"
] |
277,018
|
<p>I have a class storing the name of a WS method to call and the type and value of the only parameter that service receives (it will be a collection of parameters but lets keep it simple for the example):</p>
<pre><code>public class MethodCall
{
public string Method { get; set; }
public Type ParType { get; set; }
public string ParValue { get; set; }
public T CastedValue<T>()
{
return (T)Convert.ChangeType(ParValue, ParType);
}
}
</code></pre>
<p>I have a method that takes the method name and the parameters and using reflection calls the method and returns the result. That one works fine when i use it like this:</p>
<pre><code>callingclass.URL = url;
callingclass.Service = serviceName;
object[] Params = { (decimal)1 };
callingclass.CallMethod("Hello", Params);
</code></pre>
<p>But my type, decimal in the example, is given in the instance of MethodCall. So if i have this code:</p>
<pre><code>MethodCall call = new MethodCall();
call.Method = "Hello";
call.ParType = typeof(decimal);
call.ParValue = "1";
</code></pre>
<p>Option 1, doesn't compile:</p>
<pre><code>object[] Params = { (call.ParType)call.ParValue }; //Compilation error: The type or namespace name 'call' could not be found (are you missing a using directive or an assembly reference?)
</code></pre>
<p>Option 2, doesn't compile neither:</p>
<pre><code>object[] Params = { call.CastedValue<call.ParType>() }; //Compilation error: Cannot implicitly convert type 'call.ParType' to 'object'
</code></pre>
<p>Option 3, using reflection, compiles but doesn't work when calling the service:</p>
<pre><code>object[] Params = { typeof(MethodCall).GetMethod("CastedValue").MakeGenericMethod(call.ParType).Invoke(this, null) };
callingclass.CallMethod(call.Method, Params);
</code></pre>
<p>The exception is:
ConnectionLib.WsProxyParameterExeption: The parameters for the method 'TestService.Hello' in URL '<a href="http://localhost/MyTestingService/" rel="nofollow noreferrer">http://localhost/MyTestingService/</a>' are wrong.</p>
<p>So can someone point me the right way to make this work?</p>
<p>Thanks</p>
|
[
{
"answer_id": 277023,
"author": "Bill the Lizard",
"author_id": 1288,
"author_profile": "https://Stackoverflow.com/users/1288",
"pm_score": 9,
"selected": true,
"text": "readonly const readonly"
},
{
"answer_id": 277075,
"author": "Xiaofu",
"author_id": 31967,
"author_profile": "https://Stackoverflow.com/users/31967",
"pm_score": 6,
"selected": false,
"text": "readonly readonly internal private readonly"
},
{
"answer_id": 14491251,
"author": "Adam Naylor",
"author_id": 17540,
"author_profile": "https://Stackoverflow.com/users/17540",
"pm_score": 2,
"selected": false,
"text": "readonly out private readonly int _someNumber;\nprivate readonly string _someText;\n\npublic MyClass(int someNumber) : this(data, null)\n{ }\n\npublic MyClass(int someNumber, string someText)\n{\n Initialise(out _someNumber, someNumber, out _someText, someText);\n}\n\nprivate void Initialise(out int _someNumber, int someNumber, out string _someText, string someText)\n{\n //some logic\n}\n"
},
{
"answer_id": 37733928,
"author": "Yuriy Zaletskyy",
"author_id": 677824,
"author_profile": "https://Stackoverflow.com/users/677824",
"pm_score": 0,
"selected": false,
"text": "public sealed class Singleton\n{\n private static readonly Lazy<Singleton> lazy =\n new Lazy<Singleton>(() => new Singleton());\n\n public static Singleton Instance { get { return lazy.Value; } }\n\n private Singleton()\n {\n }\n}\n"
},
{
"answer_id": 43941195,
"author": "Mina Gabriel",
"author_id": 1410185,
"author_profile": "https://Stackoverflow.com/users/1410185",
"pm_score": 0,
"selected": false,
"text": "readonly const readonly const using System;\n\nclass MainClass {\n public static void Main (string[] args) {\n\n Console.WriteLine(new Test().c);\n Console.WriteLine(new Test(\"Constructor\").c);\n Console.WriteLine(new Test().ChangeC()); //Error A readonly field \n // `MainClass.Test.c' cannot be assigned to (except in a constructor or a \n // variable initializer)\n }\n\n\n public class Test {\n public readonly string c = \"Hello World\";\n public Test() {\n\n }\n\n public Test(string val) {\n c = val;\n }\n\n public string ChangeC() {\n c = \"Method\";\n return c ;\n }\n }\n}\n"
},
{
"answer_id": 50897195,
"author": "code14214",
"author_id": 9775301,
"author_profile": "https://Stackoverflow.com/users/9775301",
"pm_score": 1,
"selected": false,
"text": "set readonly public int Foo { get; } // a readonly property\n readonly public readonly int Foo; // a readonly field\n readonly set"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
277,029
|
<p>Let's say I've got a setup that look something like</p>
<pre><code>phd/code/
phd/figures/
phd/thesis/
</code></pre>
<p>For historical reasons, these all have their own git repositories. But I'd like to combine them into a single one to simplify things a little. For example, right now I might make two sets of changes and have to do something like</p>
<pre><code>cd phd/code
git commit
cd ../figures
git commit
</code></pre>
<p>It'd be (now) nice to just to perform</p>
<pre><code>cd phd
git commit
</code></pre>
<p>There seems to be a couple of ways of doing this using submodules or pulling from my sub-repositories, but that's a little more complex than I'm looking for. At the very least, I'd be happy with</p>
<pre><code>cd phd
git init
git add [[everything that's already in my other repositories]]
</code></pre>
<p>but that doesn't seem like a one-liner. Is there anything in <code>git</code> that can help me out?</p>
|
[
{
"answer_id": 277068,
"author": "Patrick_O",
"author_id": 11084,
"author_profile": "https://Stackoverflow.com/users/11084",
"pm_score": 2,
"selected": false,
"text": "git init\ngit add *\ngit commit -a -m \"import everything\"\n"
},
{
"answer_id": 277089,
"author": "Aristotle Pagaltzis",
"author_id": 9410,
"author_profile": "https://Stackoverflow.com/users/9410",
"pm_score": 6,
"selected": false,
"text": "git-stitch-repo git-fast-export --all --date-order git-fast-import"
},
{
"answer_id": 618113,
"author": "MiniQuark",
"author_id": 38626,
"author_profile": "https://Stackoverflow.com/users/38626",
"pm_score": 7,
"selected": false,
"text": "$ cp -r phd phd-backup\n phd/code phd/code/code $ cd phd/code\n$ git filter-branch --index-filter \\\n 'git ls-files -s | sed \"s#\\t#&code/#\" |\n GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n git update-index --index-info &&\n mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n phd/figures phd/thesis code figures thesis phd\n |_code\n | |_.git\n | |_code\n | |_(your code...)\n |_figures\n | |_.git\n | |_figures\n | |_(your figures...)\n |_thesis\n |_.git\n |_thesis\n |_(your thesis...)\n $ cd phd\n$ git init\n\n$ git pull code\n$ rm -rf code/code\n$ rm -rf code/.git\n\n$ git pull figures --allow-unrelated-histories\n$ rm -rf figures/figures\n$ rm -rf figures/.git\n\n$ git pull thesis --allow-unrelated-histories\n$ rm -rf thesis/thesis\n$ rm -rf thesis/.git\n phd\n |_.git\n |_code\n | |_(your code...)\n |_figures\n | |_(your figures...)\n |_thesis\n |_(your thesis...)\n code code figures thesis $ cd phd/code\n$ git mv code code-repository-migration\n$ git commit -m \"preparing the code directory for migration\"\n $ cd phd\n$ git mv code/code-repository-migration code/code\n$ git commit -m \"final step for code directory migration\"\n code mv git mv git commit"
},
{
"answer_id": 779834,
"author": "imz -- Ivan Zakharyaschev",
"author_id": 94687,
"author_profile": "https://Stackoverflow.com/users/94687",
"pm_score": 4,
"selected": false,
"text": "$ cd phd/code\n$ mkdir code\n# This won't work literally, because * would also match the new code/ subdir, but you understand what I mean:\n$ git mv * code/\n$ git commit -m \"preparing the code directory for migration\"\n $ cd ../..\n$ mkdir phd.all\n$ cd phd.all\n$ git init\n$ git pull ../phd/code\n...\n"
},
{
"answer_id": 3336302,
"author": "Gareth",
"author_id": 98476,
"author_profile": "https://Stackoverflow.com/users/98476",
"pm_score": 3,
"selected": false,
"text": "Rewrite 422a38a0e9d2c61098b98e6c56213ac83b7bacc2 (1/42)mv: cannot stat `/home/.../wikis/nodows/.git-rewrite/t/../index.new': No such file or directory\n HEAD [SHA of 2nd revision]..HEAD"
},
{
"answer_id": 4950742,
"author": "Leif Gruenwoldt",
"author_id": 52176,
"author_profile": "https://Stackoverflow.com/users/52176",
"pm_score": 4,
"selected": false,
"text": "git-filter-branch"
},
{
"answer_id": 15606083,
"author": "MichK",
"author_id": 729156,
"author_profile": "https://Stackoverflow.com/users/729156",
"pm_score": 3,
"selected": false,
"text": "code new_phd/code new_phd/code/code code_ code_ .git"
},
{
"answer_id": 31682404,
"author": "user123568943685",
"author_id": 4953123,
"author_profile": "https://Stackoverflow.com/users/4953123",
"pm_score": 1,
"selected": false,
"text": "git fast-export --all --date-order > /tmp/secondProjectExport\n git checkout -b secondProject\ngit fast-import --force < /tmp/secondProjectExport\n git checkout master\ngit merge secondProject\n"
},
{
"answer_id": 33181772,
"author": "chrishiestand",
"author_id": 324651,
"author_profile": "https://Stackoverflow.com/users/324651",
"pm_score": 0,
"selected": false,
"text": "git filter-branch"
},
{
"answer_id": 56788263,
"author": "bue",
"author_id": 8480811,
"author_profile": "https://Stackoverflow.com/users/8480811",
"pm_score": 0,
"selected": false,
"text": "export SUBREPO=\"subrepo\"; # <= your subrepository name here\nexport TABULATOR=`printf '\\t'`;\nFILTER='git ls-files -s | sed \"s#${TABULATOR}#&${SUBREPO}/#\" |\n GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n git update-index --index-info &&\n if [ -f \"$GIT_INDEX_FILE.new\" ]; then mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE; else echo \"git filter skipped missing file: $GIT_INXEX_FILE.new\"; fi'\n\ngit filter-branch --index-filter \"$FILTER\" HEAD\n"
},
{
"answer_id": 71854109,
"author": "Abelardo",
"author_id": 11043489,
"author_profile": "https://Stackoverflow.com/users/11043489",
"pm_score": 0,
"selected": false,
"text": "temp temp temp"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4161/"
] |
277,031
|
<p>I have created a VB.Net lending application for a cooperative that caters to widows. The application tracks the members' loans and payments, and is also used as an accounting system. In my first release, the users felt that showing a messagebox every time an error occurs is very annoying. My solution is to output errors in a label control. The users accepted the modification, but i feel i am doing it wrong. </p>
|
[
{
"answer_id": 277160,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": "https://Stackoverflow.com/users/29157",
"pm_score": 0,
"selected": false,
"text": "\"Show Errors\""
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277031",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26087/"
] |
277,053
|
<p>My code processes all the files in a folder on a Windows box. I want to offer the user (who happens to also be me) the option to select the folder to be processed, using the standard File Chooser dialog.</p>
<p>I am trying to use the <a href="http://msdn.microsoft.com/en-us/library/ms646927(VS.85).aspx" rel="nofollow noreferrer" title="MSDN Page for GetOpenFileName">GetOpenFileName</a> function to make this happen. (I am actually calling it from Python via <a href="http://docs.activestate.com/activepython/2.5/pywin32/win32gui__GetOpenFileNameW_meth.html" rel="nofollow noreferrer" title="PyWin32 Manual on GetOpenFileNameW">pywin32</a>, but that shouldn't be relevant.)</p>
<p>I can get it to select a particular file, but I can't see any options to let the user select a folder instead.</p>
<p>Is there a flag combination I haven't understood, am I calling the wrong function entirely or is there another idiom for doing this?</p>
|
[
{
"answer_id": 277078,
"author": "Martin Kenny",
"author_id": 6111,
"author_profile": "https://Stackoverflow.com/users/6111",
"pm_score": 2,
"selected": false,
"text": "SHBrowseForFolder browse_for_folder.py"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8014/"
] |
277,055
|
<p>There are a couple of different ways to remove <code>HTML tags</code> from an <code>NSString</code> in <code>Cocoa</code>.</p>
<p><a href="http://cocoa.karelia.com/Foundation_Categories/NSString/_Flatten__a_string_.m" rel="noreferrer">One way</a> is to render the string into an <code>NSAttributedString</code> and then grab the rendered text.</p>
<p><a href="http://sugarmaplesoftware.com/25/strip-html-tags/#comment-71" rel="noreferrer">Another way</a> is to use <code>NSXMLDocument's</code> -<code>objectByApplyingXSLTString</code> method to apply an <code>XSLT</code> transform that does it.</p>
<p>Unfortunately, the iPhone doesn't support <code>NSAttributedString</code> or <code>NSXMLDocument</code>. There are too many edge cases and malformed <code>HTML</code> documents for me to feel comfortable using regex or <code>NSScanner</code>. Does anyone have a solution to this?</p>
<p>One suggestion has been to simply look for opening and closing tag characters, this method won't work except for very trivial cases. </p>
<p>For example these cases (from the Perl Cookbook chapter on the same subject) would break this method:</p>
<pre><code><IMG SRC = "foo.gif" ALT = "A > B">
<!-- <A comment> -->
<script>if (a<b && a>c)</script>
<![INCLUDE CDATA [ >>>>>>>>>>>> ]]>
</code></pre>
|
[
{
"answer_id": 1519230,
"author": "Biranchi",
"author_id": 97651,
"author_profile": "https://Stackoverflow.com/users/97651",
"pm_score": 2,
"selected": false,
"text": "UIWebViewDidfinishLoading NSString *myText = [webView stringByEvaluatingJavaScriptFromString:@\"document.documentElement.textContent\"];\n"
},
{
"answer_id": 4164041,
"author": "Mohamed AHDIDOU",
"author_id": 480643,
"author_profile": "https://Stackoverflow.com/users/480643",
"pm_score": 3,
"selected": false,
"text": "NSString *myregex = @\"<[^>]*>\"; //regex to remove any html tag\n\nNSString *htmlString = @\"<html>bla bla</html>\";\nNSString *stringWithoutHTML = [hstmString stringByReplacingOccurrencesOfRegex:myregex withString:@\"\"];\n"
},
{
"answer_id": 4886998,
"author": "m.kocikowski",
"author_id": 469997,
"author_profile": "https://Stackoverflow.com/users/469997",
"pm_score": 9,
"selected": true,
"text": "-(NSString *) stringByStrippingHTML {\n NSRange r;\n NSString *s = [[self copy] autorelease];\n while ((r = [s rangeOfString:@\"<[^>]+>\" options:NSRegularExpressionSearch]).location != NSNotFound)\n s = [s stringByReplacingCharactersInRange:r withString:@\"\"];\n return s;\n}\n"
},
{
"answer_id": 7034551,
"author": "Jim Liu",
"author_id": 888639,
"author_profile": "https://Stackoverflow.com/users/888639",
"pm_score": 2,
"selected": false,
"text": "#import \"RegexKitLite.h\"\n\nstring text = [html stringByReplacingOccurrencesOfRegex:@\"<[^>]+>\" withString:@\"\"]\n"
},
{
"answer_id": 7341993,
"author": "Leigh McCulloch",
"author_id": 159762,
"author_profile": "https://Stackoverflow.com/users/159762",
"pm_score": 5,
"selected": false,
"text": "NSString NSXMLParser HTML NSString .m .h html #import \"NSString_stripHtml.h\"\n NSString* mystring = @\"<b>Hello</b> World!!\";\nNSString* stripped = [mystring stripHtml];\n// stripped will be = Hello World!!\n HTML XML"
},
{
"answer_id": 12115786,
"author": "Dan J",
"author_id": 112705,
"author_profile": "https://Stackoverflow.com/users/112705",
"pm_score": 2,
"selected": false,
"text": "+ (NSString *)stringByStrippingHTML:(NSString *)inputString;\n + (NSString *)stringByStrippingHTML:(NSString *)inputString \n{\n NSMutableString *outString;\n\n if (inputString)\n {\n outString = [[NSMutableString alloc] initWithString:inputString];\n\n if ([inputString length] > 0)\n {\n NSRange r;\n\n while ((r = [outString rangeOfString:@\"<[^>]+>\" options:NSRegularExpressionSearch]).location != NSNotFound)\n {\n [outString deleteCharactersInRange:r];\n } \n }\n }\n\n return outString; \n}\n"
},
{
"answer_id": 17081186,
"author": "MANCHIKANTI KRISHNAKISHORE",
"author_id": 2131470,
"author_profile": "https://Stackoverflow.com/users/2131470",
"pm_score": 4,
"selected": false,
"text": "UITextView *textview= [[UITextView alloc]initWithFrame:CGRectMake(10, 130, 250, 170)];\nNSString *str = @\"This is <font color='red'>simple</font>\";\n[textview setValue:str forKey:@\"contentToHTMLString\"];\ntextview.textAlignment = NSTextAlignmentLeft;\ntextview.editable = NO;\ntextview.font = [UIFont fontWithName:@\"vardana\" size:20.0];\n[UIView addSubview:textview];\n"
},
{
"answer_id": 17868362,
"author": "Ashoor",
"author_id": 1448370,
"author_profile": "https://Stackoverflow.com/users/1448370",
"pm_score": 0,
"selected": false,
"text": "@interface NSString (NAME_OF_CATEGORY)\n\n- (NSString *)stringByStrippingHTML;\n\n@end\n @implementation NSString (NAME_OF_CATEGORY)\n\n- (NSString *)stringByStrippingHTML\n{\nNSMutableString *outString;\nNSString *inputString = self;\n\nif (inputString)\n{\n outString = [[NSMutableString alloc] initWithString:inputString];\n\n if ([inputString length] > 0)\n {\n NSRange r;\n\n while ((r = [outString rangeOfString:@\"<[^>]+>\" options:NSRegularExpressionSearch]).location != NSNotFound)\n {\n [outString deleteCharactersInRange:r];\n }\n }\n}\n\nreturn outString;\n}\n\n@end\n #import \"NSString+NAME_OF_CATEGORY.h\"\n NSString* sub = [result stringByStrippingHTML];\nNSLog(@\"%@\", sub);\n"
},
{
"answer_id": 18969560,
"author": "digipeople",
"author_id": 1571878,
"author_profile": "https://Stackoverflow.com/users/1571878",
"pm_score": 2,
"selected": false,
"text": "@implementation NSString (StripXMLTags)\n\n- (NSString *)stripXMLTags\n{\n NSRange r;\n NSString *s = [self copy];\n while ((r = [s rangeOfString:@\"<[^>]+>\\\\s*\" options:NSRegularExpressionSearch]).location != NSNotFound)\n s = [s stringByReplacingCharactersInRange:r withString:@\"\"];\n return s;\n}\n\n@end\n"
},
{
"answer_id": 19291394,
"author": "Kirtikumar A.",
"author_id": 1376496,
"author_profile": "https://Stackoverflow.com/users/1376496",
"pm_score": 3,
"selected": false,
"text": "-(void)myMethod\n {\n\n NSString* htmlStr = @\"<some>html</string>\";\n NSString* strWithoutFormatting = [self stringByStrippingHTML:htmlStr];\n\n }\n\n -(NSString *)stringByStrippingHTML:(NSString*)str\n {\n NSRange r;\n while ((r = [str rangeOfString:@\"<[^>]+>\" options:NSRegularExpressionSearch]).location != NSNotFound)\n {\n str = [str stringByReplacingCharactersInRange:r withString:@\"\"];\n }\n return str;\n }\n"
},
{
"answer_id": 22382214,
"author": "hpique",
"author_id": 143378,
"author_profile": "https://Stackoverflow.com/users/143378",
"pm_score": 3,
"selected": false,
"text": "- (NSString*)hp_stringByRemovingTags\n{\n static NSRegularExpression *regex = nil;\n static dispatch_once_t onceToken;\n dispatch_once(&onceToken, ^{\n regex = [NSRegularExpression regularExpressionWithPattern:@\"<[^>]+>\" options:kNilOptions error:nil];\n });\n\n // Use reverse enumerator to delete characters without affecting indexes\n NSArray *matches =[regex matchesInString:self options:kNilOptions range:NSMakeRange(0, self.length)];\n NSEnumerator *enumerator = matches.reverseObjectEnumerator;\n\n NSTextCheckingResult *match = nil;\n NSMutableString *modifiedString = self.mutableCopy;\n while ((match = [enumerator nextObject]))\n {\n [modifiedString deleteCharactersInRange:match.range];\n }\n return modifiedString;\n}\n NSString NSScanner"
},
{
"answer_id": 23861119,
"author": "Rémy",
"author_id": 87988,
"author_profile": "https://Stackoverflow.com/users/87988",
"pm_score": 3,
"selected": false,
"text": "- (NSString *)removeHTML {\n\n static NSRegularExpression *regexp;\n static dispatch_once_t onceToken;\n dispatch_once(&onceToken, ^{\n regexp = [NSRegularExpression regularExpressionWithPattern:@\"<[^>]+>\" options:kNilOptions error:nil];\n });\n\n return [regexp stringByReplacingMatchesInString:self\n options:kNilOptions\n range:NSMakeRange(0, self.length)\n withTemplate:@\"\"];\n}\n"
},
{
"answer_id": 28596272,
"author": "tmr",
"author_id": 3120387,
"author_profile": "https://Stackoverflow.com/users/3120387",
"pm_score": 1,
"selected": false,
"text": "-(NSString *) stringByStrippingHTML:(NSString*)originalString {\n NSRange r;\n NSString *s = [originalString copy];\n while ((r = [s rangeOfString:@\"<[^>]+>\" options:NSRegularExpressionSearch]).location != NSNotFound)\n s = [s stringByReplacingCharactersInRange:r withString:@\"\"];\n return s;\n}\n"
},
{
"answer_id": 29207038,
"author": "Pavan Sisode",
"author_id": 4107865,
"author_profile": "https://Stackoverflow.com/users/4107865",
"pm_score": 3,
"selected": false,
"text": "NSAttributedString *str=[[NSAttributedString alloc] initWithData:[trimmedString dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:nil];\n"
},
{
"answer_id": 29806531,
"author": "jcpennypincher",
"author_id": 407379,
"author_profile": "https://Stackoverflow.com/users/407379",
"pm_score": 0,
"selected": false,
"text": "- (NSString *) stringByStrippingHTML {\n NSString *retVal;\n @autoreleasepool {\n NSRange r;\n NSString *s = [[self copy] autorelease];\n while ((r = [s rangeOfString:@\"<[^>]+>\" options:NSRegularExpressionSearch]).location != NSNotFound) {\n s = [s stringByReplacingCharactersInRange:r withString:@\"\"];\n }\n retVal = [s copy];\n } \n // pool is drained, release s and all temp \n // strings created by stringByReplacingCharactersInRange\n return retVal;\n}\n"
},
{
"answer_id": 33594101,
"author": "JohnVanDijk",
"author_id": 2426994,
"author_profile": "https://Stackoverflow.com/users/2426994",
"pm_score": 2,
"selected": false,
"text": "func stripHTMLFromString(string: String) -> String {\n var copy = string\n while let range = copy.rangeOfString(\"<[^>]+>\", options: .RegularExpressionSearch) {\n copy = copy.stringByReplacingCharactersInRange(range, withString: \"\")\n }\n copy = copy.stringByReplacingOccurrencesOfString(\" \", withString: \" \")\n copy = copy.stringByReplacingOccurrencesOfString(\"&\", withString: \"&\")\n return copy\n}\n"
},
{
"answer_id": 35034929,
"author": "Nike Kov",
"author_id": 5790492,
"author_profile": "https://Stackoverflow.com/users/5790492",
"pm_score": 0,
"selected": false,
"text": "-(NSString *) stringByStrippingHTML:(NSString*)inputString; (NSString *) stringByStrippingHTML:(NSString*)inputString\n{ \nNSAttributedString *attrString = [[NSAttributedString alloc] initWithData:[inputString dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)} documentAttributes:nil error:nil];\nNSString *str= [attrString string]; \n\n//you can add here replacements as your needs:\n [str stringByReplacingOccurrencesOfString:@\"[\" withString:@\"\"];\n [str stringByReplacingOccurrencesOfString:@\"]\" withString:@\"\"];\n [str stringByReplacingOccurrencesOfString:@\"\\n\" withString:@\"\"];\n\n return str;\n}\n cell.exampleClass.text = [self stringByStrippingHTML:[exampleJSONParsingArray valueForKey: @\"key\"]]; NSString *myClearStr = [self stringByStrippingHTML:rudeStr];"
},
{
"answer_id": 46582739,
"author": "Ahmed Awad",
"author_id": 1043006,
"author_profile": "https://Stackoverflow.com/users/1043006",
"pm_score": 0,
"selected": false,
"text": "-(NSString *) stringByStrippingHTMLFromString:(NSString *)str {\nNSRange range;\nwhile ((range = [str rangeOfString:@\"<[^>]+>\" options:NSRegularExpressionSearch]).location != NSNotFound)\n str = [str stringByReplacingCharactersInRange:range withString:@\"\"];\nreturn str;\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28106/"
] |
277,077
|
<p>I'm a Git newbie. I recently moved a Rails project from Subversion to Git. I followed the tutorial here: <a href="http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/" rel="noreferrer">http://www.simplisticcomplexity.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/</a></p>
<p>I am also using unfuddle.com to store my code. I make changes on my Mac laptop on the train to/from work and then push them to unfuddle when I have a network connection using the following command:</p>
<pre><code>git push unfuddle master
</code></pre>
<p>I use Capistrano for deployments and pull code from the unfuddle repository using the master branch.</p>
<p>Lately I've noticed the following message when I run "git status" on my laptop:</p>
<pre><code># On branch master
# Your branch is ahead of 'origin/master' by 11 commits.
#
nothing to commit (working directory clean)
</code></pre>
<p>And I'm confused as to why. I thought my laptop was the origin... but don't know if either the fact that I originally pulled from Subversion or push to Unfuddle is what's causing the message to show up. How can I:</p>
<ol>
<li>Find out where Git thinks 'origin/master' is?</li>
<li>If it's somewhere else, how do I turn my laptop into the 'origin/master'?</li>
<li>Get this message to go away. It makes me think Git is unhappy about something.</li>
</ol>
<p>My mac is running Git version 1.6.0.1.</p>
<hr>
<p>When I run <code>git remote show origin</code> as suggested by dbr, I get the following:</p>
<pre><code>~/Projects/GeekFor/geekfor 10:47 AM $ git remote show origin
fatal: '/Users/brian/Projects/GeekFor/gf/.git': unable to chdir or not a git archive
fatal: The remote end hung up unexpectedly
</code></pre>
<p>When I run <code>git remote -v</code> as suggested by Aristotle Pagaltzis, I get the following:</p>
<pre><code>~/Projects/GeekFor/geekfor 10:33 AM $ git remote -v
origin /Users/brian/Projects/GeekFor/gf/.git
unfuddle git@spilth.unfuddle.com:spilth/geekfor.git
</code></pre>
<p>Now, interestingly, I'm working on my project in the <code>geekfor</code> directory but it says my origin is my local machine in the <code>gf</code> directory. I believe <code>gf</code> was the temporary directory I used when converting my project from Subversion to Git and probably where I pushed to unfuddle from. Then I believe I checked out a fresh copy from unfuddle to the <code>geekfor</code> directory.</p>
<p>So it looks like I should follow dbr's advice and do:</p>
<pre><code>git remote rm origin
git remote add origin git@spilth.unfuddle.com:spilth/geekfor.git
</code></pre>
|
[
{
"answer_id": 277098,
"author": "Aristotle Pagaltzis",
"author_id": 9410,
"author_profile": "https://Stackoverflow.com/users/9410",
"pm_score": 3,
"selected": false,
"text": "origin git remote -v origin origin/master master origin master origin/master"
},
{
"answer_id": 277186,
"author": "dbr",
"author_id": 745,
"author_profile": "https://Stackoverflow.com/users/745",
"pm_score": 9,
"selected": true,
"text": "1. git-remote git remote show origin\n * remote origin\n URL: me@remote.example.com:~/something.git\n Remote branch merged with 'git pull' while on branch master\n master\n Tracked remote branch\n master\n git remote add unfuddle me@unfuddle.com/myrepo.git\ngit push unfuddle\n git status 2. git push laptop git remote rm origin\n origin origin git push git pull git remote rm origin\ngit remote add origin git@subdomain.unfuddle.com:subdomain/abbreviation.git\n git remote set-url origin git@subdomain.unfuddle.com:subdomain/abbreviation.git\n git push git pull git push unfuddle master"
},
{
"answer_id": 3365668,
"author": "Steve Hindmarch",
"author_id": 406023,
"author_profile": "https://Stackoverflow.com/users/406023",
"pm_score": 1,
"selected": false,
"text": "mkdir rep1\ncd rep1\ngit init\necho \"Line1\" > README\ngit add README\ngit commit -m \"Commit 1\"\n cd ~\ngit clone ~/rep1 rep2\ncat ~/rep2/README\n cd ~/rep1\n<change file and commit>\ngit remote add rep2 ~/rep2\ngit push rep2 master\n # On branch master\n# Your branch is ahead of 'origin/master' by 1 commit.\n#\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# modified: README\n#\n"
},
{
"answer_id": 5480767,
"author": "Mims H. Wright",
"author_id": 168665,
"author_profile": "https://Stackoverflow.com/users/168665",
"pm_score": 5,
"selected": false,
"text": "ahead of origin by X commits git pull Everything up-to-date $ git push {remote} {localbranch}:{remotebranch}\n $ git push origin master:master\n"
},
{
"answer_id": 5725070,
"author": "Vino",
"author_id": 716351,
"author_profile": "https://Stackoverflow.com/users/716351",
"pm_score": 1,
"selected": false,
"text": "$ git push"
},
{
"answer_id": 6206582,
"author": "Chris",
"author_id": 733839,
"author_profile": "https://Stackoverflow.com/users/733839",
"pm_score": 2,
"selected": false,
"text": "$ git push origin\n"
},
{
"answer_id": 6300652,
"author": "Jason Rikard",
"author_id": 116316,
"author_profile": "https://Stackoverflow.com/users/116316",
"pm_score": 0,
"selected": false,
"text": "git remote\n git remote rm {insert remote to remove}\n"
},
{
"answer_id": 6823099,
"author": "looneydoodle",
"author_id": 604556,
"author_profile": "https://Stackoverflow.com/users/604556",
"pm_score": 1,
"selected": false,
"text": "git rm $(git ls-files --deleted)\n"
},
{
"answer_id": 7163484,
"author": "RobLoach",
"author_id": 689971,
"author_profile": "https://Stackoverflow.com/users/689971",
"pm_score": 0,
"selected": false,
"text": "$ git status\n# On branch master\n# Your branch is ahead of 'origin/master' by 2 commits.\n#\nnothing to commit (working directory clean)\n git log $ git log\ncommit 3368e1c5b8a47135a34169c885e8dd5ba01af5bb\n...\ncommit baf8d5e7da9e41fcd37d63ae9483ee0b10bfac8e\n...\n git reset --hard baf8d5e7da9e41fcd37d63ae9483ee0b10bfac8e\n"
},
{
"answer_id": 8720030,
"author": "Nara Narasimhan",
"author_id": 1128864,
"author_profile": "https://Stackoverflow.com/users/1128864",
"pm_score": 1,
"selected": false,
"text": "mv myrepo myrepo\ngit clone USER@MASTER_HOST:/REPO_DIR myrepo\n"
},
{
"answer_id": 8894082,
"author": "noob",
"author_id": 1153819,
"author_profile": "https://Stackoverflow.com/users/1153819",
"pm_score": -1,
"selected": false,
"text": "git push ssh://git@xxx.repositryhosting.com/yyy/zzz.git\n git push\n"
},
{
"answer_id": 10949152,
"author": "chim",
"author_id": 673282,
"author_profile": "https://Stackoverflow.com/users/673282",
"pm_score": 5,
"selected": false,
"text": "git remote update"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8252/"
] |
277,085
|
<p>I'm trying to get the name of the executable of a window that is outside my C# 2.0 application. My app currently gets a window handle (hWnd) using the GetForegroundWindow() call from "user32.dll".</p>
<p>From the digging that I've been able to do, I think I want to use the GetModuleFileNameEx() function (from PSAPI) to obtain the name, but GetModuleFileNameEx() requires a handle to a Process, not a Window. </p>
<p>Is it possible to get a process handle from a window handle? (Do I need to get the thread handle of the window first?)</p>
<p>EDITED the first sentence to make it clearer what I'm trying to do.</p>
<p><strong>UPDATE!</strong> Here's the C# code that I found worked for me. The only caveat is <em>occasionally</em> it returns a file/path where the drive letter is a "?" instead of the actual drive letter (like "C"). -- Haven't figured out why yet.</p>
<pre><code>[DllImport("user32.dll")]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
[DllImport("kernel32.dll")]
static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);
[DllImport("psapi.dll")]
static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, [Out] StringBuilder lpBaseName, [In] [MarshalAs(UnmanagedType.U4)] int nSize);
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool CloseHandle(IntPtr hObject);
private string GetWindowModuleFileName(IntPtr hWnd)
{
uint processId = 0;
const int nChars = 1024;
StringBuilder filename = new StringBuilder(nChars);
GetWindowThreadProcessId(hWnd, out processId);
IntPtr hProcess = OpenProcess(1040, 0, processId);
GetModuleFileNameEx(hProcess,IntPtr.Zero,filename,nChars);
CloseHandle(hProcess);
return (filename.ToString());
}
</code></pre>
|
[
{
"answer_id": 321343,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "[DllImport(\"user32.dll\")]\npublic static extern IntPtr GetWindowThreadProcessId(IntPtr hWnd, IntPtr ProcessId);\n\nvoid GetProcessPathFromWindowHandle(IntPtr hwnd)\n{\n uint pid = 0;\n Win32.GetWindowThreadProcessId(hwnd, out pid);\n Process p = Process.GetProcessById((int)pid);\n return p.MainModule.FileName;\n}\n"
},
{
"answer_id": 535207,
"author": "Greg Domjan",
"author_id": 37558,
"author_profile": "https://Stackoverflow.com/users/37558",
"pm_score": 2,
"selected": false,
"text": "typedef DWORD (__stdcall *PfnQueryFullProcessImageName)(HANDLE hProcess, DWORD dwFlags, LPTSTR lpImageFileName, PDWORD nSize);\ntypedef DWORD (__stdcall *PfnGetModuleFileNameEx)(HANDLE hProcess, HMODULE hModule, LPTSTR lpImageFileName, DWORD nSize);\n\nstd::wstring GetExeName( HWND hWnd ){\n// Convert from Window to Process ID\nDWORD dwProcessID = 0;\n::GetWindowThreadProcessId(hWnd, &dwProcessID);\n\n// Get a handle to the process from the Process ID\nHANDLE hProcess = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, dwProcessID);\n\n// Get the process name\nif (NULL != hProcess) {\n TCHAR szEXEName[MAX_PATH*2] = {L'\\0'};\n DWORD nExeName = sizeof(szEXEName)/sizeof(TCHAR);\n\n // the QueryFullProcessImageNameW does not exist on W2K\n HINSTANCE hKernal32dll = LoadLibrary(L\"kernel32.dll\");\n PfnQueryFullProcessImageName pfnQueryFullProcessImageName = NULL;\n if(hKernal32dll != NULL) {\n pfnQueryFullProcessImageName = (PfnQueryFullProcessImageName)GetProcAddress(hKernal32dll, \"QueryFullProcessImageNameW\");\n if (pfnQueryFullProcessImageName != NULL) \n pfnQueryFullProcessImageName(hProcess, 0, szEXEName, &nExeName);\n ::FreeLibrary(hKernal32dll);\n } \n\n // The following was not working from 32 querying of 64 bit processes\n // Use as backup for when function above is not available \n if( pfnQueryFullProcessImageName == NULL ){ \n HINSTANCE hPsapidll = LoadLibrary(L\"Psapi.dll\");\n PfnGetModuleFileNameEx pfnGetModuleFileNameEx = (PfnGetModuleFileNameEx)GetProcAddress(hPsapidll, \"GetModuleFileNameExW\");\n if( pfnGetModuleFileNameEx != NULL ) \n pfnGetModuleFileNameEx(hProcess, NULL, szEXEName, sizeof(szEXEName)/sizeof(TCHAR));\n ::FreeLibrary(hPsapidll);\n }\n\n ::CloseHandle(hProcess);\n\n return( szEXEName );\n} \nreturn std::wstring();\n}\n"
},
{
"answer_id": 2942146,
"author": "muh",
"author_id": 354388,
"author_profile": "https://Stackoverflow.com/users/354388",
"pm_score": 0,
"selected": false,
"text": "string file = System.Windows.Forms.Application.ExecutablePath;\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21244/"
] |
277,092
|
<p>How can I refer a custom function in xml? Suppose that I have a function written in Java and want it to refer by the xml tag, how is this possible?</p>
<p>Current senario: I am using XACML2.0 which contains xml tags and I want to refer some function in Java that will talk to the backend data, I'm unable to refer a function in xacml. Could you help me please?</p>
|
[
{
"answer_id": 352783,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "Integer[] params = {new Integer(123),new Integer(567)}; \nClass cl=Class.forName(\"stringParsedFromYourXML\"); \nClass[] par=new Class[2]; \npar[0]=Integer.TYPE; \npar[1]=Integer.TYPE; \nMethod mthd=cl.getMethod(\"methodNameAsString\", parameterTypes); \nmthd.invoke(new myObjectThatContainsMethod(), params);\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
277,102
|
<p>I'm working on a System Preferences Pane. It opens fine on some computers, but on other Macs (all running 10.5.5), the preference pane refuses to load and simply hangs, spitting the following into the console:</p>
<pre><code>11/9/08 8:38:50 PM [0x0-0x31031].com.apple.systempreferences[369] Sun Nov 9 20:38:50 Macintosh.local System Preferences[369] <Error>: Failed to create window context device
11/9/08 8:38:50 PM [0x0-0x31031].com.apple.systempreferences[369] Sun Nov 9 20:38:50 Macintosh.local System Preferences[369] <Error>: CGWindowContextCreate: failed to create context delegate.
11/9/08 8:38:55 PM [0x0-0x31031].com.apple.systempreferences[369] Sun Nov 9 20:38:55 Macintosh.local System Preferences[369] <Error>: Failed to create window context device
</code></pre>
<p>Any ideas why this is happening?</p>
<p>Thanks.</p>
|
[
{
"answer_id": 352783,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "Integer[] params = {new Integer(123),new Integer(567)}; \nClass cl=Class.forName(\"stringParsedFromYourXML\"); \nClass[] par=new Class[2]; \npar[0]=Integer.TYPE; \npar[1]=Integer.TYPE; \nMethod mthd=cl.getMethod(\"methodNameAsString\", parameterTypes); \nmthd.invoke(new myObjectThatContainsMethod(), params);\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277102",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4103/"
] |
277,127
|
<p>I have a DataGridView bound to a DataTable. I have one column that's a pseudo-int -- you know the kind, where most of the time it has integers but sometimes instead there's an N/A. This column is a varchar, but I want to have it sort like an int column, treating the N/A as a -1.</p>
<p>The DataGridView provides for this -- <em>if</em> it's not bound to a DataTable. If it is bound, it uses the sorting mechanism of the bound object, and DataTables don't expose that functionality.</p>
<p>I can make a custom column in the DataTable with the behaviour I want, but because the DataGridView is bound to the DataTable, it sorts by the column it's displaying. I can make a custom column in the DataGridView, but I need to set the table to virtual mode to sort by that when I already have a solution that mostly works.</p>
<p>How do I make it sort my pseudo-int column as I want - where possible, sorting by int? This scenario seems like it's incredibly common, and I'm sure somewhere it's been provided for.</p>
|
[
{
"answer_id": 277153,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 1,
"selected": false,
"text": "private void SortByTwoColumns()\n{\n DataView myDataView = DataTable1.DefaultView;\n myDataView.Sort = \"State, ZipCode DESC\";\n myGridView.DataSource = myDataView;\n}\n"
},
{
"answer_id": 20358913,
"author": "John",
"author_id": 525539,
"author_profile": "https://Stackoverflow.com/users/525539",
"pm_score": 0,
"selected": false,
"text": "Private Sub dgDisplay_CellFormatting(ByVal sender As Object, _\nByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) _\nHandles dgDisplay.CellFormatting\n If Not (e.ColumnIndex = dgDisplay.Columns(\"NumericColumn\").Index _\n AndAlso e.RowIndex >= 0) Then Exit Sub\n\n Dim newVal As String = dgDisplay.Item(\"ActualColumn\", e.RowIndex).Value\n e.Value = newVal\nEnd Sub\n DataSource DataView DataGridView"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5133/"
] |
277,143
|
<p>What is the best way to find the total number of words in a text file in Java? I'm thinking Perl is the best on finding things such as this. If this is true then calling a Perl function from within Java would be the best? What would you have done in condition such as this? Any better ideas?</p>
|
[
{
"answer_id": 277158,
"author": "Paige Ruten",
"author_id": 813,
"author_profile": "https://Stackoverflow.com/users/813",
"pm_score": -1,
"selected": false,
"text": "word_count word_count"
},
{
"answer_id": 277161,
"author": "Steven A. Lowe",
"author_id": 9345,
"author_profile": "https://Stackoverflow.com/users/9345",
"pm_score": 0,
"selected": false,
"text": " this is some sample text\n this is some more sample text\n"
},
{
"answer_id": 277190,
"author": "Itay Maman",
"author_id": 27198,
"author_profile": "https://Stackoverflow.com/users/27198",
"pm_score": 4,
"selected": false,
"text": "int count = 0;\nScanner sc = new Scanner(new File(\"my-text-file.txt\")); \nwhile (sc.hasNext()) {\n ++count;\n sc.next();\n}\n"
},
{
"answer_id": 277424,
"author": "Elijah",
"author_id": 33611,
"author_profile": "https://Stackoverflow.com/users/33611",
"pm_score": 4,
"selected": true,
"text": "\\p{javaWhitespace}+"
},
{
"answer_id": 278473,
"author": "Leon Timmermans",
"author_id": 4727,
"author_profile": "https://Stackoverflow.com/users/4727",
"pm_score": 1,
"selected": false,
"text": "wc -w filename"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/33203/"
] |
277,149
|
<p>I have an ASP.NET MVC project and I have a single action that accepts GET, POST, and DELETE requests. Each type of request is filtered via attributes on my controllers <code>Action</code> methods.</p>
<pre><code>[ActionName(Constants.AdministrationGraphDashboardAction),
AcceptVerbs(HttpVerbs.Post)]
public ActionResult GraphAdd([ModelBinder(typeof (GraphDescriptorBinder))] GraphDescriptor details);
[ActionName(Constants.AdministrationGraphDashboardAction),
AcceptVerbs(HttpVerbs.Delete)]
public ActionResult GraphDelete([ModelBinder(typeof (RdfUriBinder))] RdfUri graphUri)
</code></pre>
<p>I have my <code>GraphAdd</code> method working very well. What I'm trying to figure out is how I can create an HTML <code><form /></code> or <code><a /></code> (link) that will cause the browser to perform an HTTP Delete request and trigger my GraphDelete method.</p>
<p>If there is a way to do this can someone post some sample HTML and if available the MVC HtmlHelper method I should be using?</p>
|
[
{
"answer_id": 277218,
"author": "Owen",
"author_id": 4853,
"author_profile": "https://Stackoverflow.com/users/4853",
"pm_score": 5,
"selected": true,
"text": "DELETE /resource.html HTTP/1.1\nHost: domain.com\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3957/"
] |
277,150
|
<p>How do I define an Extension Method for <code>IEnumerable<T></code> which returns <code>IEnumerable<T></code>?
The goal is to make the Extension Method available for all <code>IEnumerable</code> and <code>IEnumerable<T></code> where <code>T</code> can be an anonymous type.</p>
|
[
{
"answer_id": 277198,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 7,
"selected": true,
"text": "static IEnumerable<T> Where<T>(this IEnumerable<T> data, Func<T, bool> predicate)\n{\n foreach(T value in data)\n {\n if(predicate(value)) yield return value;\n }\n}\n yield return IEnumerator<T> T int[] data = {1,2,3,4,5};\nvar odd = data.Where(i=>i%2 != 0);\n T var odd = data.Where<int>(i=>i%2 != 0);\n IEnumerable .Cast<T>(...) .OfType<T>(...) IEnumerable<T> this IEnumerable T T IEnumerable T Cast<T> static void Main()\n{\n IEnumerable data = new[] { new { Foo = \"abc\" }, new { Foo = \"def\" }, new { Foo = \"ghi\" } };\n var typed = data.Cast(() => new { Foo = \"never used\" });\n foreach (var item in typed)\n {\n Console.WriteLine(item.Foo);\n }\n}\n\n// note that the template is not used, and we never need to pass one in...\npublic static IEnumerable<T> Cast<T>(this IEnumerable source, Func<T> template)\n{\n return Enumerable.Cast<T>(source);\n}\n"
},
{
"answer_id": 277203,
"author": "Howard Pinsley",
"author_id": 7961,
"author_profile": "https://Stackoverflow.com/users/7961",
"pm_score": 3,
"selected": false,
"text": "using System;\nusing System.Collections.Generic;\n\nnamespace ExtentionTest {\n class Program {\n static void Main(string[] args) {\n\n List<int> BigList = new List<int>() { 1,2,3,4,5,11,12,13,14,15};\n IEnumerable<int> Smalllist = BigList.MyMethod();\n foreach (int v in Smalllist) {\n Console.WriteLine(v);\n }\n }\n\n }\n\n static class EnumExtentions {\n public static IEnumerable<T> MyMethod<T>(this IEnumerable<T> Container) {\n int Count = 1;\n foreach (T Element in Container) {\n if ((Count++ % 2) == 0)\n yield return Element;\n }\n }\n }\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21586/"
] |
277,159
|
<p>I have a website with a mix of ASP (classic) and ASP.NET pages.</p>
<p>For some reason Visual Studio (specifically 2008 Pro) keeps trying to compile the ASP classic pages.</p>
<p><strong><em>How do I prevent it from trying to compile the .asp pages?</em></strong></p>
<p>Reason: I'm getting a ton of errors on a specific .asp file that includes a Class. I believe it's trying to compile it as a Visual Basic class instead of seeing it as a vBScript class. It should be skipping over .asp files anyway, correct?</p>
<p>Here is the error:</p>
<blockquote>
<p>Property Get/Let/Set are no longer
supported; use the new Property
declaration syntax.</p>
</blockquote>
|
[
{
"answer_id": 277331,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 0,
"selected": false,
"text": "<% @Page language=\"vbscript\" %>"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] |
277,178
|
<p>I would like to intercept any URL which the user enters in their browser and perform some tasks before allowing the navigation to continue (any way could be good - i.e. via plug in, via proxy or any other creative suggestion).
To clarify - I am not referring to a specific application that needs to catch this, but rather - any navigation that the user does on his browser needs to be caught (i.e. the user is not opening my application, it should be running in the background or something like that...)
Thanks in advance...</p>
|
[
{
"answer_id": 277182,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 0,
"selected": false,
"text": "onunload window.onunload = function() {\n alert(\"You're leaving this page.\");\n};\n"
},
{
"answer_id": 277216,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 0,
"selected": false,
"text": "window.location"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
277,181
|
<p>What do I need to do to avoid the "Manual Install" in Firefox for a Plugin and where do I have to go or what do I have to do to avoid the (Author not verified) message when downloading a Plugin. Ideally I would like to initiate the installation of the Plugin automatically and if I need to sign the Plugin somehow to show that it is not doing any kind of malicious things I would like to do that as well.</p>
<p>Thanks!</p>
|
[
{
"answer_id": 11640734,
"author": "XPIinstall",
"author_id": 1550085,
"author_profile": "https://Stackoverflow.com/users/1550085",
"pm_score": 1,
"selected": false,
"text": "<script type=\"application/javascript\">\n<!--\nfunction install (aEvent)\n{\n var params = {\n \"Foo\": { URL: aEvent.target.href,\n IconURL: aEvent.target.getAttribute(\"iconURL\"),\n Hash: aEvent.target.getAttribute(\"hash\"),\n toString: function () { return this.URL; }\n }\n };\n InstallTrigger.install(params);\n\n return false;\n}\n-->\n</script>\n\n<a href=\"http://www.example.com/foo.xpi\"\n iconURL=\"http://www.example.com/foo.png\"\n hash=\"sha1:28857e60d043447c5f4550853f2d40770b326a13\"\n onclick=\"return install(event);\">Install Extension!</a>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1890/"
] |
277,187
|
<p>I am using BeautifulSoup in Python to parse some HTML. One of the problems I am dealing with is that I have situations where the colspans are different across header rows. (Header rows are the rows that need to be combined to get the column headings in my jargon) That is one column may span a number of columns above or below it and the words need to be appended or prepended based on the spanning. Below is a routine to do this. I use BeautifulSoup to pull the colspans and to pull the contents of each cell in each row. longHeader is the contents of the header row with the most items, spanLong is a list with the colspans of each item in the row. This works but it is not looking very Pythonic. </p>
<p>Alos-it is not going to work if the diff is <0, I can fix that with the same approach I used to get this to work. But before I do I wonder if anyone can quickly look at this and suggest a more Pythonic approach. I am a long time SAS programmer and so I struggle to break the mold-well I will write code as if I am writing a SAS macro.</p>
<pre><code>longHeader=['','','bananas','','','','','','','','','','trains','','planes','','','','']
shortHeader=['','','bunches','','cars','','trucks','','freight','','cargo','','all other','','']
spanShort=[1,1,3,1,3,1,3,1,3,1,3,1,3,1,3]
spanLong=[1,1,3,1,1,1,1,1,1,1,1,1,3,1,3,1,3,1,3]
combinedHeader=[]
sumSpanLong=0
sumSpanShort=0
spanDiff=0
longHeaderCount=0
for each in range(len(shortHeader)):
sumSpanLong=sumSpanLong+spanLong[longHeaderCount]
sumSpanShort=sumSpanShort+spanShort[each]
spanDiff=sumSpanShort-sumSpanLong
if spanDiff==0:
combinedHeader.append([longHeader[longHeaderCount]+' '+shortHeader[each]])
longHeaderCount=longHeaderCount+1
continue
for i in range(0,spanDiff):
combinedHeader.append([longHeader[longHeaderCount]+' '+shortHeader[each]])
longHeaderCount=longHeaderCount+1
sumSpanLong=sumSpanLong+spanLong[longHeaderCount]
spanDiff=sumSpanShort-sumSpanLong
if spanDiff==0:
combinedHeader.append([longHeader[longHeaderCount]+' '+shortHeader[each]])
longHeaderCount=longHeaderCount+1
break
print combinedHeader
</code></pre>
|
[
{
"answer_id": 277280,
"author": "unmounted",
"author_id": 11596,
"author_profile": "https://Stackoverflow.com/users/11596",
"pm_score": 1,
"selected": false,
"text": ">>> execfile('so_ques.py')\n[[' '], [' '], ['bananas bunches'], [' '], [' cars'], [' cars'], [' cars'], [' '], [' trucks'], [' trucks'], [' trucks'], [' '], ['trains freight'], [' '], ['planes cargo'], [' '], [' all other'], [' '], [' ']]\n\n>>> zip(long_header, short_header)\n[('', ''), ('', ''), ('bananas', 'bunches'), ('', ''), ('', 'cars'), ('', ''), ('', 'trucks'), ('', ''), ('', 'freight'), ('', ''), ('', 'cargo'), ('', ''), ('trains', 'all other'), ('', ''), ('planes', '')]\n>>> \n enumerate >>> diff_list = []\n>>> for place, header in enumerate(short_header):\n diff_list.append(abs(span_short[place] - span_long[place]))\n\n>>> for place, num in enumerate(diff_list):\n if num:\n new_shortlist.extend(short_header[place] for item in range(num+1))\n else:\n new_shortlist.append(short_header[place])\n\n\n>>> new_shortlist\n['', '', 'bunches', '', 'cars', 'cars', 'cars', '', 'trucks', 'trucks', 'trucks', '',... \n>>> z = zip(new_shortlist, long_header)\n>>> z\n[('', ''), ('', ''), ('bunches', 'bananas'), ('', ''), ('cars', ''), ('cars', ''), ('cars', '')...\n for each in range(len(short_header)):\n sum_span_long += span_long[long_header_count]\n sum_span_short += span_short[each]\n span_diff = sum_span_short - sum_span_long\n if not span_diff:\n combined_header.append...\n"
},
{
"answer_id": 277390,
"author": "gimel",
"author_id": 6491,
"author_profile": "https://Stackoverflow.com/users/6491",
"pm_score": 2,
"selected": false,
"text": "class collector(object):\n def __init__(self, header):\n self.longHeader = header\n self.combinedHeader = []\n self.longHeaderCount = 0\n def combine(self, shortValue):\n self.combinedHeader.append(\n [self.longHeader[self.longHeaderCount]+' '+shortValue] )\n self.longHeaderCount += 1\n return self.longHeaderCount\n\ndef main():\n longHeader = [ \n '','','bananas','','','','','','','','','','trains','','planes','','','','']\n shortHeader = [\n '','','bunches','','cars','','trucks','','freight','','cargo','','all other','','']\n spanShort=[1,1,3,1,3,1,3,1,3,1,3,1,3,1,3]\n spanLong=[1,1,3,1,1,1,1,1,1,1,1,1,3,1,3,1,3,1,3]\n sumSpanLong=0\n sumSpanShort=0\n\n combiner = collector(longHeader)\n for sLen,sHead in zip(spanShort,shortHeader):\n sumSpanLong += spanLong[combiner.longHeaderCount]\n sumSpanShort += sLen\n while sumSpanShort - sumSpanLong > 0:\n combiner.combine(sHead)\n sumSpanLong += spanLong[combiner.longHeaderCount]\n combiner.combine(sHead)\n\n return combiner.combinedHeader\n"
},
{
"answer_id": 277837,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 3,
"selected": true,
"text": "def merge3( row1, row2 ):\n i1= 0\n i2= 0\n result= []\n while i1 != len(row1) or i2 != len(row2):\n if i1 == len(row1):\n result.append( ' '.join(row1[i1].contents) )\n i2 += 1\n elif i2 == len(row2):\n result.append( ' '.join(row2[i2].contents) )\n i1 += 1\n else:\n if row1[i1]['colspan'] < row2[i2]['colspan']:\n # Fill extra cols from row1\n c1= row1[i1]['colspan']\n while c1 != row2[i2]['colspan']:\n result.append( ' '.join(row2[i2].contents) )\n c1 += 1\n elif row1[i1]['colspan'] > row2[i2]['colspan']:\n # Fill extra cols from row2\n c2= row2[i2]['colspan']\n while row1[i1]['colspan'] != c2:\n result.append( ' '.join(row1[i1].contents) )\n c2 += 1\n else:\n assert row1[i1]['colspan'] == row2[i2]['colspan']\n pass\n txt1= ' '.join(row1[i1].contents)\n txt2= ' '.join(row2[i2].contents)\n result.append( txt1 + \" \" + txt2 )\n i1 += 1\n i2 += 1\n return result\n"
},
{
"answer_id": 280181,
"author": "PyNEwbie",
"author_id": 30105,
"author_profile": "https://Stackoverflow.com/users/30105",
"pm_score": 0,
"selected": false,
"text": "row1=headerCells[0]\nrow2=headerCells[1]\n\ni1= 0\ni2= 0\nresult= []\nwhile i1 != len(row1) or i2 != len(row2):\n if i1 == len(row1):\n result.append( ' '.join(row1[i1]) )\n i2 += 1\n elif i2 == len(row2):\n result.append( ' '.join(row2[i2]) )\n i1 += 1\n else:\n if int(row1[i1].get(\"colspan\",\"1\")) < int(row2[i2].get(\"colspan\",\"1\")):\n c1= int(row1[i1].get(\"colspan\",\"1\"))\n while c1 != int(row2[i2].get(\"colspan\",\"1\")): \n txt1= ' '.join(row1[i1]) # needed to add when working adjust opposing case\n txt2= ' '.join(row2[i2]) # needed to add when working adjust opposing case\n result.append( txt1 + \" \" + txt2 ) # needed to add when working adjust opposing case\n print 'stayed in middle', 'i1=',i1,'i2=',i2, ' c1=',c1\n c1 += 1\n i1 += 1 # Is this the problem it\n \n elif int(row1[i1].get(\"colspan\",\"1\"))> int(row2[i2].get(\"colspan\",\"1\")):\n # Fill extra cols from row2 Make same adjustment as above\n c2= int(row2[i2].get(\"colspan\",\"1\"))\n while int(row1[i1].get(\"colspan\",\"1\")) != c2:\n result.append( ' '.join(row1[i1]) )\n c2 += 1\n i2 += 1\n else:\n assert int(row1[i1].get(\"colspan\",\"1\")) == int(row2[i2].get(\"colspan\",\"1\"))\n pass\n \n \n txt1= ' '.join(row1[i1])\n txt2= ' '.join(row2[i2])\n result.append( txt1 + \" \" + txt2 )\n print 'went to bottom', 'i1=',i1,'i2=',i2\n i1 += 1\n i2 += 1\nprint result\n"
},
{
"answer_id": 283026,
"author": "PyNEwbie",
"author_id": 30105,
"author_profile": "https://Stackoverflow.com/users/30105",
"pm_score": 0,
"selected": false,
"text": "from BeautifulSoup import BeautifulSoup\n\noriginal=file(r\"C:\\testheaders.htm\").read()\n\nsoupOriginal=BeautifulSoup(original)\nall_Rows=soupOriginal.findAll('tr')\n\n\nheader_Rows=[]\nfor each in range(len(all_Rows)):\n header_Rows.append(all_Rows[each])\n\n\nheader_Cells=[]\nfor each in header_Rows:\n header_Cells.append(each.findAll('td'))\n\ntemp_Header_Row=[]\nheader=[]\nfor row in range(len(header_Cells)):\n for column in range(len(header_Cells[row])):\n x=int(header_Cells[row][column].get(\"colspan\",\"1\"))\n if x==1:\n temp_Header_Row.append( ' '.join(header_Cells[row][column]) )\n\n else:\n for item in range(x):\n\n temp_Header_Row.append( ''.join(header_Cells[row][column]) )\n\n header.append(temp_Header_Row)\ntemp_Header_Row=[]\ncombined_Header=zip(*header)\n\nfor each in combined_Header:\n print each\n <TABLE style=\"font-size: 10pt\" cellspacing=\"0\" border=\"0\" cellpadding=\"0\" width=\"100%\">\n <TR valign=\"bottom\">\n <TD width=\"40%\"> </TD>\n <TD width=\"5%\"> </TD>\n <TD width=\"3%\"> </TD>\n <TD width=\"3%\"> </TD>\n <TD width=\"1%\"> </TD>\n\n <TD width=\"5%\"> </TD>\n <TD width=\"3%\"> </TD>\n <TD width=\"3%\"> </TD>\n <TD width=\"1%\"> </TD>\n\n <TD width=\"5%\"> </TD>\n <TD width=\"3%\"> </TD>\n <TD width=\"1%\"> </TD>\n <TD width=\"1%\"> </TD>\n\n <TD width=\"5%\"> </TD>\n <TD width=\"3%\"> </TD>\n <TD width=\"1%\"> </TD>\n <TD width=\"1%\"> </TD>\n\n <TD width=\"5%\"> </TD>\n <TD width=\"3%\"> </TD>\n <TD width=\"3%\"> </TD>\n <TD width=\"1%\"> </TD>\n </TR>\n <TR style=\"font-size: 10pt\" valign=\"bottom\">\n <TD> </TD>\n <TD> </TD>\n <TD> </TD>\n <TD> </TD>\n <TD> </TD>\n <TD> </TD>\n <TD> </TD>\n <TD> </TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">FOODS WE LIKE</TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\"> </TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\"> </TD>\n <TD> </TD>\n </TR>\n <TR style=\"font-size: 10pt\" valign=\"bottom\">\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"CENTER\" colspan=\"6\">SILLY STUFF</TD>\n\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">OTHER THAN</TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"CENTER\" colspan=\"6\">FAVORITE PEOPLE</TD>\n <TD> </TD>\n </TR>\n <TR style=\"font-size: 10pt\" valign=\"bottom\">\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">MONTY PYTHON</TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">CHERRYPY</TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">APPLE PIE</TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">MOTHERS</TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">FATHERS</TD>\n <TD> </TD>\n </TR>\n <TR style=\"font-size: 10pt\" valign=\"bottom\">\n <TD nowrap align=\"left\">Name</TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">SHOWS</TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">PROGRAMS</TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">BANANAS</TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">PERFUME</TD>\n <TD> </TD>\n <TD> </TD>\n <TD nowrap align=\"right\" colspan=\"2\">TOOLS</TD>\n <TD> </TD>\n </TR>\n </TABLE>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30105/"
] |
277,195
|
<p>Given a bitmap image with some blots of solid color on it, what algorithm would you employ to construct polygons in the same shape as the blots?</p>
<p>This can be done in multiple steps: a high-resolution polygon could be later cut down by a best fit algorithm. Bonus points if you can tell me how to cut the resulting polygons into convex components so that they can be rendered in OpenGL without problems.</p>
|
[
{
"answer_id": 67205568,
"author": "nmz787",
"author_id": 253127,
"author_profile": "https://Stackoverflow.com/users/253127",
"pm_score": 0,
"selected": false,
"text": "findContours"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2653/"
] |
277,197
|
<p>The site I'm working on is using a Databound asp:Menu control. When sending 1 menu item it renders HTML that is absolutely correct in Firefox (and IE), but really messed up code in Safari and Chrome. Below is the code that was sent to each browser. I've tested it a few browsers, and they are all pretty similarly rendered, so I am only posting the two variations on the rendering source. </p>
<p><strong>My question is: How do I get ASP.NET to send the same html and javascript to Chrome and Safari as it does to Firefox and IE?</strong></p>
<pre><code><!-- This is how the menu control is defined -->
<asp:Menu ID="menu" runat="server" BackColor="#cccccc"
DynamicHorizontalOffset="2" Font-Names="Verdana" StaticSubMenuIndent="10px" StaticDisplayLevels="1"
CssClass="left_menuTxt1" Font-Bold="true" ForeColor="#0066CC">
<DataBindings>
<asp:MenuItemBinding DataMember="MenuItem" NavigateUrlField="NavigateUrl" TextField="Text"
ToolTipField="ToolTip" />
</DataBindings>
<StaticSelectedStyle BackColor="#0066CC" HorizontalPadding="5px" VerticalPadding="2px"
Font-Names="Verdama" CssClass="left_menuTxt1" Font-Bold="true" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="8px" />
<DynamicMenuStyle BackColor="#fbfbfb" BorderColor="#989595" BorderStyle="Inset" BorderWidth="1"
Width="80px" VerticalPadding="1" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" Font-Name="Verdama"
ForeColor="#c6c4c4" CssClass="left_menuTxt1" Font-Bold="true" />
<DynamicSelectedStyle BackColor="#cccccc" HorizontalPadding="5px" VerticalPadding="2px"
Font-Names="Verdama" CssClass="left_menuTxt1" Font-Bold="true" />
</asp:Menu>
<!-- From Safari View Page Source (Chrome source very similar) -->
<span title="Order" class="ctl00_leftNav_menu_4">
<a class="ctl00_leftNav_menu_1 ctl00_leftNav_menu_3"
href="javascript:__doPostBack('ctl00$leftNav$menu','oMy Order')">
My Order
<img src="/WWW/WebResource.axd?d=glUTEfEv7p9OrdeaMxkMzhqz2JugrMr8aE43O2XGHAA1&amp;t=633590571537099818"
alt="Expand My Order"
align="absmiddle"
style="border-width:0px;" /></a></span><br />
<!-- From Firefox View Page Source (IE View page similar) -->
<table>
<tr onmouseover="Menu_HoverStatic(this)"
onmouseout="Menu_Unhover(this)"
onkeyup="Menu_Key(event)"
title="Order"
id="ctl00_leftNav_menun0">
<td>
<table class="ctl00_leftNav_menu_4" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td style="white-space:nowrap;width:100%;">
<a class="ctl00_leftNav_menu_1 ctl00_leftNav_menu_3"
href="../Order/OrderList.aspx">
My Order
</a>
</td>
<td style="width:0;">
<img src="/WWW/WebResource.axd?d=glUTEfEv7p9OrdeaMxkMzhqz2JugrMr8aE43O2XGHAA1&amp;t=633590571537099818"
alt="Expand My Order" style="border-style:none;vertical-align:middle;" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</code></pre>
<p>Update: My solution post is correct.. but i can't mark my own as correct... so if anyone wants to copy it so I can close this. :)</p>
|
[
{
"answer_id": 277231,
"author": "stephenbayer",
"author_id": 18893,
"author_profile": "https://Stackoverflow.com/users/18893",
"pm_score": 5,
"selected": true,
"text": " if (Request.UserAgent.IndexOf(\"AppleWebKit\") > 0)\n {\n\n Request.Browser.Adapters.Clear();\n\n }\n"
},
{
"answer_id": 277977,
"author": "Keltex",
"author_id": 28260,
"author_profile": "https://Stackoverflow.com/users/28260",
"pm_score": 3,
"selected": false,
"text": "<ul class=\"AspNet-Menu\">\n <li class=\"Leaf Selected\">\n <a href=\"Orders.aspx\" class=\"Link Selected\">Orders</a></li>\n <li class=\"ALeaf\">\n <a href=\"MyOrders.aspx\" class=\"Link\">My Orders</a></li>\n</ul>\n"
},
{
"answer_id": 425989,
"author": "Seth Reno",
"author_id": 50225,
"author_profile": "https://Stackoverflow.com/users/50225",
"pm_score": 3,
"selected": false,
"text": "<browsers>\n <browser refID=\"Safari1Plus\">\n <controlAdapters>\n <adapter controlType=\"System.Web.UI.WebControls.Menu\"\n adapterType=\"\" />\n </controlAdapters>\n </browser>\n</browsers>\n"
},
{
"answer_id": 894559,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "ClientTarget=\"uplevel\" <%@ Page ClientTarget=\"uplevel\" ... %>\n"
},
{
"answer_id": 3025301,
"author": "jball",
"author_id": 223391,
"author_profile": "https://Stackoverflow.com/users/223391",
"pm_score": 2,
"selected": false,
"text": "using System;\nusing System.Web.UI;\n\n/// <summary>\n/// Summary description for ExampleMasterPage\n/// </summary>\npublic class ExampleMasterPage : MasterPage\n{ \n public ExampleMasterPage() { }\n\n protected override void AddedControl(Control control, int index)\n {\n if (Request.ServerVariables[\"http_user_agent\"]\n .IndexOf(\"Safari\", StringComparison.CurrentCultureIgnoreCase) != -1)\n {\n this.Page.ClientTarget = \"uplevel\";\n }\n base.AddedControl(control, index);\n }\n}\n"
},
{
"answer_id": 3142083,
"author": "romac",
"author_id": 379150,
"author_profile": "https://Stackoverflow.com/users/379150",
"pm_score": 0,
"selected": false,
"text": "Protected Overrides Sub AddedControl(ByVal control As Control, ByVal index As Integer)\n If Request.ServerVariables(\"http_user_agent\").IndexOf(\"fake_user_agent\", StringComparison.CurrentCultureIgnoreCase) <> -1 Then\n Me.Page.ClientTarget = \"uplevel\"\n End If\n MyBase.AddedControl(control, index)\n End Sub\n"
},
{
"answer_id": 4900577,
"author": "user603480",
"author_id": 603480,
"author_profile": "https://Stackoverflow.com/users/603480",
"pm_score": 3,
"selected": false,
"text": "<browsers> <browser id=\"Chrome\" parentID=\"Safari1Plus\"> <controlAdapters> <adapter controlType=\"System.Web.UI.WebControls.Menu\" adapterType=\"\" /> </controlAdapters> </browser>"
},
{
"answer_id": 5912507,
"author": "albert",
"author_id": 741896,
"author_profile": "https://Stackoverflow.com/users/741896",
"pm_score": 0,
"selected": false,
"text": "display: none;"
},
{
"answer_id": 7512117,
"author": "colin",
"author_id": 958680,
"author_profile": "https://Stackoverflow.com/users/958680",
"pm_score": 2,
"selected": false,
"text": " If Request.ServerVariables(\"http_user_agent\").IndexOf(\"Safari\", StringComparison.CurrentCultureIgnoreCase) <> -1 Or Request.UserAgent.Contains(\"AppleWebKit\") Then\n Request.Browser.Adapters.Clear()\n Page.ClientTarget = \"uplevel\"\n End If\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18893/"
] |
277,207
|
<p>I am a bit confused why this code compiles. I leave out the "necessary" <code>#include <OpenGL/gl.h></code> and still the program can compile. How is this possible when my program is calling functions from the GL library, without including them.</p>
<pre><code>int main(int argc, char** argv)
{
glClearColor(1.0,1.0,1.0,1.0);
return 0;
}
</code></pre>
<p>I use this compilation command:</p>
<pre><code> gcc -framework GLUT -framework OpenGL test.c
</code></pre>
<p>I was under the assumption that adding -framework just specifies to the linker where the library is, but I thought I still need the headers?</p>
|
[
{
"answer_id": 277233,
"author": "Jason Coco",
"author_id": 34218,
"author_profile": "https://Stackoverflow.com/users/34218",
"pm_score": 3,
"selected": false,
"text": "gcc -o test -Wall -W test.c -framework GLUT -framework OpenGL\n"
},
{
"answer_id": 277239,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 3,
"selected": true,
"text": "int /* file1.c */\nvoid foo(char a, char b) {\n /* doing something ... */\n}\n\n/* main.c */\nint main(void) {\n char a = 'a', b = 'b';\n /* char variables are promoted to int \n before being passed */\n foo(b, a); \n}\n char -> int, float -> double vararg functions prinft void f() va_arg char literals 'a' int"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28486/"
] |
277,208
|
<p>I've decided that I want to use Mercurial for a small, personal project. </p>
<p>Most of the help I've read about it talks about merging changes between multiple users. Since I'm solo, that's not going to happen.</p>
<p>Should I have multiple repositories? My development computer is already backed up nightly to my Windows Home Server, so it doesn't seem valuable to have a second repository elsewhere just for backup purposes.</p>
<p>Should I be branching every day? Or just around releases? Or when?</p>
<p>In general, what practices do you recommend for the lone developer using Mercurial?</p>
|
[
{
"answer_id": 580828,
"author": "Tim Post",
"author_id": 50049,
"author_profile": "https://Stackoverflow.com/users/50049",
"pm_score": 3,
"selected": false,
"text": "(See where I left off)\n# hg status \n\n(See what I was doing with foo)\n# hg diff -r tip src/foo/foo.c\n\n(Finish one module, commit it)\n# hg commit src/foo/foo.c\n\n(Push changes)\n# hg push\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5314/"
] |
277,224
|
<p>I can use <code>set_error_handler()</code> to catch most PHP errors, but it doesn't work for fatal (<code>E_ERROR</code>) errors, such as calling a function that doesn't exist. Is there another way to catch these errors?</p>
<p>I am trying to call <code>mail()</code> for all errors and am running PHP 5.2.3.</p>
|
[
{
"answer_id": 2146171,
"author": "user259973",
"author_id": 259973,
"author_profile": "https://Stackoverflow.com/users/259973",
"pm_score": 9,
"selected": false,
"text": "register_shutdown_function register_shutdown_function( \"fatal_handler\" );\n\nfunction fatal_handler() {\n $errfile = \"unknown file\";\n $errstr = \"shutdown\";\n $errno = E_CORE_ERROR;\n $errline = 0;\n\n $error = error_get_last();\n\n if($error !== NULL) {\n $errno = $error[\"type\"];\n $errfile = $error[\"file\"];\n $errline = $error[\"line\"];\n $errstr = $error[\"message\"];\n\n error_mail(format_error( $errno, $errstr, $errfile, $errline));\n }\n}\n error_mail format_error function format_error( $errno, $errstr, $errfile, $errline ) {\n $trace = print_r( debug_backtrace( false ), true );\n\n $content = \"\n <table>\n <thead><th>Item</th><th>Description</th></thead>\n <tbody>\n <tr>\n <th>Error</th>\n <td><pre>$errstr</pre></td>\n </tr>\n <tr>\n <th>Errno</th>\n <td><pre>$errno</pre></td>\n </tr>\n <tr>\n <th>File</th>\n <td>$errfile</td>\n </tr>\n <tr>\n <th>Line</th>\n <td>$errline</td>\n </tr>\n <tr>\n <th>Trace</th>\n <td><pre>$trace</pre></td>\n </tr>\n </tbody>\n </table>\";\n return $content;\n}\n error_mail"
},
{
"answer_id": 3389021,
"author": "periklis",
"author_id": 408773,
"author_profile": "https://Stackoverflow.com/users/408773",
"pm_score": 7,
"selected": false,
"text": "function shutDownFunction() {\n $error = error_get_last();\n // Fatal error, E_ERROR === 1\n if ($error['type'] === E_ERROR) {\n // Do your stuff\n }\n}\nregister_shutdown_function('shutDownFunction');\n"
},
{
"answer_id": 3795403,
"author": "hipertracker",
"author_id": 247200,
"author_profile": "https://Stackoverflow.com/users/247200",
"pm_score": 4,
"selected": false,
"text": "<?php\n function shutdown() {\n if (($error = error_get_last())) {\n ob_clean();\n throw new Exception(\"fatal error\");\n }\n }\n\n try {\n $x = null;\n $x->method()\n } catch(Exception $e) {\n # This won't work\n }\n?>\n <?php\n function shutdown() {\n if (($error = error_get_last())) {\n ob_clean();\n # Report the event, send email, etc.\n header(\"Location: http://localhost/error-capture\");\n # From /error-capture. You can use another\n # redirect, to e.g. the home page\n }\n }\n register_shutdown_function('shutdown');\n\n $x = null;\n $x->method()\n?>\n"
},
{
"answer_id": 5192011,
"author": "sakhunzai",
"author_id": 416100,
"author_profile": "https://Stackoverflow.com/users/416100",
"pm_score": 5,
"selected": false,
"text": "ob_start('fatal_error_handler');\n\nfunction fatal_error_handler($buffer){\n $error = error_get_last();\n if($error['type'] == 1){\n // Type, message, file, line\n $newBuffer='<html><header><title>Fatal Error </title></header>\n <style>\n .error_content{\n background: ghostwhite;\n vertical-align: middle;\n margin:0 auto;\n padding: 10px;\n width: 50%;\n }\n .error_content label{color: red;font-family: Georgia;font-size: 16pt;font-style: italic;}\n .error_content ul li{ background: none repeat scroll 0 0 FloralWhite;\n border: 1px solid AliceBlue;\n display: block;\n font-family: monospace;\n padding: 2%;\n text-align: left;\n }\n </style>\n <body style=\"text-align: center;\">\n <div class=\"error_content\">\n <label >Fatal Error </label>\n <ul>\n <li><b>Line</b> ' . $error['line'] . '</li>\n <li><b>Message</b> ' . $error['message'] . '</li>\n <li><b>File</b> ' . $error['file'] . '</li>\n </ul>\n\n <a href=\"javascript:history.back()\"> Back </a>\n </div>\n </body></html>';\n\n return $newBuffer;\n }\n return $buffer;\n}\n"
},
{
"answer_id": 7827720,
"author": "Prof",
"author_id": 629157,
"author_profile": "https://Stackoverflow.com/users/629157",
"pm_score": 3,
"selected": false,
"text": "function fatal_error_handler() {\n\n if (@is_array($e = @error_get_last())) {\n $code = isset($e['type']) ? $e['type'] : 0;\n $msg = isset($e['message']) ? $e['message'] : '';\n $file = isset($e['file']) ? $e['file'] : '';\n $line = isset($e['line']) ? $e['line'] : '';\n if ($code>0)\n error_handler($code, $msg, $file, $line);\n }\n}\nset_error_handler(\"error_handler\");\nregister_shutdown_function('fatal_error_handler');\n @ob_end_clean(); @"
},
{
"answer_id": 8057591,
"author": "Kendall Hopkins",
"author_id": 188044,
"author_profile": "https://Stackoverflow.com/users/188044",
"pm_score": 2,
"selected": false,
"text": "register_shutdown_function function superTryCatchFinallyAndExit( Closure $try, Closure $catch = NULL, Closure $finally )\n{\n $finished = FALSE;\n register_shutdown_function( function() use ( &$finished, $catch, $finally ) {\n if( ! $finished ) {\n $finished = TRUE;\n print \"EXPLODE!\".PHP_EOL;\n if( $catch ) {\n superTryCatchFinallyAndExit( function() use ( $catch ) {\n $catch( new Exception( \"Fatal Error!!!\" ) );\n }, NULL, $finally ); \n } else {\n $finally(); \n }\n }\n } );\n try {\n $try();\n } catch( Exception $e ) {\n if( $catch ) {\n try {\n $catch( $e );\n } catch( Exception $e ) {}\n }\n }\n $finished = TRUE;\n $finally();\n exit();\n}\n"
},
{
"answer_id": 10545621,
"author": "Lucas Batistussi",
"author_id": 1238654,
"author_profile": "https://Stackoverflow.com/users/1238654",
"pm_score": 5,
"selected": false,
"text": "<?php\n define('E_FATAL', E_ERROR | E_USER_ERROR | E_PARSE | E_CORE_ERROR |\n E_COMPILE_ERROR | E_RECOVERABLE_ERROR);\n\n define('ENV', 'dev');\n\n // Custom error handling vars\n define('DISPLAY_ERRORS', TRUE);\n define('ERROR_REPORTING', E_ALL | E_STRICT);\n define('LOG_ERRORS', TRUE);\n\n register_shutdown_function('shut');\n\n set_error_handler('handler');\n\n // Function to catch no user error handler function errors...\n function shut(){\n\n $error = error_get_last();\n\n if($error && ($error['type'] & E_FATAL)){\n handler($error['type'], $error['message'], $error['file'], $error['line']);\n }\n\n }\n\n function handler( $errno, $errstr, $errfile, $errline ) {\n\n switch ($errno){\n\n case E_ERROR: // 1 //\n $typestr = 'E_ERROR'; break;\n case E_WARNING: // 2 //\n $typestr = 'E_WARNING'; break;\n case E_PARSE: // 4 //\n $typestr = 'E_PARSE'; break;\n case E_NOTICE: // 8 //\n $typestr = 'E_NOTICE'; break;\n case E_CORE_ERROR: // 16 //\n $typestr = 'E_CORE_ERROR'; break;\n case E_CORE_WARNING: // 32 //\n $typestr = 'E_CORE_WARNING'; break;\n case E_COMPILE_ERROR: // 64 //\n $typestr = 'E_COMPILE_ERROR'; break;\n case E_CORE_WARNING: // 128 //\n $typestr = 'E_COMPILE_WARNING'; break;\n case E_USER_ERROR: // 256 //\n $typestr = 'E_USER_ERROR'; break;\n case E_USER_WARNING: // 512 //\n $typestr = 'E_USER_WARNING'; break;\n case E_USER_NOTICE: // 1024 //\n $typestr = 'E_USER_NOTICE'; break;\n case E_STRICT: // 2048 //\n $typestr = 'E_STRICT'; break;\n case E_RECOVERABLE_ERROR: // 4096 //\n $typestr = 'E_RECOVERABLE_ERROR'; break;\n case E_DEPRECATED: // 8192 //\n $typestr = 'E_DEPRECATED'; break;\n case E_USER_DEPRECATED: // 16384 //\n $typestr = 'E_USER_DEPRECATED'; break;\n }\n\n $message =\n '<b>' . $typestr .\n ': </b>' . $errstr .\n ' in <b>' . $errfile .\n '</b> on line <b>' . $errline .\n '</b><br/>';\n\n if(($errno & E_FATAL) && ENV === 'production'){\n\n header('Location: 500.html');\n header('Status: 500 Internal Server Error');\n\n }\n\n if(!($errno & ERROR_REPORTING))\n return;\n\n if(DISPLAY_ERRORS)\n printf('%s', $message);\n\n //Logging error on php file error log...\n if(LOG_ERRORS)\n error_log(strip_tags($message), 0);\n }\n\n ob_start();\n\n @include 'content.php';\n\n ob_end_flush();\n?>\n"
},
{
"answer_id": 11633893,
"author": "Cyril Tata",
"author_id": 1549152,
"author_profile": "https://Stackoverflow.com/users/1549152",
"pm_score": 4,
"selected": false,
"text": "<?php\n // Define an error handler\n function exception_error_handler($errno, $errstr, $errfile, $errline ) {\n throw new ErrorException($errstr, $errno, 0, $errfile, $errline);\n }\n\n // Set your error handler\n set_error_handler(\"exception_error_handler\");\n\n /* Trigger exception */\n try\n {\n // Try to do something like finding the end of the internet\n }\n catch(ErrorException $e)\n {\n // Anything you want to do with $e\n }\n?>\n"
},
{
"answer_id": 13986716,
"author": "tix3",
"author_id": 900617,
"author_profile": "https://Stackoverflow.com/users/900617",
"pm_score": 2,
"selected": false,
"text": "class PHPFatalError {\n\n public function setHandler() {\n register_shutdown_function('handleShutdown');\n }\n}\n\nfunction handleShutdown() {\n if (($error = error_get_last())) {\n ob_start();\n echo \"<pre>\";\n var_dump($error);\n echo \"</pre>\";\n $message = ob_get_clean();\n sendEmail($message);\n ob_start();\n echo '{\"status\":\"error\",\"message\":\"Internal application error!\"}';\n ob_flush();\n exit();\n }\n}\n"
},
{
"answer_id": 17343858,
"author": "Sander Visser",
"author_id": 2032020,
"author_profile": "https://Stackoverflow.com/users/2032020",
"pm_score": 3,
"selected": false,
"text": "<?php\n register_shutdown_function('__fatalHandler');\n\n function __fatalHandler()\n {\n $error = error_get_last();\n\n // Check if it's a core/fatal error. Otherwise, it's a normal shutdown\n if($error !== NULL && $error['type'] === E_ERROR) {\n\n // It is a bit hackish, but the set_exception_handler\n // will return the old handler\n function fakeHandler() { }\n\n $handler = set_exception_handler('fakeHandler');\n restore_exception_handler();\n if($handler !== null) {\n call_user_func(\n $handler,\n new ErrorException(\n $error['message'],\n $error['type'],\n 0,\n $error['file'],\n $error['line']));\n }\n exit;\n }\n }\n?>\n <?php\n ini_set('display_errors', false);\n?>\n"
},
{
"answer_id": 26487785,
"author": "algorhythm",
"author_id": 655224,
"author_profile": "https://Stackoverflow.com/users/655224",
"pm_score": 3,
"selected": false,
"text": "/**\n * ErrorHandler that can be used to catch internal PHP errors\n * and convert to an ErrorException instance.\n */\nabstract class ErrorHandler\n{\n /**\n * Active stack\n *\n * @var array\n */\n protected static $stack = array();\n\n /**\n * Check if this error handler is active\n *\n * @return bool\n */\n public static function started()\n {\n return (bool) static::getNestedLevel();\n }\n\n /**\n * Get the current nested level\n *\n * @return int\n */\n public static function getNestedLevel()\n {\n return count(static::$stack);\n }\n\n /**\n * Starting the error handler\n *\n * @param int $errorLevel\n */\n public static function start($errorLevel = \\E_WARNING)\n {\n if (!static::$stack) {\n set_error_handler(array(get_called_class(), 'addError'), $errorLevel);\n }\n\n static::$stack[] = null;\n }\n\n /**\n * Stopping the error handler\n *\n * @param bool $throw Throw the ErrorException if any\n * @return null|ErrorException\n * @throws ErrorException If an error has been catched and $throw is true\n */\n public static function stop($throw = false)\n {\n $errorException = null;\n\n if (static::$stack) {\n $errorException = array_pop(static::$stack);\n\n if (!static::$stack) {\n restore_error_handler();\n }\n\n if ($errorException && $throw) {\n throw $errorException;\n }\n }\n\n return $errorException;\n }\n\n /**\n * Stop all active handler\n *\n * @return void\n */\n public static function clean()\n {\n if (static::$stack) {\n restore_error_handler();\n }\n\n static::$stack = array();\n }\n\n /**\n * Add an error to the stack\n *\n * @param int $errno\n * @param string $errstr\n * @param string $errfile\n * @param int $errline\n * @return void\n */\n public static function addError($errno, $errstr = '', $errfile = '', $errline = 0)\n {\n $stack = & static::$stack[count(static::$stack) - 1];\n $stack = new ErrorException($errstr, 0, $errno, $errfile, $errline, $stack);\n }\n}\n ErrorHandler ErrorHandler::start(E_WARNING);\n$return = call_function_raises_E_WARNING();\n\nif ($innerException = ErrorHandler::stop()) {\n throw new Exception('Special Exception Text', 0, $innerException);\n}\n\n// or\nErrorHandler::stop(true); // directly throws an Exception;\n register_shutdown_function array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR) class ErrorHandler\n{\n // [...]\n\n public function registerExceptionHandler($level = null, $callPrevious = true)\n {\n $prev = set_exception_handler(array($this, 'handleException'));\n $this->uncaughtExceptionLevel = $level;\n if ($callPrevious && $prev) {\n $this->previousExceptionHandler = $prev;\n }\n }\n\n public function registerErrorHandler(array $levelMap = array(), $callPrevious = true, $errorTypes = -1)\n {\n $prev = set_error_handler(array($this, 'handleError'), $errorTypes);\n $this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap);\n if ($callPrevious) {\n $this->previousErrorHandler = $prev ?: true;\n }\n }\n\n public function registerFatalHandler($level = null, $reservedMemorySize = 20)\n {\n register_shutdown_function(array($this, 'handleFatalError'));\n\n $this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize);\n $this->fatalLevel = $level;\n }\n\n // [...]\n}\n"
},
{
"answer_id": 26828734,
"author": "Mahn",
"author_id": 1329367,
"author_profile": "https://Stackoverflow.com/users/1329367",
"pm_score": 3,
"selected": false,
"text": "function errorHandler($errno, $errstr, $errfile = '', $errline = 0, $errcontext = array()) {\n //Do stuff: mail, log, etc\n}\n\nfunction fatalHandler() {\n $error = error_get_last();\n if($error) errorHandler($error[\"type\"], $error[\"message\"], $error[\"file\"], $error[\"line\"]);\n}\n\nset_error_handler(\"errorHandler\")\nregister_shutdown_function(\"fatalHandler\");\n"
},
{
"answer_id": 36638910,
"author": "zainengineer",
"author_id": 3232611,
"author_profile": "https://Stackoverflow.com/users/3232611",
"pm_score": 5,
"selected": false,
"text": "function __fatalHandler()\n{\n $error = error_get_last();\n\n // Check if it's a core/fatal error, otherwise it's a normal shutdown\n if ($error !== NULL && in_array($error['type'],\n array(E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING,\n E_COMPILE_ERROR, E_COMPILE_WARNING,E_RECOVERABLE_ERROR))) {\n\n echo \"<pre>fatal error:\\n\";\n print_r($error);\n echo \"</pre>\";\n die;\n }\n}\n\nregister_shutdown_function('__fatalHandler');\n"
},
{
"answer_id": 48381661,
"author": "LugiHaue",
"author_id": 3271096,
"author_profile": "https://Stackoverflow.com/users/3271096",
"pm_score": 6,
"selected": false,
"text": "Error Error try/catch <?php\n$variable = 'not an object';\n\ntry {\n $variable->method(); // Throws an Error object in PHP 7 or higger.\n} catch (Error $e) {\n // Handle error\n echo $e->getMessage(); // Call to a member function method() on string\n}\n Throwable <?php\n try {\n undefinedFunctionCall();\n } catch (Throwable $e) {\n // Handle error\n echo $e->getMessage(); // Call to undefined function undefinedFunctionCall()\n }\n"
},
{
"answer_id": 68138459,
"author": "David Spector",
"author_id": 2184308,
"author_profile": "https://Stackoverflow.com/users/2184308",
"pm_score": 0,
"selected": false,
"text": "set_error_handler(\"ErrorCB\");\nset_exception_handler(\"ExceptCB\");\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28835/"
] |
277,226
|
<p>I want to check whether the user is viewing my site from a mobile device or PC. If it's a mobile device, I want to redirect my site URL like Google does...</p>
<p>If possible I would like to implement this in JavaScript. How can I do this?</p>
|
[
{
"answer_id": 277541,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "mobile.html winWidth=document.all?document.body.clientwidth:window.innderwidth;\nif (winwidth<800)\n{\n window.location.replace(\"mobile.html\");\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
277,247
|
<p>How do I add a certain number of days to the current date in PHP?</p>
<p>I already got the current date with:</p>
<pre><code>$today = date('y:m:d');
</code></pre>
<p>Just need to add x number of days to it</p>
|
[
{
"answer_id": 277251,
"author": "nickf",
"author_id": 9021,
"author_profile": "https://Stackoverflow.com/users/9021",
"pm_score": 5,
"selected": false,
"text": "$tomorrow = date('y:m:d', time() + 86400);\n"
},
{
"answer_id": 277252,
"author": "eplawless",
"author_id": 1370,
"author_profile": "https://Stackoverflow.com/users/1370",
"pm_score": 3,
"selected": false,
"text": "date_add() DateTime"
},
{
"answer_id": 277259,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 8,
"selected": true,
"text": "php strtotime $Today=date('y:m:d');\n\n// add 3 days to date\n$NewDate=Date('y:m:d', strtotime('+3 days'));\n\n// subtract 3 days from date\n$NewDate=Date('y:m:d', strtotime('-3 days'));\n\n// PHP returns last sunday's date\n$NewDate=Date('y:m:d', strtotime('Last Sunday'));\n\n// One week from last sunday\n$NewDate=Date('y:m:d', strtotime('+7 days Last Sunday'));\n <select id=\"date_list\" class=\"form-control\" style=\"width:100%;\">\n<?php\n$max_dates = 15;\n$countDates = 0;\nwhile ($countDates < $max_dates) {\n $NewDate=Date('F d, Y', strtotime(\"+\".$countDates.\" days\"));\n echo \"<option>\" . $NewDate . \"</option>\";\n $countDates += 1;\n}\n?>\n"
},
{
"answer_id": 14027441,
"author": "Xavier John",
"author_id": 1394827,
"author_profile": "https://Stackoverflow.com/users/1394827",
"pm_score": 3,
"selected": false,
"text": " $date = new DateTime();\n $interval = new DateInterval('P1D');\n echo $date->format('Y-m-d') , PHP_EOL;\n $date->add($interval);\n echo $date->format('Y-m-d'), PHP_EOL;\n $date->add($interval);\n echo $date->format('Y-m-d'), PHP_EOL;\n"
},
{
"answer_id": 28011356,
"author": "Biswadeep Sarkar",
"author_id": 4367758,
"author_profile": "https://Stackoverflow.com/users/4367758",
"pm_score": 4,
"selected": false,
"text": "echo date('Y-m-d',strtotime('+1 day')); //+1 day from today\n echo date('Y-m-d',strtotime('+1 day', strtotime('2007-02-28')));\n"
},
{
"answer_id": 29850650,
"author": "Philipp",
"author_id": 313501,
"author_profile": "https://Stackoverflow.com/users/313501",
"pm_score": 2,
"selected": false,
"text": "function add_days( $days, $from_date = null ) {\n if ( is_numeric( $from_date ) ) { \n $new_date = $from_date; \n } else { \n $new_date = time();\n }\n\n // Timestamp is the number of seconds since an event in the past\n // To increate the value by one day we have to add 86400 seconds to the value\n // 86400 = 24h * 60m * 60s\n $new_date += $days * 86400;\n\n return $new_date;\n}\n $today = add_days( 0 );\n$tomorrow = add_days( 1 );\n$yesterday = add_days( -1 );\n$in_36_hours = add_days( 1.5 );\n\n$first_reminder = add_days( 10 );\n$second_reminder = add_days( 5, $first_reminder );\n$last_reminder = add_days( 3, $second_reminder );\n"
},
{
"answer_id": 40903830,
"author": "Abdul Rafay",
"author_id": 7224751,
"author_profile": "https://Stackoverflow.com/users/7224751",
"pm_score": -1,
"selected": false,
"text": "<?php\n$dt = new DateTime;\nif(isset($_GET['year']) && isset($_GET['week'])) {\n $dt->setISODate($_GET['year'], $_GET['week']);\n} else {\n $dt->setISODate($dt->format('o'), $dt->format('W'));\n}\n$year = $dt->format('o');\n$week = $dt->format('W');\n?>\n\n<a href=\"<?php echo $_SERVER['PHP_SELF'].'?week='.($week-1).'&year='.$year; ?>\">Pre Week</a> \n<a href=\"<?php echo $_SERVER['PHP_SELF'].'?week='.($week+1).'&year='.$year; ?>\">Next Week</a>\n<table width=\"100%\" style=\"height: 75px; border: 1px solid #00A2FF;\">\n<tr>\n<td style=\"display: table-cell;\n vertical-align: middle;\n cursor: pointer;\n width: 75px;\n height: 75px;\n border: 4px solid #00A2FF;\n border-radius: 50%;\">Employee</td>\n<?php\ndo {\n echo \"<td>\" . $dt->format('M') . \"<br>\" . $dt->format('d M Y') . \"</td>\\n\";\n $dt->modify('+1 day');\n} while ($week == $dt->format('W'));\n?>\n</tr>\n</table>\n"
},
{
"answer_id": 49948517,
"author": "Rayed",
"author_id": 2284961,
"author_profile": "https://Stackoverflow.com/users/2284961",
"pm_score": 0,
"selected": false,
"text": "<select id=\"date_list\" class=\"form-control\" style=\"width:100%;\">\n<?php\n$max_dates = 15;\n$countDates = 0;\nwhile ($countDates < $max_dates) {\n $NewDate=Date('F d, Y', strtotime(\"+\".$countDates.\" days\"));\n echo \"<option>\" . $NewDate . \"</option>\";\n $countDates += 1;\n}\n?>\n"
},
{
"answer_id": 56249975,
"author": "Kaushik shrimali",
"author_id": 9106811,
"author_profile": "https://Stackoverflow.com/users/9106811",
"pm_score": 2,
"selected": false,
"text": "$NewDate=Date('Y-m-d', strtotime('+365 days'));\n"
},
{
"answer_id": 56546423,
"author": "humbads",
"author_id": 553396,
"author_profile": "https://Stackoverflow.com/users/553396",
"pm_score": 0,
"selected": false,
"text": "$NewTime = mktime(date('G'), date('i'), date('s'), date('n'), date('j') + $DaysToAdd, date('Y'));"
},
{
"answer_id": 65058609,
"author": "pjehan",
"author_id": 2159979,
"author_profile": "https://Stackoverflow.com/users/2159979",
"pm_score": 0,
"selected": false,
"text": "$fiveDays = new DateInterval('P5D');\n$today = new DateTime();\n$fiveDaysAgo = $today->sub(fiveDays); // or ->add(fiveDays); to add 5 days\n $fiveDaysAgo = (new DateTime())->sub(new DateInterval('P5D'));\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
277,256
|
<p>Is it possible to have a CSS rule which basically "undoes" a prior rule?</p>
<p>An example:</p>
<pre><code><blockquote>
some text <em>more text</em> other text
</blockquote>
</code></pre>
<p>and let's say there's this CSS:</p>
<pre><code>blockquote {
color: red;
}
</code></pre>
<p>...but I want the <code><em></code> to remain the normal text color (which you may not necessarily know).</p>
<p>Basically, would there be a way to do something like this?</p>
<pre><code>blockquote em {
color: inherit-from-blockquote's-parent
}
</code></pre>
<hr>
<p>Edit: The code I'm actually trying to get this to work on is actually a bit more complicated. Maybe this would explain it better:</p>
<pre><code>This text should be *some unknown colour*
<ul>
<li>This text should be BLUE
<ul>
<li>Same as outside the UL</li>
<li>Same as outside the UL</li>
</ul>
</li>
</ul>
ul {
color: blue;
}
ul ul {
color: ???;
}
</code></pre>
|
[
{
"answer_id": 277270,
"author": "Toon Krijthe",
"author_id": 18061,
"author_profile": "https://Stackoverflow.com/users/18061",
"pm_score": 0,
"selected": false,
"text": "ul {\n color: blue;\n}\nli ul {\n color: sameenvironment; /* Sorry but you have to add the specific colour here */\n}\n"
},
{
"answer_id": 277275,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 0,
"selected": false,
"text": "blockquote {\n color: red;\n}\n\nblockquote em {\n color: inherit;\n}\n <em>'s blockquote em {\n color: Purple;\n} \n"
},
{
"answer_id": 277299,
"author": "Gene",
"author_id": 22673,
"author_profile": "https://Stackoverflow.com/users/22673",
"pm_score": 0,
"selected": false,
"text": "<li><span>This text should be BLUE</span>\n <ul>\n <li>Same as outside the UL</li>\n <li>Same as outside the UL</li>\n </ul>\n</li>\n li span{\n color: blue;\n}\n .parentStyle,\n.parentStyle li li{\n color:red;\n}\nli{\n color:blue;\n}\n"
},
{
"answer_id": 277343,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 4,
"selected": true,
"text": "<td>\n This is the enclosing element.\n <ul>\n <li>This is the first level UL, direct child of TD\n <ul>\n <li>This is the second level UL</li>\n <li>Same as outside the UL</li>\n </ul>\n </li>\n </ul>\n</td>\n td > ul\n color: blue; /* this affects the \"direct child\" UL only */\n}\n td ul {\n color: expression(/TD/.test(this.parentNode.tagName)? \"blue\" : \"black\");\n}\n expression() td ul.first {\n color: blue;\n}\n"
},
{
"answer_id": 278705,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 3,
"selected": false,
"text": "blockquote em {\n color: inherit !important;\n}\n"
},
{
"answer_id": 428224,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "body, blockquote em {\n color:[whatever];\n}\n\n\nblockquote {\n color:red;\n}\n body, ul ul {\n color:[whatever];\n}\n\n\nul {\n color:blue;\n}\n"
},
{
"answer_id": 23039159,
"author": "Codingale",
"author_id": 3340763,
"author_profile": "https://Stackoverflow.com/users/3340763",
"pm_score": 0,
"selected": false,
"text": " body {\n color : initial;\n }\n body {\n color : unset;\n }\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9021/"
] |
277,258
|
<p>Let's say I have a source file with many preprocessor directives. Is it possible to see how it looks after the preprocessor is done with it?</p>
|
[
{
"answer_id": 277262,
"author": "Todd Gamblin",
"author_id": 9122,
"author_profile": "https://Stackoverflow.com/users/9122",
"pm_score": 7,
"selected": false,
"text": " -E Stop after the preprocessing stage; do not run the compiler proper. \n The output is in the form of preprocessed source code, which is sent\n to the standard output.\n gcc -E foo.c\n cpp foo.c\n"
},
{
"answer_id": 277264,
"author": "Atempcode",
"author_id": 33823,
"author_profile": "https://Stackoverflow.com/users/33823",
"pm_score": 3,
"selected": false,
"text": "cl /EP"
},
{
"answer_id": 277336,
"author": "ididak",
"author_id": 28888,
"author_profile": "https://Stackoverflow.com/users/28888",
"pm_score": 4,
"selected": false,
"text": "gcc -E code.c | sed '/^\\#/d' | indent -st -i2 > code-x.c\n"
},
{
"answer_id": 277362,
"author": "bk1e",
"author_id": 8090,
"author_profile": "https://Stackoverflow.com/users/8090",
"pm_score": 8,
"selected": true,
"text": "cl.exe /E /P /EP /P /EP"
},
{
"answer_id": 14509341,
"author": "Sam Pittman",
"author_id": 2008810,
"author_profile": "https://Stackoverflow.com/users/2008810",
"pm_score": 3,
"selected": false,
"text": "CL blah-blah-blah myfile.c CL /P blah-blah-blah myfile.c"
},
{
"answer_id": 15260086,
"author": "dzav",
"author_id": 1095712,
"author_profile": "https://Stackoverflow.com/users/1095712",
"pm_score": 3,
"selected": false,
"text": "gcc -E -P -o result.c my_file.h\n gcc -E -C -P -o result.c my_file.h\n"
},
{
"answer_id": 28247516,
"author": "manty",
"author_id": 4085421,
"author_profile": "https://Stackoverflow.com/users/4085421",
"pm_score": 2,
"selected": false,
"text": "CL /P /C myprogram.c\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31610/"
] |
277,284
|
<p>I've been playing around with ASP.NET MVC and had a question. Or maybe its a concern that I am doing this wrong. Just working on a lame site to stretch my wings a bit. I am sorry this question is not at all concise.</p>
<p>Ok, here's the scenario. When the user visits home/index, the page should show a list of products and a list of articles. The file layout is such (DAL is my data access layer):</p>
<pre>
Controllers
Home
Index
Views
Home
Index inherits from ViewPage
Product
List inherits from ViewUserControl<IEnumerable<DAL.Product>>
Single inherits from ViewUserControl<DAL.Product>
Article
List inherits from ViewUserControl<IEnumerable<DAL.Article>>
Single inherits from ViewUserControl<DAL.Article>
</pre>
<pre><code>Controllers.HomeController.Index produces a View whose ViewData contains two entries, a IEnumerable<DAL.Product> and a IEnumerable<DAL.Article>.
View.Home.Index will use those view entries to call:
Html.RenderPartial("~/Views/Product/List.ascx", ViewData["ProductList"])
and Html.RenderPartial("~/Views/Article/List.ascx", ViewData["ArticleList"])
View.Product.List will call
foreach(Product product in View.Model)
Html.RenderPartial("Single", product);
View.Article.List does something similar to View.Product.List
</code></pre>
<p>This approach fails however. The approach makes sense to me, but maybe someone with more experience with these MVC platforms will recognize a better way.</p>
<p>The above produces an error inside View.Product.List. The call to <code>Html.RenderPartial("Single",...)</code> complains that "Single" view was not found. The error indicates:</p>
<pre>
The partial view 'Single' could not be found. The following locations were searched:
~/Views/Home/Single.aspx
~/Views/Home/Single.ascx
~/Views/Shared/Single.aspx
~/Views/Shared/Single.ascx
</pre>
<p>Because I was calling RenderAction() from a view in Product, I expected the runtime to look for the "Single" view within Views\Product. It seems however the lookup is relative the controller which invoked the original view (/Controller/Home invoked /Views/Product) rather than the current view.</p>
<p>So I am able to fix this by changing Views\Product, such that:</p>
<pre><code>View.Product.List will call
foreach(Product product in View.Model)
Html.RenderPartial(<b>"~/Views/Product/Single.ascx"</b>, product);</code></pre>
<p>instead of</p>
<pre><code>View.Product.List will call
foreach(Product product in View.Model)
Html.RenderPartial(<b>"Single"</b>, product);
</code></pre>
<p>This fix works but.. I do not understand why I needed to specify the full path of the view. It would make sense to me for the relative name to be interpreted relative to the current view's path rather than the original controller's view path. I cannot think of any useful case where interpreting the name relative to the controller's view instead of the current view is useful (except in the typical case where they are the same).</p>
<p>Around this time I should have a question mark? To emphasis this actually is a question.</p>
|
[
{
"answer_id": 282110,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 2,
"selected": false,
"text": "Views\n Shared\n ProductSingle\n ProductList\n ArticleSingle\n ArticleList\n <% Html.RenderPartial(\"ProductSingle\", ViewData[\"ProductList\"]); %>\n<% Html.RenderPartial(\"ProductList\", product); %>\n<% Html.RenderPartial(\"ArticleSingle\", article); %>\n<% Html.RenderPartial(\"ArticleList\", ViewData[\"ArticleList\"]); %>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32203/"
] |
277,288
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://stackoverflow.com/questions/334879/how-do-i-get-the-application-exit-code-from-a-windows-command-line">How do I get the application exit code from a Windows command line?</a> </p>
</blockquote>
<p>In Unix/bash, I can simply say:</p>
<blockquote>
<p>$ echo $?</p>
</blockquote>
<p>to find out the return/exit code of a program, both from interactive and non-interactive shells.</p>
<p>Now, how can I do the equivalent in Windows/cmd.exe? </p>
|
[
{
"answer_id": 277302,
"author": "JesperE",
"author_id": 13051,
"author_profile": "https://Stackoverflow.com/users/13051",
"pm_score": 4,
"selected": false,
"text": "IF ERRORLEVEL 1 GOTO ERROR\n IF %ERRORLEVEL% NEQ 0 GOTO ERROR\n"
},
{
"answer_id": 1236989,
"author": "ebryn",
"author_id": 3572,
"author_profile": "https://Stackoverflow.com/users/3572",
"pm_score": 3,
"selected": false,
"text": "echo %ERRORLEVEL%\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277288",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10955/"
] |
277,291
|
<p>In Eclipse RCP way of doing things, where should I keep my model objects? And when they are loaded or changed, how should they talk to the views?</p>
<p>I am attempting to port my existing application to Eclipse RCP. It could be viewed as an IDE-like application: I open a file, which contains links to source files. The source files are displayed in the tree view. I can edit the source, and build the sources into some output...</p>
<p>For example, when I handle the Open command, where would I create the model object so my views can see them? I'd rather avoid the use of singleton manager class, but that maybe the simplest way.</p>
<p>Interesting code I found browsing JDT's source code are JavaCore, JavaModel, JavaModelManager. and JavaProject.</p>
<hr>
<pre><code>IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
</code></pre>
<hr>
<pre><code>public static IJavaProject create(IProject project) {
if (project == null) {
return null;
}
JavaModel javaModel = JavaModelManager.getJavaModelManager().getJavaModel();
return javaModel.getJavaProject(project);
}
</code></pre>
<hr>
<p>Related:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/282509/how-do-you-communicate-between-eclipse-declarative-services-and-views-contentpr">How do you communicate between eclipse declarative services and Views (ContentProviders)</a></li>
<li><a href="http://www-128.ibm.com/developerworks/java/library/os-ecllink/index.html" rel="nofollow noreferrer">Make your Eclipse applications richer with view linking</a></li>
</ul>
|
[
{
"answer_id": 277411,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 4,
"selected": true,
"text": "MyPlugin.getDefault().getModel()\n"
},
{
"answer_id": 277753,
"author": "jamesh",
"author_id": 4737,
"author_profile": "https://Stackoverflow.com/users/4737",
"pm_score": 2,
"selected": false,
"text": "IEditorPart IEditorInput"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3827/"
] |
277,316
|
<p>I place the following statements in the second row of my grid in the xaml:</p>
<pre><code><ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1">
<ListView Name="listView" Margin="5" Grid.Row="1">
<ListView.View>
<GridView AllowsColumnReorder="True">
<GridViewColumn DisplayMemberBinding="{Binding Path=DateTime}" Header="Date Time" Width="140"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Vehicle}" Header="Vehicle" Width="130"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=AlarmType}" Header="Alarm Type" Width="100"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Direction}" Header="Direction" Width="100"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Speed}" Header="Speed" Width="100"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Alarmed}" Header="Alarmed" Width="100"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=LoadType}" Header="Load Type" Width="100"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=Status}" Header="Status" Width="110"/>
</GridView>
</ListView.View>
</ListView>
</ScrollViewer>
</Grid>
</code></pre>
<p>I binded the listView.ItemSource to an ObservableCollection defined in the code to populate data to the list. When the number of items added to the GridView exceeded the listview height, the vertical scroll bar did not appear as i specified in the XAML. What did I do wrong? Your input is greatly appreciated. Thank you.</p>
|
[
{
"answer_id": 277567,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 3,
"selected": false,
"text": "<Window x:Class=\"WpfApplication1.Window1\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n Title=\"Window1\" Height=\"300\" Width=\"300\">\n <Grid>\n <Grid.RowDefinitions>\n <RowDefinition Height=\"*\"/>\n <RowDefinition Height=\"*\"/>\n </Grid.RowDefinitions>\n\n <ScrollViewer VerticalScrollBarVisibility=\"Auto\" Grid.Row=\"1\">\n <ListView Name=\"listView\" Margin=\"5\" Grid.Row=\"1\">\n\n <ListView.View>\n <GridView AllowsColumnReorder=\"True\">\n <GridViewColumn DisplayMemberBinding=\"{Binding Path=.}\" Header=\"Whatever\" Width=\"140\"/>\n </GridView>\n </ListView.View>\n </ListView>\n </ScrollViewer>\n </Grid>\n</Window>\n ListView ScrollViewer ScrollViewer ListView"
},
{
"answer_id": 1865015,
"author": "Praveen Chandran",
"author_id": 226918,
"author_profile": "https://Stackoverflow.com/users/226918",
"pm_score": 0,
"selected": false,
"text": "ScrollViewer ScrollViewer ListView ListView listView = new ListView();\nlistView.SetValue(Grid.RowProperty, 1);\nlistView.SetValue(Grid.ColumnProperty, 1);\nMainGrid.Children.Add(listView);\n"
},
{
"answer_id": 10368063,
"author": "ankit",
"author_id": 1363480,
"author_profile": "https://Stackoverflow.com/users/1363480",
"pm_score": 0,
"selected": false,
"text": "<Grid x:Name=\"MainMenuButtonGrid\">\n <StackPanel Margin=\"50,0,0,0\">\n <TextBlock Text=\"Please select any employee\" Foreground=\"Wheat\"/>\n <ListView x:Name=\"listEmployeeDetail\" SelectedValuePath=\"EmployeeID\">\n <ListView.View>\n <GridView>\n <GridViewColumn Header=\"EmployeeName\" Width=\"100\" DisplayMemberBinding=\"{Binding EmployeeName}\"></GridViewColumn>\n </GridView>\n </ListView.View>\n </ListView>\n </StackPanel>\n</Grid>\n"
},
{
"answer_id": 11238755,
"author": "lincy oommen",
"author_id": 1485461,
"author_profile": "https://Stackoverflow.com/users/1485461",
"pm_score": 1,
"selected": false,
"text": "ListView listView = new ListView();\nlistView.SetValue(Grid.RowProperty, 1);\nlistView.SetValue(Grid.ColumnProperty, 1);\nMainGrid.Children.Add(listView);\n"
},
{
"answer_id": 65982305,
"author": "Baptiste Florentin",
"author_id": 9184081,
"author_profile": "https://Stackoverflow.com/users/9184081",
"pm_score": 0,
"selected": false,
"text": " <ListView Name=\"listView\" Margin=\"5\" Grid.Row=\"1\" MaxHeight=\"300\">\n <ListView.View>\n <GridView AllowsColumnReorder=\"True\">\n <GridViewColumn DisplayMemberBinding=\"{Binding Path=DateTime}\" Header=\"Date Time\" Width=\"140\"/>\n <GridViewColumn DisplayMemberBinding=\"{Binding Path=Vehicle}\" Header=\"Vehicle\" Width=\"130\"/>\n <GridViewColumn DisplayMemberBinding=\"{Binding Path=AlarmType}\" Header=\"Alarm Type\" Width=\"100\"/>\n <GridViewColumn DisplayMemberBinding=\"{Binding Path=Direction}\" Header=\"Direction\" Width=\"100\"/>\n <GridViewColumn DisplayMemberBinding=\"{Binding Path=Speed}\" Header=\"Speed\" Width=\"100\"/>\n <GridViewColumn DisplayMemberBinding=\"{Binding Path=Alarmed}\" Header=\"Alarmed\" Width=\"100\"/>\n <GridViewColumn DisplayMemberBinding=\"{Binding Path=LoadType}\" Header=\"Load Type\" Width=\"100\"/>\n <GridViewColumn DisplayMemberBinding=\"{Binding Path=Status}\" Header=\"Status\" Width=\"110\"/>\n </GridView>\n </ListView.View>\n </ListView> \n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
277,327
|
<p>Is there a built in way to determine if a component is fully visible in a Flex application (i.e. not offscreen one way or the other). If not how would I go about figurin it out?</p>
<p>I want to show or hide additional 'next' and 'previous' buttons if my primary 'next' and 'previous' buttons are off screen.</p>
<p>What event would be best to listen to to 'recalculate' ? stage.resize?</p>
<p>thanks!</p>
|
[
{
"answer_id": 280876,
"author": "Matt MacLean",
"author_id": 22,
"author_profile": "https://Stackoverflow.com/users/22",
"pm_score": 1,
"selected": false,
"text": "public function isComponentWithinStage(c:UIComponent):Boolean {\n var tl:Point = c.localToGlobal(new Point(0, 0));\n var br:Point = c.localToGlobal(new Point(c.width, c.height));\n\n //are we off the left or top of stage?\n if ( tl.x < 0 || tl.y < 0 ) {\n return false;\n }\n\n var stage:Stage = Application.application.stage;\n\n //off the right or bottom of stage?\n if ( br.x > stage.width || br.y > stage.height ) {\n return false;\n }\n\n return true;\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277327",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16940/"
] |
277,340
|
<p>I'm executing a query like this</p>
<pre><code>select field from table;
</code></pre>
<p>In that query, there is a loop running on many tables. So, if the field is not present in a table I get a </p>
<blockquote>
<p>Runtime Error 3061</p>
</blockquote>
<p>How can I by pass this error such as that on this error flow should go to another point?</p>
<p>This is the code I have recently after going through this forum.</p>
<pre><code>Option Explicit
Private Sub UpdateNulls()
Dim rs2 As DAO.Recordset
Dim tdf As DAO.TableDef
Dim db As Database
Dim varii As Variant, strField As String
Dim strsql As String, strsql2 As String, strsql3 As String
Dim astrFields As Variant
Dim intIx As Integer
Dim field As Variant
Dim astrvalidcodes As Variant
Dim found As Boolean
Dim v As Variant
Open "C:\Documents and Settings\Desktop\testfile.txt" For Input As #1
varii = ""
Do While Not EOF(1)
Line Input #1, strField
varii = varii & "," & strField
Loop
Close #1
astrFields = Split(varii, ",") 'Element 0 empty
For intIx = 1 To UBound(astrFields)
'Function ListFieldDescriptions()
Dim cn As New ADODB.Connection, cn2 As New ADODB.Connection
Dim rs As ADODB.Recordset, rs3 As ADODB.Recordset
Dim connString As String
Dim SelectFieldName
Set cn = CurrentProject.Connection
SelectFieldName = astrFields(intIx)
Set rs = cn.OpenSchema(adSchemaColumns, Array(Empty, Empty, Empty, SelectFieldName))
'Show the tables that have been selected '
While Not rs.EOF
'Exclude MS system tables '
If Left(rs!Table_Name, 4) <> "MSys" Then
strsql = "Select t.* From [" & rs!Table_Name & "] t Inner Join 01UMWELT On t.fall = [01UMWELT].fall Where [01UMWELT].Status = 4"
End If
Set rs3 = CurrentDb.OpenRecordset(strsql)
'End Function
strsql2 = "SELECT label.validcode FROM variablen s INNER JOIN label ON s.id=label.variablenid WHERE varname='" & astrFields(intIx) & "'"
Set db = OpenDatabase("C:\Documents and Settings\Desktop\Codebook.mdb")
Set rs2 = db.OpenRecordset(strsql2)
With rs2
.MoveLast
.MoveFirst
astrvalidcodes = rs2.GetRows(.RecordCount)
.Close '
End With
With rs3
.MoveFirst
While Not rs3.EOF
found = False
For Each v In astrvalidcodes
If v = .Fields(0) Then
found = True
Debug.Print .Fields(0)
Debug.Print .Fields(1)
Exit For
End If
Next
If Not found Then
msgbox "xxxxxxxxxxxxxxxx"
End If
End If
.MoveNext
Wend
End With
On Error GoTo 0 'End of special handling
Wend
Next intIx
End Sub
</code></pre>
<p>I'm getting a</p>
<blockquote>
<p>Type Mismatch Runtime Error </p>
</blockquote>
<p>in <code>Set rs3 = CurrentDb.OpenRecordset(strsql)</code></p>
<p>I guess I'm mixing up <code>ado</code> and <code>dao</code> but I'm not certainly sure where it is.</p>
|
[
{
"answer_id": 277366,
"author": "JTeagle",
"author_id": 162171,
"author_profile": "https://Stackoverflow.com/users/162171",
"pm_score": 0,
"selected": false,
"text": "...act on error, or simply ignore if necessary...\n"
},
{
"answer_id": 277369,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "On Error Sub TableTest\n On Error Goto TableTest_Error\n\n ' ...code that can fail... '\n\n Exit Sub\n\n:TableTest_Error\n If Err.Number = 3061 Then\n Err.Clear()\n DoSomething()\n Else\n MsgBox Err.Description ' or whatever you find appropriate '\n End If\nEnd Sub\n Sub TableTest\n ' ... fail-safe code ... '\n\n On Error Resume Next\n ' ...code that can fail... '\n If Err.Number = 3061 Then\n Err.Clear()\n DoSomething()\n Else\n MsgBox Err.Description\n End If\n On Error Goto 0\n\n ' ...mode fail-safe code... '\nEnd Sub\n On Error Resume Next On Error Goto <Jump Label> On Error Goto <Line Number> On Error Goto 0 For Each FieldName In FieldNames ' assuming you have some looping construct here '\n\n strsql3 = \"SELECT \" & FieldName & \" FROM table\"\n\n On Error Resume Next\n Set rs3 = CurrentDb.OpenRecordset(strsql3)\n\n If Err.Number = 3061 Then\n ' Do nothing. We dont care about this error '\n Err.Clear\n Else\n MsgBox \"Uncaught error number \" & Err.Number & \" (\" & Err.Description & \")\"\n Err.Clear\n End If\n\n On Error GoTo 0\n\nNext FieldName\n"
},
{
"answer_id": 277612,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 3,
"selected": true,
"text": "Function ListTablesContainingField()\nDim cn As New ADODB.Connection, cn2 As New ADODB.Connection\nDim rs As ADODB.Recordset, rs2 As ADODB.Recordset\nDim connString As String\nDim SelectFieldName\n\n Set cn = CurrentProject.Connection\n\n SelectFieldName = \"Fall\" 'For tksy '\n\n 'Get names of all tables that have a column called 'ID' '\n Set rs = cn.OpenSchema(adSchemaColumns, _\n Array(Empty, Empty, Empty, SelectFieldName))\n\n 'Show the tables that have been selected '\n While Not rs.EOF\n\n 'Exclude MS system tables '\n If Left(rs!Table_Name, 4) <> \"MSys\" Then\n ' Edit for tksy, who is using more than one forum '\n If tdf.Name = \"01UMWELT\" Then\n strSQL = \"Select * From 01UMWELT Where Status = 5\"\n Else\n strSQL = \"Select a.* From [\" & rs!Table_Name _\n & \"] a Inner Join 01UMWELT On a.fall = 01UMWELT.fall \" _\n & \"Where 01UMWELT.Status = 5\"\n End If\n Set rs2 = CurrentDb.OpenRecordset(strSQL)\n\n Do While Not rs2.EOF\n For i = 0 To rs2.Fields.Count - 1\n If IsNull(rs2.Fields(i)) Then\n rs2.Edit\n rs2.Fields(i) = 111111\n rs2.Update\n End If\n Next\n rs2.MoveNext\n Loop\n End If\n rs.MoveNext\n Wend\n rs.Close\n Set cn = Nothing\n\nEnd Function\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31132/"
] |
277,345
|
<p>I want to be able to compare Dates and Times in Rails without always having to call the to_time or to_date method. So I wrote the following code:</p>
<pre><code>class Date
def ==(other)
if other.kind_of?(Time)
self.to_time == other
else
super(other)
end
end
end
</code></pre>
<p>I know there's an easy way to write this so that I can make this work for >, <, >=, <= and <=>. But I forgot how :P Any ideas?</p>
|
[
{
"answer_id": 277520,
"author": "Christoph Schiessl",
"author_id": 20467,
"author_profile": "https://Stackoverflow.com/users/20467",
"pm_score": 0,
"selected": false,
"text": "kind_of? other to_time <=>"
},
{
"answer_id": 278073,
"author": "segy",
"author_id": 19006,
"author_profile": "https://Stackoverflow.com/users/19006",
"pm_score": 0,
"selected": false,
"text": "(segfault@megumi)(01:35)% ./script/console\nLoading development environment (Rails 2.2.0)\nirb(main):001:0> a = Date.now\nNoMethodError: private method `now' called for Date:Class\n from (irb):1\n from :0\nirb(main):002:0> a = Date.today\n => Mon, 10 Nov 2008\nirb(main):003:0> b = Time.today\n => Mon Nov 10 00:00:00 -0500 2008\nirb(main):004:0> a == b\n => nil\nirb(main):005:0> puts \"a\" if a == b\n => nil\nirb(main):006:0> puts \"a\" if a != b\n a\n => nil\nirb(main):007:0> \n"
},
{
"answer_id": 281075,
"author": "Chu Yeow",
"author_id": 25226,
"author_profile": "https://Stackoverflow.com/users/25226",
"pm_score": 4,
"selected": true,
"text": "include Comparable <=> <=>"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277345",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11082/"
] |
277,351
|
<p>What is a mathematical way of of saying 1 - 1 = 12 for a month calculation? Adding is easy, 12 + 1 % 12 = 1, but subtraction introduces 0, stuffing things up.</p>
<p>My actual requirement is x = x + d, where x must always be between 1 and 12 before and after the summing, and d any unsigned integer.</p>
|
[
{
"answer_id": 277355,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 2,
"selected": false,
"text": "((x - y + 11) % 12) + 1\n // Range = [0, 22]\nx - y + 11\n\n// Range = [0, 11]\n(x - y + 11) % 12\n\n// Range = [1, 12]\n((x - y + 11) % 12) + 1\n"
},
{
"answer_id": 277359,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 0,
"selected": false,
"text": "x % 12 + 1\n norm(x) = ((x - 1) % 12) + 1\n norm(x + 1) = (((x + 1) - 1) % 12 + 1\n\nnorm(x + 1) = (x) % 12 + 1\n"
},
{
"answer_id": 277361,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 3,
"selected": true,
"text": ">>> for i in range(15):\n... print '%d + 1 => %d' % (i, (i+1)%12)\n...\n0 + 1 => 1\n1 + 1 => 2\n2 + 1 => 3\n3 + 1 => 4\n4 + 1 => 5\n5 + 1 => 6\n6 + 1 => 7\n7 + 1 => 8\n8 + 1 => 9\n9 + 1 => 10\n10 + 1 => 11\n11 + 1 => 0\n12 + 1 => 1\n13 + 1 => 2\n14 + 1 => 3\n>>> for i in range(15):\n... print '%d - 1 => %d' % (i, (i-1)%12)\n...\n0 - 1 => 11\n1 - 1 => 0\n2 - 1 => 1\n3 - 1 => 2\n4 - 1 => 3\n5 - 1 => 4\n6 - 1 => 5\n7 - 1 => 6\n8 - 1 => 7\n9 - 1 => 8\n10 - 1 => 9\n11 - 1 => 10\n12 - 1 => 11\n13 - 1 => 0\n14 - 1 => 1\n"
},
{
"answer_id": 277370,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 0,
"selected": false,
"text": "(x + y - 1) % 12 + 1\n x % 12 + 1\n (x + (12 - (y % 12) - 1) % 12 + 1\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8741/"
] |
277,364
|
<p>I've been reading through the details of the <code>System</code> libraries <code>set</code> and <code>get</code> methods yet the parameters are usually Strings.</p>
<p>Would you consider the use of <code>String</code> as parameters bad practise since the inclusion of <code>enum</code>?</p>
<p>A better alternative at minimum might be <code>public final String</code>, No?</p>
|
[
{
"answer_id": 277376,
"author": "Martin",
"author_id": 24364,
"author_profile": "https://Stackoverflow.com/users/24364",
"pm_score": 3,
"selected": false,
"text": "public final String enum"
},
{
"answer_id": 277457,
"author": "akuhn",
"author_id": 24468,
"author_profile": "https://Stackoverflow.com/users/24468",
"pm_score": 4,
"selected": false,
"text": "enum"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4857/"
] |
277,368
|
<p>I hate to have to ask, but I'm pretty stuck here.</p>
<p>I need to test a sequence of numbers to find the first which has over 500 factors:
<a href="http://projecteuler.net/index.php?section=problems&id=12" rel="nofollow noreferrer">http://projecteuler.net/index.php?section=problems&id=12</a></p>
<p>-At first I attempted to brute force the answer (finding a number with 480 after a LONG time)</p>
<p>-I am now looking at determining the prime factors of a number and then use them to find all other factors.</p>
<p>I am currently at the stage where I can get an array of prime factors for any number I input - i.e 300 has the prime factors 2 2 3 5 5</p>
<p>Using this array of prime factors I need to be able to calculate the remaining factors - This is the part I am stuck on. Basically, as I understand it, I need to calculate ALL possible combinations of the numbers in the array...</p>
<p>i.e
2 * 2 <br>
2 * 2 * 3 <br>
2 * 2 * 3 * 5 <br>
2 * 3 <br>
2 * 3 * 3 <br>
...and so forth - But where it gets interesting is with things like...<br>
2 * 5 <br>
2 * 3 * 5 <br>
...i.e Numbers which are not adjacent to each other in the array</p>
<p>I can't think of a way to code this in a generic fashion for any length array...</p>
<p>I need help! P.S - I am working in Java</p>
<p>EDIT: My brute force code - As it has been suggested brute forcing the problem will work and so there may be an error in my code :(</p>
<pre><code>package euler.problem12;
public class Solution {
public static void main(String[] args) {
int next = 1;
int triangle = 0;
int maxFactors = 0;
while(true) {
triangle = triangle + next;
int factors = 1;
int max = (int) triangle / 2;
for(int i = 1; i <= max; ++i) {
if(triangle % i == 0) {
factors ++;
}
}
if(factors > maxFactors) {
maxFactors = factors;
System.out.println(triangle + "\t" + factors);
}
next++;
}
}
}
</code></pre>
|
[
{
"answer_id": 605796,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "public static void main(String[] args) {\n int[] primeFactors = new int[] {2, 2, 3, 5, 5};\n List<Integer> allFactors = getAllFactors(primeFactors);\n for (int factor : allFactors) {\n System.out.println(\"Factor: \" + factor);\n }\n}\n\nprivate static List<Integer> getAllFactors(int[] primeFactors) {\n Set<Integer> distinctFactors = new HashSet<Integer>();\n for (int maxDepth = 0; maxDepth <= primeFactors.length; maxDepth++) {\n permutatPrimeFactors(0, maxDepth, 0, 1, primeFactors, distinctFactors);\n }\n List<Integer> result = new ArrayList<Integer>(distinctFactors);\n Collections.sort(result);\n return result;\n}\n\nprivate static void permutatPrimeFactors(int depth, int maxDepth, int minIndex, int valueSoFar, int[] primeFactors, Set<Integer> distinctFactors) {\n if (depth == maxDepth) {\n distinctFactors.add(valueSoFar);\n return;\n }\n\n for (int index = minIndex; index < primeFactors.length; index++) {\n permutatPrimeFactors(depth + 1, maxDepth, index + 1, valueSoFar * primeFactors[index], primeFactors, distinctFactors);\n }\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15075/"
] |
277,383
|
<p>I have list store in mysql table file1=(1,2,3,4,6,7) and other list file2 = (3,2,4,8,9,10,12) is not stored in table, i want compare both and result should be like
result=(6,7,8,9,10,12) then calculate the percentage. like 100*(result/file1+file2) in mysql data structure. i do not know how i will do it.
please know body know guide me or give me a small example.
thanks </p>
|
[
{
"answer_id": 277446,
"author": "Anthony Williams",
"author_id": 5597,
"author_profile": "https://Stackoverflow.com/users/5597",
"pm_score": 1,
"selected": false,
"text": "GROUP BY COUNT HAVING"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
277,384
|
<p>I have a little Perl script (On Windows) that checks some files for me as an aid to my day-to-day business. At the moment it prints out something like...</p>
<pre><code>0%
25%
50%
75%
Complete
</code></pre>
<p>But I can remember scripts I've used in the past that didn't print progress on a line-by-line basis, but which updated the output on the display, presumably by moving the cursor back and over-printing what was there.</p>
<p>Anyone know what magic is required? Portability isn't important to me, the script is quite disposable.</p>
|
[
{
"answer_id": 277407,
"author": "daniels",
"author_id": 9789,
"author_profile": "https://Stackoverflow.com/users/9789",
"pm_score": 3,
"selected": false,
"text": "print \"##### [ 10%]\\r\";\n# Do something\nprint \"########## [ 20%]\\r\";\n# Do something else\nprint \"############### [ 30%]\\r\";\n# Do some more\n# ...\n# ...\n# ...\nprint \"##################################### [100%]\\n\";\nprint \"Done.\\n\";\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/974/"
] |
277,409
|
<p>I want to store a list of the following tuples in a compressed format and I was wondering which algorithm gives me</p>
<ul>
<li>smallest compressed size</li>
<li>fastest de/compression</li>
<li>tradeoff optimum ("knee" of the tradeoff curve)</li>
</ul>
<p>My data looks like this:</p>
<pre><code>(<int>, <int>, <double>),
(<int>, <int>, <double>),
...
(<int>, <int>, <double>)
</code></pre>
<p>One of the two ints refers to a point in time and it's very likely that the numbers ending up in one list are close to each other. The other int represents an abstract id and the values are less likely to be close, although they aren't going to be completely random, either. The double is representing a sensor reading and while there is some correlation between the values, it's probably not of much use.</p>
|
[
{
"answer_id": 277441,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "[ProtoContract]\npublic class Foo {\n [ProtoMember(1)]\n public int Value1 {get;set;}\n [ProtoMember(2)]\n public int Value2 {get;set;}\n [ProtoMember(3)]\n public double Value3 {get;set;}\n}\n"
},
{
"answer_id": 277559,
"author": "Hanno Fietz",
"author_id": 2077,
"author_profile": "https://Stackoverflow.com/users/2077",
"pm_score": 0,
"selected": false,
"text": "(<int1>, <int2>, <double>), ... ([<int1>, <int1> ...], [<int2>, <int2> ... ], [<double>, <double> ...])"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] |
277,423
|
<p>Does anybody know how I can see the actual machine code that <a href="http://code.google.com/p/v8/" rel="noreferrer">v8</a> generates from Javascript? I've gotten as far as <code>Script::Compile()</code> in <code>src/api.cc</code> but I can't figure out where to go from there.</p>
|
[
{
"answer_id": 1197559,
"author": "sstock",
"author_id": 58926,
"author_profile": "https://Stackoverflow.com/users/58926",
"pm_score": 4,
"selected": false,
"text": "scons [your v8 build options here] disassembler=on sample=shell\n ./shell --print_code hello.js\n --- Raw source ---\nprint(\"hello world\");\n\n--- Code ---\nkind = FUNCTION\nInstructions (size = 134)\n0x2ad0a77ceea0 0 55 push rbp\n0x2ad0a77ceea1 1 488bec REX.W movq rbp,rsp\n0x2ad0a77ceea4 4 56 push rsi\n0x2ad0a77ceea5 5 57 push rdi\n0x2ad0a77ceea6 6 49ba59c13da9d02a0000 REX.W movq r10,0x2ad0a93dc159 ;; object: 0xa93dc159 <undefined>\n0x2ad0a77ceeb0 16 4952 REX.W push r10\n0x2ad0a77ceeb2 18 49ba688b700000000000 REX.W movq r10,0x708b68\n0x2ad0a77ceebc 28 493b22 REX.W cmpq rsp,[r10]\n0x2ad0a77ceebf 31 0f824e000000 jc 115 (0x2ad0a77cef13)\n0x2ad0a77ceec5 37 488b462f REX.W movq rax,[rsi+0x2f]\n0x2ad0a77ceec9 41 4883ec18 REX.W subq rsp,0xlx\n0x2ad0a77ceecd 45 49ba094b3ea9d02a0000 REX.W movq r10,0x2ad0a93e4b09 ;; object: 0xa93e4b09 <String[5]: print>\n0x2ad0a77ceed7 55 4c8955e0 REX.W movq [rbp-0x20],r10\n0x2ad0a77ceedb 59 488945d8 REX.W movq [rbp-0x28],rax\n0x2ad0a77ceedf 63 49ba014d3ea9d02a0000 REX.W movq r10,0x2ad0a93e4d01 ;; object: 0xa93e4d01 <String[11]: hello world>\n0x2ad0a77ceee9 73 4c8955d0 REX.W movq [rbp-0x30],r10\n0x2ad0a77ceeed 77 49baa06c7ba7d02a0000 REX.W movq r10,0x2ad0a77b6ca0 ;; debug: statement 0\n ;; code: contextual, CALL_IC, UNINITIALIZED, argc = 1\n0x2ad0a77ceef7 87 49ffd2 REX.W call r10\n0x2ad0a77ceefa 90 488b75f8 REX.W movq rsi,[rbp-0x8]\n0x2ad0a77ceefe 94 4883c408 REX.W addq rsp,0xlx\n0x2ad0a77cef02 98 488945e8 REX.W movq [rbp-0x18],rax\n0x2ad0a77cef06 102 488be5 REX.W movq rsp,rbp ;; js return\n0x2ad0a77cef09 105 5d pop rbp\n0x2ad0a77cef0a 106 c20800 ret 0x8\n0x2ad0a77cef0d 109 cc int3\n0x2ad0a77cef0e 110 cc int3\n0x2ad0a77cef0f 111 cc int3\n0x2ad0a77cef10 112 cc int3\n0x2ad0a77cef11 113 cc int3\n0x2ad0a77cef12 114 cc int3\n0x2ad0a77cef13 115 49ba60657ba7d02a0000 REX.W movq r10,0x2ad0a77b6560 ;; code: STUB, StackCheck, minor: 0\n0x2ad0a77cef1d 125 49ffd2 REX.W call r10\n0x2ad0a77cef20 128 488b7df0 REX.W movq rdi,[rbp-0x10]\n0x2ad0a77cef24 132 eb9f jmp 37 (0x2ad0a77ceec5)\n\nRelocInfo (size = 10)\n0x2ad0a77ceea8 embedded object (0xa93dc159 <undefined>)\n0x2ad0a77ceecf embedded object (0xa93e4b09 <String[5]: print>)\n0x2ad0a77ceee1 embedded object (0xa93e4d01 <String[11]: hello world>)\n0x2ad0a77ceeed statement position (0)\n0x2ad0a77ceeef code target (context) (CALL_IC) (0x2ad0a77b6ca0)\n0x2ad0a77cef06 js return\n0x2ad0a77cef15 code target (STUB) (0x2ad0a77b6560)\n\nhello world\n"
},
{
"answer_id": 22960151,
"author": "Diego Pino",
"author_id": 134758,
"author_profile": "https://Stackoverflow.com/users/134758",
"pm_score": 3,
"selected": false,
"text": "git clone https://chromium.googlesource.com/v8/v8.git\n make dependencies\nmake ia32.release objectprint=on disassembler=on\n out/ia32.release/d8 --code-comments --print-code <app.js>\n"
},
{
"answer_id": 29607938,
"author": "coder23",
"author_id": 2167962,
"author_profile": "https://Stackoverflow.com/users/2167962",
"pm_score": 0,
"selected": false,
"text": "v8_root/build/features.gypi"
},
{
"answer_id": 46511251,
"author": "Manjeet",
"author_id": 1513779,
"author_profile": "https://Stackoverflow.com/users/1513779",
"pm_score": 3,
"selected": false,
"text": "-print-opt-code -print-bytecode -trace-opt -trace-deopt D8 V8"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36128/"
] |
277,431
|
<p>I have huge number of Word files I need to merge (join) into one file, and will be time consuming to use the Word merger (one by one). Have you experienced any tool that can handle this job?</p>
|
[
{
"answer_id": 277449,
"author": "Mitch Wheat",
"author_id": 16076,
"author_profile": "https://Stackoverflow.com/users/16076",
"pm_score": 2,
"selected": false,
"text": "Sub InsertFiles()\n Dim strFileName As String\n Dim rng As Range\n Dim Doc As Document\n Const strPath = \"C:\\Documents and Settings\\Graham Skan\\My Documents\\Allwork\\\" 'adjust as necessary '\"\n\n Set Doc = Documents.Add\n strFileName = Dir$(strPath & \"\\*.doc\")\n Do\n Set rng = Doc.Bookmarks(\"\\EndOfDoc\").Range\n If rng.End > 0 Then 'section break not necessary before first document.'\n rng.InsertBreak wdSectionBreakNextPage\n rng.Collapse wdCollapseEnd\n End If\n rng.InsertFile strPath & \"\\\" & strFileName\n strFileName = Dir$()\n Loop Until strFileName = \"\"\nEnd Sub\n"
},
{
"answer_id": 277470,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 3,
"selected": true,
"text": "Sub MergeAllDocuments(AllDocumentsPath as String, MasterDocumentPath as String)\n Dim MasterDocument As Document\n\n Set MasterDocument = Documents.Open(FileName:=MasterDocumentPath)\n\n TheDocumentPath = Dir(AllDocumentsPath , vbNormal)\n While TheDocumentPath <> \"\"\n ' Append the next doc to the end of the master doc. (The \n ' special \"\\EndOfDoc\" bookmark is always available!)\n MasterDocument.Bookmarks(\"\\EndOfDoc\").Range.InsertFile TheDocumentPath\n TheDocumentPath = Dir\n Wend\n\n MasterDocument.Save\nEnd Sub\n\nMergeAllDocuments \"C:\\MySeparateDocuments\\*.doc\", \"C:\\MasterDocument.doc\"\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1233512/"
] |
277,437
|
<p>This has got to be something simple: I set up a frames page with two possible sources for the target frame based on a form with two options. I used the OnClick event to trap the user's click to show the appropriate page. It works fine in Internet Explorer 7, swapping the two source pages. FireFox 3 and Chrome show only the default source.</p>
<p>HEAD Script section:</p>
<pre><code>function SwapInlineFrameSource()
{
var rsRadio, rsiFrame;
rsRadio=document.getElementById('County');
rsiFrame=document.getElementById('RatesFrame')
if (rsRadio.checked===true) {
rsiFrame.src="SantaCruzRates.htm";
}
else {
rsiFrame.src="DelNorteRates.htm";
}
}
</code></pre>
<p>BODY Form section (commented to show up here):</p>
<pre><code><input type="radio" value="SC" checked name="County" onclick="SwapInlineFrameSource()">
Santa Cruz
<input type="radio" value="DN" name="County" onclick="SwapInlineFrameSource()" >
Del Norte
</code></pre>
<p>What am I missing? (Live example: <a href="http://www.raintrees.com/rates.html" rel="nofollow noreferrer">http://www.raintrees.com/rates.html</a>)</p>
<p>Thanks!</p>
<p>mr</p>
|
[
{
"answer_id": 277456,
"author": "James Hughes",
"author_id": 34671,
"author_profile": "https://Stackoverflow.com/users/34671",
"pm_score": 2,
"selected": false,
"text": "var rsRadio, rsiFrame;\nrsRadio=document.getElementById('County');\nrsiFrame=document.getElementById('RatesFrame')\nif (rsRadio.checked===true) {\n if(document.getElementsByName()[0].checked){\n // show Santa Cruz Rates\n}else{\n // show other rates\n}\n"
},
{
"answer_id": 277458,
"author": "OJ.",
"author_id": 611,
"author_profile": "https://Stackoverflow.com/users/611",
"pm_score": 4,
"selected": true,
"text": "function SwapInlineFrameSource(rdoButton)\n{\n rsiFrame = document.getElementById(\"RatesFrame\");\n rsiFrame.src = rdoButton.value;\n}\n\n<input type=\"radio\" value=\"SantaCruzRates.htm\" checked=\"checked\" name=\"County\" onClick=\"SwapInlineFrameSource(this);\">Santa Cruz</input>\n<input type=\"radio\" value=\"DelNorteRates.htm\" name=\"County\" onClick=\"SwapInlineFrameSource(this);\">Del Norte</input>\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277437",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3125/"
] |
277,469
|
<p>Right, in short we basically already have a system in place where the HTML content for emails is generated. It's not perfect, but it works.</p>
<p>From this, we need to be able to derive a plaintext alternative for the email. I was thinking of instantly jumping on and creating a RegEx to strip the <code><*></code> tags from the message - but then I realised <strong>this would be no good because we do need some of the formatting information (paragraphs, line breaks, images etc).</strong></p>
<p><strong>NOTE:</strong> I am OK with actually sending the mail and setting up alternative views etc, this is <strong>only about getting plaintext from HTML.</strong></p>
<p>So, I am pondering some ideas. Will post one as an answer to see what you guys think, but thought I would open it up to the floor. :)</p>
<p>If you need any more clarification then please shout.</p>
<p>Many thanks,</p>
<p>Rob</p>
|
[
{
"answer_id": 277839,
"author": "Rob Cooper",
"author_id": 832,
"author_profile": "https://Stackoverflow.com/users/832",
"pm_score": 2,
"selected": true,
"text": "SendMail(\"PageX.aspx\") Page_Load SendMail type=html type=text"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] |
277,482
|
<p>This has just come up as a question where I worked so I did a little digging and the answer is a ExpertsExchange one. So I hand you over to the original question asker, Manchung:</p>
<blockquote>
<p>I have a project written in pure C which is to be used in embedded system. So, I use pure C to minimize the code size.</p>
<p>When I compile the project, I use the -ansi flag in order to make sure the code complies with the ANSI standard. However, the down side of using this ansi flag is that I am only allowed to use C styled comments (/*comments */). This is giving me a headache when I need to use nested comments.</p>
<p>So, my question is: what switches/flags can I use to allow me to use C++ styled comments (// comments) while keeping the ANSI checking enabled at the same time?</p>
</blockquote>
<p>Which pretty much sums my question up too.</p>
|
[
{
"answer_id": 277497,
"author": "philant",
"author_id": 18804,
"author_profile": "https://Stackoverflow.com/users/18804",
"pm_score": 4,
"selected": false,
"text": "gcc -Wp,-lang-c-c++-comments -c source.c\n"
},
{
"answer_id": 277549,
"author": "CesarB",
"author_id": 28258,
"author_profile": "https://Stackoverflow.com/users/28258",
"pm_score": 5,
"selected": false,
"text": "-ansi -std=c89 -std=c99 -std=gnu89 -std=c89 -pedantic"
},
{
"answer_id": 277562,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": false,
"text": "#if 0\n... code ...\n#endif\n"
},
{
"answer_id": 3308488,
"author": "Nordic Mainframe",
"author_id": 385433,
"author_profile": "https://Stackoverflow.com/users/385433",
"pm_score": 2,
"selected": false,
"text": "-ansi SRC=main.c blip.c blip.h\ncp makefile ansi-src/\nfor F in $SRC do\n# does not handle // in string literals or /**/ comments!\nsed 's/\\/\\/.*//g' < $F >ansi-src/$F\ndone\ncd ansi-src\nmake CFLAGS=-ansi\n"
},
{
"answer_id": 3338668,
"author": "bta",
"author_id": 79566,
"author_profile": "https://Stackoverflow.com/users/79566",
"pm_score": 0,
"selected": false,
"text": "-ansi -std=c89 -std=c99"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/342/"
] |
277,485
|
<p>In Python, if I do this:</p>
<pre><code>print "4" * 4
</code></pre>
<p>I get</p>
<pre><code>> "4444"
</code></pre>
<p>In Perl, I'd get</p>
<pre><code>> 16
</code></pre>
<p>Is there an easy way to do the former in Perl?</p>
|
[
{
"answer_id": 277489,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 8,
"selected": true,
"text": "$ perl -e 'print \"4\" x 4; print \"\\n\"'\n4444\n qw/STRING/ print '-' x 80; # Print row of dashes\n\n print \"\\t\" x ($tab/8), ' ' x ($tab%8); # Tab over\n\n @ones = (1) x 80; # A list of 80 1’s\n @ones = (5) x @ones; # Set all elements to 5\n perl -e"
},
{
"answer_id": 277496,
"author": "The Archetypal Paul",
"author_id": 21755,
"author_profile": "https://Stackoverflow.com/users/21755",
"pm_score": 4,
"selected": false,
"text": "print \"4\" x 4;\n"
},
{
"answer_id": 277662,
"author": "bart",
"author_id": 19966,
"author_profile": "https://Stackoverflow.com/users/19966",
"pm_score": 6,
"selected": false,
"text": "\"4\" x 4\n (\"4\") x 4\n \"4444\"\n (\"4\", \"4\", \"4\", \"4\")\n"
},
{
"answer_id": 277831,
"author": "Aristotle Pagaltzis",
"author_id": 9410,
"author_profile": "https://Stackoverflow.com/users/9410",
"pm_score": 4,
"selected": false,
"text": "print 4 x 4"
},
{
"answer_id": 30100928,
"author": "Wolf",
"author_id": 2932052,
"author_profile": "https://Stackoverflow.com/users/2932052",
"pm_score": 2,
"selected": false,
"text": "x use feature 'say';\n\nmy $msg = \"hello \";\nsay $msg x 2;\nsay chr(33) x 3;\n hello hello\n!!!\n x say 4 x 2;\nsay [$msg] x 2;\n 44\nARRAY(0x30ca10)ARRAY(0x30ca10)\n"
},
{
"answer_id": 44756518,
"author": "Charlotte Russell",
"author_id": 7949710,
"author_profile": "https://Stackoverflow.com/users/7949710",
"pm_score": 2,
"selected": false,
"text": "perl -e 'print \"A\" x 10'; echo\n user@linux:~$ perl -e 'print \"A\" x 10'; echo\nAAAAAAAAAA\nuser@linux:~$ \n"
},
{
"answer_id": 74252643,
"author": "Clarius",
"author_id": 4470510,
"author_profile": "https://Stackoverflow.com/users/4470510",
"pm_score": 0,
"selected": false,
"text": "$table = \"ORDERS\";\n\n@fields = (\"ORDER_ID\", \"SALESMAN_ID\", \"CUSTOMER_ID\", \"ORDER_DATE\", \"STATUS\");\n\n$sql = \"INSERT INTO $table (\" . join(',', @fields) . ') VALUES (' . '?,' x (@fields - 1) . '?)';\n\nprint $sql;\n INSERT INTO ORDERS (ORDER_ID,SALESMAN_ID,CUSTOMER_ID,ORDER_DATE,STATUS) VALUES (?,?,?,?,?)\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/974/"
] |
277,492
|
<p>In a database, I have a string that contains "default" written in it. I just want to replace that default with 0. I have something like: </p>
<pre><code>select * from tblname where test = 'default'
</code></pre>
<p>I do not want quotes in the replacement for "default".</p>
<p>I want </p>
<pre><code>select * from tblname where test = 0
</code></pre>
<p>is there any way to do this?</p>
|
[
{
"answer_id": 277503,
"author": "Dave Anderson",
"author_id": 371,
"author_profile": "https://Stackoverflow.com/users/371",
"pm_score": 0,
"selected": false,
"text": "string myVar = \"0\";\nstring sql = String.Format(@\"select * from tblname where test = \\\"{0}\\\"\", myVar);\n"
},
{
"answer_id": 277507,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "test UPDATE tblname SET test = '0' WHERE test = 'default'\n SELECT * FROM tblname WHERE test = '0'\n"
},
{
"answer_id": 277535,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "'default' @p1 -- TSQL\nREPLACE(@cmd, '''default''', '@p1')\n // C#\n.Replace(@\"'default'\", @\"@p1\")\n DbCommand sp_ExecuteSQL select * from tblname where test = @p1\n DbParameter param = cmd.CreateParameter();\nparam.Value = 0; // etc\ncmd.Parameters.Add(param);\n EXEC sp_ExecuteSQL @cmd, N'@p1 varchar(50)', 0\n varchar(50)"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277492",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
277,494
|
<p>I am trying to let a piece of runtime state decide WHICH implementation of an interface to use, preferably solely by autowiring. </p>
<p>I have tried making an object factory for the interface thet uses dynamic proxies, and I used qualifiers to coerce the @Autowired injections to use the factory. The qualifiers are necessary because both the factory and the implementations respond to the same interface.</p>
<p>The problem with this is that I end up annotating every @Autowired reference with the @Qualifier. What I'd really want to do is annotate the non-factory implementations with something like @NotCandidateForAutowiringByInterface (my fantasy annotation), or even better make spring prefer the single un-qualified bean when injecting to an un-qualified field </p>
<p>I may thinking along the totally wrong lines here, so alternate suggestions are welcome.
Anyone know how to make this happen ?</p>
|
[
{
"answer_id": 277503,
"author": "Dave Anderson",
"author_id": 371,
"author_profile": "https://Stackoverflow.com/users/371",
"pm_score": 0,
"selected": false,
"text": "string myVar = \"0\";\nstring sql = String.Format(@\"select * from tblname where test = \\\"{0}\\\"\", myVar);\n"
},
{
"answer_id": 277507,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 2,
"selected": false,
"text": "test UPDATE tblname SET test = '0' WHERE test = 'default'\n SELECT * FROM tblname WHERE test = '0'\n"
},
{
"answer_id": 277535,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 0,
"selected": false,
"text": "'default' @p1 -- TSQL\nREPLACE(@cmd, '''default''', '@p1')\n // C#\n.Replace(@\"'default'\", @\"@p1\")\n DbCommand sp_ExecuteSQL select * from tblname where test = @p1\n DbParameter param = cmd.CreateParameter();\nparam.Value = 0; // etc\ncmd.Parameters.Add(param);\n EXEC sp_ExecuteSQL @cmd, N'@p1 varchar(50)', 0\n varchar(50)"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277494",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23691/"
] |
277,502
|
<p>My schema specifies a namespace, but the documents don't. What's the simplest way to ignore namespace during JAXB unmarshalling (XML -> object)?</p>
<p>In other words, I have</p>
<pre><code><foo><bar></bar></foo>
</code></pre>
<p>instead of,</p>
<pre><code><foo xmlns="http://tempuri.org/"><bar></bar></foo>
</code></pre>
|
[
{
"answer_id": 277512,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 5,
"selected": true,
"text": "public static Object unmarshallWithFilter(Unmarshaller unmarshaller,\njava.io.File source) throws FileNotFoundException, JAXBException \n{\n FileReader fr = null;\n try {\n fr = new FileReader(source);\n XMLReader reader = new NamespaceFilterXMLReader();\n InputSource is = new InputSource(fr);\n SAXSource ss = new SAXSource(reader, is);\n return unmarshaller.unmarshal(ss);\n } catch (SAXException e) {\n //not technically a jaxb exception, but close enough\n throw new JAXBException(e);\n } catch (ParserConfigurationException e) {\n //not technically a jaxb exception, but close enough\n throw new JAXBException(e);\n } finally {\n FileUtil.close(fr); //replace with this some safe close method you have\n }\n}\n"
},
{
"answer_id": 326140,
"author": "mafro",
"author_id": 1562,
"author_profile": "https://Stackoverflow.com/users/1562",
"pm_score": 1,
"selected": false,
"text": "public class XMLObjectFactory {\n private static Namespace DEFAULT_NS = Namespace.getNamespace(\"http://tempuri.org/\");\n\n public static Object createObject(InputStream in) {\n try {\n SAXBuilder sb = new SAXBuilder(false);\n Document doc = sb.build(in);\n setNamespace(doc.getRootElement(), DEFAULT_NS, true);\n Source src = new JDOMSource(doc);\n JAXBContext context = JAXBContext.newInstance(\"org.tempuri\");\n Unmarshaller unmarshaller = context.createUnmarshaller();\n JAXBElement root = unmarshaller.unmarshal(src);\n return root.getValue();\n } catch (Exception e) {\n throw new RuntimeException(\"Failed to create Object\", e);\n }\n }\n\n private static void setNamespace(Element elem, Namespace ns, boolean recurse) {\n elem.setNamespace(ns);\n if (recurse) {\n for (Object o : elem.getChildren()) {\n setNamespace((Element) o, ns, recurse);\n }\n }\n }\n"
},
{
"answer_id": 2148541,
"author": "Kristofer",
"author_id": 259485,
"author_profile": "https://Stackoverflow.com/users/259485",
"pm_score": 7,
"selected": false,
"text": "import org.xml.sax.Attributes;\nimport org.xml.sax.SAXException;\n\nimport org.xml.sax.helpers.XMLFilterImpl;\n\npublic class NamespaceFilter extends XMLFilterImpl {\n\n private String usedNamespaceUri;\n private boolean addNamespace;\n\n //State variable\n private boolean addedNamespace = false;\n\n public NamespaceFilter(String namespaceUri,\n boolean addNamespace) {\n super();\n\n if (addNamespace)\n this.usedNamespaceUri = namespaceUri;\n else \n this.usedNamespaceUri = \"\";\n this.addNamespace = addNamespace;\n }\n\n\n\n @Override\n public void startDocument() throws SAXException {\n super.startDocument();\n if (addNamespace) {\n startControlledPrefixMapping();\n }\n }\n\n\n\n @Override\n public void startElement(String arg0, String arg1, String arg2,\n Attributes arg3) throws SAXException {\n\n super.startElement(this.usedNamespaceUri, arg1, arg2, arg3);\n }\n\n @Override\n public void endElement(String arg0, String arg1, String arg2)\n throws SAXException {\n\n super.endElement(this.usedNamespaceUri, arg1, arg2);\n }\n\n @Override\n public void startPrefixMapping(String prefix, String url)\n throws SAXException {\n\n\n if (addNamespace) {\n this.startControlledPrefixMapping();\n } else {\n //Remove the namespace, i.e. don´t call startPrefixMapping for parent!\n }\n\n }\n\n private void startControlledPrefixMapping() throws SAXException {\n\n if (this.addNamespace && !this.addedNamespace) {\n //We should add namespace since it is set and has not yet been done.\n super.startPrefixMapping(\"\", this.usedNamespaceUri);\n\n //Make sure we dont do it twice\n this.addedNamespace = true;\n }\n }\n\n}\n new NamespaceFilter(\"http://www.example.com/namespaceurl\", true);\n new NamespaceFilter(null, false);\n //Prepare JAXB objects\nJAXBContext jc = JAXBContext.newInstance(\"jaxb.package\");\nUnmarshaller u = jc.createUnmarshaller();\n\n//Create an XMLReader to use with our filter\nXMLReader reader = XMLReaderFactory.createXMLReader();\n\n//Create the filter (to add namespace) and set the xmlReader as its parent.\nNamespaceFilter inFilter = new NamespaceFilter(\"http://www.example.com/namespaceurl\", true);\ninFilter.setParent(reader);\n\n//Prepare the input, in this case a java.io.File (output)\nInputSource is = new InputSource(new FileInputStream(output));\n\n//Create a SAXSource specifying the filter\nSAXSource source = new SAXSource(inFilter, is);\n\n//Do unmarshalling\nObject myJaxbObject = u.unmarshal(source);\n //Prepare JAXB objects\nJAXBContext jc = JAXBContext.newInstance(\"jaxb.package\");\nMarshaller m = jc.createMarshaller();\n\n//Define an output file\nFile output = new File(\"test.xml\");\n\n//Create a filter that will remove the xmlns attribute \nNamespaceFilter outFilter = new NamespaceFilter(null, false);\n\n//Do some formatting, this is obviously optional and may effect performance\nOutputFormat format = new OutputFormat();\nformat.setIndent(true);\nformat.setNewlines(true);\n\n//Create a new org.dom4j.io.XMLWriter that will serve as the \n//ContentHandler for our filter.\nXMLWriter writer = new XMLWriter(new FileOutputStream(output), format);\n\n//Attach the writer to the filter \noutFilter.setContentHandler(writer);\n\n//Tell JAXB to marshall to the filter which in turn will call the writer\nm.marshal(myJaxbObject, outFilter);\n"
},
{
"answer_id": 13762119,
"author": "Henrique",
"author_id": 1620589,
"author_profile": "https://Stackoverflow.com/users/1620589",
"pm_score": 2,
"selected": false,
"text": " import javax.xml.namespace.QName;\n import org.xml.sax.Attributes;\n import org.xml.sax.ContentHandler;\n import org.xml.sax.SAXException;\n import org.xml.sax.helpers.XMLFilterImpl;\n import com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector;\n\n public class NamespaceFilter extends XMLFilterImpl {\n private SAXConnector saxConnector;\n\n @Override\n public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {\n if(saxConnector != null) {\n Collection<QName> expected = saxConnector.getContext().getCurrentExpectedElements();\n for(QName expectedQname : expected) {\n if(localName.equals(expectedQname.getLocalPart())) {\n super.startElement(expectedQname.getNamespaceURI(), localName, qName, atts);\n return;\n }\n }\n }\n super.startElement(uri, localName, qName, atts);\n }\n\n @Override\n public void setContentHandler(ContentHandler handler) {\n super.setContentHandler(handler);\n if(handler instanceof SAXConnector) {\n saxConnector = (SAXConnector) handler;\n }\n }\n}\n"
},
{
"answer_id": 24387115,
"author": "lunicon",
"author_id": 602719,
"author_profile": "https://Stackoverflow.com/users/602719",
"pm_score": 5,
"selected": false,
"text": "class XMLReaderWithoutNamespace extends StreamReaderDelegate {\n public XMLReaderWithoutNamespace(XMLStreamReader reader) {\n super(reader);\n }\n @Override\n public String getAttributeNamespace(int arg0) {\n return \"\";\n }\n @Override\n public String getNamespaceURI() {\n return \"\";\n }\n}\n\nInputStream is = new FileInputStream(name);\nXMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(is);\nXMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);\nUnmarshaller um = jc.createUnmarshaller();\nObject res = um.unmarshal(xr);\n"
},
{
"answer_id": 64441436,
"author": "tomorrow",
"author_id": 3519572,
"author_profile": "https://Stackoverflow.com/users/3519572",
"pm_score": 0,
"selected": false,
"text": "public class XMLReaderWithNamespaceCorrection extends StreamReaderDelegate {\n\n private final String wrongNamespace;\n private final String correctNamespace;\n\n public XMLReaderWithNamespaceCorrection(XMLStreamReader reader, String wrongNamespace, String correctNamespace) {\n super(reader);\n\n this.wrongNamespace = wrongNamespace;\n this.correctNamespace = correctNamespace;\n }\n\n @Override\n public String getAttributeNamespace(int arg0) {\n// System.out.println(\"--------------------------\\n\");\n// System.out.println(\"arg0: \" + arg0);\n// System.out.println(\"getAttributeName: \" + getAttributeName(arg0));\n// System.out.println(\"super.getAttributeNamespace: \" + super.getAttributeNamespace(arg0));\n// System.out.println(\"getAttributeLocalName: \" + getAttributeLocalName(arg0));\n// System.out.println(\"getAttributeType: \" + getAttributeType(arg0));\n// System.out.println(\"getAttributeValue: \" + getAttributeValue(arg0));\n// System.out.println(\"getAttributeValue(correctNamespace, LN):\"\n// + getAttributeValue(correctNamespace, getAttributeLocalName(arg0)));\n// System.out.println(\"getAttributeValue(wrongNamespace, LN):\"\n// + getAttributeValue(wrongNamespace, getAttributeLocalName(arg0)));\n\n String origNamespace = super.getAttributeNamespace(arg0);\n\n boolean replace = (((wrongNamespace == null) && (origNamespace == null))\n || ((wrongNamespace != null) && wrongNamespace.equals(origNamespace)));\n return replace ? correctNamespace : origNamespace;\n }\n\n @Override\n public String getNamespaceURI() {\n// System.out.println(\"getNamespaceCount(): \" + getNamespaceCount());\n// for (int i = 0; i < getNamespaceCount(); i++) {\n// System.out.println(i + \": \" + getNamespacePrefix(i));\n// }\n//\n// System.out.println(\"super.getNamespaceURI: \" + super.getNamespaceURI());\n\n String origNamespace = super.getNamespaceURI();\n\n boolean replace = (((wrongNamespace == null) && (origNamespace == null))\n || ((wrongNamespace != null) && wrongNamespace.equals(origNamespace)));\n return replace ? correctNamespace : origNamespace;\n }\n}\n InputStream is = new FileInputStream(xmlFile);\nXMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(is);\nXMLReaderWithNamespaceCorrection xr =\n new XMLReaderWithNamespaceCorrection(xsr, \"http://wrong.namespace.uri\", \"http://correct.namespace.uri\");\nrootJaxbElem = (JAXBElement<SqgRootType>) um.unmarshal(xr);\nhandleSchemaError(rootJaxbElem, pmRes);\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3827/"
] |
277,514
|
<p>I've been thinking of rolling my own code for enabling my Delphi application to update seamlessly as I'll be going for "release often, release early" mentality furthermore. There are various Delphi solutions (both freeware and paid) out there and I'd like to ask if you've been using any of them or simply went on with your own solutions in this area. Any comments on the auto-update topic are welcome.</p>
|
[
{
"answer_id": 3482492,
"author": "BlackOut",
"author_id": 404809,
"author_profile": "https://Stackoverflow.com/users/404809",
"pm_score": 2,
"selected": false,
"text": "[Dirs]\nName: \"{app}\"; Permissions: users-modify\n [Files]\nSource: \"C:\\Your Project\\YourApp.exe\"; DestDir: \"{commonappdata}\\Company Name\\App Name\\\"; \n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277514",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14716/"
] |
277,521
|
<p>How do you identify the file content as being in ASCII or binary using C++?</p>
|
[
{
"answer_id": 277538,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": false,
"text": "<= 127 int c;\nstd::ifstream a(\"file.txt\");\nwhile((c = a.get()) != EOF && c <= 127) \n ;\nif(c == EOF) {\n /* file is all ASCII */\n}\n"
},
{
"answer_id": 277568,
"author": "Daniel Cassidy",
"author_id": 31662,
"author_profile": "https://Stackoverflow.com/users/31662",
"pm_score": 6,
"selected": false,
"text": "FE FF FF FE 00 00 00 00 FE FF FF FE 00 00"
},
{
"answer_id": 277600,
"author": "MSalters",
"author_id": 15416,
"author_profile": "https://Stackoverflow.com/users/15416",
"pm_score": 1,
"selected": false,
"text": "const unsigned char ASCII_A = 0x41; // NOT 'A'\nconst unsigned char ASCII_Z = ASCII_A + 25;\n"
},
{
"answer_id": 68585170,
"author": "Marck",
"author_id": 16558477,
"author_profile": "https://Stackoverflow.com/users/16558477",
"pm_score": -1,
"selected": false,
"text": "bool checkFileASCIIFormat(std::string fileName)\n{\n bool ascii = true;\n std::ifstream read(fileName);\n int line;\n while ((ascii) && (!read.eof())) {\n line = read.get();\n if (line > 127) {\n //ASCII codes only go up to 127\n ascii = false;\n }\n }\n\n return ascii;\n}\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
277,529
|
<p>I’m currently using the OpenNETCF.Desktop.Communication.dll to copy files from my desktop to a CE device, but I keep getting an error:</p>
<p>‘Could not create remote file’ </p>
<p>My development environment is VS2005 (VB.NET)</p>
<p>My code:</p>
<pre><code>ObjRapi.Connect()
ObjRapi.CopyFileToDevice("C:\results.txt", "\results.txt")
ObjRapi.Dispose()
ObjRapi.Disconnect()
</code></pre>
<p>Has anyone run into this and did you manage to get around it. </p>
<p>Thanks</p>
|
[
{
"answer_id": 277548,
"author": "Nathan W",
"author_id": 6335,
"author_profile": "https://Stackoverflow.com/users/6335",
"pm_score": 2,
"selected": true,
"text": "ObjRapi.CopyFileToDevice(\"C:\\results.txt\", \"\\ \\results.txt\") \n ObjRapi.CopyFileToDevice(\"C:\\results.txt\", \"\\My Documents\\results.txt\")\n ObjRapi.CopyFileToDevice(\"C:\\results.txt\", \"\\My Documents\\results.txt\",True)\n"
},
{
"answer_id": 313401,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": " If myrapi.DevicePresent = True Then\n myrapi.Connect()\n\n If myrapi.Connected = True Then\n Windows.Forms.Cursor.Current = Cursors.WaitCursor\n If myrapi.DeviceFileExists(\"\\Backup\\stock.txt\") Then\n myrapi.CopyFileFromDevice(Application.StartupPath \n\n Windows.Forms.Cursor.Current = Cursors.Default\n MessageBox.Show(\"File Copied Successfully\", \"Success\", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)\n\n Else\n MessageBox.Show(\"Please Connect to the Mobile Device\", \"Connection Failed\", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)\n End If\n\n Else\n MessageBox.Show(\"Please Connect to the Mobile Device\", \"Connection Failed\", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1)\n End If\n\n Catch ex As Exception\n MsgBox(ex.Message)\n End Try\n"
},
{
"answer_id": 2498533,
"author": "Suraj Namdeo",
"author_id": 299733,
"author_profile": "https://Stackoverflow.com/users/299733",
"pm_score": -1,
"selected": false,
"text": "op.CopyFileToDevice(@\"C:\\results.txt\", @\"\\Temp\\results.txt\");\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1731/"
] |
277,540
|
<p>On our build server, we've installed the .NET Framework 2.0 SDK in order to kick off MSBuild and run our builds. Now we are upgrading to the .NET Framework 3.5. We do not want to install the complete Visual Studio, but we cannot find a .NET Framework 3.5 SDK on the internet either?</p>
<p>The question: What do we need ot download and install to get the equivalent of a .NET Framework 3.5 SDK installation?</p>
|
[
{
"answer_id": 277563,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 3,
"selected": true,
"text": ".targets"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277540",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2822/"
] |
277,544
|
<p>Is there a simple way to <strong>set the focus</strong> (input cursor) of a web page <strong>on the first input element</strong> (textbox, dropdownlist, ...) on loading the page without having to know the id of the element?</p>
<p>I would like to implement it as a common script for all my pages/forms of my web application.</p>
|
[
{
"answer_id": 277561,
"author": "bobince",
"author_id": 18936,
"author_profile": "https://Stackoverflow.com/users/18936",
"pm_score": 5,
"selected": false,
"text": "document.forms[0].elements[0].focus();\n"
},
{
"answer_id": 277615,
"author": "Marko Dumic",
"author_id": 5817,
"author_profile": "https://Stackoverflow.com/users/5817",
"pm_score": 3,
"selected": false,
"text": "for (var i = 0; document.forms[0].elements[i].type == 'hidden'; i++);\ndocument.forms[0].elements[i].focus();\n"
},
{
"answer_id": 277642,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 3,
"selected": false,
"text": "Form.focusFirstElement(document.forms[0]);\n"
},
{
"answer_id": 277802,
"author": "James Hughes",
"author_id": 34671,
"author_profile": "https://Stackoverflow.com/users/34671",
"pm_score": 2,
"selected": false,
"text": "body <script>\n (function(){\n var forms = document.forms || [];\n for(var i = 0; i < forms.length; i++){\n for(var j = 0; j < forms[i].length; j++){\n if(!forms[i][j].readonly != undefined && forms[i][j].type != \"hidden\" && forms[i][j].disabled != true && forms[i][j].style.display != 'none'){\n forms[i][j].focus();\n return;\n }\n }\n }\n })();\n</script>\n"
},
{
"answer_id": 279153,
"author": "Marko Dumic",
"author_id": 5817,
"author_profile": "https://Stackoverflow.com/users/5817",
"pm_score": 8,
"selected": true,
"text": "$(document).ready(function() {\n $('form:first *:input[type!=hidden]:first').focus();\n});\n"
},
{
"answer_id": 2744824,
"author": "ngeek",
"author_id": 267001,
"author_profile": "https://Stackoverflow.com/users/267001",
"pm_score": 4,
"selected": false,
"text": "$(document).ready(function() {\n $('input:visible:enabled:first').focus();\n});\n"
},
{
"answer_id": 6446374,
"author": "Jacob Stanley",
"author_id": 72821,
"author_profile": "https://Stackoverflow.com/users/72821",
"pm_score": 7,
"selected": false,
"text": "<form>\n <input type=\"text\" name=\"username\" autofocus>\n <input type=\"password\" name=\"password\">\n <input type=\"submit\" value=\"Login\">\n</form>\n"
},
{
"answer_id": 13022713,
"author": "Dave K",
"author_id": 172278,
"author_profile": "https://Stackoverflow.com/users/172278",
"pm_score": 2,
"selected": false,
"text": "$(\"input:visible:enabled:not([readonly]),textarea:visible:enabled:not([readonly]),select:visible:enabled:not([readonly])\", \n target).first().focus();\n"
},
{
"answer_id": 14515475,
"author": "Max West",
"author_id": 1441180,
"author_profile": "https://Stackoverflow.com/users/1441180",
"pm_score": 2,
"selected": false,
"text": "$(\"input:text:visible:first\").focus();\n"
},
{
"answer_id": 18348284,
"author": "Robert Brooker",
"author_id": 654654,
"author_profile": "https://Stackoverflow.com/users/654654",
"pm_score": 2,
"selected": false,
"text": "$(\"form:first *:input,select,textarea\").filter(\":not([readonly='readonly']):not([disabled='disabled']):not([type='hidden'])\").first().focus();\n"
},
{
"answer_id": 23541183,
"author": "EpokK",
"author_id": 1875004,
"author_profile": "https://Stackoverflow.com/users/1875004",
"pm_score": 0,
"selected": false,
"text": "AngularJS angular.element('#Element')[0].focus();\n"
},
{
"answer_id": 23993495,
"author": "HectorPerez",
"author_id": 2140139,
"author_profile": "https://Stackoverflow.com/users/2140139",
"pm_score": 0,
"selected": false,
"text": "$(document).ready(function() {\n var first_input = $('input[type=text]:visible:enabled:first, textarea:visible:enabled:first')[0];\n if(first_input != undefined){ first_input.focus(); }\n});\n"
},
{
"answer_id": 26459634,
"author": "feder",
"author_id": 2815264,
"author_profile": "https://Stackoverflow.com/users/2815264",
"pm_score": 1,
"selected": false,
"text": " p:autofocus=\"true\"\n <html ... xmlns:p=\"http://java.sun.com/jsf/passthrough\">\n"
},
{
"answer_id": 47677689,
"author": "thecoolmacdude",
"author_id": 1410728,
"author_profile": "https://Stackoverflow.com/users/1410728",
"pm_score": 0,
"selected": false,
"text": "function setFocus() {\n var forms = document.forms || [];\n for (var i = 0; i < forms.length; i++) {\n for (var j = 0; j < forms[i].length; j++) {\n var widget = forms[i][j];\n if ((widget && widget.domNode && widget.domNode.clientHeight > 0) && typeof widget.focus === \"function\")\n && (typeof widget.disabled === \"undefined\" || widget.disabled === false)\n && (typeof widget.readOnly === \"undefined\" || widget.readOnly === false)) {\n widget.focus();\n break;\n }\n }\n }\n } \n}\n"
},
{
"answer_id": 54752436,
"author": "cghislai",
"author_id": 3074381,
"author_profile": "https://Stackoverflow.com/users/3074381",
"pm_score": 0,
"selected": false,
"text": " const inputElements = parentElement.getElementsByTagName('input')\n if (inputChilds.length > 0) {\n inputChilds.item(0).focus();\n }\n"
},
{
"answer_id": 55761872,
"author": "localhostdotdev",
"author_id": 10993539,
"author_profile": "https://Stackoverflow.com/users/10993539",
"pm_score": 1,
"selected": false,
"text": "document.querySelector('form input:not([type=hidden])').focus()\n"
},
{
"answer_id": 65936624,
"author": "Scott Means",
"author_id": 149407,
"author_profile": "https://Stackoverflow.com/users/149407",
"pm_score": 4,
"selected": false,
"text": "autofocus display autofocus form.querySelector('*[autofocus]').focus();\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6461/"
] |
277,546
|
<p>Just say I have a file: "HelloWorld.pm" in multiple subdirectories within a Git repository.</p>
<p>I would like to issue a command to find the full paths of all the files matching "HelloWorld.pm":</p>
<p>For example:</p>
<pre><code>/path/to/repository/HelloWorld.pm
/path/to/repository/but/much/deeper/down/HelloWorld.pm
/path/to/repository/please/dont/make/me/search/through/the/lot/HelloWorld.pm
</code></pre>
<p>How can I use Git to efficiently find all the full paths that match a given filename?</p>
<p>I realise I can do this with the Linux/Unix find command but I was hoping to avoid scanning all subdirectories looking for instances of the filename.</p>
|
[
{
"answer_id": 277557,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 5,
"selected": false,
"text": "git ls-tree -r HEAD | grep HelloWorld.pm\n"
},
{
"answer_id": 5681657,
"author": "Brian Campbell",
"author_id": 69755,
"author_profile": "https://Stackoverflow.com/users/69755",
"pm_score": 7,
"selected": false,
"text": "git ls-files git ls-files HelloWorld.pm '**/HelloWorld.pm'\n git grep git grep some-string -- HelloWorld.pm '**/HelloWorld.pm'\n"
},
{
"answer_id": 6960138,
"author": "Uwe Geuder",
"author_id": 880945,
"author_profile": "https://Stackoverflow.com/users/880945",
"pm_score": 6,
"selected": false,
"text": "#! /bin/sh\ntmpdir=$(mktemp -td git-find.XXXX)\ntrap \"rm -r $tmpdir\" EXIT INT TERM\n\nallrevs=$(git rev-list --all)\n# well, nearly all revs, we could still check the log if we have\n# dangling commits and we could include the index to be perfect...\n\nfor rev in $allrevs\ndo\n git ls-tree --full-tree -r $rev >$tmpdir/$rev \ndone\n\ncd $tmpdir\ngrep $1 * \n"
},
{
"answer_id": 16492352,
"author": "Dean Hall",
"author_id": 299525,
"author_profile": "https://Stackoverflow.com/users/299525",
"pm_score": 2,
"selected": false,
"text": "#!/bin/bash\n#\n#\n\n# I'm using a fixed string here, not a regular expression, but you can easily\n# use a regular expression by altering the call to grep below.\nname=\"$1\"\n\n# Verify usage.\nif [[ -z \"$name\" ]]\nthen\n echo \"Usage: $(basename \"$0\") <file name>\" 1>&2\n exit 100\nfi \n\n# Search all revisions; get unique results.\nwhile IFS= read rev\ndo\n # Find $name in $rev's tree and only use its path.\n grep -F -- \"$name\" \\\n <(git ls-tree --full-tree -r \"$rev\" | awk '{ print $4 }')\ndone < \\\n <(git rev-list --all) \\\n | sort -u\n for item in \"${array[@]}\" while IFS= read var ; do ... ; done < <(command) read -d'' $'\\0' git rev-list --all git rev-list --all"
},
{
"answer_id": 24289481,
"author": "Bull",
"author_id": 1143433,
"author_profile": "https://Stackoverflow.com/users/1143433",
"pm_score": 3,
"selected": false,
"text": "git ls-files | grep -i HelloWorld.pm\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36142/"
] |
277,547
|
<p>Is it possible to skip a couple of characters in a capture group in regular expressions? I am using .NET regexes but that shouldn't matter.</p>
<p>Basically, what I am looking for is:</p>
<blockquote>
<p>[random text]AB-123[random text]</p>
</blockquote>
<p>and I need to capture 'AB123', without the hyphen.</p>
<p>I know that AB is 2 or 3 uppercase characters and 123 is 2 or 3 digits, but that's not the hard part. The hard part (at least for me) is skipping the hyphen.</p>
<p>I guess I could capture both separately and then concatenate them in code, but I wish I had a more elegant, regex-only solution.</p>
<p>Any suggestions?</p>
|
[
{
"answer_id": 277585,
"author": "Jeff Hillman",
"author_id": 3950,
"author_profile": "https://Stackoverflow.com/users/3950",
"pm_score": 4,
"selected": false,
"text": "match = Regex.Match( text, \"([A-B]{2,3})-([0-9]{2,3})\" );\nmatchedText = string.Format( \"{0}{1}\", \n match.Groups.Item(1).Value, \n match.Groups.Item(2).Value );\n match = Regex.Match( text, \"[A-B]{2,3}-[0-9]{2,3}\" );\nmatchedText = match.Value.Replace( \"-\", \"\" );\n"
},
{
"answer_id": 277609,
"author": "Kent Fredric",
"author_id": 15614,
"author_profile": "https://Stackoverflow.com/users/15614",
"pm_score": 2,
"selected": false,
"text": " function strip_reverse( $a )\n {\n $a = preg_replace(\"/-/\", \"\", $a );\n return reverse($a);\n }\n $b = preg_replace_callback( \"/(AB[-]?cde)/\" , 'strip_reverse' , \"Hello World AB-cde\" ; \n"
},
{
"answer_id": 33846614,
"author": "Steve",
"author_id": 5589812,
"author_profile": "https://Stackoverflow.com/users/5589812",
"pm_score": 2,
"selected": false,
"text": "((AB)-(123))\n AB-123 AB 123"
},
{
"answer_id": 48473847,
"author": "Logan9773",
"author_id": 8698370,
"author_profile": "https://Stackoverflow.com/users/8698370",
"pm_score": 0,
"selected": false,
"text": "(?i)English\\\\(?<Series>[^ ]+) - (?<Title>.+(?= #))(?<garb1>..)(?<Number>[^.]+)(?-i)\n F:\\Downloads\\Downloads\\500 Comics CCC CBR English\\Isukani - Great Girl #01.cbr\n"
},
{
"answer_id": 62495694,
"author": "rky",
"author_id": 13323137,
"author_profile": "https://Stackoverflow.com/users/13323137",
"pm_score": 0,
"selected": false,
"text": "| ((?<=[A-Z]{2}-)\\d\\d\\d)|([A-Z]{2}(?=-\\d\\d\\d))\n \\(\\([A-Z]\\{2}-\\)\\@<=\\d\\d\\d\\)\\|\\([A-Z]\\{2}\\(-\\d\\d\\d\\)\\@=\\)\n"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8954/"
] |
277,551
|
<p>It looks like all the methods for loading SQLite involve loading from a named file using a string. I would like to load SQlite database from memory.</p>
<p>The database is already loaded into memory.</p>
|
[
{
"answer_id": 277558,
"author": "Alex B",
"author_id": 23643,
"author_profile": "https://Stackoverflow.com/users/23643",
"pm_score": 5,
"selected": true,
"text": ":memory: sqlite3_open(\":memory:\", &db);\n libsqlite SQLITE_OMIT_MEMORYDB SQLITE_OMIT_MEMORYDB \":memory:\" \":memory:\" sqlite3_open() sqlite3_open16() sqlite3_open_v2() sqlite3_vfs sqlite3_io_methods"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277551",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35223/"
] |
277,552
|
<p>Outlook 2007 shows pictures of contacts on the right hand side of the mail form. This only works for your personal contacts and if you have photos.</p>
<p>Is there a way to hook that picture up to the GAL or AD for the company so that all employees photos show automatically? Hopefully without having to write and deploy a new msg form.</p>
|
[
{
"answer_id": 277622,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": false,
"text": "jpegPhoto jpegPhoto"
}
] |
2008/11/10
|
[
"https://Stackoverflow.com/questions/277552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.