qid
int64 4
19.1M
| question
stringlengths 18
48.3k
| answers
list | date
stringlengths 10
10
| metadata
list |
|---|---|---|---|---|
84,243
|
<p>I am developing a website that relies much on XML data. The web site has an interface where user can update data. The data provided by user will be updated to the respective XML file. However, the changes is not reflected until after 1 or 2 minutes.</p>
<p>Anyone knows how to force the browser to load the latest XML file immediately?</p>
|
[
{
"answer_id": 84351,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 2,
"selected": false,
"text": "Cache-Control: no-cache Pragma: no-cache"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
84,263
|
<p>I'm designing a web site navigation hierarchy. It's a tree of nodes.</p>
<p>Most nodes are pages. Some nodes are links (think shortcuts in Windows).</p>
<p>Most pages hold HTML content. Some execute code.</p>
<p>I'd like to represent these as this collection of classes and abstract (MustInherit) classes…</p>
<p><img src="https://i.stack.imgur.com/0gNAy.gif" alt="class diagram"></p>
<p>This is the database table where I'm going to store all this…</p>
<p><a href="http://img178.imageshack.us/img178/8573/nodetablefm8.gif" rel="nofollow noreferrer">database table http://img178.imageshack.us/img178/8573/nodetablefm8.gif</a></p>
<p>Here's where I'm stumped. PageNodes may or may not be roots.</p>
<p>How should I handle the root class?</p>
<p><img src="https://i.stack.imgur.com/1stKR.gif" alt="class diagram"></p>
<p>I don't want to have to have all four of…</p>
<ul>
<li>HtmlPageNode</li>
<li>CodePageNode</li>
<li>Html<strong>Root</strong>PageNode</li>
<li>Code<strong>Root</strong>PageNode</li>
</ul>
<p>I want the HtmlPageNode and CodePageNode classes to inherit <em>either</em> from PageNode or else from RootPageNode. Is that possible?</p>
<hr>
<p>Clarification: There are multiple root nodes and roots may have parent nodes. Each is the root of only a sub-tree that has distinct styling. Think of different, color-coded departments. (Perhaps root is a poor name choice. Suggestions?)</p>
<hr>
<p>Update: Regarding the "Root" name...<br>
I've asked: <a href="https://stackoverflow.com/questions/86790/is-there-a-specific-name-for-the-node-that-coresponds-to-a-subtree">Is there a specific name for the node that coresponds to a subtree?</a></p>
|
[
{
"answer_id": 84336,
"author": "Sunny Milenov",
"author_id": 8220,
"author_profile": "https://Stackoverflow.com/users/8220",
"pm_score": 1,
"selected": false,
"text": "class Node\n{\n private bool isRootNode;\n public bool IsRootNode;\n\n private StylingData stylingData;\n public StylingData StylingData\n {\n set\n {\n if (this.IsRootNode)\n this.stylingData = value;\n else\n throw new ApplicationException(\"The node is not root.\");\n }\n get\n {\n if (this.IsRootNode)\n return this.stylingData;\n else\n return this.parent.StylingData;\n }\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] |
84,278
|
<p>How do I use <code>RelativeSource</code> with WPF bindings and what are the different use-cases?</p>
|
[
{
"answer_id": 84314,
"author": "Bob King",
"author_id": 6897,
"author_profile": "https://Stackoverflow.com/users/6897",
"pm_score": 5,
"selected": false,
"text": "<Binding RelativeSource=\"{RelativeSource TemplatedParent}\"/>\n {Binding RelativeSource={RelativeSource TemplatedParent}}\n"
},
{
"answer_id": 84317,
"author": "Abe Heidebrecht",
"author_id": 9268,
"author_profile": "https://Stackoverflow.com/users/9268",
"pm_score": 11,
"selected": true,
"text": "{Binding Path=PathToProperty, RelativeSource={RelativeSource Self}}\n {Binding Path=PathToProperty,\n RelativeSource={RelativeSource AncestorType={x:Type typeOfAncestor}}}\n {Binding Path=PathToProperty, RelativeSource={RelativeSource TemplatedParent}}\n {TemplateBinding Path=PathToProperty}\n"
},
{
"answer_id": 605695,
"author": "Drew Noakes",
"author_id": 24874,
"author_profile": "https://Stackoverflow.com/users/24874",
"pm_score": 7,
"selected": false,
"text": "Binding RelativeSource={\n RelativeSource Mode=FindAncestor, AncestorType={x:Type ItemType}\n}\n...\n RelativeSource Mode"
},
{
"answer_id": 3547783,
"author": "Juve",
"author_id": 8986,
"author_profile": "https://Stackoverflow.com/users/8986",
"pm_score": 4,
"selected": false,
"text": "Binding ElementName"
},
{
"answer_id": 11833632,
"author": "Luis Perez",
"author_id": 984780,
"author_profile": "https://Stackoverflow.com/users/984780",
"pm_score": 4,
"selected": false,
"text": "{Binding Path=PathToProperty, RelativeSource={RelativeSource Self}}\n{Binding Path=PathToProperty, RelativeSource={RelativeSource AncestorType={x:Type typeOfAncestor}}}\n{Binding Path=PathToProperty, RelativeSource={RelativeSource TemplatedParent}}\n{Binding Path=Text, ElementName=MyTextBox}\n {BindTo PathToProperty}\n{BindTo Ancestor.typeOfAncestor.PathToProperty}\n{BindTo Template.PathToProperty}\n{BindTo #MyTextBox.Text}\n // C# code\nprivate ICommand _saveCommand;\npublic ICommand SaveCommand {\n get {\n if (_saveCommand == null) {\n _saveCommand = new RelayCommand(x => this.SaveObject());\n }\n return _saveCommand;\n }\n}\n\nprivate void SaveObject() {\n // do something\n}\n\n// XAML\n{Binding Path=SaveCommand}\n // C# code\nprivate void SaveObject() {\n // do something\n}\n\n// XAML\n{BindTo SaveObject()}\n RelayCommand"
},
{
"answer_id": 13137935,
"author": "Nathan Cooper",
"author_id": 1734730,
"author_profile": "https://Stackoverflow.com/users/1734730",
"pm_score": 4,
"selected": false,
"text": "Binding b = new Binding();\nb.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, this.GetType(), 1);\nb.Path = new PropertyPath(\"MyElementThatNeedsBinding\");\nMyLabel.SetBinding(ContentProperty, b);\n"
},
{
"answer_id": 19470853,
"author": "Cornel Marian",
"author_id": 736113,
"author_profile": "https://Stackoverflow.com/users/736113",
"pm_score": 6,
"selected": false,
"text": "<Rectangle Fill=\"Red\" Name=\"rectangle\" \n Height=\"100\" Stroke=\"Black\" \n Canvas.Top=\"100\" Canvas.Left=\"100\"\n Width=\"{Binding ElementName=rectangle,\n Path=Height}\"/>\n <Rectangle Fill=\"Red\" Height=\"100\" \n Stroke=\"Black\" \n Width=\"{Binding RelativeSource={RelativeSource Self},\n Path=Height}\"/>\n <TextBlock Width=\"{Binding RelativeSource={RelativeSource Self},\n Path=Parent.ActualWidth}\"/>\n <Canvas Name=\"Parent0\">\n <Border Name=\"Parent1\"\n Width=\"{Binding RelativeSource={RelativeSource Self},\n Path=Parent.ActualWidth}\"\n Height=\"{Binding RelativeSource={RelativeSource Self},\n Path=Parent.ActualHeight}\">\n <Canvas Name=\"Parent2\">\n <Border Name=\"Parent3\"\n Width=\"{Binding RelativeSource={RelativeSource Self},\n Path=Parent.ActualWidth}\"\n Height=\"{Binding RelativeSource={RelativeSource Self},\n Path=Parent.ActualHeight}\">\n <Canvas Name=\"Parent4\">\n <TextBlock FontSize=\"16\" \n Margin=\"5\" Text=\"Display the name of the ancestor\"/>\n <TextBlock FontSize=\"16\" \n Margin=\"50\" \n Text=\"{Binding RelativeSource={RelativeSource \n FindAncestor,\n AncestorType={x:Type Border}, \n AncestorLevel=2},Path=Name}\" \n Width=\"200\"/>\n </Canvas>\n </Border>\n </Canvas>\n </Border>\n </Canvas>\n <Window.Resources>\n<ControlTemplate x:Key=\"template\">\n <Canvas>\n <Canvas.RenderTransform>\n <RotateTransform Angle=\"20\"/>\n </Canvas.RenderTransform>\n <Ellipse Height=\"100\" Width=\"150\" \n Fill=\"{Binding \n RelativeSource={RelativeSource TemplatedParent},\n Path=Background}\">\n\n </Ellipse>\n <ContentPresenter Margin=\"35\" \n Content=\"{Binding RelativeSource={RelativeSource \n TemplatedParent},Path=Content}\"/>\n </Canvas>\n </ControlTemplate>\n</Window.Resources>\n <Canvas Name=\"Parent0\">\n <Button Margin=\"50\" \n Template=\"{StaticResource template}\" Height=\"0\" \n Canvas.Left=\"0\" Canvas.Top=\"0\" Width=\"0\">\n <TextBlock FontSize=\"22\">Click me</TextBlock>\n </Button>\n </Canvas>\n"
},
{
"answer_id": 29946000,
"author": "Edd",
"author_id": 2399164,
"author_profile": "https://Stackoverflow.com/users/2399164",
"pm_score": 3,
"selected": false,
"text": "<Style.Triggers>\n <DataTrigger Binding=\"{Binding Items.Count, RelativeSource={RelativeSource Self}}\" Value=\"0\">\n <Setter Property=\"Background\">\n <Setter.Value>\n <VisualBrush Stretch=\"None\">\n <VisualBrush.Visual>\n <TextBlock Text=\"We did't find any matching records for your search...\" FontSize=\"16\" FontWeight=\"SemiBold\" Foreground=\"LightCoral\"/>\n </VisualBrush.Visual>\n </VisualBrush>\n </Setter.Value>\n </Setter>\n </DataTrigger>\n</Style.Triggers>\n"
},
{
"answer_id": 34925445,
"author": "Kylo Ren",
"author_id": 4576125,
"author_profile": "https://Stackoverflow.com/users/4576125",
"pm_score": 5,
"selected": false,
"text": "RelativeSource properties enum value=0 property value=1 templates control ControlTemplate <ControlTemplate>\n <CheckBox IsChecked=\"{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}\" />\n </ControlTemplate>\n value=2 self property checkbox CommandParameter Command CheckBox <CheckBox ...... CommandParameter=\"{Binding RelativeSource={RelativeSource Self},Path=IsChecked}\" />\n value=3 control Visual Tree checkbox records grid header checkbox <CheckBox IsChecked=\"{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type iDP:XamDataGrid}}, Path=DataContext.IsHeaderChecked, Mode=TwoWay}\" />\n FindAncestor RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type iDP:XamDataGrid}}\n FindAncestor visual tree RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type iDP:XamDataGrid, AncestorLevel=1}}\n RelativeSource binding"
},
{
"answer_id": 38654107,
"author": "Kevin VDF",
"author_id": 6653298,
"author_profile": "https://Stackoverflow.com/users/6653298",
"pm_score": 3,
"selected": false,
"text": "Mode=FindAncestor Command=\"{Binding Path=DataContext.CommandProperty, RelativeSource={...}}\"\n"
},
{
"answer_id": 46053079,
"author": "Contango",
"author_id": 107409,
"author_profile": "https://Stackoverflow.com/users/107409",
"pm_score": 3,
"selected": false,
"text": "<DataGridTextColumn Header=\"Price\" Binding=\"{Binding Price}\" IsReadOnly=\"False\"\n Visibility=\"{Binding ShowPrice,\n Converter={StaticResource visibilityConverter}}\"/>\n <DataGridTextColumn Header=\"Price\" Binding=\"{Binding Price}\" IsReadOnly=\"False\"\n Visibility=\"{Binding DataContext.ShowPrice,\n Converter={StaticResource visibilityConverter},\n RelativeSource={RelativeSource FindAncestor, AncestorType=DataGrid}}\"/>\n <DataGridTextColumn Header=\"Price\" Binding=\"{Binding Price}\" IsReadOnly=\"False\"\n Visibility=\"{Binding IsChecked,\n Converter={StaticResource visibilityConverter},\n ElementName=chkShowPrice}\"/>\n public class BindingProxy : Freezable\n{\n #region Overrides of Freezable\n \n protected override Freezable CreateInstanceCore()\n {\n return new BindingProxy();\n }\n \n #endregion\n \n public object Data\n {\n get { return (object)GetValue(DataProperty); }\n set { SetValue(DataProperty, value); }\n }\n \n // Using a DependencyProperty as the backing store for Data. This enables animation, styling, binding, etc...\n public static readonly DependencyProperty DataProperty =\n DependencyProperty.Register(\"Data\", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));\n}\n <DataGrid.Resources>\n <local:BindingProxy x:Key=\"proxy\" Data=\"{Binding}\" />\n</DataGrid.Resources>\n <DataGridTextColumn Header=\"Price\" Binding=\"{Binding Price}\" IsReadOnly=\"False\"\n Visibility=\"{Binding Data.ShowPrice,\n Converter={StaticResource visibilityConverter},\n Source={StaticResource proxy}}\"/>\n"
},
{
"answer_id": 67119194,
"author": "james.lee",
"author_id": 9438258,
"author_profile": "https://Stackoverflow.com/users/9438258",
"pm_score": 4,
"selected": false,
"text": "PresentationFramework.dll namespace System.Windows\n{\n public class FrameworkElement : UIElement\n {\n public static readonly DependencyProperty DataContextProperty;\n public object DataContext { get; set; }\n }\n}\n FrameworkElement <TextBlock Text=\"{Binding}\" DataContext=\"James\"/>\n Text=\"{Binding}\" TextBlock Text mscrolib sys xmlns:sys=\"clr-namespace:System;assembly=mscorlib\"\n YEAR <Window.Resources>\n <sys:Int32 x:Key=\"YEAR\">2020</sys:Int32>\n</Window.Resources>\n...\n<TextBlock Text=\"{Binding}\" DataContext=\"{StaticResource YEAR\"/>\n <Window.Resources>\n <sys:Boolean x:Key=\"IsEnabled\">true</sys:Boolean>\n <sys:double x:Key=\"Price\">7.77</sys:double>\n</Window.Resources>\n...\n<StackPanel>\n <TextBlock Text=\"{Binding}\" DataContext=\"{StaticResource IsEnabled}\"/>\n <TextBlock Text=\"{Binding}\" DataContext=\"{StaticResource Price}\"/>\n</StackPanel>\n string property <TextBox Text=\"{Binding Keywords}\"/>\n <CheckBox x:Name=\"usingEmail\"/>\n<TextBlock Text=\"{Binding ElementName=usingEmail, Path=IsChecked}\"/>\n <TextBlock Margin=\"5,2\" Text=\"This disappears as the control gets focus...\">\n <TextBlock.Visibility>\n <MultiBinding Converter=\"{StaticResource TextInputToVisibilityConverter}\">\n <Binding ElementName=\"txtUserEntry2\" Path=\"Text.IsEmpty\" />\n <Binding ElementName=\"txtUserEntry2\" Path=\"IsFocused\" />\n </MultiBinding>\n </TextBlock.Visibility>\n</TextBlock>\n <TextBlock x:Name=\"txt\" Text=\"{Binding ElementName=txt, Path=Tag}\"/>\n Self Property Binding Element Binding x:Name <TextBlock Text=\"{Binding RelativeSource={RelativeSource Self}, Path=Tag}\"/>\n <TextBlock Text=\"{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=Title}\"/>\n <TextBlock Text=\"{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.Email}\"/>\n ControlTemplate ControlTemplate <Style TargetType=\"Button\">\n <Setter Property=\"Template\">\n <Setter.Value>\n <ControlTemplate TargetType=\"Button\">\n <TextBlock Text=\"{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}\"/>\n </ControlTemplate>\n </Setter.Value>\n </Setter>\n <TextBlock Text=\"{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}\"/>\n static namespace Exam\n{\n public class ExamClass\n {\n public static string ExamText { get; set; }\n }\n} \n <Window ... xmlns:exam=\"clr-namespace:Exam\">\n <TextBlock Text=\"{Binding exam:ExamClass.ExamText}\"/>\n Converter <Window.Resource>\n <cvt:VisibilityToBooleanConverter x:Key=\"VisibilityToBooleanConverter\"/>\n <exam:ExamClass x:Key=\"ExamClass\">\n</Window.Resource>\n...\n\n<TextBlock Text=\"{Binding Source={StaticResource ExamClass}, Path=ExamText}\"/>\n <TextBox x:Name=\"text\" Text=\"{Binding UserName}\"/>\n...\n<TextBlock Text=\"{Binding ElementName=text, Path=Text}\"/>\n <TextBox Text=\"{Binding UserName}\"/>\n...\n<TextBlock Text=\"{Binding UserName}\"/>\n <Window x:Name=\"win\">\n <TextBlock Text=\"{Binding ElementName=win, Path=DataContext.UserName}\"/>\n ...\n <Window>\n <TextBlock Text=\"{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.UserName}\"/>\n ...\n <Window>\n <TextBlock DataContext=\"{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext}\" \n Text=\"{Binding UserName}\"/>\n ...\n <TextBlock x:Name=\"txt\" Text=\"{Binding ElementName=txt, Path=Foreground}\"/>\n <TextBlock Text=\"{Binding RelativeSource={RelativeSource Self}, Path=Foreground}\"/>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4918/"
] |
84,285
|
<p>is it legal for a thread to call this.start() inside its own constructor? and if so what potential issues can this cause? I understand that the object wont have fully initialized until the constructor has run to completion but aside from this are there any other issues? </p>
|
[
{
"answer_id": 84550,
"author": "Eli Courtwright",
"author_id": 1694,
"author_profile": "https://Stackoverflow.com/users/1694",
"pm_score": 2,
"selected": false,
"text": "Thread t = new CustomThread();\nt.start();\nactiveThreads.add(t);\n activeThreads.add( new CustomThread() );\n start start"
},
{
"answer_id": 84611,
"author": "millenomi",
"author_id": 6061,
"author_profile": "https://Stackoverflow.com/users/6061",
"pm_score": 2,
"selected": false,
"text": "activeThreads.add( CustomThread.newStartedThread() );\n"
},
{
"answer_id": 9547273,
"author": "OldCurmudgeon",
"author_id": 823393,
"author_profile": "https://Stackoverflow.com/users/823393",
"pm_score": 1,
"selected": false,
"text": "public class ThreadCreationTest {\n public static void main(String[] args) throws InterruptedException {\n final AtomicInteger threads_created = new AtomicInteger(0);\n while (true) {\n final CountDownLatch latch = new CountDownLatch(1);\n new Thread() {\n { start(); } // <--- Like this ... sweet and simple.\n public void run() {\n latch.countDown();\n synchronized (this) {\n System.out.println(\"threads created: \" +\n threads_created.incrementAndGet());\n try {\n wait();\n } catch (InterruptedException e) {\n Thread.currentThread().interrupt();\n }\n }\n }\n };\n latch.await();\n }\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
84,290
|
<p>How do I get a a complete list of all the urls that my rails application could generate? </p>
<p>I don't want the routes that I get get form rake routes, instead I want to get the actul URLs corrosponding to all the dynmically generated pages in my application...</p>
<p>Is this even possible?</p>
<p>(Background: I'm doing this because I want a complete list of URLs for some load testing I want to do, which has to cover the entire breadth of the application)</p>
|
[
{
"answer_id": 84482,
"author": "Jeremiah Peschka",
"author_id": 11780,
"author_profile": "https://Stackoverflow.com/users/11780",
"pm_score": 1,
"selected": false,
"text": "rake routes"
},
{
"answer_id": 90868,
"author": "kch",
"author_id": 13989,
"author_profile": "https://Stackoverflow.com/users/13989",
"pm_score": 4,
"selected": true,
"text": "$ wget --spider -r -nv -nd -np http://localhost:3209/ 2>&1 | ack -o '(?<=URL:)\\S+'\nhttp://localhost:3209/\nhttp://localhost:3209/robots.txt\nhttp://localhost:3209/agenda/2008/08\nhttp://localhost:3209/agenda/2008/10\nhttp://localhost:3209/agenda/2008/09/01\nhttp://localhost:3209/agenda/2008/09/02\nhttp://localhost:3209/agenda/2008/09/03\n^C\n wget # --spider don't download anything.\n# -r, --recursive specify recursive download.\n# -nv, --no-verbose turn off verboseness, without being quiet.\n# -nd, --no-directories don't create directories.\n# -np, --no-parent don't ascend to the parent directory.\n ack ack grep perl -o ack 'URL:'"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7473/"
] |
84,310
|
<p>I'm connecting to an AS/400 stored procedure layer using the IBM iSeries Access for Windows package. This provides a .NET DLL with classes similar to those in the <code>System.Data</code> namespace. As such we use their implementation of the connection class and provide it with a connection string.</p>
<p>Does anyone know how I can amend the connection string to indicate the default library it should use?</p>
|
[
{
"answer_id": 84374,
"author": "Dillie-O",
"author_id": 71,
"author_profile": "https://Stackoverflow.com/users/71",
"pm_score": 1,
"selected": false,
"text": "<add name=\"AS400ConnectionString\" connectionString=\"Data Source=DEVL820;Initial Catalog=Q1A_DATABASE_SRVR;Persist Security Info=False;User ID=BLAH;Password=BLAHBLAH;Provider=IBMDASQL.DataSource.1;**Catalog Library List="HTSUTST, HTEUSRJ, HTEDTA"**\" providerName=\"System.Data.OleDb\" />\n"
},
{
"answer_id": 84854,
"author": "CrashCodes",
"author_id": 16260,
"author_profile": "https://Stackoverflow.com/users/16260",
"pm_score": 2,
"selected": false,
"text": "DBQ System ConnectionString :=\n 'Driver={Client Access ODBC Driver (32-bit)};' +\n 'System=' + System + ';' +\n 'DBQ=' + Lib + ';' +\n 'TRANSLATE=1;' +\n 'CMT=0;' +\n //'DESC=Client Access Express ODBC data source;' +\n 'QAQQINILIB=;' +\n 'PKG=QGPL/DEFAULT(IBM),2,0,1,0,512;' + \n 'SORTTABLE=;' +\n 'LANGUAGEID=ENU;' +\n 'XLATEDLL=;' +\n 'DFTPKGLIB=QGPL;';\n"
},
{
"answer_id": 97858,
"author": "Gustavo Rubio",
"author_id": 14533,
"author_profile": "https://Stackoverflow.com/users/14533",
"pm_score": 2,
"selected": false,
"text": "Provider=IBMDA400;Data Source=as400.com;User Id=user;Password=password;Default Collection=yourLibrary;\n DRIVER=Client Access ODBC Driver(32-bit);SYSTEM=as400.com;EXTCOLINFO=1;UID=user;PWD=password;LibraryList=yourLibrary\n DRIVER=iSeries Access ODBC Driver;SYSTEM=as400.com;EXTCOLINFO=1;UID=user;PWD=password;LibraryList=yourLibrary\n providerName=\"System.Data.OleDb\"\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12277/"
] |
84,322
|
<p>It appears that using perldoc perl gives the list of, e.g. perlre, perlvar, etc.</p>
<p>Is this the best place to find the list of what's available as an overview or tutorial or reference manual section? Is there another, better list?</p>
|
[
{
"answer_id": 84417,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 4,
"selected": true,
"text": "perldoc perltoc\n perldoc perlmodlib\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84322",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8763/"
] |
84,330
|
<p><strong>Here is the updated question:</strong></p>
<p>the current query is doing something like:<br></p>
<pre><code>$sql1 = "TRUNCATE TABLE fubar";
$sql2 = "CREATE TEMPORARY TABLE IF NOT EXISTS fubar SELECT id, name FROM barfu";
</code></pre>
<p>The first time the method containing this is run, it generates an error message on the truncate since the table doesn't exist yet.</p>
<p>Is my only option to do the <code>CREATE TABLE</code>, run the <code>TRUNCATE TABLE</code>, and then fill the table? (3 separate queries)</p>
<p><strong>original question was:</strong></p>
<p>
I've been having a hard time trying to figure out if the following is possible in MySql without having to write block sql:</p>
<pre><code>CREATE TABLE fubar IF NOT EXISTS ELSE TRUNCATE TABLE fubar
</code></pre>
<p>If I run truncate separately before the create table, and the table doesn't exist, then I get an error message. I'm trying to eliminate that error message without having to add any more queries.</p>
<p>This code will be executed using PHP.</p>
|
[
{
"answer_id": 84396,
"author": "Ben",
"author_id": 11522,
"author_profile": "https://Stackoverflow.com/users/11522",
"pm_score": 2,
"selected": false,
"text": "DROP TABLE IF EXISTS fubar;\nCREATE TABLE fubar;\n"
},
{
"answer_id": 84405,
"author": "Mark Janssen",
"author_id": 15828,
"author_profile": "https://Stackoverflow.com/users/15828",
"pm_score": 2,
"selected": false,
"text": "CREATE TABLE fubar IF NOT EXISTS\nTRUNCATE TABLE fubar\n"
},
{
"answer_id": 1666567,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "call Edit_table(database-name,table-name,query-string); DELIMITER $$\n\nDROP PROCEDURE IF EXISTS `Edit_table` $$\nCREATE PROCEDURE `Edit_table` (in_db_nm varchar(20), in_tbl_nm varchar(20), in_your_query varchar(200))\nDETERMINISTIC\nBEGIN\n\nDECLARE var_table_count INT;\n\nselect count(*) INTO @var_table_count from information_schema.TABLES where TABLE_NAME=in_tbl_nm and TABLE_SCHEMA=in_db_nm;\nIF (@var_table_count > 0) THEN\n SET @in_your_query = in_your_query;\n #SELECT @in_your_query;\n PREPARE my_query FROM @in_your_query;\n EXECUTE my_query;\n\nELSE\n select \"Table Not Found\";\nEND IF;\n\nEND $$\nDELIMITER ;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16186/"
] |
84,331
|
<p>Is there a macro or a way to conditionally copy rows from one worksheet to another in Excel 2003?</p>
<p>I'm pulling a list of data from SharePoint via a web query into a blank worksheet in Excel, and then I want to copy the rows for a particular month to a particular worksheet (for example, all July data from a SharePoint worksheet to the Jul worksheet, all June data from a SharePoint worksheet to Jun worksheet, etc.).</p>
<p><strong>Sample data</strong></p>
<pre><code>Date - Project - ID - Engineer
8/2/08 - XYZ - T0908-5555 - JS
9/4/08 - ABC - T0908-6666 - DF
9/5/08 - ZZZ - T0908-7777 - TS
</code></pre>
<p>It's not a one-off exercise. I'm trying to put together a dashboard that my boss can pull the latest data from SharePoint and see the monthly results, so it needs to be able to do it all the time and organize it cleanly.</p>
|
[
{
"answer_id": 84526,
"author": "BKimmel",
"author_id": 13776,
"author_profile": "https://Stackoverflow.com/users/13776",
"pm_score": 0,
"selected": false,
"text": "rows = ActiveSheet.UsedRange.Rows\nn = 0\n\nwhile n <= rows\n if ActiveSheet.Rows(n).Cells(DateColumnOrdinal).Value > '8/1/08' AND < '8/30/08' then\n ActiveSheet.Rows(n).CopyTo(DestinationSheet)\n endif\n n = n + 1\nwend\n"
},
{
"answer_id": 84614,
"author": "theo",
"author_id": 7870,
"author_profile": "https://Stackoverflow.com/users/7870",
"pm_score": 3,
"selected": false,
"text": "Public Sub MoveData(MonthNumber As Integer, SheetName As String)\n\nDim sharePoint As Worksheet\nDim Month As Worksheet\nDim spRange As Range\nDim cell As Range\n\nSet sharePoint = Sheets(\"Sharepoint\")\nSet Month = Sheets(SheetName)\nSet spRange = sharePoint.Range(\"A2\")\nSet spRange = sharePoint.Range(\"A2:\" & spRange.End(xlDown).Address)\nFor Each cell In spRange\n If Format(cell.Value, \"MM\") = MonthNumber Then\n copyRowTo sharePoint.Range(cell.Row & \":\" & cell.Row), Month\n End If\nNext cell\n\nEnd Sub\n\nSub copyRowTo(rng As Range, ws As Worksheet)\n Dim newRange As Range\n Set newRange = ws.Range(\"A1\")\n If newRange.Offset(1).Value <> \"\" Then\n Set newRange = newRange.End(xlDown).Offset(1)\n Else\n Set newRange = newRange.Offset(1)\n End If\n rng.Copy\n newRange.PasteSpecial (xlPasteAll)\nEnd Sub\n"
},
{
"answer_id": 87356,
"author": "Jon Fournier",
"author_id": 5106,
"author_profile": "https://Stackoverflow.com/users/5106",
"pm_score": 1,
"selected": false,
"text": "Public Sub MoveData(MonthNum As Integer, FromSheet As Worksheet, ToSheet As Worksheet)\n Const DateCol = \"A\" 'column where dates are store\n Const DestCol = \"A\" 'destination column where dates are stored. We use this column to find the last populated row in ToSheet\n Const FirstRow = 2 'first row where date data is stored\n 'Copy range of values to Dates array\n Dates = FromSheet.Range(DateCol & CStr(FirstRow) & \":\" & DateCol & CStr(FromSheet.Range(DateCol & CStr(FromSheet.Rows.Count)).End(xlUp).Row)).Value\n Dim i As Integer\n For i = LBound(Dates) To UBound(Dates)\n If IsDate(Dates(i, 1)) Then\n If Month(CDate(Dates(i, 1))) = MonthNum Then\n Dim CurrRow As Long\n 'get the current row number in the worksheet\n CurrRow = FirstRow + i - 1\n Dim DestRow As Long\n 'get the destination row\n DestRow = ToSheet.Range(DestCol & CStr(ToSheet.Rows.Count)).End(xlUp).Row + 1\n 'copy row CurrRow in FromSheet to row DestRow in ToSheet\n FromSheet.Range(CStr(CurrRow) & \":\" & CStr(CurrRow)).Copy ToSheet.Range(DestCol & CStr(DestRow))\n End If\n End If\n Next i\nEnd Sub\n"
},
{
"answer_id": 94282,
"author": "Robert Mearns",
"author_id": 5050,
"author_profile": "https://Stackoverflow.com/users/5050",
"pm_score": 0,
"selected": false,
"text": " Sub SeperateData()\n\n Dim vMonthText As Variant\n Dim ExcelLastCell As Range\n Dim intMonth As Integer\n\n vMonthText = Array(\"January\", \"February\", \"March\", \"April\", \"May\", _\n \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\")\n\n ThisWorkbook.Worksheets(\"Sharepoint\").Select\n Range(\"A1\").Select\n\n RowCount = ThisWorkbook.Worksheets(\"Sharepoint\").UsedRange.Rows.Count\n'Forces excel to determine the last cell, Usually only done on save\n Set ExcelLastCell = ThisWorkbook.Worksheets(\"Sharepoint\"). _\n Cells.SpecialCells(xlLastCell)\n'Determines the last cell with data in it\n\n\n Selection.EntireColumn.Insert\n Range(\"A1\").FormulaR1C1 = \"Month No.\"\n Range(\"A2\").FormulaR1C1 = \"=MONTH(RC[1])\"\n Range(\"A2\").Select\n Selection.Copy\n Range(\"A3:A\" & ExcelLastCell.Row).Select\n ActiveSheet.Paste\n Application.CutCopyMode = False\n Calculate\n 'Insert a helper column to determine the month number for the date\n\n For intMonth = 1 To 12\n Range(\"A1\").CurrentRegion.Select\n Selection.AutoFilter Field:=1, Criteria1:=\"\" & intMonth\n Selection.Copy\n ThisWorkbook.Worksheets(\"\" & vMonthText(intMonth - 1)).Select\n Range(\"A1\").Select\n ActiveSheet.Paste\n Columns(\"A:A\").Delete Shift:=xlToLeft\n Cells.Select\n Cells.EntireColumn.AutoFit\n Range(\"A1\").Select\n ThisWorkbook.Worksheets(\"Sharepoint\").Select\n Range(\"A1\").Select\n Application.CutCopyMode = False\n Next intMonth\n 'Filter the data to a particular month\n 'Convert the month number to text\n 'Copy the filtered data to the month sheet\n 'Delete the helper column\n 'Repeat for each month\n\n Selection.AutoFilter\n Columns(\"A:A\").Delete Shift:=xlToLeft\n 'Get rid of the auto-filter and delete the helper column\n\n End Sub\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
84,332
|
<p>My Access 2000 DB causes me problems - sometimes (haven't pinpointed the cause) the "book" form won't close. Clicking its close button does nothing, File -> Close does nothing, even closing Access results in no action. I don't have an OnClose handler for this form. The only workaround I can find involves opening the Vba editor, making a change to the code for that form (even adding a space and then immediately deleting the space), and then going back to close the "book" form, closing it, and saying "no, I don't want to save the changes". Only then will it close. Any help?</p>
|
[
{
"answer_id": 84907,
"author": "Chris OC",
"author_id": 11041,
"author_profile": "https://Stackoverflow.com/users/11041",
"pm_score": 0,
"selected": false,
"text": "If Me.chkbox Then\n If Me.chkbox.Value Then\n"
},
{
"answer_id": 88914,
"author": "David-W-Fenton",
"author_id": 9787,
"author_profile": "https://Stackoverflow.com/users/9787",
"pm_score": 1,
"selected": false,
"text": "(Me.Checkbox) \n (Me!Checkbox)\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12874/"
] |
84,341
|
<p>I have a core file generated on a remote system that I don't have direct access to. I also have local copies of the library files from the remote system, and the executable file for the crashing program.</p>
<p>I'd like to analyse this core dump in gdb.</p>
<p>For example:</p>
<pre><code>gdb path/to/executable path/to/corefile
</code></pre>
<p>My libraries are in the current directory.</p>
<p>In the past I've seen debuggers implement this by supplying the option "-p ." or "-p /=."; so my question is:</p>
<p>How can I specify that libraries be loaded first from paths relative to my current directory when analysing a corefile in gdb?</p>
|
[
{
"answer_id": 84546,
"author": "Drew Frezell",
"author_id": 10954,
"author_profile": "https://Stackoverflow.com/users/10954",
"pm_score": 7,
"selected": true,
"text": "set solib-absolute-prefix ./usr\nfile path/to/executable\ncore-file path/to/corefile\n set solib-search-path <path>\n solib-absolute-prefix"
},
{
"answer_id": 84722,
"author": "Mike Tunnicliffe",
"author_id": 13956,
"author_profile": "https://Stackoverflow.com/users/13956",
"pm_score": 2,
"selected": false,
"text": "set solib-search-path path\n solib-search-path' is used after\n solib-search-path' instead of\n "
},
{
"answer_id": 84778,
"author": "bltxd",
"author_id": 11892,
"author_profile": "https://Stackoverflow.com/users/11892",
"pm_score": 2,
"selected": false,
"text": "ldd path/to/executable\n readelf -d path/to/executable | grep RPATH\n man ld.so\n"
},
{
"answer_id": 3293122,
"author": "psihodelia",
"author_id": 215571,
"author_profile": "https://Stackoverflow.com/users/215571",
"pm_score": 0,
"selected": false,
"text": "file ECECUTABLE_NAME Using host libthread_db library \"/lib/libthread_db.so.1\"\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13956/"
] |
84,346
|
<p>How do I create an index on a column in MySQL v 5.0 (myisam db engine) based upon the length of its value its a TEXT data type up to 7000 characters, do I have to add another column with the length of the first column?</p>
|
[
{
"answer_id": 84500,
"author": "Henning",
"author_id": 7034,
"author_profile": "https://Stackoverflow.com/users/7034",
"pm_score": 3,
"selected": true,
"text": "ADD INDEX myIndex(LENGTH(text)))"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16191/"
] |
84,378
|
<p>When using <code>divs</code> when is it best to use a <code>class</code> vs <code>id</code>? </p>
<p>Is it best to use <code>class</code>, on say font variant or elements within the html? Then use <code>id</code> for the structure/containers? </p>
<p>This is something I've always been a little uncertain on, any help would be great.</p>
|
[
{
"answer_id": 84409,
"author": "Oli",
"author_id": 12870,
"author_profile": "https://Stackoverflow.com/users/12870",
"pm_score": 5,
"selected": false,
"text": "<div id=\"section\" class=\"section\">Text</div>\n #section {font-color:#fff}\n.section {font-color:#000}\n"
},
{
"answer_id": 84412,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 0,
"selected": false,
"text": "<div class=\"code-formatting-style-name\" id=\"myfirstDivForCode\">\n</div>\n"
},
{
"answer_id": 84416,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 7,
"selected": true,
"text": "id id=\"navigation\" class <span class='company'>"
},
{
"answer_id": 84520,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_profile": "https://Stackoverflow.com/users/3043",
"pm_score": 2,
"selected": false,
"text": "div.NavArea ul { /* styles go here */ }\n"
},
{
"answer_id": 84652,
"author": "Dave Rutledge",
"author_id": 2486915,
"author_profile": "https://Stackoverflow.com/users/2486915",
"pm_score": 3,
"selected": false,
"text": "<h2 id=\"CurrentSale\">Product I'm selling</h2>\n <a href=\"#CurrentSale\">the Current Sale</a>\n"
},
{
"answer_id": 548337,
"author": "Sampson",
"author_id": 54680,
"author_profile": "https://Stackoverflow.com/users/54680",
"pm_score": 5,
"selected": false,
"text": "<student id=\"JonathanSampson\" class=\"Biology\" />\n<student id=\"MarySmith\" class=\"Biology\" />\n .BiologyClass {\n shirt-color:red;\n}\n #JonathanSampson {\n shirt-color:green;\n}\n"
},
{
"answer_id": 13704931,
"author": "l2aelba",
"author_id": 622813,
"author_profile": "https://Stackoverflow.com/users/622813",
"pm_score": 0,
"selected": false,
"text": "<div id=\"post-289\" class=\"box clear black bold radius\">\n .clear {clear:both;}\n.black {color:black;}\n.bold {font-weight:bold;}\n.radius {border-radius:2px;}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16195/"
] |
84,404
|
<p>Visual Studio 2003 and 2005 (and perhaps 2008 for all I know) require the command line user to run in the 'Visual Studio Command Prompt'. When starting this command prompt it sets various environment variables that the C++ compiler, cl, uses when compiling.</p>
<p>This is not always desirable. If, for example, I want to run 'cl' from within Ant, I'd like to avoid having to run Ant from within the 'Visual Studio Command Prompt'. Running vcvars32.bat isn't an option as the environment set by vcvars32.bat would be lost by the time cl was run (if running from within Ant).</p>
<p>Is there an easy way to run cl without having to run from within the Visual Studio command prompt?</p>
|
[
{
"answer_id": 84431,
"author": "ljs",
"author_id": 3394,
"author_profile": "https://Stackoverflow.com/users/3394",
"pm_score": 3,
"selected": false,
"text": "C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcvarsall.bat\n"
},
{
"answer_id": 87052,
"author": "Eclipse",
"author_id": 8701,
"author_profile": "https://Stackoverflow.com/users/8701",
"pm_score": 5,
"selected": false,
"text": "@echo off\n:: Load compilation environment\ncall \"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcvarsall.bat\"\n:: Invoke compiler with any options passed to this batch file\n\"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\\cl.exe\" %*\n"
},
{
"answer_id": 11053719,
"author": "Joel Purra",
"author_id": 907779,
"author_profile": "https://Stackoverflow.com/users/907779",
"pm_score": 0,
"selected": false,
"text": "Compile and execute other steps.cmd @echo off\n\nREM Load Visual Studio's build tools\ncall \"%ProgramFiles(x86)%\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat\" x86\n\nREM Choose what you want to do, 1 or 2 by (un)commenting\n\nREM 1. Add your cl.exe (or msbuild.exe or other) commands here\nREM msbuild.exe MyProject.csproj\nREM cl.exe\nREM custom-step.exe %*\nREM pause\n\nREM 2. Open a normal interactive system command shell with all variables loaded\n%comspec% /k\n REM %comspec% /k"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6839/"
] |
84,421
|
<p>Is there a built in way to convert an integer in Ruby into its hexadecimal equivalent?</p>
<p>Something like the opposite of <a href="http://ruby-doc.org/core-2.0.0/String.html#method-i-to_i" rel="noreferrer"><code>String#to_i</code></a>:</p>
<pre><code>"0A".to_i(16) #=>10
</code></pre>
<p>Like perhaps:</p>
<pre><code>"0A".hex #=>10
</code></pre>
<p>I know how to roll my own, but it's probably more efficient to use a built in Ruby function.</p>
|
[
{
"answer_id": 84455,
"author": "flxkid",
"author_id": 13036,
"author_profile": "https://Stackoverflow.com/users/13036",
"pm_score": 6,
"selected": false,
"text": "% sprintf i = 20\n\"%x\" % i #=> \"14\"\n"
},
{
"answer_id": 84485,
"author": "Jean",
"author_id": 7898,
"author_profile": "https://Stackoverflow.com/users/7898",
"pm_score": 9,
"selected": true,
"text": "to_s 10.to_s(16) #=> \"a\"\n FixNum BigNum Integer to_s to_s"
},
{
"answer_id": 5474985,
"author": "Ultrasaurus",
"author_id": 682349,
"author_profile": "https://Stackoverflow.com/users/682349",
"pm_score": 4,
"selected": false,
"text": "sprintf(\"%02x\", 10).upcase\n sprintf"
},
{
"answer_id": 7882918,
"author": "Lri",
"author_id": 495470,
"author_profile": "https://Stackoverflow.com/users/495470",
"pm_score": 6,
"selected": false,
"text": "p 10.to_s(16) #=> \"a\"\np \"%x\" % 10 #=> \"a\"\np \"%02X\" % 10 #=> \"0A\"\np sprintf(\"%02X\", 10) #=> \"0A\"\np \"#%02X%02X%02X\" % [255, 0, 10] #=> \"#FF000A\"\n"
},
{
"answer_id": 23266744,
"author": "tool maker",
"author_id": 2895616,
"author_profile": "https://Stackoverflow.com/users/2895616",
"pm_score": 3,
"selected": false,
"text": "p \"%x\" % -1 #=> \"..f\"\np -1.to_s(16) #=> \"-1\"\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84421",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6106/"
] |
84,422
|
<p>in XSLT processing, is there a performance difference between apply-template and call-template? In my stylesheets there are many instances where I can use either, which is the best choice?</p>
|
[
{
"answer_id": 85514,
"author": "JeniT",
"author_id": 6739,
"author_profile": "https://Stackoverflow.com/users/6739",
"pm_score": 6,
"selected": false,
"text": "<xsl:apply-templates> <xsl:apply-templates> <xsl:for-each> <xsl:choose> <xsl:call-template> <xsl:for-each> <xsl:call-template> <xsl:apply-templates> <xsl:call-template> <xsl:for-each> <xsl:choose> <xsl:apply-templates> <xsl:call-template> <xsl:function>"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
84,427
|
<p>Specifically, is the following legal C++?</p>
<pre>class A{};
void foo(A*);
void bar(const A&);
int main(void)
{
foo(&A()); // 1
bar(A()); // 2
}</pre>
<p>It appears to work correctly, but that doesn't mean it's necessarily legal. Is it?</p>
<p><i>Edit - changed <code>A&</code> to <code>const A&</code></i></p>
|
[
{
"answer_id": 84494,
"author": "roo",
"author_id": 716,
"author_profile": "https://Stackoverflow.com/users/716",
"pm_score": -1,
"selected": false,
"text": "int dosomething(error_code& _e = ignore_errorcode()) {\n //do something\n}\n error_code"
},
{
"answer_id": 84521,
"author": "Matt Price",
"author_id": 852,
"author_profile": "https://Stackoverflow.com/users/852",
"pm_score": 3,
"selected": false,
"text": "class A{};\n\nvoid bar(const A&);\n\nint main(void)\n{\n bar(A()); // 2\n}\n"
},
{
"answer_id": 1152218,
"author": "CsTamas",
"author_id": 140006,
"author_profile": "https://Stackoverflow.com/users/140006",
"pm_score": 2,
"selected": false,
"text": "bar(const A&) foo(A*) bar(A&)"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9530/"
] |
84,449
|
<p>The XML Schema Part 2 specifies that an instance of a datatype that is defined as boolean can have the following legal literals {true, false, 1, 0}.
The following XML, for example, when deserialized, sets the boolean property "Emulate" to <code>true</code>.</p>
<pre><code><root>
<emulate>1</emulate>
</root>
</code></pre>
<p>However, when I serialize the object back to the XML, I get <code>true</code> instead of the numerical value. My question is, is there a way that I can control the boolean representation in the XML?</p>
|
[
{
"answer_id": 85468,
"author": "Simon Steele",
"author_id": 4591,
"author_profile": "https://Stackoverflow.com/users/4591",
"pm_score": 6,
"selected": false,
"text": "[XmlIgnore]\npublic bool MyValue { get; set; }\n\n/// <summary>Get a value purely for serialization purposes</summary>\n[XmlElement(\"MyValue\")]\npublic string MyValueSerialize\n{\n get { return this.MyValue ? \"1\" : \"0\"; }\n set { this.MyValue = XmlConvert.ToBoolean(value); }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84449",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8205/"
] |
84,460
|
<p>I've been using Destop.open() to launch a .pdf viewer on Windows machines, both Vista and XP, and most of them work just fine. However, on one XP machine the call does not work, simply returning without throwing any exceptions, and the viewer does not launch. On that machine the file association is properly set up as far as I can tell: double-clicking a .pdf works, as does the "start xxx.pdf" command on the command prompt. I'm thinking it must be a Windows configuration issue, but can't put my finger on it.</p>
<p>Has anyone else seen this problem?</p>
|
[
{
"answer_id": 84529,
"author": "Martin Spamer",
"author_id": 15527,
"author_profile": "https://Stackoverflow.com/users/15527",
"pm_score": 2,
"selected": false,
"text": "Control Panel->Java Control Panel->Advanced->Java Console.\n"
},
{
"answer_id": 9962004,
"author": "Lund Wolfe",
"author_id": 1247753,
"author_profile": "https://Stackoverflow.com/users/1247753",
"pm_score": 1,
"selected": false,
"text": "Runtime rt = Runtime.getRuntime();\nrt.exec(new String[]{\"explorer\", \"C:\\\\myfile.pdf\"});\nrt.exec(new String[]{\"explorer\", \"C:\\\\myfile.wmv\"});\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84460",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16213/"
] |
84,463
|
<p>For example I want to be able to programatically hit a line of code like the following where the function name is dynamically assigned without using Evaluate(). The code below of course doesn't work but represents what I would like to do.</p>
<pre><code>application.obj[funcName](argumentCollection=params)
</code></pre>
<p>The only way I can find to call a function dynamically is by using cfinvoke, but as far as I can tell that instantiates the related cfc/function on the fly and can't use a previously instantiated cfc.</p>
<p>Thanks</p>
|
[
{
"answer_id": 84836,
"author": "Ben Doom",
"author_id": 12267,
"author_profile": "https://Stackoverflow.com/users/12267",
"pm_score": 4,
"selected": true,
"text": "<!--- Create the component instance. --->\n<cfobject component=\"tellTime2\" name=\"tellTimeObj\">\n<!--- Invoke the methods. --->\n<cfinvoke component=\"#tellTimeObj#\" method=\"getLocalTime\" returnvariable=\"localTime\">\n<cfinvoke component=\"#tellTimeObj#\" method=\"getUTCTime\" returnvariable=\"UTCTime\">\n"
},
{
"answer_id": 84840,
"author": "Patrick McElhaney",
"author_id": 437,
"author_profile": "https://Stackoverflow.com/users/437",
"pm_score": 2,
"selected": false,
"text": "<cfinvoke method=\"application.#funcName#\" argumentCollection=\"#params#\">\n"
},
{
"answer_id": 7802182,
"author": "Nick Harvey",
"author_id": 788583,
"author_profile": "https://Stackoverflow.com/users/788583",
"pm_score": 1,
"selected": false,
"text": "<!--- get the component (has methods 'sayHi' and a method 'sayHello') --->\n<cfset myObj = createObject(\"component\", \"test_object\")>\n\n<!--- set the function that we want dynamically then call it (it's a two step process) --->\n<cfset func = \"sayHi\">\n<cfset funcInstance = myObj[func]>\n<cfoutput>#funcInstance(\"Dave\")#</cfoutput>\n\n<cfset func = \"sayHello\">\n<cfset funcInstance = myObj[func]>\n<cfoutput>#funcInstance(\"Dave\")#</cfoutput>\n"
},
{
"answer_id": 7805955,
"author": "Aaron Greenlee",
"author_id": 88813,
"author_profile": "https://Stackoverflow.com/users/88813",
"pm_score": 1,
"selected": false,
"text": "funcName = 'foobar'; \napplication.obj.$fn = application.obj[funcName];\napplication.obj.$fn(argumentCollection=arguments);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8345/"
] |
84,486
|
<p>I've spent far too much time trying to figure this out. This should be the simplest thing and everyone who distributes Java applications in jars must have to deal with it.</p>
<p>I just want to know the proper way to add versioning to my Java app so that I can access the version information when I'm testing, e.g. debugging in Eclipse <strong>and</strong> running from a jar.</p>
<p>Here's what I have in my build.xml:</p>
<pre><code><target name="jar" depends = "compile">
<property name="version.num" value="1.0.0"/>
<buildnumber file="build.num"/>
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<manifest file="${build}/META-INF/MANIFEST.MF">
<attribute name="Built-By" value="${user.name}" />
<attribute name="Built-Date" value="${TODAY}" />
<attribute name="Implementation-Title" value="MyApp" />
<attribute name="Implementation-Vendor" value="MyCompany" />
<attribute name="Implementation-Version" value="${version.num}-b${build.number}"/>
</manifest>
<jar destfile="${build}/myapp.jar" basedir="${build}" excludes="*.jar" />
</target>
</code></pre>
<p>This creates /META-INF/MANIFEST.MF and I can read the values when I'm debugging in Eclipse thusly:</p>
<pre><code>public MyClass()
{
try
{
InputStream stream = getClass().getResourceAsStream("/META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(stream);
Attributes attributes = manifest.getMainAttributes();
String implementationTitle = attributes.getValue("Implementation-Title");
String implementationVersion = attributes.getValue("Implementation-Version");
String builtDate = attributes.getValue("Built-Date");
String builtBy = attributes.getValue("Built-By");
}
catch (IOException e)
{
logger.error("Couldn't read manifest.");
}
</code></pre>
<p>}</p>
<p>But, when I create the jar file, it loads the manifest of another jar (presumably the first jar loaded by the application - in my case, activation.jar).</p>
<p>Also, the following code doesn't work either although all the proper values are in the manifest file.</p>
<pre><code> Package thisPackage = getClass().getPackage();
String implementationVersion = thisPackage.getImplementationVersion();
</code></pre>
<p>Any ideas?</p>
|
[
{
"answer_id": 84945,
"author": "Martin Spamer",
"author_id": 15527,
"author_profile": "https://Stackoverflow.com/users/15527",
"pm_score": 1,
"selected": false,
"text": "this.getClass().getClassLoader().getResourceAsStream( ... ) ;\n Thread.currentThread().getContextClassLoader().getResourceAsStream( ... ) ;\n"
},
{
"answer_id": 94325,
"author": "basszero",
"author_id": 287,
"author_profile": "https://Stackoverflow.com/users/287",
"pm_score": 2,
"selected": false,
"text": "Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources(\"META-INF/MANIFEST.MF\");\n"
},
{
"answer_id": 149477,
"author": "user16216",
"author_id": 16216,
"author_profile": "https://Stackoverflow.com/users/16216",
"pm_score": 1,
"selected": false,
"text": "package com.company.division.project.packageversion;\n\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.util.jar.Attributes;\nimport java.util.jar.Manifest;\n\npublic class packageVersion\n{\n void printVersion()\n {\n try\n { \n InputStream stream = getClass().getResourceAsStream(\"/META-INF/MANIFEST.MF\");\n\n if (stream == null)\n {\n System.out.println(\"Couldn't find manifest.\");\n System.exit(0);\n }\n\n Manifest manifest = new Manifest(stream);\n\n Attributes attributes = manifest.getMainAttributes();\n\n String impTitle = attributes.getValue(\"Implementation-Title\");\n String impVersion = attributes.getValue(\"Implementation-Version\");\n String impBuildDate = attributes.getValue(\"Built-Date\");\n String impBuiltBy = attributes.getValue(\"Built-By\");\n\n if (impTitle != null)\n {\n System.out.println(\"Implementation-Title: \" + impTitle);\n } \n if (impVersion != null)\n {\n System.out.println(\"Implementation-Version: \" + impVersion);\n }\n if (impBuildDate != null)\n {\n System.out.println(\"Built-Date: \" + impBuildDate);\n }\n if (impBuiltBy != null)\n {\n System.out.println(\"Built-By: \" + impBuiltBy);\n }\n\n System.exit(0);\n }\n catch (IOException e)\n { \n System.out.println(\"Couldn't read manifest.\");\n } \n }\n\n /**\n * @param args\n */\n public static void main(String[] args)\n {\n packageVersion version = new packageVersion();\n version.printVersion(); \n }\n\n}\n <project name=\"packageVersion\" default=\"run\" basedir=\".\">\n\n <property name=\"src\" location=\"src\"/>\n <property name=\"build\" location=\"bin\"/>\n <property name=\"dist\" location=\"dist\"/>\n\n <target name=\"init\">\n <tstamp>\n <format property=\"TIMESTAMP\" pattern=\"yyyy-MM-dd HH:mm:ss\" />\n </tstamp>\n <mkdir dir=\"${build}\"/>\n <mkdir dir=\"${build}/META-INF\"/>\n </target>\n\n <target name=\"compile\" depends=\"init\">\n <javac debug=\"on\" srcdir=\"${src}\" destdir=\"${build}\"/>\n </target>\n\n <target name=\"dist\" depends = \"compile\"> \n <mkdir dir=\"${dist}\"/> \n <property name=\"version.num\" value=\"1.0.0\"/>\n <buildnumber file=\"build.num\"/>\n <manifest file=\"${build}/META-INF/MANIFEST.MF\">\n <attribute name=\"Built-By\" value=\"${user.name}\" />\n <attribute name=\"Built-Date\" value=\"${TIMESTAMP}\" /> \n <attribute name=\"Implementation-Vendor\" value=\"Company\" />\n <attribute name=\"Implementation-Title\" value=\"PackageVersion\" />\n <attribute name=\"Implementation-Version\" value=\"${version.num} (b${build.number})\"/>\n <section name=\"com/company/division/project/packageversion\">\n <attribute name=\"Sealed\" value=\"false\"/>\n </section> \n </manifest> \n <jar destfile=\"${dist}/packageversion-${version.num}.jar\" basedir=\"${build}\" manifest=\"${build}/META-INF/MANIFEST.MF\"/> \n </target>\n\n <target name=\"clean\">\n <delete dir=\"${build}\"/>\n <delete dir=\"${dist}\"/>\n </target>\n\n <target name=\"run\" depends=\"dist\"> \n <java classname=\"com.company.division.project.packageversion.packageVersion\">\n <arg value=\"-h\"/>\n <classpath>\n <pathelement location=\"${dist}/packageversion-${version.num}.jar\"/>\n <pathelement path=\"${java.class.path}\"/>\n </classpath>\n </java>\n </target>\n\n</project>\n"
},
{
"answer_id": 3069207,
"author": "Glenn Burkhardt",
"author_id": 370243,
"author_profile": "https://Stackoverflow.com/users/370243",
"pm_score": 1,
"selected": false,
"text": "String cp = PCAS.class.getResource(PCAS.class.getSimpleName() + \".class\").toString();\ncp = cp.substring(0, cp.indexOf(PCAS.class.getPackage().getName())) \n + \"META-INF/MANIFEST.MF\";\nManifest mf = new Manifest((new URL(cp)).openStream());\n"
},
{
"answer_id": 3071608,
"author": "gibbss",
"author_id": 116621,
"author_profile": "https://Stackoverflow.com/users/116621",
"pm_score": 4,
"selected": false,
"text": "@Test\npublic void testManifest() throws IOException {\n URL res = org.junit.Assert.class.getResource(org.junit.Assert.class.getSimpleName() + \".class\");\n JarURLConnection conn = (JarURLConnection) res.openConnection();\n Manifest mf = conn.getManifest();\n Attributes atts = mf.getMainAttributes();\n for (Object v : atts.values()) {\n System.out.println(v);\n }\n}\n"
},
{
"answer_id": 14089550,
"author": "yegor256",
"author_id": 187141,
"author_profile": "https://Stackoverflow.com/users/187141",
"pm_score": 0,
"selected": false,
"text": "Manifests MANIFEST.MF final String name = Manifests.read(\"Build-By\");\nfinal String date = Manifests.read(\"Build-Date\");\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16216/"
] |
84,488
|
<p>Is there some built-in way to share files between Xen guests? I don't currently need to share the actual images, just some data files.</p>
|
[
{
"answer_id": 35119359,
"author": "Vorell",
"author_id": 5865147,
"author_profile": "https://Stackoverflow.com/users/5865147",
"pm_score": 1,
"selected": false,
"text": "xvda3 /dev/md0 /dev/vg0/lg0"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9594/"
] |
84,506
|
<p>I find from reading perldoc perlvar, about a thousand lines in is help for %ENV. Is there a way to find that from the command line directly?</p>
<p>On my Windows machine, I've tried the following</p>
<pre><code>perldoc ENV
perldoc %ENV
perldoc %%ENV
perldoc -r ENV (returns info about Use Env)
perldoc -r %ENV
perldoc -r %%%ENV
perldoc -r %%%%ENV (says No documentation found for "%ENV")
</code></pre>
<p>None actually return information about the %ENV variable.</p>
<p>How do I use perldoc to find out about %ENV, if I don't want to have to eye-grep through thousands of line?</p>
<p>I've tried the suggested "perldoc perlvar" and then typing /%ENV, but nothing happens. </p>
<pre><code>perl -v: This is perl, v5.8.0 built for MSWin32-x86-multi-thread
</code></pre>
<p>Though I've asked about %ENV, this also applies to any general term, so knowing that %ENV is in perlvar for this one example won't help me next time when I don't know which section.</p>
<p>Is there a way to get perldoc to dump everything (ugh) and I can grep the output?</p>
|
[
{
"answer_id": 84786,
"author": "Eli Bendersky",
"author_id": 8206,
"author_profile": "https://Stackoverflow.com/users/8206",
"pm_score": 0,
"selected": false,
"text": "unixutils perldoc perlvar | grep -A10 %env"
},
{
"answer_id": 84791,
"author": "Ovid",
"author_id": 8003,
"author_profile": "https://Stackoverflow.com/users/8003",
"pm_score": 4,
"selected": false,
"text": "$ perldoc -v '%ENV'\n\n%ENV\n$ENV{expr}\nThe hash %ENV contains your current environment. Setting a value in\n\"ENV\" changes the environment for any child processes you subsequently\nfork() off.\n"
},
{
"answer_id": 91195,
"author": "ysth",
"author_id": 17389,
"author_profile": "https://Stackoverflow.com/users/17389",
"pm_score": 0,
"selected": false,
"text": "firefox http://perldoc.perl.org/perlvar.html#%ENV\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8763/"
] |
84,556
|
<p>Personally I like this one:</p>
<p><img src="https://i.stack.imgur.com/ZNtvc.jpg" alt=""></p>
<p>P.S. Do not hotlink the cartoon without the site's permission please. </p>
|
[
{
"answer_id": 1469915,
"author": "fixxxer",
"author_id": 170005,
"author_profile": "https://Stackoverflow.com/users/170005",
"pm_score": 3,
"selected": false,
"text": "HAI\nCAN HAS STDIO?\nI HAS A VAR\nIM IN YR LOOP\n UP VAR!!1\n VISIBLE VAR\n IZ VAR BIGGER THAN 10? KTHXBYE\nIM OUTTA YR LOOP\nKTHXBAI\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4230/"
] |
84,583
|
<p>The DBAs here maintain all SQL Server and SQL Reporting servers. I have a custom developed SQL Reporting 2005 project in Visual Studio that runs fine on my local SQL Database and Reporting instances. I need to deploy to a production server, so I had a folder created on a SQL Reporting 2005 server with permissions to upload files. Normally, a deploy from within Visual Studio is all that is needed to upload the report files.</p>
<p>However, for security purposes, data sources are maintained explicitly by DBAs and stored in a separated locked down common folder on the reporting server. I had them create the data source for me.</p>
<p>When I attempt to deploy from VS, it gives me the error </p>
<blockquote>
<p>The item '/Data Sources' already exists.</p>
</blockquote>
<p>I get this whether I'm deploying the whole project or just a single report file. I already set <code>OverwriteDataSources=false</code> in the project properties. The TargetServer URL and folder are verified correct.</p>
<p>I suppose I could copy the files manually, but I'd like to be able to deploy from within VS. What could I be doing wrong?</p>
|
[
{
"answer_id": 156077,
"author": "Peter Wone",
"author_id": 1715673,
"author_profile": "https://Stackoverflow.com/users/1715673",
"pm_score": 2,
"selected": false,
"text": " <DataSources>\n <DataSource Name=\"preserve the datasource name you've been using\">\n <ConnectionProperties>\n <DataProvider>SQL</DataProvider>\n <ConnectString>=Parameters!ConnectionString.Value</ConnectString>\n </ConnectionProperties>\n <rd:DataSourceID>preserve your existing GUID</rd:DataSourceID>\n </DataSource>\n </DataSources>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3347/"
] |
84,644
|
<p>To make it short: hibernate doesn't support projections and query by example? I found this post:</p>
<p>The code is this:</p>
<pre><code>User usr = new User();
usr.setCity = 'TEST';
getCurrentSession().createCriteria(User.class)
.setProjection( Projections.distinct( Projections.projectionList()
.add( Projections.property("name"), "name")
.add( Projections.property("city"), "city")))
.add( Example.create(usr))
</code></pre>
<p>Like the other poster said, The generated sql keeps having a where class refering to just <strong>y0_= ? instead of this_.city</strong>. </p>
<p>I already tried several approaches, and searched the issue tracker but found nothing about this.</p>
<p>I even tried to use Projection alias and Transformers, but it does not work:</p>
<pre><code>User usr = new User();
usr.setCity = 'TEST';
getCurrentSession().createCriteria(User.class)
.setProjection( Projections.distinct( Projections.projectionList()
.add( Projections.property("name"), "name")
.add( Projections.property("city"), "city")))
.add( Example.create(usr)).setResultTransformer(Transformers.aliasToBean(User.class));
</code></pre>
<p>Has anyone used projections and query by example ?</p>
|
[
{
"answer_id": 86752,
"author": "Arthur Thomas",
"author_id": 14009,
"author_profile": "https://Stackoverflow.com/users/14009",
"pm_score": 5,
"selected": true,
"text": "getCurrentSession().createCriteria(User.class)\n.setProjection( Projections.distinct( Projections.projectionList()\n.add( Projections.property(\"name\"), \"name\")\n.add( Projections.property(\"city\"), \"city\")))\n.add( Restrictions.eq(\"city\", \"TEST\")))\n.setResultTransformer(Transformers.aliasToBean(User.class))\n.list();\n List<Object> rows = criteria.list();\nfor(Object r: rows){\n Object[] row = (Object[]) r;\n Type t = ((<Type>) row[0]);\n}\n"
},
{
"answer_id": 960278,
"author": "Ryan Cook",
"author_id": 43029,
"author_profile": "https://Stackoverflow.com/users/43029",
"pm_score": 6,
"selected": false,
"text": "Criteria criteria = session.createCriteria(MyClass.class)\n .setProjection(Projections.projectionList()\n .add(Projections.property(\"sectionHeader\"), \"sectionHeader\")\n .add(Projections.property(\"subSectionHeader\"), \"subSectionHeader\")\n .add(Projections.property(\"sectionNumber\"), \"sectionNumber\"))\n .add(Restrictions.ilike(\"sectionHeader\", sectionHeaderVar)) // <- Problem!\n .setResultTransformer(Transformers.aliasToBean(MyDTO.class));\n select\n this_.SECTION_HEADER as y1_,\n this_.SUB_SECTION_HEADER as y2_,\n this_.SECTION_NUMBER as y3_,\nfrom\n MY_TABLE this_ \nwhere\n ( lower(y1_) like ? ) \n Criteria criteria = session.createCriteria(MyClass.class)\n .setProjection(Projections.projectionList()\n .add(Projections.property(\"sectionHeader\"), \"sectionHeader\")\n .add(Projections.property(\"subSectionHeader\"), \"subSectionHeader\")\n .add(Projections.property(\"sectionNumber\"), \"sectionNumber\"))\n .add(Restrictions.ilike(\"this.sectionHeader\", sectionHeaderVar)) // <- Problem Solved!\n .setResultTransformer(Transformers.aliasToBean(MyDTO.class));\n select\n this_.SECTION_HEADER as y1_,\n this_.SUB_SECTION_HEADER as y2_,\n this_.SECTION_NUMBER as y3_,\nfrom\n MY_TABLE this_ \nwhere\n ( lower(this_.SECTION_HEADER) like ? ) \n"
},
{
"answer_id": 976595,
"author": "VHristov",
"author_id": 120582,
"author_profile": "https://Stackoverflow.com/users/120582",
"pm_score": 0,
"selected": false,
"text": "select pageNo, abs(pageNo - 434) as diff\nfrom relA\nwhere year = 2009\norder by diff\n Criteria crit = getSession().createCriteria(Entity.class);\ncrit.add(exampleObject);\nProjectionList pl = Projections.projectionList();\npl.add( Projections.property(\"id\") );\npl.add(Projections.sqlProjection(\"abs(`pageNo`-\"+pageNo+\") as diff\", new String[] {\"diff\"}, types ));\ncrit.setProjection(pl);\n crit.addOrder(Order.asc(\"diff\"));\n"
},
{
"answer_id": 35381484,
"author": "singh",
"author_id": 5922685,
"author_profile": "https://Stackoverflow.com/users/5922685",
"pm_score": 0,
"selected": false,
"text": "ProjectionList pl = Projections.projectionList();\npl.add(Projections.property(\"id\"));\npl.add(Projections.sqlProjection(\"abs(`pageNo`-\" + pageNo + \") as diff\", new String[] {\"diff\"}, types ), diff); ---- solution\ncrit.addOrder(Order.asc(\"diff\"));\ncrit.setProjection(pl);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
84,661
|
<p>Sometimes, in PL SQL you want to add a parameter to a Package, Function or Procedure in order to prepare future functionality. For example:</p>
<pre><code>create or replace function doGetMyAccountMoney( Type_Of_Currency IN char := 'EUR') return number
is
Result number(12,2);
begin
Result := 10000;
IF char <> 'EUR' THEN
-- ERROR NOT IMPLEMENTED YET
END IF;
return(Result);
end doGetMyAccountMoney;also
</code></pre>
<p>It can lead to lots of warnings like</p>
<pre><code>Compilation errors for FUNCTION APPUEMP_PRAC.DOGETMYACCOUNTMONEY
Error: Hint: Parameter 'Currency' is declared but never used in 'doGetMyAccountMoney'
Line: 1
</code></pre>
<p>What would be the best way to avoid those warnings? </p>
|
[
{
"answer_id": 88742,
"author": "Sergey Stadnik",
"author_id": 10557,
"author_profile": "https://Stackoverflow.com/users/10557",
"pm_score": 1,
"selected": false,
"text": "ALTER SESSION SET PLSQL_WARNINGS='ENABLE:SEVERE';\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16206/"
] |
84,680
|
<p>I'm writing a Spring web application that requires users to login. My company has an Active Directory server that I'd like to make use of for this purpose. However, I'm having trouble using Spring Security to connect to the server.</p>
<p>I'm using Spring 2.5.5 and Spring Security 2.0.3, along with Java 1.6.</p>
<p>If I change the LDAP URL to the wrong IP address, it doesn't throw an exception or anything, so I'm wondering if it's even <em>trying</em> to connect to the server to begin with.</p>
<p>Although the web application starts up just fine, any information I enter into the login page is rejected. I had previously used an InMemoryDaoImpl, which worked fine, so the rest of my application seems to be configured correctly.</p>
<p>Here are my security-related beans:</p>
<pre><code> <beans:bean id="ldapAuthProvider" class="org.springframework.security.providers.ldap.LdapAuthenticationProvider">
<beans:constructor-arg>
<beans:bean class="org.springframework.security.providers.ldap.authenticator.BindAuthenticator">
<beans:constructor-arg ref="initialDirContextFactory" />
<beans:property name="userDnPatterns">
<beans:list>
<beans:value>CN={0},OU=SBSUsers,OU=Users,OU=MyBusiness,DC=Acme,DC=com</beans:value>
</beans:list>
</beans:property>
</beans:bean>
</beans:constructor-arg>
</beans:bean>
<beans:bean id="userDetailsService" class="org.springframework.security.userdetails.ldap.LdapUserDetailsManager">
<beans:constructor-arg ref="initialDirContextFactory" />
</beans:bean>
<beans:bean id="initialDirContextFactory" class="org.springframework.security.ldap.DefaultInitialDirContextFactory">
<beans:constructor-arg value="ldap://192.168.123.456:389/DC=Acme,DC=com" />
</beans:bean>
</code></pre>
|
[
{
"answer_id": 86367,
"author": "delfuego",
"author_id": 16414,
"author_profile": "https://Stackoverflow.com/users/16414",
"pm_score": 6,
"selected": true,
"text": "<beans:bean id=\"contextSource\"\n class=\"org.springframework.security.ldap.DefaultSpringSecurityContextSource\">\n <beans:constructor-arg value=\"ldap://hostname.queso.com:389/\" />\n</beans:bean>\n\n<beans:bean id=\"ldapAuthenticationProvider\"\n class=\"org.queso.ad.service.authentication.LdapAuthenticationProvider\">\n <beans:property name=\"authenticator\" ref=\"ldapAuthenticator\" />\n <custom-authentication-provider />\n</beans:bean>\n\n<beans:bean id=\"ldapAuthenticator\"\n class=\"org.queso.ad.service.authentication.LdapAuthenticatorImpl\">\n <beans:property name=\"contextFactory\" ref=\"contextSource\" />\n <beans:property name=\"principalPrefix\" value=\"QUESO\\\" />\n</beans:bean>\n /**\n * Custom Spring Security authentication provider which tries to bind to an LDAP server with\n * the passed-in credentials; of note, when used with the custom {@link LdapAuthenticatorImpl},\n * does <strong>not</strong> require an LDAP username and password for initial binding.\n * \n * @author Jason\n */\npublic class LdapAuthenticationProvider implements AuthenticationProvider {\n\n private LdapAuthenticator authenticator;\n\n public Authentication authenticate(Authentication auth) throws AuthenticationException {\n\n // Authenticate, using the passed-in credentials.\n DirContextOperations authAdapter = authenticator.authenticate(auth);\n\n // Creating an LdapAuthenticationToken (rather than using the existing Authentication\n // object) allows us to add the already-created LDAP context for our app to use later.\n LdapAuthenticationToken ldapAuth = new LdapAuthenticationToken(auth, \"ROLE_USER\");\n InitialLdapContext ldapContext = (InitialLdapContext) authAdapter\n .getObjectAttribute(\"ldapContext\");\n if (ldapContext != null) {\n ldapAuth.setContext(ldapContext);\n }\n\n return ldapAuth;\n }\n\n public boolean supports(Class clazz) {\n return (UsernamePasswordAuthenticationToken.class.isAssignableFrom(clazz));\n }\n\n public LdapAuthenticator getAuthenticator() {\n return authenticator;\n }\n\n public void setAuthenticator(LdapAuthenticator authenticator) {\n this.authenticator = authenticator;\n }\n\n}\n /**\n * Custom Spring Security LDAP authenticator which tries to bind to an LDAP server using the\n * passed-in credentials; does <strong>not</strong> require \"master\" credentials for an\n * initial bind prior to searching for the passed-in username.\n * \n * @author Jason\n */\npublic class LdapAuthenticatorImpl implements LdapAuthenticator {\n\n private DefaultSpringSecurityContextSource contextFactory;\n private String principalPrefix = \"\";\n\n public DirContextOperations authenticate(Authentication authentication) {\n\n // Grab the username and password out of the authentication object.\n String principal = principalPrefix + authentication.getName();\n String password = \"\";\n if (authentication.getCredentials() != null) {\n password = authentication.getCredentials().toString();\n }\n\n // If we have a valid username and password, try to authenticate.\n if (!(\"\".equals(principal.trim())) && !(\"\".equals(password.trim()))) {\n InitialLdapContext ldapContext = (InitialLdapContext) contextFactory\n .getReadWriteContext(principal, password);\n\n // We need to pass the context back out, so that the auth provider can add it to the\n // Authentication object.\n DirContextOperations authAdapter = new DirContextAdapter();\n authAdapter.addAttributeValue(\"ldapContext\", ldapContext);\n\n return authAdapter;\n } else {\n throw new BadCredentialsException(\"Blank username and/or password!\");\n }\n }\n\n /**\n * Since the InitialLdapContext that's stored as a property of an LdapAuthenticationToken is\n * transient (because it isn't Serializable), we need some way to recreate the\n * InitialLdapContext if it's null (e.g., if the LdapAuthenticationToken has been serialized\n * and deserialized). This is that mechanism.\n * \n * @param authenticator\n * the LdapAuthenticator instance from your application's context\n * @param auth\n * the LdapAuthenticationToken in which to recreate the InitialLdapContext\n * @return\n */\n static public InitialLdapContext recreateLdapContext(LdapAuthenticator authenticator,\n LdapAuthenticationToken auth) {\n DirContextOperations authAdapter = authenticator.authenticate(auth);\n InitialLdapContext context = (InitialLdapContext) authAdapter\n .getObjectAttribute(\"ldapContext\");\n auth.setContext(context);\n return context;\n }\n\n public DefaultSpringSecurityContextSource getContextFactory() {\n return contextFactory;\n }\n\n /**\n * Set the context factory to use for generating a new LDAP context.\n * \n * @param contextFactory\n */\n public void setContextFactory(DefaultSpringSecurityContextSource contextFactory) {\n this.contextFactory = contextFactory;\n }\n\n public String getPrincipalPrefix() {\n return principalPrefix;\n }\n\n /**\n * Set the string to be prepended to all principal names prior to attempting authentication\n * against the LDAP server. (For example, if the Active Directory wants the domain-name-plus\n * backslash prepended, use this.)\n * \n * @param principalPrefix\n */\n public void setPrincipalPrefix(String principalPrefix) {\n if (principalPrefix != null) {\n this.principalPrefix = principalPrefix;\n } else {\n this.principalPrefix = \"\";\n }\n }\n\n}\n /**\n * <p>\n * Authentication token to use when an app needs further access to the LDAP context used to\n * authenticate the user.\n * </p>\n * \n * <p>\n * When this is the Authentication object stored in the Spring Security context, an application\n * can retrieve the current LDAP context thusly:\n * </p>\n * \n * <pre>\n * LdapAuthenticationToken ldapAuth = (LdapAuthenticationToken) SecurityContextHolder\n * .getContext().getAuthentication();\n * InitialLdapContext ldapContext = ldapAuth.getContext();\n * </pre>\n * \n * @author Jason\n * \n */\npublic class LdapAuthenticationToken extends AbstractAuthenticationToken {\n\n private static final long serialVersionUID = -5040340622950665401L;\n\n private Authentication auth;\n transient private InitialLdapContext context;\n private List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();\n\n /**\n * Construct a new LdapAuthenticationToken, using an existing Authentication object and\n * granting all users a default authority.\n * \n * @param auth\n * @param defaultAuthority\n */\n public LdapAuthenticationToken(Authentication auth, GrantedAuthority defaultAuthority) {\n this.auth = auth;\n if (auth.getAuthorities() != null) {\n this.authorities.addAll(Arrays.asList(auth.getAuthorities()));\n }\n if (defaultAuthority != null) {\n this.authorities.add(defaultAuthority);\n }\n super.setAuthenticated(true);\n }\n\n /**\n * Construct a new LdapAuthenticationToken, using an existing Authentication object and\n * granting all users a default authority.\n * \n * @param auth\n * @param defaultAuthority\n */\n public LdapAuthenticationToken(Authentication auth, String defaultAuthority) {\n this(auth, new GrantedAuthorityImpl(defaultAuthority));\n }\n\n public GrantedAuthority[] getAuthorities() {\n GrantedAuthority[] authoritiesArray = this.authorities.toArray(new GrantedAuthority[0]);\n return authoritiesArray;\n }\n\n public void addAuthority(GrantedAuthority authority) {\n this.authorities.add(authority);\n }\n\n public Object getCredentials() {\n return auth.getCredentials();\n }\n\n public Object getPrincipal() {\n return auth.getPrincipal();\n }\n\n /**\n * Retrieve the LDAP context attached to this user's authentication object.\n * \n * @return the LDAP context\n */\n public InitialLdapContext getContext() {\n return context;\n }\n\n /**\n * Attach an LDAP context to this user's authentication object.\n * \n * @param context\n * the LDAP context\n */\n public void setContext(InitialLdapContext context) {\n this.context = context;\n }\n\n}\n"
},
{
"answer_id": 12468450,
"author": "rjc730",
"author_id": 714366,
"author_profile": "https://Stackoverflow.com/users/714366",
"pm_score": 0,
"selected": false,
"text": "$ host -t SRV _ldap._tcp.samdom.example.com.\n_ldap._tcp.samdom.example.com has SRV record 0 100 389 samba.samdom.example.com.\n $ host -t A samba.samdom.example.com.\nsamba.samdom.example.com has address 10.0.0.1\n"
},
{
"answer_id": 26425976,
"author": "Cookalino",
"author_id": 1069027,
"author_profile": "https://Stackoverflow.com/users/1069027",
"pm_score": 1,
"selected": false,
"text": "ldapAuthProvider1(ActiveDirectoryLdapAuthenticationProvider,\n \"mydomain.com\",\n \"ldap://mydomain.com/\"\n)\n grails.plugin.springsecurity.providerNames = ['ldapAuthProvider1']\n"
},
{
"answer_id": 36738996,
"author": "Riddhi Gohil",
"author_id": 5947458,
"author_profile": "https://Stackoverflow.com/users/5947458",
"pm_score": 1,
"selected": false,
"text": "@Configuration\n@EnableWebSecurity\npublic class SecurityConfig extends WebSecurityConfigurerAdapter {\n\n\nstatic final Logger LOGGER = LoggerFactory.getLogger(SecurityConfig.class);\n\n@Autowired\nprotected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {\n auth.authenticationProvider(activeDirectoryLdapAuthenticationProvider());\n}\n\n@Override\nprotected void configure(HttpSecurity http) throws Exception {\n http\n .authorizeRequests()\n .antMatchers(\"/\").permitAll()\n .anyRequest().authenticated();\n .and()\n .formLogin()\n .and()\n .logout();\n}\n\n@Bean\npublic AuthenticationProvider activeDirectoryLdapAuthenticationProvider() {\n ActiveDirectoryLdapAuthenticationProvider authenticationProvider = \n new ActiveDirectoryLdapAuthenticationProvider(\"<domain>\", \"<url>\");\n\n authenticationProvider.setConvertSubErrorCodesToExceptions(true);\n authenticationProvider.setUseAuthenticationRequestCredentials(true);\n\n return authenticationProvider;\n}\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13379/"
] |
84,716
|
<p>I use the jQuery <a href="http://docs.jquery.com/Utilities/jQuery.extend" rel="nofollow noreferrer">extend</a> function to extend a class prototype.</p>
<p>For example:</p>
<pre><code>MyWidget = function(name_var) {
this.init(name_var);
}
$.extend(MyWidget.prototype, {
// object variables
widget_name: '',
init: function(widget_name) {
// do initialization here
this.widget_name = widget_name;
},
doSomething: function() {
// an example object method
alert('my name is '+this.widget_name);
}
});
// example of using the class built above
var widget1 = new MyWidget('widget one');
widget1.doSomething();
</code></pre>
<p>Is there a better way to do this? Is there a cleaner way to create the class above with only one statement instead of two?</p>
|
[
{
"answer_id": 84824,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 6,
"selected": false,
"text": "var MyWidget = Class.extend({\n init: function(widget_name){\n this.widget_name = widget_name;\n },\n\n doSomething: function() {\n alert('my name is ' + this.widget_name);\n }\n});\n"
},
{
"answer_id": 88452,
"author": "Devon",
"author_id": 13850,
"author_profile": "https://Stackoverflow.com/users/13850",
"pm_score": 4,
"selected": false,
"text": "// Inspired by base2 and Prototype\n(function(){\n var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\\b_super\\b/ : /.*/;\n\n // The base Class implementation (does nothing)\n this.Class = function(){};\n\n // Create a new Class that inherits from this class\n Class.extend = function(prop) {\n var _super = this.prototype;\n\n // Instantiate a base class (but only create the instance,\n // don't run the init constructor)\n initializing = true;\n var prototype = new this();\n initializing = false;\n\n // Copy the properties over onto the new prototype\n for (var name in prop) {\n // Check if we're overwriting an existing function\n prototype[name] = typeof prop[name] == \"function\" &&\n typeof _super[name] == \"function\" && fnTest.test(prop[name]) ?\n (function(name, fn){\n return function() {\n var tmp = this._super;\n\n // Add a new ._super() method that is the same method\n // but on the super-class\n this._super = _super[name];\n\n // The method only need to be bound temporarily, so we\n // remove it when we're done executing\n var ret = fn.apply(this, arguments); \n this._super = tmp;\n\n return ret;\n };\n })(name, prop[name]) :\n prop[name];\n }\n\n // The dummy class constructor\n function Class() {\n // All construction is actually done in the init method\n if ( !initializing && this.init )\n this.init.apply(this, arguments);\n }\n\n // Populate our constructed prototype object\n Class.prototype = prototype;\n\n // Enforce the constructor to be what we expect\n Class.constructor = Class;\n\n // And make this class extendable\n Class.extend = arguments.callee;\n\n return Class;\n };\n})();\n var MyWidget = Class.extend({\n init: function(widget_name){\n this.widget_name = widget_name;\n },\n\n doSomething: function() {\n alert('my name is ' + this.widget_name);\n }\n});\n"
},
{
"answer_id": 14007970,
"author": "Paul Allsopp",
"author_id": 1620987,
"author_profile": "https://Stackoverflow.com/users/1620987",
"pm_score": 5,
"selected": false,
"text": "var myClass = function(){};\nmyClass.prototype = {\n some_property: null,\n some_other_property: 0,\n\n doSomething: function(msg) {\n this.some_property = msg;\n alert(this.some_property);\n }\n};\n var myClassObject = new myClass();\nmyClassObject.doSomething(\"Hello Worlds\");\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84716",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13850/"
] |
84,717
|
<p>What are the best conventions of naming testing-assemblies in .NET (or any other language or platform)?</p>
<p>What I'm mainly split between are these options (please provide others!):</p>
<ul>
<li><strong>Company.Website</strong> - <em>the project</em></li>
<li><strong>Company.Website.Tests</strong></li>
</ul>
<p><em>or</em></p>
<ul>
<li><strong>Company.Website</strong></li>
<li><strong>Company.WebsiteTests</strong></li>
</ul>
<p>The problem with the first solution is that it looks like .Tests are a sub-namespace to the site, while they really are more parallel in my mind. What happens when a new sub-namespace comes into play, like <strong>Company.Website.Controls</strong>, where should I put the tests for that namespace, for instance?</p>
<p>Maybe it should even be: <strong>Tests.Company.Website</strong> and <strong>Tests.Company.Website.Controls</strong>, and so on.</p>
|
[
{
"answer_id": 84809,
"author": "Tom Carr",
"author_id": 14954,
"author_profile": "https://Stackoverflow.com/users/14954",
"pm_score": 1,
"selected": false,
"text": "Company.Namespace.Test\nCompany.Namespace.Data.Test\n"
},
{
"answer_id": 84972,
"author": "Claus Thomsen",
"author_id": 15555,
"author_profile": "https://Stackoverflow.com/users/15555",
"pm_score": 6,
"selected": true,
"text": "* Company.Website - the project\n* Company.Website.Tests\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2429/"
] |
84,759
|
<p>This is an Eclipse question, and you can assume the Java package for all these Eclipse classes is <code>org.eclipse.core.resources</code>. </p>
<p>I want to get an <code>IFile</code> corresponding to a location <code>String</code> I have:</p>
<pre><code> "platform:/resource/Tracbility_All_Supported_lib/processes/gastuff/globalht/GlobalHTInterface.wsdl"
</code></pre>
<p>I have the enclosing <code>IWorkspace</code> and <code>IWorkspaceRoot</code>. If I had the <code>IPath</code> corresponding to the location above, I could simply call <code>IWorkspaceRoot.getFileForLocation(IPath)</code>.</p>
<p>How do I get the corresponding <code>IPath</code> from the location <code>String</code>? Or is there some other way to get the corresponding <code>IFile</code>?</p>
|
[
{
"answer_id": 85074,
"author": "Paul Reiners",
"author_id": 7648,
"author_profile": "https://Stackoverflow.com/users/7648",
"pm_score": 2,
"selected": false,
"text": "String platformLocationString = portTypeContainer\n .getLocation();\nString locationString = platformLocationString\n .substring(\"platform:/resource/\".length());\nIWorkspace workspace = ResourcesPlugin.getWorkspace();\nIWorkspaceRoot workspaceRoot = workspace.getRoot();\nIFile wSDLFile = (IFile) workspaceRoot\n .findMember(locationString);\n"
},
{
"answer_id": 85128,
"author": "Tirno",
"author_id": 9886,
"author_profile": "https://Stackoverflow.com/users/9886",
"pm_score": 3,
"selected": true,
"text": "IPath p = new Path(locationString);\nIWorkspaceRoot.getFileForLocation(p);\n fileUrl = FileLocator.toFileURL(new URL(locationString)); \nIWorkspaceRoot.getFileForLocation(fileUrl.getPath());\n"
},
{
"answer_id": 85502,
"author": "Roel Spilker",
"author_id": 12634,
"author_profile": "https://Stackoverflow.com/users/12634",
"pm_score": 2,
"selected": false,
"text": "workspaceRoot.findMember(String name)"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7648/"
] |
84,782
|
<p>I am writting JAVA programme using JDBC for database conntectivity , I am calling one stored procedure in that which is returning ORACLE REF CURSOR , IS there any way I can handle that without importing ORACLE PACKAGES ?</p>
|
[
{
"answer_id": 85766,
"author": "jwiklund",
"author_id": 4208,
"author_profile": "https://Stackoverflow.com/users/4208",
"pm_score": 2,
"selected": true,
"text": "select * from table( sp_returning( ? ) )\n"
},
{
"answer_id": 411052,
"author": "tuinstoel",
"author_id": 43901,
"author_profile": "https://Stackoverflow.com/users/43901",
"pm_score": -1,
"selected": false,
"text": "select * from table( sp_returning( ? ) )\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14299/"
] |
84,795
|
<p>How can I optimize the following code, which currently takes over 2 minutes to retrieve and loop through 800+ records from a pool of over 100K records, returning 6 fields per record (adds approximately 20 seconds per additional field):</p>
<pre><code><cfset dllPath="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.DirectoryServices.dll" />
<cfset LDAPPath="LDAP://" & arguments.searchPath />
<cfset theLookUp=CreateObject(".NET","System.DirectoryServices.DirectoryEntry", dllPath).init(LDAPPath) />
<cfset theSearch=CreateObject(".NET","System.DirectoryServices.DirectorySearcher", dllPath).init(theLookUp) />
<cfset theSearch.Set_Filter(arguments.theFilter) />
<cfset theObject = theSearch.FindAll() />
<cfloop index="row" from="#startRow#" to="#endRow#">
<cfset QueryAddRow(theQuery) />
<cfloop list="#columnList#" index="col">
<cfloop from="0" to="#theObject.Get_Item(row).Get_Properties().Get_Item(col).Get_Count()-1#" index="item">
<cftry>
<cfset theQuery[col][theQuery.recordCount]=ListAppend(theQuery[col][theQuery.recordCount],theObject.Get_Item(row).Get_Properties().Get_Item(col).Get_Item(item),"|") />
<cfcatch type="any">
</cfcatch>
</cftry>
</cfloop>
</cfloop>
</cfloop>
</code></pre>
|
[
{
"answer_id": 85913,
"author": "Peter Boughton",
"author_id": 9360,
"author_profile": "https://Stackoverflow.com/users/9360",
"pm_score": 3,
"selected": true,
"text": "<cfset dllPath=\"C:\\WINDOWS\\Microsoft.NET\\Framework\\v1.1.4322\\System.DirectoryServices.dll\" />\n<cfset LDAPPath=\"LDAP://\" & arguments.searchPath />\n<cfset theLookUp=CreateObject(\".NET\",\"System.DirectoryServices.DirectoryEntry\", dllPath).init(LDAPPath) />\n<cfset theSearch=CreateObject(\".NET\",\"System.DirectoryServices.DirectorySearcher\", dllPath).init(theLookUp) />\n<cfset theSearch.Set_Filter(arguments.theFilter) />\n<cfset theObject = theSearch.FindAll() />\n\n<cfloop index=\"row\" from=\"#startRow#\" to=\"#endRow#\">\n\n <cfset Props = theObject.get_item(row).get_properties() />\n\n <cfset QueryAddRow(theQuery) />\n\n <cfloop list=\"#columnList#\" index=\"col\">\n\n <cfset CurrentCol = Props.getItem(col) />\n\n <cfset ItemArray = ArrayNew(1)/>\n <cfloop from=\"0\" to=\"#CurrentCol.getcount() - 1#\" index=\"item\">\n <cftry>\n <cfset ArrayAppend( ItemArray , CurrentCol.Get_Item(item) )/>\n <cfcatch type=\"any\">\n </cfcatch>\n </cftry>\n </cfloop>\n <cfset theQuery[col][theQuery.recordCount] = ArrayToList( ItemArray , '|' )/>\n\n </cfloop>\n\n</cfloop>\n"
},
{
"answer_id": 85944,
"author": "kooshmoose",
"author_id": 7436,
"author_profile": "https://Stackoverflow.com/users/7436",
"pm_score": 0,
"selected": false,
"text": "<cfloop index=\"row\" from=\"#startRow#\" to=\"#endRow#\">\n<cfset QueryAddRow(theQuery) />\n<cfloop list=\"#columnList#\" index=\"col\">\n <cfset PipedVals = \"\">\n <cfset theItem = theObject.Get_Item(row).Get_Properties().Get_Item(col)>\n <cfset ColCount = theItem.Get_Count()-1>\n <cfloop from=\"0\" to=\"#ColCount#\" index=\"item\">\n <cftry>\n <cfset PipedVals = ListAppend(PipedVals,theItem.Get_Item(item),\"|\")>\n <cfcatch type=\"any\"></cfcatch>\n </cftry>\n </cfloop>\n <cfset QuerySetCell(theQuery,col) = PipedVals>\n</cfloop>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16289/"
] |
84,800
|
<p>I am looking for an efficient way to pull the data I want out of an array called $submission_info so I can easily auto-fill my form fields. The array size is about 120.</p>
<p>I want to find the field name and extract the content. In this case, the field name is <strong>loanOfficer</strong> and the content is <strong>John Doe</strong>.</p>
<pre><code>Output of Print_r($submission_info[1]):
Array (
[field_id] => 2399
[form_id] => 4
[field_name] => loanOfficer
[field_test_value] => ABCDEFGHIJKLMNOPQRSTUVWXYZ
[field_size] => medium
[field_type] => other
[data_type] => string
[field_title] => LoanOfficer
[col_name] => loanOfficer
[list_order] => 2
[admin_display] => yes
[is_sortable] => yes
[include_on_redirect] => yes
[option_orientation] => vertical
[file_upload_dir] =>
[file_upload_url] =>
[file_upload_max_size] => 1000000
[file_upload_types] =>
[content] => John Doe
)
</code></pre>
<p>I want to find the field name and extract the content. In this case, the field name is <strong>loanOfficer</strong> and the content is <strong>John Doe</strong>.</p>
|
[
{
"answer_id": 85117,
"author": "Randy",
"author_id": 9361,
"author_profile": "https://Stackoverflow.com/users/9361",
"pm_score": 3,
"selected": true,
"text": "foreach($submission_info as $elem) {\n $newarray[$elem[\"field_name\"]] = $elem[\"content\"];\n}\n"
},
{
"answer_id": 85199,
"author": "Matthew Encinas",
"author_id": 14433,
"author_profile": "https://Stackoverflow.com/users/14433",
"pm_score": 1,
"selected": false,
"text": "foreach($submission_info as $info){\n if($info['field_name'] == 'loanOfficer'){ //check the field name\n $content = $info['content']; //store the desired value\n continue; //this will stop the loop after the desired item is found\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16292/"
] |
84,803
|
<p>has anyone else seen this error message. a quick check with google doesn't show me much.</p>
|
[
{
"answer_id": 84900,
"author": "jessegavin",
"author_id": 5651,
"author_profile": "https://Stackoverflow.com/users/5651",
"pm_score": 2,
"selected": false,
"text": "alert($(\"#myElement\").tagName);\n alert($(\"#myElement\")[0].tagName);\n"
},
{
"answer_id": 5640718,
"author": "Abc",
"author_id": 369724,
"author_profile": "https://Stackoverflow.com/users/369724",
"pm_score": 1,
"selected": false,
"text": "$('body').append('hi!') append($('<div>hi</div><div>there</div>')) \n append($('<div><div>hi</div><div>there</div></div>')) \n appendChild insertBefore replaceChild window.fixDivxPlayerBug = function () {\n var b = document.getElementsByTagName('body')[0];\n if ( window['ReplaceVideoElements'] && ! b.appendChildDivx ){\n b.appendChildDivx = b.appendChild;\n b.appendChild = function (el) {\n if( el.tagName == null) {\n var wrap = document.createElement('div');\n wrap.appendChild(el);\n b.appendChildDivx(wrap);\n }\n else {\n b.appendChildDivx(el);\n }\n return el;\n };\n }\n};\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13800/"
] |
84,817
|
<p>We are producing a portable code (win+macOs) and we are looking at how to make the code more rubust as it crashes every so often... (overflows or bad initializations usually) :-(</p>
<p>I was reading that Google Chrome uses a process for every tab so if something goes wrong then the program does not crash compleatelly, only that tab. I think that is quite neat, so i might give it a go!</p>
<p>So i was wondering if someone has some tips, help, reading list, comment, or something that can help me build more rubust c++ code (portable is always better).</p>
<p>In the same topic i was also wondering if there is a portable library for processes (like boost)?</p>
<p>Well many Thanks. </p>
|
[
{
"answer_id": 85289,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 1,
"selected": false,
"text": "doSomethingBad(T * t)\n{\n if(t == NULL) return ;\n\n // do the processing.\n}\n doSomethingBad(T * t)\n{\n if(t == NULL) ::DebugBreak() ; // it will call the debugger\n\n // do the processing.\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16269/"
] |
84,837
|
<p>I have an ASP.NET 1.1 application, and on my local machine the submit button on my page works fine, but when I deploy it to our development application server, I click on Submit and nothing happens.. I'm assuming that the Page_Validate() function is failing and disabling the POSTBACK, but how do I debug this and determine what is failing? It sounds like some config problem since it works great on my local machine but not on the remote server...</p>
|
[
{
"answer_id": 145061,
"author": "Mauricio Scheffer",
"author_id": 21239,
"author_profile": "https://Stackoverflow.com/users/21239",
"pm_score": 0,
"selected": false,
"text": "aspnet_regiis.exe -c"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7243/"
] |
84,839
|
<p>I am trying to create an XML file based on data fields from a table, and I want to have the nodes named based on the value in a field from the table. The problem is that sometimes values entered in that column contain spaces and other characters not allowed in Node names.</p>
<p>Does anyone have any code that will cleanup a passed in string and repalce invalid characters with replacement text so that it can be reversed on the other end and get the original value back?</p>
<p>I am using .net (vb.net but I can read/convert c#)</p>
|
[
{
"answer_id": 145061,
"author": "Mauricio Scheffer",
"author_id": 21239,
"author_profile": "https://Stackoverflow.com/users/21239",
"pm_score": 0,
"selected": false,
"text": "aspnet_regiis.exe -c"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1889/"
] |
84,842
|
<p>I'm programmatically adding ToolStripButton items to a context menu.</p>
<p>That part is easy.</p>
<pre><code>this.tsmiDelete.DropDownItems.Add("The text on the item.");
</code></pre>
<p>However, I also need to wire up the events so that when the user clicks the item something actually happens!</p>
<p>How do I do this? The method that handles the click also needs to receive some sort of id or object that relates to the particular ToolStripButton that the user clicked.</p>
|
[
{
"answer_id": 84909,
"author": "Andy",
"author_id": 3857,
"author_profile": "https://Stackoverflow.com/users/3857",
"pm_score": 3,
"selected": true,
"text": "ToolStripButton btn = new ToolStripButton(\"The text on the item.\");\nthis.tsmiDelete.DropDownItems.Add(btn);\nbtn.Click += new EventHandler(OnBtnClicked);\n private void OnBtnClicked(object sender, EventArgs e)\n{\n ToolStripButton btn = sender as ToolStripButton;\n\n // handle the button click\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7837/"
] |
84,847
|
<p>How do I create a self-signed certificate for code signing using tools from the Windows SDK?</p>
|
[
{
"answer_id": 201277,
"author": "Roger Lipscombe",
"author_id": 8446,
"author_profile": "https://Stackoverflow.com/users/8446",
"pm_score": 10,
"selected": true,
"text": "makecert -r -pe -n \"CN=My CA\" -ss CA -sr CurrentUser ^\n -a sha256 -cy authority -sky signature -sv MyCA.pvk MyCA.cer\n certutil -user -addstore Root MyCA.cer\n makecert -pe -n \"CN=My SPC\" -a sha256 -cy end ^\n -sky signature ^\n -ic MyCA.cer -iv MyCA.pvk ^\n -sv MySPC.pvk MySPC.cer\n pvk2pfx -pvk MySPC.pvk -spc MySPC.cer -pfx MySPC.pfx\n pvk2pfx -pvk MySPC.pvk -spc MySPC.cer -pfx MySPC.pfx -po fess\n signtool sign /v /f MySPC.pfx ^\n /t http://timestamp.url MyExecutable.exe\n signtool sign /v /n \"Me\" /s SPC ^\n /t http://timestamp.url MyExecutable.exe\n signtool /t http://timestamp.verisign.com/scripts/timstamp.dll http://timestamp.globalsign.com/scripts/timstamp.dll http://timestamp.comodoca.com/authenticode http://timestamp.digicert.com"
},
{
"answer_id": 16027204,
"author": "Dan Kegel",
"author_id": 1539692,
"author_profile": "https://Stackoverflow.com/users/1539692",
"pm_score": 5,
"selected": false,
"text": "certutil -addstore Root Demo_CA.cer\n REM Demo of signing a printer driver with a self-signed test certificate.\nREM Run as administrator (else devcon won't be able to try installing the driver)\nREM Use a single 'x' as the password for all certificates for simplicity.\n\nPATH %PATH%;\"c:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\";\"c:\\Program Files\\Microsoft SDKs\\Windows\\v7.0\\Bin\";c:\\WinDDK\\7600.16385.1\\bin\\selfsign;c:\\WinDDK\\7600.16385.1\\Tools\\devcon\\amd64\n\nmakecert -r -pe -n \"CN=Demo_CA\" -ss CA -sr CurrentUser ^\n -a sha256 -cy authority -sky signature ^\n -sv Demo_CA.pvk Demo_CA.cer\n\nmakecert -pe -n \"CN=Demo_SPC\" -a sha256 -cy end ^\n -sky signature ^\n -ic Demo_CA.cer -iv Demo_CA.pvk ^\n -sv Demo_SPC.pvk Demo_SPC.cer\n\npvk2pfx -pvk Demo_SPC.pvk -spc Demo_SPC.cer ^\n -pfx Demo_SPC.pfx ^\n -po x\n\ninf2cat /drv:driver /os:XP_X86,Vista_X64,Vista_X86,7_X64,7_X86 /v\n\nsigntool sign /d \"description\" /du \"www.yoyodyne.com\" ^\n /f Demo_SPC.pfx ^\n /p x ^\n /v driver\\demoprinter.cat\n\ncertutil -addstore Root Demo_CA.cer\n\nrem Needs administrator. If this command works, the driver is properly signed.\ndevcon install driver\\demoprinter.inf LPTENUM\\Yoyodyne_IndustriesDemoPrinter_F84F\n\nrem Now uninstall the test driver and certificate.\ndevcon remove driver\\demoprinter.inf LPTENUM\\Yoyodyne_IndustriesDemoPrinter_F84F\n\ncertutil -delstore Root Demo_CA\n"
},
{
"answer_id": 47144138,
"author": "GorvGoyl",
"author_id": 3073272,
"author_profile": "https://Stackoverflow.com/users/3073272",
"pm_score": 5,
"selected": false,
"text": "D:/ setx CSC_KEY_PASSWORD \"my_password\""
},
{
"answer_id": 51443366,
"author": "chaami",
"author_id": 2647222,
"author_profile": "https://Stackoverflow.com/users/2647222",
"pm_score": 7,
"selected": false,
"text": "New-SelfSignedCertificate -DnsName email@yourdomain.com -Type CodeSigning -CertStoreLocation cert:\\CurrentUser\\My\n Export-Certificate -Cert (Get-ChildItem Cert:\\CurrentUser\\My -CodeSigningCert)[0] -FilePath code_signing.crt\n Import-Certificate -FilePath .\\code_signing.crt -Cert Cert:\\CurrentUser\\TrustedPublisher\n Import-Certificate -FilePath .\\code_signing.crt -Cert Cert:\\CurrentUser\\Root\n Set-AuthenticodeSignature .\\script.ps1 -Certificate (Get-ChildItem Cert:\\CurrentUser\\My -CodeSigningCert)\n"
},
{
"answer_id": 71770052,
"author": "Server Overflow",
"author_id": 46207,
"author_profile": "https://Stackoverflow.com/users/46207",
"pm_score": 0,
"selected": false,
"text": "prompt $\necho off\ncls\n\ncopy \"my.exe\" \"my.bak.exe\"\n\n\"c:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.22000.0\\x64\\signtool.exe\" sign /fd SHA256 /f MyCertificate.pfx /p MyPassword My.exe\n\npause \n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] |
84,882
|
<p>This is a pretty simple question, at least it seems like it should be, about sudo permissions in Linux.</p>
<p>There are a lot of times when I just want to append something to <code>/etc/hosts</code> or a similar file but end up not being able to because both <code>></code> and <code>>></code> are not allowed, even with root.</p>
<p>Is there someway to make this work without having to <code>su</code> or <code>sudo su</code> into root?</p>
|
[
{
"answer_id": 84898,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 4,
"selected": false,
"text": "sudo sh -c \"echo 127.0.0.1 localhost >> /etc/hosts\"\n"
},
{
"answer_id": 84899,
"author": "Matt P",
"author_id": 14230,
"author_profile": "https://Stackoverflow.com/users/14230",
"pm_score": 8,
"selected": false,
"text": "sudo sh -c \"echo 'something' >> /etc/privilegedfile\"\n"
},
{
"answer_id": 84914,
"author": "Incident",
"author_id": 11613,
"author_profile": "https://Stackoverflow.com/users/11613",
"pm_score": 5,
"selected": false,
"text": "sudo sh -c \"echo 'something' >> /etc/privilegedFile\"\n"
},
{
"answer_id": 84921,
"author": "agnul",
"author_id": 6069,
"author_profile": "https://Stackoverflow.com/users/6069",
"pm_score": 4,
"selected": false,
"text": "sudo sh -c \"echo >> somefile\"\n"
},
{
"answer_id": 550808,
"author": "Yoo",
"author_id": 37664,
"author_profile": "https://Stackoverflow.com/users/37664",
"pm_score": 11,
"selected": true,
"text": "tee --append tee -a echo 'deb blah ... blah' | sudo tee -a /etc/apt/sources.list\n echo 'deb blah ... blah' | sudo tee -a /etc/apt/sources.list > /dev/null\n -a --append tee > tee -a >>"
},
{
"answer_id": 21764479,
"author": "msanford",
"author_id": 114900,
"author_profile": "https://Stackoverflow.com/users/114900",
"pm_score": 4,
"selected": false,
"text": "sudo bash -c \"cat <<EOIPFW >> /etc/ipfw.conf\n<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\n\n<plist version=\\\"1.0\\\">\n <dict>\n <key>Label</key>\n <string>com.company.ipfw</string>\n <key>Program</key>\n <string>/sbin/ipfw</string>\n <key>ProgramArguments</key>\n <array>\n <string>/sbin/ipfw</string>\n <string>-q</string>\n <string>/etc/ipfw.conf</string>\n </array>\n <key>RunAtLoad</key>\n <true></true>\n </dict>\n</plist>\nEOIPFW\"\n"
},
{
"answer_id": 22517844,
"author": "Vytenis Bivainis",
"author_id": 815741,
"author_profile": "https://Stackoverflow.com/users/815741",
"pm_score": 3,
"selected": false,
"text": "tee > /dev/null echo \"# comment\" | sudo tee -a /etc/hosts > /dev/null\n"
},
{
"answer_id": 26023336,
"author": "hololeap",
"author_id": 983883,
"author_profile": "https://Stackoverflow.com/users/983883",
"pm_score": 3,
"selected": false,
"text": "~/.bashrc sudoe() {\n [[ \"$#\" -ne 2 ]] && echo \"Usage: sudoe <text> <file>\" && return 1\n echo \"$1\" | sudo tee --append \"$2\" > /dev/null\n}\n sudoe 'deb blah # blah' /etc/apt/sources.list -a sudoe() {\n if ([[ \"$1\" == \"-a\" ]] || [[ \"$1\" == \"--no-append\" ]]); then\n shift &>/dev/null || local failed=1\n else\n local append=\"--append\"\n fi\n\n while [[ $failed -ne 1 ]]; do\n if [[ -t 0 ]]; then\n text=\"$1\"; shift &>/dev/null || break\n else\n text=\"$(cat <&0)\"\n fi\n\n [[ -z \"$1\" ]] && break\n echo \"$text\" | sudo tee $append \"$1\" >/dev/null; return $?\n done\n\n echo \"Usage: $0 [-a|--no-append] [text] <file>\"; return 1\n}\n"
},
{
"answer_id": 41785490,
"author": "pixistix",
"author_id": 7451883,
"author_profile": "https://Stackoverflow.com/users/7451883",
"pm_score": -1,
"selected": false,
"text": "cat >> sudo chown youruser /etc/hosts \nsudo cat /downloaded/hostsadditions >> /etc/hosts \nsudo chown root /etc/hosts \n"
},
{
"answer_id": 46251017,
"author": "Fthi.a.Abadi",
"author_id": 3135632,
"author_profile": "https://Stackoverflow.com/users/3135632",
"pm_score": -1,
"selected": false,
"text": "echo \"export CATALINA_HOME=\"/opt/tomcat9\"\" >> /etc/environment\n echo \"export CATALINA_HOME=\"/opt/tomcat9\"\" |sudo tee /etc/environment\n"
},
{
"answer_id": 50003244,
"author": "Noam Manos",
"author_id": 658497,
"author_profile": "https://Stackoverflow.com/users/658497",
"pm_score": 2,
"selected": false,
"text": "sudo sed -i \"\\$ a $NEW_IP\\t\\t$NEW_HOST.domain.local\\t$NEW_HOST\" /etc/hosts\n"
},
{
"answer_id": 51053054,
"author": "Michael Goldshteyn",
"author_id": 473798,
"author_profile": "https://Stackoverflow.com/users/473798",
"pm_score": 2,
"selected": false,
"text": "sponge moreutils tee echo 'Add this line' | sudo sponge -a privfile\n"
},
{
"answer_id": 64048847,
"author": "abkrim",
"author_id": 736872,
"author_profile": "https://Stackoverflow.com/users/736872",
"pm_score": 3,
"selected": false,
"text": "sudo tee -a /path/file/to/create_with_text > /dev/null <<EOT \nline 1\nline 2\nline 3\nEOT\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9908/"
] |
84,885
|
<p>Wondering if anybody out there has any success in using the JDEdwards XMLInterop functionality. I've been using it for a while (with a simple PInvoke, will post code later). I'm looking to see if there's a better and/or more robust way.</p>
<p>Thanks.</p>
|
[
{
"answer_id": 154634,
"author": "Jon Dewees",
"author_id": 1365,
"author_profile": "https://Stackoverflow.com/users/1365",
"pm_score": 4,
"selected": true,
"text": "namespace YourNameSpace\n /// <summary>\n/// This webservice allows you to submit JDE XML CallObject requests via a c# webservice\n/// </summary>\n[WebService(Namespace = \"http://WebSite.com/\")]\n[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]\npublic class JdeBFService : System.Web.Services.WebService\n{\n private string _strServerName;\n private UInt16 _intServerPort;\n private Int16 _intServerTimeout;\n\n public JdeBFService()\n {\n // Load JDE ServerName, Port, & Connection Timeout from the Web.config file.\n _strServerName = ConfigurationManager.AppSettings[\"JdeServerName\"];\n _intServerPort = Convert.ToUInt16(ConfigurationManager.AppSettings[\"JdePort\"], CultureInfo.InvariantCulture);\n _intServerTimeout = Convert.ToInt16(ConfigurationManager.AppSettings[\"JdeTimeout\"], CultureInfo.InvariantCulture);\n\n }\n\n /// <summary>\n /// This webmethod allows you to submit an XML formatted jdeRequest document\n /// that will call any Master Business Function referenced in the XML document\n /// and return a response.\n /// </summary>\n /// <param name=\"Xml\"> The jdeRequest XML document </param>\n [WebMethod]\n public XmlDocument JdeXmlRequest(XmlDocument xmlInput)\n {\n try\n {\n string outputXml = string.Empty;\n outputXml = NativeMethods.JdeXmlRequest(xmlInput, _strServerName, _intServerPort, _intServerTimeout);\n\n XmlDocument outputXmlDoc = new XmlDocument();\n outputXmlDoc.LoadXml(outputXml);\n return outputXmlDoc;\n }\n catch (Exception ex)\n {\n ErrorReporting.SendEmail(ex);\n throw;\n }\n }\n}\n\n/// <summary>\n/// This interop class uses pinvoke to call the JDE C++ dll. It only has one static function.\n/// </summary>\n/// <remarks>\n/// This class calls the xmlinterop.dll which can be found in the B9/system/bin32 directory. \n/// Copy the dll to the webservice project's /bin directory before running the project.\n/// </remarks>\ninternal static class NativeMethods\n{\n [DllImport(\"xmlinterop.dll\",\n EntryPoint = \"_jdeXMLRequest@20\",\n CharSet = CharSet.Auto,\n ExactSpelling = false,\n CallingConvention = CallingConvention.StdCall,\n SetLastError = true)]\n private static extern IntPtr jdeXMLRequest([MarshalAs(UnmanagedType.LPWStr)] StringBuilder server, UInt16 port, Int32 timeout, [MarshalAs(UnmanagedType.LPStr)] StringBuilder buf, Int32 length);\n\n public static string JdeXmlRequest(XmlDocument xmlInput, string strServerName, UInt16 intPort, Int32 intTimeout)\n {\n StringBuilder sbServerName = new StringBuilder(strServerName);\n StringBuilder sbXML = new StringBuilder();\n XmlWriter xWriter = XmlWriter.Create(sbXML);\n xmlInput.WriteTo(xWriter);\n xWriter.Close();\n\n string result = Marshal.PtrToStringAnsi(jdeXMLRequest(sbServerName, intPort, intTimeout, sbXML, sbXML.Length));\n\n return result;\n }\n}\n <jdeRequest type='callmethod' user='USER' pwd='PWD' environment='ENV'>\n <callMethod name='GetEffectiveAddress' app='JdeWebRequest' runOnError='no'>\n <params>\n <param name='mnAddressNumber'>10000</param>\n </params>\n </callMethod>\n</jdeRequest>\n"
},
{
"answer_id": 19598192,
"author": "nkuebelbeck",
"author_id": 411490,
"author_profile": "https://Stackoverflow.com/users/411490",
"pm_score": 1,
"selected": false,
"text": "PSThread.dll\nicudt32.dll\nicui18n.dll\nicuuc.dll\njdel.dll\njdeunicode.dll\nlibeay32.dll\nmsvcp71.dll\nssleay32.dll\nustdio.dll\nxmlinterop.dll\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1365/"
] |
84,912
|
<p>Making a web page display correctly im all major browsers today is a very time consuming task.</p>
<p>Is there a easy way to make a CSS style that looks identical in every browser?
Or at least do you have some tips to make this work easier?</p>
|
[
{
"answer_id": 84975,
"author": "Toby Mills",
"author_id": 12377,
"author_profile": "https://Stackoverflow.com/users/12377",
"pm_score": 3,
"selected": false,
"text": "<!--[if lte IE 6]>\n<link href=\"/css/eqtr_ie6.css\" rel=\"stylesheet\" type=\"text/css\" />\n<![endif]-->\n"
},
{
"answer_id": 84977,
"author": "Twan",
"author_id": 6702,
"author_profile": "https://Stackoverflow.com/users/6702",
"pm_score": 0,
"selected": false,
"text": "$sHTML .= \"\\t\\t<LINK rel=\\\"stylesheet\\\" type=\\\"text/css\\\" href=\\\"\".$sURLCSS.$sStyle.\"\\\" />\\n\";\nif (file_exists($sPathCSS.$sFileStyle.\"_\".BROWSER_AGENT.\".\".$sExtension))\n $sHTML .= \"\\t\\t<LINK rel=\\\"stylesheet\\\" type=\\\"text/css\\\" href=\\\"\".$sURLCSS.$sFileStyle.\"_\".BROWSER_AGENT.\".\".$sExtension.\"\\\" />\\n\";\nif (file_exists($sPathCSS.$sFileStyle.\"_\".BROWSER_AGENT.\"_\".BROWSER_VERSION.\".\".$sExtension))\n $sHTML .= \"\\t\\t<LINK rel=\\\"stylesheet\\\" type=\\\"text/css\\\" href=\\\"\".$sURLCSS.$sFileStyle.\"_\".BROWSER_AGENT.\"_\".BROWSER_VERSION.\".\".$sExtension.\"\\\" />\\n\";\n"
},
{
"answer_id": 85112,
"author": "micahwittman",
"author_id": 11181,
"author_profile": "https://Stackoverflow.com/users/11181",
"pm_score": 2,
"selected": false,
"text": "<head>\n <link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"styles/yui/grids/base-min.css\" />\n <link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"styles/yui/grids/grids.css\" />\n <link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"styles/screen.foo.css\" />\n <link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\"styles/print.foo.css\" /> <!--[if gt IE 5]> <link rel=\"stylesheet\" type=\"text/css\" href=\"styles/ie.screen.foo.css\" /> <![endif]-->\n </head>"
},
{
"answer_id": 85817,
"author": "jelmer",
"author_id": 16499,
"author_profile": "https://Stackoverflow.com/users/16499",
"pm_score": 2,
"selected": false,
"text": "*{margin: 0; padding: 0}\n"
},
{
"answer_id": 210736,
"author": "Jethro Larson",
"author_id": 22425,
"author_profile": "https://Stackoverflow.com/users/22425",
"pm_score": -1,
"selected": false,
"text": "*{display:none}\n"
},
{
"answer_id": 395676,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<!DOCTYPE html>\n<html>\n<head>\n <style>* { background: #fff }</style>\n</head>\n<body></body>\n</html>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14635/"
] |
84,932
|
<p>I have Perl script and need to determine the full path and filename of the script during execution. I discovered that depending on how you call the script <code>$0</code> varies and sometimes contains the <code>fullpath+filename</code> and sometimes just <code>filename</code>. Because the working directory can vary as well I can't think of a way to reliably get the <code>fullpath+filename</code> of the script.</p>
<p>Anyone got a solution?</p>
|
[
{
"answer_id": 84959,
"author": "Ovid",
"author_id": 8003,
"author_profile": "https://Stackoverflow.com/users/8003",
"pm_score": 7,
"selected": false,
"text": "use Cwd 'abs_path';\nprint abs_path($0);\n"
},
{
"answer_id": 84973,
"author": "Sean",
"author_id": 4919,
"author_profile": "https://Stackoverflow.com/users/4919",
"pm_score": 3,
"selected": false,
"text": "$ENV{'SCRIPT_NAME'}\n use FindBin '$Bin';\nprint \"The script is located in $Bin.\\n\";\n"
},
{
"answer_id": 84982,
"author": "bmdhacks",
"author_id": 14032,
"author_profile": "https://Stackoverflow.com/users/14032",
"pm_score": 4,
"selected": false,
"text": "#!/usr/bin/perl\nuse FindBin;\n\n$0 = \"stealth\";\nprint \"The actual path to this is: $FindBin::Bin/$FindBin::Script\\n\";\n"
},
{
"answer_id": 85037,
"author": "Benjamin W. Smith",
"author_id": 1068060,
"author_profile": "https://Stackoverflow.com/users/1068060",
"pm_score": 4,
"selected": false,
"text": "use Cwd qw(abs_path);\nmy $path = abs_path($0);\nprint \"$path\\n\";\n"
},
{
"answer_id": 85070,
"author": "Mark",
"author_id": 16363,
"author_profile": "https://Stackoverflow.com/users/16363",
"pm_score": 5,
"selected": false,
"text": "use File::Spec;\nFile::Spec->rel2abs( __FILE__ );\n"
},
{
"answer_id": 85098,
"author": "moritz",
"author_id": 14132,
"author_profile": "https://Stackoverflow.com/users/14132",
"pm_score": 2,
"selected": false,
"text": "rel2abs() $0"
},
{
"answer_id": 85264,
"author": "wnoise",
"author_id": 15464,
"author_profile": "https://Stackoverflow.com/users/15464",
"pm_score": 3,
"selected": false,
"text": "__FILE__ $0 File::Spec->rel2abs( __FILE__ );"
},
{
"answer_id": 90721,
"author": "Drew Stephens",
"author_id": 17339,
"author_profile": "https://Stackoverflow.com/users/17339",
"pm_score": 9,
"selected": true,
"text": "$0 cwd() getcwd() abs_path() Cwd FindBin $Bin $RealBin $Script $RealScript __FILE__ $0 Cwd FindBin mod_perl '.' __FILE__ File::Basename use File::Basename;\nmy $dirname = dirname(__FILE__);\n"
},
{
"answer_id": 90769,
"author": "Eric Wilhelm",
"author_id": 11580,
"author_profile": "https://Stackoverflow.com/users/11580",
"pm_score": 3,
"selected": false,
"text": "$0 __FILE__ chdir() $0 BEGIN{} FindBin $PATH basename($0) File::Fu File::Fu->program_name File::Fu->program_dir"
},
{
"answer_id": 5516160,
"author": "Yong Li",
"author_id": 687946,
"author_profile": "https://Stackoverflow.com/users/687946",
"pm_score": 1,
"selected": false,
"text": "my $thisfile = $1 if $0 =~\n/\\\\([^\\\\]*)$|\\/([^\\/]*)$/;\n\nprint \"You are running $thisfile\nnow.\\n\";\n You are running MyFileName.pl now.\n"
},
{
"answer_id": 6997006,
"author": "Yordan Georgiev",
"author_id": 65706,
"author_profile": "https://Stackoverflow.com/users/65706",
"pm_score": 0,
"selected": false,
"text": "use strict ; use warnings ; use Cwd 'abs_path';\n sub ResolveMyProductBaseDir { \n\n # Start - Resolve the ProductBaseDir\n #resolve the run dir where this scripts is placed\n my $ScriptAbsolutPath = abs_path($0) ; \n #debug print \"\\$ScriptAbsolutPath is $ScriptAbsolutPath \\n\" ;\n $ScriptAbsolutPath =~ m/^(.*)(\\\\|\\/)(.*)\\.([a-z]*)/; \n $RunDir = $1 ; \n #debug print \"\\$1 is $1 \\n\" ;\n #change the \\'s to /'s if we are on Windows\n $RunDir =~s/\\\\/\\//gi ; \n my @DirParts = split ('/' , $RunDir) ; \n for (my $count=0; $count < 4; $count++) { pop @DirParts ; }\n my $ProductBaseDir = join ( '/' , @DirParts ) ; \n # Stop - Resolve the ProductBaseDir\n #debug print \"ResolveMyProductBaseDir $ProductBaseDir is $ProductBaseDir \\n\" ; \n return $ProductBaseDir ; \n } #eof sub \n"
},
{
"answer_id": 13566423,
"author": "mkc",
"author_id": 1853620,
"author_profile": "https://Stackoverflow.com/users/1853620",
"pm_score": 1,
"selected": false,
"text": "#!/usr/bin/perl -w\nuse strict;\n\n\nmy $path = $0;\n$path =~ s/\\.\\///g;\nif ($path =~ /\\//){\n if ($path =~ /^\\//){\n $path =~ /^((\\/[^\\/]+){1,}\\/)[^\\/]+$/;\n $path = $1;\n }\n else {\n $path =~ /^(([^\\/]+\\/){1,})[^\\/]+$/;\n my $path_b = $1;\n my $path_a = `pwd`;\n chop($path_a);\n $path = $path_a.\"/\".$path_b;\n }\n }\nelse{\n $path = `pwd`;\n chop($path);\n $path.=\"/\";\n }\n$path =~ s/\\/\\//\\//g;\n\n\n\nprint \"\\n$path\\n\";\n"
},
{
"answer_id": 17735548,
"author": "Matt",
"author_id": 2597514,
"author_profile": "https://Stackoverflow.com/users/2597514",
"pm_score": 3,
"selected": false,
"text": "#!/usr/bin/perl\nuse strict;\nuse warnings;\nuse File::Spec;\nuse File::Basename;\n\nmy $dir = dirname(File::Spec->rel2abs(__FILE__));\n"
},
{
"answer_id": 20349041,
"author": "user3061015",
"author_id": 3061015,
"author_profile": "https://Stackoverflow.com/users/3061015",
"pm_score": -1,
"selected": false,
"text": "$^X #!/usr/bin/env perl<br>\nprint \"This is executed by $^X\\n\";\n"
},
{
"answer_id": 20565937,
"author": "Jonathan",
"author_id": 271450,
"author_profile": "https://Stackoverflow.com/users/271450",
"pm_score": 0,
"selected": false,
"text": "__FILE__ Cwd my $path;\n\nuse File::Basename;\nmy $file = basename($ENV{SCRIPT_NAME});\n\nif (exists $ENV{MOD_PERL} && ($ENV{MOD_PERL_API_VERSION} < 2)) {\n if ($^O =~/Win/) {\n $path = `echo %cd%`;\n chop $path;\n $path =~ s!\\\\!/!g;\n $path .= $ENV{SCRIPT_NAME};\n }\n else {\n $path = `pwd`;\n $path .= \"/$file\";\n }\n # add support for other operating systems\n}\nelse {\n require Cwd;\n $path = Cwd::getcwd().\"/$file\";\n}\nprint $path;\n"
},
{
"answer_id": 21605869,
"author": "Putnik",
"author_id": 1013183,
"author_profile": "https://Stackoverflow.com/users/1013183",
"pm_score": 0,
"selected": false,
"text": "my $self = `pwd`;\nchomp $self;\n$self .='/'.$1 if $0 =~/([^\\/]*)$/; #keep the filename only\nprint \"self=$self\\n\";\n $ /my/temp/Host$ perl ./host-mod.pl \nself=/my/temp/Host/host-mod.pl\n\n$ /my/temp/Host$ ./host-mod.pl \nself=/my/temp/Host/host-mod.pl\n\n$ /my/temp/Host$ ../Host/./host-mod.pl \nself=/my/temp/Host/host-mod.pl\n"
},
{
"answer_id": 23149908,
"author": "DavidGamba",
"author_id": 1601989,
"author_profile": "https://Stackoverflow.com/users/1601989",
"pm_score": 1,
"selected": false,
"text": "dirname(__FILE__) use File::Basename;\nmy $script_dir = undef;\nif(-l __FILE__) {\n $script_dir = dirname(readlink(__FILE__));\n}\nelse {\n $script_dir = dirname(__FILE__);\n}\n"
},
{
"answer_id": 24515046,
"author": "daniel souza",
"author_id": 1226168,
"author_profile": "https://Stackoverflow.com/users/1226168",
"pm_score": 2,
"selected": false,
"text": "$0 =~ m/(.+)[\\/\\\\](.+)$/;\nprint \"full path: $1, file name: $2\\n\";\n"
},
{
"answer_id": 25663214,
"author": "Elmar",
"author_id": 4007562,
"author_profile": "https://Stackoverflow.com/users/4007562",
"pm_score": 0,
"selected": false,
"text": " my $callpath = $0;\n my $pwd = `pwd`; chomp($pwd);\n\n # if called relative -> add pwd in front\n if ($callpath !~ /^\\//) { $callpath = $pwd.\"/\".$callpath; } \n\n # do the cleanup\n $callpath =~ s!^\\./!!; # starts with ./ -> drop\n $callpath =~ s!/\\./!/!g; # /./ -> /\n $callpath =~ s!/\\./!/!g; # /./ -> / (twice)\n\n $callpath =~ s!/[^/]+/\\.\\./!/!g; # /xxx/../ -> /\n $callpath =~ s!/[^/]+/\\.\\./!/!g; # /xxx/../ -> / (twice)\n\n my $calldir = $callpath;\n $calldir =~ s/(.*)\\/([^\\/]+)/$1/;\n"
},
{
"answer_id": 52944919,
"author": "drjumper",
"author_id": 5116399,
"author_profile": "https://Stackoverflow.com/users/5116399",
"pm_score": 0,
"selected": false,
"text": "sub get_script_full_path {\n use File::Basename;\n use File::Spec;\n use Cwd qw(chdir cwd);\n my $curr_dir = cwd();\n chdir(dirname($0));\n my $dir = $ENV{PWD};\n chdir( $curr_dir);\n return File::Spec->catfile($dir, basename($0));\n}\n"
},
{
"answer_id": 58417063,
"author": "user3228609",
"author_id": 3228609,
"author_profile": "https://Stackoverflow.com/users/3228609",
"pm_score": 0,
"selected": false,
"text": "dirname abs_path use File::Basename;\nuse Cwd qw(abs_path);\n\n# absolute path of the directory containing the executing script\nmy $abs_dirname = dirname(abs_path($0));\nprint \"\\ndirname(abs_path(\\$0)) -> $abs_dirname\\n\";\n # this gives the answer I want in relative path form, not absolute\nmy $rel_dirname = dirname(__FILE__); \nprint \"dirname(__FILE__) -> $rel_dirname\\n\"; \n\n# this gives the slightly wrong answer, but in the form I want \nmy $full_filepath = abs_path($0);\nprint \"abs_path(\\$0) -> $full_filepath\\n\";\n"
},
{
"answer_id": 63550144,
"author": "user3673",
"author_id": 871821,
"author_profile": "https://Stackoverflow.com/users/871821",
"pm_score": 0,
"selected": false,
"text": "use File::Basename;\nuse Cwd 'abs_path';\nprint dirname(abs_path(__FILE__)) ;\n $ cat >testdirname\nuse File::Basename;\nprint dirname(__FILE__);\n$ perl testdirname\n.$ perl -v\n\nThis is perl 5, version 28, subversion 1 (v5.28.1) built for x86_64-linux-gnu-thread-multi][1]\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16331/"
] |
84,968
|
<p>If I open a file in Design View (web form), I get intellisense for my display code, but not my script code.. If I open with source code editor I, occasionally, get intellisense within the script tags. </p>
<p>Anyone know how to get intellisense working all of the time for all of my code? </p>
<p>Been living with this one for a long time.</p>
|
[
{
"answer_id": 85583,
"author": "devlord",
"author_id": 16454,
"author_profile": "https://Stackoverflow.com/users/16454",
"pm_score": 1,
"selected": false,
"text": "<script runat=\"server\"> <%@ Page Language=\"C#\" %>\n <script>"
},
{
"answer_id": 86256,
"author": "madcolor",
"author_id": 13954,
"author_profile": "https://Stackoverflow.com/users/13954",
"pm_score": 2,
"selected": true,
"text": "<%@ Page Language=\"C#\" MasterPageFile=\"~/common/masterpages/MasterPage.master\" %> <asp: <script> <script>"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13954/"
] |
84,992
|
<p>I'm trying to register an externally hosted SQL 2000 server through Enterprise Manager which isn't on the default port and I can't see anywhere to change it within Enterprise Manager.</p>
<p>So, the question is, how do I connect to the database if:</p>
<p>I.P. Address is 123.456.789 (example)</p>
<p>Port is 1334</p>
|
[
{
"answer_id": 86031,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "\\\\[instance]"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
84,995
|
<p>I'm looking for a way to stream a PDF file from my server to the browser using .NET 2.0 (in binary).</p>
<p>I'm trying to grab an existing PDF file from a server path and push that up as binary to the browser.</p>
|
[
{
"answer_id": 85002,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 1,
"selected": false,
"text": "Response.OutputStream Content-Disposition"
},
{
"answer_id": 85053,
"author": "foxxtrot",
"author_id": 10369,
"author_profile": "https://Stackoverflow.com/users/10369",
"pm_score": 2,
"selected": false,
"text": "Response.ContentType = \"application/pdf\" Response.Headers.Add(\"Content-Disposition\", \"attachment: filename=file.pdf\"); Response.OutputStream"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/84995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2701/"
] |
85,006
|
<p>I have loaded image into a new, initialized Oracle ORDImage object and am processing it by PL/SQL. I can read its properties, but cannot process it with the process() method. </p>
<pre><code>vLocalImage ORDImage := ORDImage.init();
...
vLocalImage.source.localdata := PORTAL.wwdoc_admin.get_document_blob_content(pFile);
vLocalImage.setProperties();
...
if vLocalImage.width > lMaxWidth
then
vLocalImage.process('maxScale 534 401');
end if;
</code></pre>
<p>This should scale the image down, conserving aspect ratio, so that it is no more than 534 px wide and no more than 401 px high. </p>
<p>However, I get the following error stack:</p>
<pre><code>Internal error: ORA-29400: data cartridge error
IMG-00710: unable to write to destination image
ORA-01031: insufficient privileges
</code></pre>
<p>Trying other operations (like 'rotate 90') gives same errors.</p>
|
[
{
"answer_id": 253114,
"author": "Sten Vesterli",
"author_id": 9363,
"author_profile": "https://Stackoverflow.com/users/9363",
"pm_score": 3,
"selected": true,
"text": " vNewImage ORDImage;\n...\n vLocalImage.processCopy('maxScale 534 401', vNewImage);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9363/"
] |
85,019
|
<p>Google Maps used to do this bit where when you hit the "Print" link, what would be sent to the printer wasn't exactly what you had on the screen, but rather a differently-formatted version of mostly the same information.</p>
<p>It appears that they've largely moved away from this concept (I guess people didn't understand it) and most websites have a "print version" of things like articles and so forth.</p>
<p>But if you wanted to make a webpage such that a "printer friendly" version of the page is what gets sent to the printer without having to make a separate page for it, how would you do that?</p>
|
[
{
"answer_id": 85061,
"author": "skamradt",
"author_id": 9217,
"author_profile": "https://Stackoverflow.com/users/9217",
"pm_score": 3,
"selected": false,
"text": "<link rel=\"stylesheet\" type=\"text/css\" href=\"print.css\" media=\"print, handheld\" />\n<link rel=\"stylesheet\" type=\"text/css\" href=\"screen.css\" media=\"screen\" />\n .newStyle1 {\n display: none;\n}\n newStyle1"
},
{
"answer_id": 85067,
"author": "Toby Mills",
"author_id": 12377,
"author_profile": "https://Stackoverflow.com/users/12377",
"pm_score": 1,
"selected": false,
"text": "<link href=\"css/print.css\" type=\"text/css\" rel=\"stylesheet\" media=\"print\" />"
},
{
"answer_id": 85087,
"author": "Twan",
"author_id": 6702,
"author_profile": "https://Stackoverflow.com/users/6702",
"pm_score": 0,
"selected": false,
"text": "if (!BOOL_PRINT)\n echo \"<TD class=\\\"tbl_teams_scroll_item\\\"><SPAN class=\\\"span_password_hidden\\\" id=\\\"span_password_{\\$team_id}\\\" onClick=\\\"RevealPassword('{\\$team_id}','{\\$password}');\\\"><xsl:value-of select=\\\"/PAGE/TEXTS/HIDDEN\\\" /></SPAN></TD>\\n\";\nelse\n echo \"TD class=\\\"tbl_teams_scroll_item\\\"><xsl:value-of select=\\\"PASSWORD\\\" /></TD>\\n\";\n"
},
{
"answer_id": 85107,
"author": "JacquesB",
"author_id": 7488,
"author_profile": "https://Stackoverflow.com/users/7488",
"pm_score": 2,
"selected": false,
"text": "@media @media print {\n .sidebar { display: none; }\n}\n <link rel=\"stylesheet\" href=\"print.css\" type=\"text/css\" media=\"print\" />\n"
},
{
"answer_id": 85110,
"author": "dave",
"author_id": 14355,
"author_profile": "https://Stackoverflow.com/users/14355",
"pm_score": 0,
"selected": false,
"text": " @media print {\n BODY { font-size: 10pt }\n }\n @media screen {\n BODY { font-size: 12pt }\n }\n @media screen, print {\n BODY { line-height: 1.2 }\n }\n <link href=\"webstyles.css\" type=\"text/css\" rel=\"stylesheet\" media=\"screen\"/>\n <link href=\"printstyles.css\" type=\"text/css\" rel=\"stylesheet\" media=\"print\"/>\n <link href=\"commonstyles.css\" type=\"text/css\" rel=\"stylesheet\" media=\"screen,print\"/>\n"
},
{
"answer_id": 87095,
"author": "Steve Perks",
"author_id": 16124,
"author_profile": "https://Stackoverflow.com/users/16124",
"pm_score": 0,
"selected": false,
"text": "window.print() $(document).ready(function(){\n $(\"#printFriendly\").click(function(){\n $(link[rel=link][media=screen]).remove();\n $(link[rel=link][media=print]).attr(\"media\",\"screen\");\n });\n});\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2577/"
] |
85,033
|
<p>I am wrapping a native C++ class, which has the following methods:</p>
<pre><code>class Native
{
public:
class Local
{
std::string m_Str;
int m_Int;
};
typedef std::vector<Local> LocalVec;
typedef LocalVec::iterator LocalIter;
LocalIter BeginLocals();
LocalIter EndLocals();
private:
LocalVec m_Locals;
};
</code></pre>
<p>1) What is the ".NET way" of representing this same kind of interface? A single method returning an array<>? Does the array<> generic have iterators, so that I could implement BeginLocals() and EndLocals()? </p>
<p>2) Should Local be declared as a <strong>value struct</strong> in the .NET wrapper?</p>
<p>I'd really like to represent the wrapped class with a .NET flavor, but I'm very new to the managed world - and this type of information is frustrating to google for...</p>
|
[
{
"answer_id": 85402,
"author": "Philip Rieck",
"author_id": 12643,
"author_profile": "https://Stackoverflow.com/users/12643",
"pm_score": 4,
"selected": true,
"text": " vector<int> a_vector;\n vector<int>::iterator a_iterator;\n for(int i= 0; i < 100; i++)\n {\n a_vector.push_back(i);\n }\n\n int total = 0;\n a_iterator = a_vector.begin();\n while( a_iterator != a_vector.end() ) {\n total += *a_iterator;\n a_iterator++;\n }\n List<int> a_list = new List<int>();\nfor(int i=0; i < 100; i++)\n{\n a_list.Add(i);\n}\nint total = 0;\nforeach( int item in a_list)\n{\n total += item;\n}\n List<int> a_list = new List<int>();\nfor (int i = 0; i < 100; i++)\n{\n a_list.Add(i);\n}\nint total = 0;\nIEnumerator<int> a_enumerator = a_list.GetEnumerator();\nwhile (a_enumerator.MoveNext())\n{\n total += a_enumerator.Current;\n}\n public class Native\n{\n public class Local\n { \n public string m_str;\n public int m_int;\n }\n\n private List<Local> m_Locals = new List<Local>();\n\n public List<Local> Locals\n {\n get{ return m_Locals;}\n }\n}\n foreach( Local item in someNative.Locals) \n{\n ... \n}\n"
},
{
"answer_id": 86875,
"author": "Brian Stewart",
"author_id": 3114,
"author_profile": "https://Stackoverflow.com/users/3114",
"pm_score": 0,
"selected": false,
"text": "public ref class Managed\n{\n public:\n ref class Local\n {\n String^ m_Str;\n int m_Int;\n };\n\n property const Local^ Locals[int]\n {\n const Local^ get(int Index)\n {\n // error checking here...\n return m_Locals[Index];\n }\n };\n\n private:\n List<Local^> m_Locals;\n};\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3114/"
] |
85,034
|
<p>I want to make a table in SqlServer that will add, on insert, a auto incremented primary key. This should be an autoincremented id similar to MySql auto_increment functionality. (Below)</p>
<pre><code>create table foo
(
user_id int not null auto_increment,
name varchar(50)
)
</code></pre>
<p>Is there a way of doing this with out creating an insert trigger?</p>
|
[
{
"answer_id": 85042,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": 5,
"selected": true,
"text": "create table foo \n( \nuser_id int not null identity, \nname varchar(50) \n)\n"
},
{
"answer_id": 85858,
"author": "Nasir",
"author_id": 16522,
"author_profile": "https://Stackoverflow.com/users/16522",
"pm_score": 1,
"selected": false,
"text": "CREATE TABLE foo\n(\nuser_id int IDENTITY(1,1) NOT NULL,\nname varchar(50)\n)\n"
},
{
"answer_id": 86110,
"author": "Amy B",
"author_id": 8155,
"author_profile": "https://Stackoverflow.com/users/8155",
"pm_score": 3,
"selected": false,
"text": "CREATE TABLE user\n(\n TheKey int IDENTITY(1,1) PRIMARY KEY,\n Name varchar(50)\n)\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12942/"
] |
85,036
|
<p>I need to manually migrate modified stored procedures from a DEV SQL Server 2005 database instance to a TEST instance. Except for the changes I'm migrating, the databases have the same schemas. How can I quickly identify which stored procedures have been modified in the DEV database for migration to the TEST instance?</p>
<p>I assume I can write a query against some of the system tables to view database objects of type stored procedure, sorting by some sort of last modified or compiled data, but I'm not sure. Maybe there is some sort of free utility someone can point me to.</p>
|
[
{
"answer_id": 85084,
"author": "RBS",
"author_id": 14299,
"author_profile": "https://Stackoverflow.com/users/14299",
"pm_score": 0,
"selected": false,
"text": "SELECT name\n FROM sys.objects\n WHERE type = 'P'\n AND DATEDIFF(D,modify_date, GETDATE()) < 7\n"
},
{
"answer_id": 85096,
"author": "Jason Stevenson",
"author_id": 13368,
"author_profile": "https://Stackoverflow.com/users/13368",
"pm_score": 4,
"selected": false,
"text": "SELECT name\nFROM sys.objects\nWHERE type = 'P'\n AND DATEDIFF(D,modify_date, GETDATE()) < X\n"
},
{
"answer_id": 85111,
"author": "RBS",
"author_id": 14299,
"author_profile": "https://Stackoverflow.com/users/14299",
"pm_score": 1,
"selected": false,
"text": "USE AdventureWorks2008;\n\nGO\n\nSELECT SprocName=name, create_date, modify_date\n\nFROM sys.objects\n\nWHERE type = 'P' \n\nAND name = 'uspUpdateEmployeeHireInfo'\n\nGO\n"
},
{
"answer_id": 85150,
"author": "Tom H",
"author_id": 5696608,
"author_profile": "https://Stackoverflow.com/users/5696608",
"pm_score": 0,
"selected": false,
"text": "SELECT name\nFROM sys.objects\nWHERE modify_date > @cutoffdate\n"
},
{
"answer_id": 85191,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": 7,
"selected": true,
"text": "select name,create_date,modify_date\nfrom sys.procedures\norder by modify_date desc\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16137/"
] |
85,046
|
<p>Are there any good books or website that go over creating a <code>JTable</code>? I want to make one column editable. I would like to actually put a inherited <code>JCheckBox</code> component (that we created here) into one of the table columns instead of just having the table put <code>JCheckBox</code> in based on it being an editable <code>boolean</code> field.</p>
<p>I have the <a href="https://rads.stackoverflow.com/amzn/click/com/0201914670" rel="nofollow noreferrer" rel="nofollow noreferrer">JFC Swing Tutorial Second Edition</a> book but I just would like to know if there are other examples I could look at and learn how to deal with the tables better. The book seems to just take the java 'trail' online and put it in the book.</p>
<p>I am re-reading the stuff though, just curious if anyone has found something that might help out more.</p>
|
[
{
"answer_id": 105005,
"author": "Richard Walton",
"author_id": 15075,
"author_profile": "https://Stackoverflow.com/users/15075",
"pm_score": 0,
"selected": false,
"text": "Package javax.swing.table TableModel tablemodel AbstractTableModel DefaultTableModel arrays[] Vectors isCellEditable(int row, int col)"
},
{
"answer_id": 105380,
"author": "morsch",
"author_id": 19256,
"author_profile": "https://Stackoverflow.com/users/19256",
"pm_score": 6,
"selected": true,
"text": "isCellEditable TableModel TableModel AbstractTableModel JTable TableModel JTable TableCellEditor getCellEditorComponent TableCellEditor stopEditing() JTable EventListeners getTableCellRendererComponent setText(...) setFont(...) TextComponent JTable JTable TableModel getColumnClass(...) Object.class TableColumn getTableColumn(...) JTable JLabel/DefaultRenderer JButton JTable"
},
{
"answer_id": 117016,
"author": "ShawnD",
"author_id": 6186,
"author_profile": "https://Stackoverflow.com/users/6186",
"pm_score": 1,
"selected": false,
"text": "JTable isCellEditable myTable.setModel(new DefaultTableModel(){\n@Override\npublic boolean isCellEditable(int row, int column) {\n if (column == x) {\n return true;\n } else\n return false;\n}\n});\n MyCheckBoxRenderer extends JCheckBox implements TableCellRenderer\n"
},
{
"answer_id": 39328305,
"author": "Maxwell Cheng",
"author_id": 6206976,
"author_profile": "https://Stackoverflow.com/users/6206976",
"pm_score": 0,
"selected": false,
"text": "public ArrayList<XXXDO> tbmData = new ArrayList<XXXDO>(); //arraylist for data in table\n\n@Override\npublic boolean isCellEditable(int row, int col) {\n if (col == 4) {\n return true;\n } else {\n return false;\n }\n}\n\n@Override\npublic void setValueAt(Object value, int row, int col) {\n if ((row >= 0) && (row < this.tbmData.size()) && (col >= 0) && (col < this.colNm.length)) {\n if (col == 4) {\n tbmData.get(row).col4= (String) value;\n }\n fireTableCellUpdated(row, col);\n } else {\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14009/"
] |
85,051
|
<p>Assuming network access is sporadic with no central server, what would be the best way to use git to keep three or more branches in sync? Is there a way to extract just my deltas, email those, and merge them on the other end?</p>
|
[
{
"answer_id": 85079,
"author": "Jim Puls",
"author_id": 6010,
"author_profile": "https://Stackoverflow.com/users/6010",
"pm_score": 3,
"selected": false,
"text": "git-format-patch git-am"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16203/"
] |
85,058
|
<p>I see <a href="http://www.is-research.de/info/vmlanguages/index.html" rel="noreferrer">here</a> that there are a load of languages aside from Java that run on the JVM. I'm a bit confused about the whole concept of other languages running in the JVM. So:</p>
<p>What is the advantage in having other languages for the JVM?</p>
<p>What is required (in high level terms) to write a language/compiler for the JVM? </p>
<p>How do you write/compile/run code in a language (other than Java) in the JVM?</p>
<hr>
<p><strong>EDIT:</strong> There were 3 follow up questions (originally comments) that were answered in the accepted answer. They are reprinted here for legibility:</p>
<p>How would an app written in, say, JPython, interact with a Java app? </p>
<p>Also, Can that JPython application use any of the JDK functions/objects?? </p>
<p>What if it was Jaskell code, would the fact that it is a functional language not make it incompatible with the JDK?</p>
|
[
{
"answer_id": 86201,
"author": "toluju",
"author_id": 12457,
"author_profile": "https://Stackoverflow.com/users/12457",
"pm_score": 6,
"selected": true,
"text": "from java.net import URL\nu = URL('http://jython.org')\n object Timer {\n def oncePerSecond(callback: () => unit) {\n while (true) { callback(); Thread sleep 1000 }\n }\n def timeFlies() {\n println(\"time flies like an arrow...\")\n }\n def main(args: Array[String]) {\n oncePerSecond(timeFlies)\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/142/"
] |
85,085
|
<p>I've got an RMI call defined as:</p>
<pre><code>public void remoteGetCustomerNameNumbers(ArrayList<String> customerNumberList, ArrayList<String> customerNameList) throws java.rmi.RemoteException;
</code></pre>
<p>The function does a database lookup and populates the two ArrayLists. The calling function gets nothing. I believe this works with Vector types.</p>
<p>Do I need to use the Vector, or is there a way to get this to work without making two calls. I've got some other ideas that I'd probably use, like returning a key/value pair, but I'd like to know if I can get this to work.</p>
<p>Update:<br/>
I would accept all of the answers given so far if I could. I hadn't known the network cost, so It makes sense to rework the function to return a LinkedHashMap instead of the two ArrayLists.</p>
|
[
{
"answer_id": 86847,
"author": "BCunningham",
"author_id": 7689,
"author_profile": "https://Stackoverflow.com/users/7689",
"pm_score": 1,
"selected": false,
"text": "public ArrayList<String> getCustomerNames() throws java.rmi.RemoteException;\n\npublic ArrayList<String> getCustomerNumbers() throws java.rmi.RemoteException;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16345/"
] |
85,091
|
<p>OK, this begins to drive me crazy. I have an asp.net webapp. Pretty straightforward, most of the code in the .aspx.vb, and a few classes in App_Code.</p>
<p>The problem, which has begun to occur only today (even though most of the code was already written), is that once in a while, I have this error message :</p>
<blockquote>
<p>Error BC30002: Type ‘XXX’ is not defined</p>
</blockquote>
<p>The error occurs about every time I modify the files in the App_Code folder. EDIT : OK, this happens also if I don't touch anything for a while then refresh the page. I'm still trying to figure out exactly how to trigger this error.</p>
<p>I just have to wait a little bit without touching anything, then refresh the page and it works, but it's very annoying.</p>
<p>So I searched a little bit, but nothing came up except imports missing. Any idea ?</p>
|
[
{
"answer_id": 156933,
"author": "thomasb",
"author_id": 6776,
"author_profile": "https://Stackoverflow.com/users/6776",
"pm_score": 4,
"selected": true,
"text": "Imports CMS\n\nSub Whatever()\n Dim a as new Arbo.MyObject() ' Arbo is a namespace inside CMS\n Dim b as new Util.MyOtherObject() ' Util is a namespace inside Util\nEnd Sub\n Imports CMS.Arbo\nImports CMS.Util \n\nSub Whatever()\n Dim a as new MyObject()\n Dim b as new MyOtherObject()\nEnd Sub\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6776/"
] |
85,116
|
<p>I want the server to always serve dates in UTC in the HTML, and have JavaScript on the client site convert it to the user's local timezone.</p>
<p>Bonus if I can output in the user's locale date format.</p>
|
[
{
"answer_id": 85161,
"author": "japollock",
"author_id": 1210318,
"author_profile": "https://Stackoverflow.com/users/1210318",
"pm_score": -1,
"selected": false,
"text": "usersLocalTime = new Date();\n"
},
{
"answer_id": 85213,
"author": "dave",
"author_id": 14355,
"author_profile": "https://Stackoverflow.com/users/14355",
"pm_score": 2,
"selected": false,
"text": "new Date().getTimezoneOffset();\n"
},
{
"answer_id": 85235,
"author": "jop",
"author_id": 11830,
"author_profile": "https://Stackoverflow.com/users/11830",
"pm_score": 5,
"selected": false,
"text": "new Date().getTimezoneOffset()/60 toLocaleString()"
},
{
"answer_id": 85357,
"author": "Mark",
"author_id": 9303,
"author_profile": "https://Stackoverflow.com/users/9303",
"pm_score": 3,
"selected": false,
"text": "var myDate = new Date();\nvar tzo = (myDate.getTimezoneOffset()/60)*(-1);\n//get server date value here, the parseInvariant is from MS Ajax, you would need to do something similar on your own\nmyDate = new Date.parseInvariant('<%=DataCurrentDate%>', 'yyyyMMdd hh:mm:ss');\nmyDate.setHours(myDate.getHours() + tzo);\n//here you would have to get a handle to your span / div to set. again, I'm using MS Ajax's $get\nvar dateSpn = $get('dataDate');\ndateSpn.innerHTML = myDate.localeFormat('F');\n"
},
{
"answer_id": 85793,
"author": "Már Örlygsson",
"author_id": 16271,
"author_profile": "https://Stackoverflow.com/users/16271",
"pm_score": 2,
"selected": false,
"text": ".getTimezoneOffset() var timeOffsetInHours = -(new Date()).getTimezoneOffset()/60\n"
},
{
"answer_id": 86533,
"author": "kch",
"author_id": 13989,
"author_profile": "https://Stackoverflow.com/users/13989",
"pm_score": 9,
"selected": true,
"text": "Date setUTC… toLocale…String // This would come from the server.\n// Also, this whole block could probably be made into an mktime function.\n// All very bare here for quick grasping.\nd = new Date();\nd.setUTCFullYear(2004);\nd.setUTCMonth(1);\nd.setUTCDate(29);\nd.setUTCHours(2);\nd.setUTCMinutes(45);\nd.setUTCSeconds(26);\n\nconsole.log(d); // -> Sat Feb 28 2004 23:45:26 GMT-0300 (BRT)\nconsole.log(d.toLocaleString()); // -> Sat Feb 28 23:45:26 2004\nconsole.log(d.toLocaleDateString()); // -> 02/28/2004\nconsole.log(d.toLocaleTimeString()); // -> 23:45:26"
},
{
"answer_id": 2830494,
"author": "simianarmy",
"author_id": 222367,
"author_profile": "https://Stackoverflow.com/users/222367",
"pm_score": 3,
"selected": false,
"text": "Date.strftime function UTCToLocalTimeString(d, format) {\n if (timeOffsetInHours == null) {\n timeOffsetInHours = (new Date().getTimezoneOffset()/60) * (-1);\n }\n d.setHours(d.getHours() + timeOffsetInHours);\n\n return d.strftime(format);\n}\n"
},
{
"answer_id": 23872920,
"author": "theDmi",
"author_id": 219187,
"author_profile": "https://Stackoverflow.com/users/219187",
"pm_score": 6,
"selected": false,
"text": "var m = moment(\"2013-02-08T09:30:26Z\");\n m m.format('LLL') // Returns \"February 8 2013 8:30 AM\" on en-us\n"
},
{
"answer_id": 32781372,
"author": "hriziya",
"author_id": 1005741,
"author_profile": "https://Stackoverflow.com/users/1005741",
"pm_score": 2,
"selected": false,
"text": "function getLocalDate(php_date) {\n var dt = new Date(php_date);\n var minutes = dt.getTimezoneOffset();\n dt = new Date(dt.getTime() + minutes*60000);\n return dt;\n}\n var localdateObj = getLocalDate('2015-09-25T02:57:46');\n"
},
{
"answer_id": 41000624,
"author": "Anja",
"author_id": 1544659,
"author_profile": "https://Stackoverflow.com/users/1544659",
"pm_score": 2,
"selected": false,
"text": "language = request.META.get('HTTP_ACCEPT_LANGUAGE')\nreturn render(request, 'cssexy/index.html', { \"language\": language })\n <input type=\"hidden\" id=\"browserlanguage\" value={{ language }}/>\n const browserlanguage = document.getElementById(\"browserlanguage\").value;\nvar defaultlang = browserlanguage.replace(/(\\w{2}\\-\\w{2}),.*/, \"$1\");\n var options = { hour: \"2-digit\", minute: \"2-digit\" };\nvar dt = (new Date(str)).toLocaleDateString(defaultlang, options);\n"
},
{
"answer_id": 43863035,
"author": "Jeremy Chone",
"author_id": 686724,
"author_profile": "https://Stackoverflow.com/users/686724",
"pm_score": 4,
"selected": false,
"text": "var d = new Date(); \nd = new Date(d.getTime() - d.getTimezoneOffset() * 60000)\nvar yyyymmdd = t.toISOString().slice(0, 10); \n// 2017-05-09T08:24:26.581Z (but this is not UTC)\n"
},
{
"answer_id": 51259500,
"author": "Codemaker",
"author_id": 7103882,
"author_profile": "https://Stackoverflow.com/users/7103882",
"pm_score": 0,
"selected": false,
"text": "var date = (new Date(str)).toLocaleDateString(defaultlang, options);\n var time = (new Date(str)).toLocaleTimeString(defaultlang, options);\n"
},
{
"answer_id": 54813917,
"author": "Serg",
"author_id": 1844247,
"author_profile": "https://Stackoverflow.com/users/1844247",
"pm_score": 3,
"selected": false,
"text": "// new Date(year, monthIndex [, day [, hours [, minutes [, seconds [, milliseconds]]]]])\nvar serverDate = new Date(2018, 5, 30, 19, 13, 15); // just any date that comes from server\nvar serverDateStr = serverDate.toLocaleString(\"en-US\", {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n})\nvar userDate = new Date(serverDateStr + \" UTC\");\nvar locale = window.navigator.userLanguage || window.navigator.language;\n\nvar clientDateStr = userDate.toLocaleString(locale, {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric'\n});\n\nvar clientDateTimeStr = userDate.toLocaleString(locale, {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric'\n});\n\nconsole.log(\"Server UTC date: \" + serverDateStr);\nconsole.log(\"User's local date: \" + clientDateStr);\nconsole.log(\"User's local date&time: \" + clientDateTimeStr);"
},
{
"answer_id": 67201763,
"author": "Flavien Volken",
"author_id": 532695,
"author_profile": "https://Stackoverflow.com/users/532695",
"pm_score": 3,
"selected": false,
"text": "const utcDate = new Date(Date.UTC(2020, 11, 20, 3, 23, 16, 738));\nconsole.log(new Intl.DateTimeFormat().format(utcDate));\n// expected output: \"21/04/2021\", my locale is Switzerland\n const date = new Date(Date.UTC(2020, 11, 20, 3, 23, 16, 738));\n// Results below assume UTC timezone - your results may vary\n\n// Specify default date formatting for language (locale)\nconsole.log(new Intl.DateTimeFormat('en-US').format(date));\n// expected output: \"12/20/2020\"\n \n// Specify default date formatting for language with a fallback language (in this case Indonesian)\nconsole.log(new Intl.DateTimeFormat(['ban', 'id']).format(date));\n// expected output: \"20/12/2020\"\n \n// Specify date and time format using \"style\" options (i.e. full, long, medium, short)\nconsole.log(new Intl.DateTimeFormat('en-GB', { dateStyle: 'full', timeStyle: 'long' }).format(date));\n// Expected output \"Sunday, 20 December 2020 at 14:23:16 GMT+11\"\n"
},
{
"answer_id": 71803712,
"author": "Hans Bouwmeester",
"author_id": 8005373,
"author_profile": "https://Stackoverflow.com/users/8005373",
"pm_score": 0,
"selected": false,
"text": "export const humanFriendlyDateStr = (iso8601) => {\n\n // Examples (using Node.js):\n\n // Get an ISO8601 date string using Date()\n // > new Date()\n // 2022-04-08T22:05:18.595Z\n\n // If it was earlier today, just show the time:\n // > humanFriendlyDateStr('2022-04-08T22:05:18.595Z')\n // '3:05 PM'\n\n // If it was during the past week, add the day:\n // > humanFriendlyDateStr('2022-04-07T22:05:18.595Z')\n // 'Thu 3:05 PM'\n\n // If it was more than a week ago, add the date\n // > humanFriendlyDateStr('2022-03-07T22:05:18.595Z')\n // '3/7, 2:05 PM'\n\n // If it was more than a year ago add the year\n // > humanFriendlyDateStr('2021-03-07T22:05:18.595Z')\n // '3/7/2021, 2:05 PM'\n\n // If it's sometime in the future return the full date+time:\n // > humanFriendlyDateStr('2023-03-07T22:05:18.595Z')\n // '3/7/2023, 2:05 PM'\n\n const datetime = new Date(Date.parse(iso8601))\n const now = new Date()\n const ageInDays = (now - datetime) / 86400000\n let str\n\n // more than 1 year old?\n if (ageInDays > 365) {\n str = datetime.toLocaleDateString([], {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n })\n // more than 1 week old?\n } else if (ageInDays > 7) {\n str = datetime.toLocaleDateString([], {\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n })\n // more than 1 day old?\n } else if (ageInDays > 1) {\n str = datetime.toLocaleDateString([], {\n weekday: 'short',\n hour: 'numeric',\n minute: 'numeric',\n })\n // some time today?\n } else if (ageInDays > 0) {\n str = datetime.toLocaleTimeString([], {\n timeStyle: 'short',\n })\n // in the future?\n } else {\n str = datetime.toLocaleDateString([], {\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n })\n }\n return str\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85116",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13989/"
] |
85,119
|
<p>I know you can do redirection based on the domain or path to rewrite the URI to point at a site-specific location and I've also seen some brutish <code>if</code> and <code>elif</code> statements for every site as shown in the following code, which I would like to avoid.</p>
<pre class="lang-py prettyprint-override"><code>if site == 'site1':
...
elif site == 'site2:
...
</code></pre>
<p>What are some good and clever ways of running multiple sites from a single, common Python web framework (i.e., Pylons, TurboGears, etc)?</p>
|
[
{
"answer_id": 85134,
"author": "Jim",
"author_id": 8427,
"author_profile": "https://Stackoverflow.com/users/8427",
"pm_score": 5,
"selected": true,
"text": "Host"
},
{
"answer_id": 86705,
"author": "Gabriel Ross",
"author_id": 10751,
"author_profile": "https://Stackoverflow.com/users/10751",
"pm_score": 3,
"selected": false,
"text": "<VirtualHost 1.2.3.4>\n DocumentRoot /www/site1\n ServerName site1.com\n <Location />\n SetHandler python-program\n SetEnv DJANGO_SETTINGS_MODULE site1.settings\n PythonPath \"['/www'] + sys.path\"\n PythonDebug On\n PythonInterpreter site1\n </Location>\n</VirtualHost>\n\n<VirtualHost 1.2.3.4>\n DocumentRoot /www/site2\n ServerName site2.com\n <Location />\n SetHandler python-program\n SetEnv DJANGO_SETTINGS_MODULE site2.settings\n PythonPath \"['/www'] + sys.path\"\n PythonDebug On\n PythonInterpreter site2\n </Location>\n</VirtualHost>\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4919/"
] |
85,122
|
<p>On Windows I have a problem I never encountered on Unix. That is how to get a thread to sleep for less than one millisecond. On Unix you typically have a number of choices (sleep, usleep and nanosleep) to fit your needs. On Windows, however, there is only <em>Sleep</em> with millisecond granularity. </p>
<p>On Unix, I can use the use the <code>select</code> system call to create a microsecond sleep which is pretty straightforward:</p>
<pre><code>int usleep(long usec)
{
struct timeval tv;
tv.tv_sec = usec/1000000L;
tv.tv_usec = usec%1000000L;
return select(0, 0, 0, 0, &tv);
}
</code></pre>
<p>How can I achieve the same on Windows?</p>
|
[
{
"answer_id": 85143,
"author": "Jorge Ferreira",
"author_id": 6508,
"author_profile": "https://Stackoverflow.com/users/6508",
"pm_score": -1,
"selected": true,
"text": "select WORD wVersionRequested = MAKEWORD(1,0);\nWSADATA wsaData;\nWSAStartup(wVersionRequested, &wsaData);\n int usleep(long usec)\n{\n struct timeval tv;\n fd_set dummy;\n SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);\n FD_ZERO(&dummy);\n FD_SET(s, &dummy);\n tv.tv_sec = usec/1000000L;\n tv.tv_usec = usec%1000000L;\n return select(0, 0, 0, &dummy, &tv);\n}\n"
},
{
"answer_id": 1448900,
"author": "Hendrik",
"author_id": 123411,
"author_profile": "https://Stackoverflow.com/users/123411",
"pm_score": 2,
"selected": false,
"text": "bool usleep(unsigned long usec)\n{\n struct timeval tv;\n fd_set dummy;\n SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);\n FD_ZERO(&dummy);\n FD_SET(s, &dummy);\n tv.tv_sec = usec / 1000000ul;\n tv.tv_usec = usec % 1000000ul;\n bool success = (0 == select(0, 0, 0, &dummy, &tv));\n closesocket(s);\n return success;\n}\n"
},
{
"answer_id": 11456112,
"author": "Arno",
"author_id": 1504523,
"author_profile": "https://Stackoverflow.com/users/1504523",
"pm_score": 3,
"selected": false,
"text": "NtQueryTimerResolution Sleep(0) Sleep(0) waitable object WaitForSingleObject()"
},
{
"answer_id": 31411628,
"author": "Oskar Dahlberg",
"author_id": 4858189,
"author_profile": "https://Stackoverflow.com/users/4858189",
"pm_score": 5,
"selected": false,
"text": "#include <Windows.h>\n\nstatic NTSTATUS(__stdcall *NtDelayExecution)(BOOL Alertable, PLARGE_INTEGER DelayInterval) = (NTSTATUS(__stdcall*)(BOOL, PLARGE_INTEGER)) GetProcAddress(GetModuleHandle(\"ntdll.dll\"), \"NtDelayExecution\");\nstatic NTSTATUS(__stdcall *ZwSetTimerResolution)(IN ULONG RequestedResolution, IN BOOLEAN Set, OUT PULONG ActualResolution) = (NTSTATUS(__stdcall*)(ULONG, BOOLEAN, PULONG)) GetProcAddress(GetModuleHandle(\"ntdll.dll\"), \"ZwSetTimerResolution\");\n\nstatic void SleepShort(float milliseconds) {\n static bool once = true;\n if (once) {\n ULONG actualResolution;\n ZwSetTimerResolution(1, true, &actualResolution);\n once = false;\n }\n\n LARGE_INTEGER interval;\n interval.QuadPart = -1 * (int)(milliseconds * 10000.0f);\n NtDelayExecution(false, &interval);\n}\n"
},
{
"answer_id": 33448417,
"author": "rauprog",
"author_id": 4798975,
"author_profile": "https://Stackoverflow.com/users/4798975",
"pm_score": 0,
"selected": false,
"text": "while (timer1 < 100 microseconds) {\nsleep(0);\n}\n\nif (timer2 >=100 microseconds) {\nmove projectile one pixel\n}\n\n//Rest of code in iteration here\n"
},
{
"answer_id": 43564734,
"author": "Ian Boyd",
"author_id": 12597,
"author_profile": "https://Stackoverflow.com/users/12597",
"pm_score": 1,
"selected": false,
"text": "void SpinOnce(ref Int32 spin)\n{\n /*\n SpinOnce is called each time we need to wait. \n But the action it takes depends on how many times we've been spinning:\n\n 1..12 spins: spin 2..4096 cycles\n 12..32: call SwitchToThread (allow another thread ready to go on time core to execute)\n over 32 spins: Sleep(0) (give up the remainder of our timeslice to any other thread ready to run, also allows APC and I/O callbacks)\n */\n spin += 1;\n\n if (spin > 32)\n Sleep(0); //give up the remainder of our timeslice\n else if (spin > 12)\n SwitchTothread(); //allow another thread on our CPU to have the remainder of our timeslice\n else\n {\n int loops = (1 << spin); //1..12 ==> 2..4096\n while (loops > 0)\n loops -= 1;\n }\n}\n int spin = 0;\nwhile (!TryAcquireLock()) \n{ \n SpinOne(ref spin);\n}\n"
},
{
"answer_id": 72823146,
"author": "sir-pinecone",
"author_id": 134027,
"author_profile": "https://Stackoverflow.com/users/134027",
"pm_score": 0,
"selected": false,
"text": "CreateWaitableTimerExW CREATE_WAITABLE_TIMER_HIGH_RESOLUTION"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6508/"
] |
85,137
|
<p>Say I have a class named Frog, it looks like:</p>
<pre><code>public class Frog
{
public int Location { get; set; }
public int JumpCount { get; set; }
public void OnJump()
{
JumpCount++;
}
}
</code></pre>
<p>I need help with 2 things:</p>
<ol>
<li>I want to create an event named Jump in the class definition.</li>
<li>I want to create an instance of the Frog class, and then create another method that will be called when the Frog jumps.</li>
</ol>
|
[
{
"answer_id": 85188,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 7,
"selected": true,
"text": "public event EventHandler Jump;\npublic void OnJump()\n{\n EventHandler handler = Jump;\n if (null != handler) handler(this, EventArgs.Empty);\n}\n Frog frog = new Frog();\nfrog.Jump += new EventHandler(yourMethod);\n\nprivate void yourMethod(object s, EventArgs e)\n{\n Console.WriteLine(\"Frog has Jumped!\");\n}\n"
},
{
"answer_id": 54242833,
"author": "Tezra",
"author_id": 6893866,
"author_profile": "https://Stackoverflow.com/users/6893866",
"pm_score": 3,
"selected": false,
"text": "?. . public delegate void MyAwesomeEventHandler(int rawr);\npublic event MyAwesomeEventHandler AwesomeJump;\n\npublic event EventHandler Jump;\n\npublic void OnJump()\n{\n AwesomeJump?.Invoke(42);\n Jump?.Invoke(this, EventArgs.Empty);\n}\n public event EventHandler Jump = delegate { };\n\npublic void OnJump()\n{\n Jump(this, EventArgs.Empty);\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1368/"
] |
85,147
|
<p>I've never used any of the .NET generics in my work, but I understand that they are fairly popular. Does anyone have any good links or book suggestions for learning them? As a bonus; I only vaguely understand what .NET generic collections are and what they do...does anyone have any practical examples of how they might be used to greater advantage than the normal collections in .NET?</p>
|
[
{
"answer_id": 85249,
"author": "William Yeung",
"author_id": 16371,
"author_profile": "https://Stackoverflow.com/users/16371",
"pm_score": -1,
"selected": false,
"text": "public T GetValue<T>() {\n return (T) ...;\n}\n public class MyList<T>\n{\n private List<T> _list;\n...\npublic T GetValue(int index)\n{\n return _list[index];\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13776/"
] |
85,159
|
<p>Is there any way to parse a string in the format HH:MM into a Date (or other) object using the standard libraries?</p>
<p>I know that I can parse something like "9/17/2008 10:30" into a Date object using</p>
<pre><code>var date:Date = new Date(Date.parse("9/17/2008 10:30");
</code></pre>
<p>But I want to parse just 10:30 by itself. The following code will not work.</p>
<pre><code>var date:Date = new Date(Date.parse("10:30");
</code></pre>
<p>I know I can use a custom RegEx to do this fairly easily, but it seems like this should be possible using the existing Flex API.</p>
|
[
{
"answer_id": 87125,
"author": "mikechambers",
"author_id": 10232,
"author_profile": "https://Stackoverflow.com/users/10232",
"pm_score": 2,
"selected": false,
"text": "var str:String = \"9/17/2008 10:30\"\n\nvar items:Array = str.split(\" \");\nvar dateElements:Array = items[0].split(\"/\");\nvar timeElements:Array = items[1].split(\":\");\n\nvar n:Date = new Date(dateElements[2],\n dateElements[0],\n dateElements[1].\n timeElements[0],\n timeElements[1]);\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1247/"
] |
85,181
|
<p>This is pretty weird.</p>
<p>I have my Profiler open and it obviously shows that a stored procedure is called. I open the database and the SP list, but the SP doesn't exist. However, there's another SP whose name is the same except it has a prefix 'x'</p>
<p>Is SQL Server 2005 mapping the SP name to a different one for security purposes?</p>
<p>EDIT: I found out it's a Synonym, whatever that is. </p>
|
[
{
"answer_id": 85341,
"author": "Kevin Crumley",
"author_id": 1818,
"author_profile": "https://Stackoverflow.com/users/1818",
"pm_score": 4,
"selected": true,
"text": "select *\nfrom sys.objects\nwhere name = 'THE_NAME_YOU_WANT'\n"
},
{
"answer_id": 6598930,
"author": "Amit Sharma",
"author_id": 831758,
"author_profile": "https://Stackoverflow.com/users/831758",
"pm_score": 1,
"selected": false,
"text": "select * from sys.objects where name = 'name of stored procedure'\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10088/"
] |
85,183
|
<p>I have an object that implements IDisposable that is registered with the Windsor Container and I would like to dispose of it so it's Dispose method is called and next time Resolve is called it fetches a new instance.</p>
<p>Does </p>
<pre><code>container.Release(obj);
</code></pre>
<p>automatically call Dispose() immediately? Or do I need to do</p>
<pre><code>obj.Dispose();
container.Release(obj);
</code></pre>
<p>Couldn't find anything in the documentation on what exactly Release does</p>
<p><strong>EDIT:</strong>
See my answer below for the results of tests I ran. Now the question becomes, how do I force the container to release an instance of a component with a singleton lifecycle? This only needs to be done in one place and writing a custom lifecycle seems far too heavyweight, is there no built in way of doing it?</p>
|
[
{
"answer_id": 85498,
"author": "Philip Rieck",
"author_id": 12643,
"author_profile": "https://Stackoverflow.com/users/12643",
"pm_score": 2,
"selected": false,
"text": "using(ISomeService service = container.Resolve<ISomeService>())\n{\n // Do stuff here\n // service.Dispose is automatically called \n}\n"
},
{
"answer_id": 85820,
"author": "George Mauer",
"author_id": 5056,
"author_profile": "https://Stackoverflow.com/users/5056",
"pm_score": 1,
"selected": false,
"text": "Container.Release() Dispose() Container.Dispose() var container = new WindsorContainer();\ncontainer.AddComponentWithLifestyle<MyDisposable>(Castle.Core.LifestyleType.Singleton);\nvar obj = container.Resolve<MyDisposable>(); // Create a new instance of MyDisposable\nobj.DoSomething();\nvar obj2 = container.Resolve<MyDisposable>(); // Returns the same instance as obj\nobj2.DoSomething();\ncontainer.Dispose(); // Will call the Disposable method of obj\n// Now the components need to be added back in \n container.AddComponentWithLifestyle<MyDisposable>(Castle.Core.LifestyleType.Singleton);\nvar obj3 = container.Resolve<MyDisposable>(); // Create a new instance of MyDisposable\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
85,190
|
<p>Consider:</p>
<pre><code>List<String> someList = new ArrayList<String>();
// add "monkey", "donkey", "skeleton key" to someList
</code></pre>
<pre><code>for (String item : someList) {
System.out.println(item);
}
</code></pre>
<p>What would the equivalent <code>for</code> loop look like without using the <em>for each</em> syntax?</p>
|
[
{
"answer_id": 85206,
"author": "nsayer",
"author_id": 13757,
"author_profile": "https://Stackoverflow.com/users/13757",
"pm_score": 11,
"selected": true,
"text": "for (Iterator<String> i = someIterable.iterator(); i.hasNext();) {\n String item = i.next();\n System.out.println(item);\n}\n i.remove(); for ( : ) Iterable for (:) array Iterable array.length"
},
{
"answer_id": 85209,
"author": "toluju",
"author_id": 12457,
"author_profile": "https://Stackoverflow.com/users/12457",
"pm_score": 6,
"selected": false,
"text": "Iterator<String> iterator = someList.iterator();\n\nwhile (iterator.hasNext()) {\n String item = iterator.next();\n System.out.println(item);\n}\n"
},
{
"answer_id": 85220,
"author": "Hank",
"author_id": 7610,
"author_profile": "https://Stackoverflow.com/users/7610",
"pm_score": 4,
"selected": false,
"text": "for(Iterator<String> sit = someList.iterator(); sit.hasNext(); ) {\n System.out.println(sit.next());\n}\n"
},
{
"answer_id": 85221,
"author": "Pete",
"author_id": 13472,
"author_profile": "https://Stackoverflow.com/users/13472",
"pm_score": 3,
"selected": false,
"text": "for (Iterator<String> i = someList.iterator(); i.hasNext(); )\n System.out.println(i.next());\n"
},
{
"answer_id": 85232,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 4,
"selected": false,
"text": "for (Iterator<String> itr = someList.iterator(); itr.hasNext(); ) {\n String item = itr.next();\n System.out.println(item);\n}\n"
},
{
"answer_id": 85424,
"author": "Mikezx6r",
"author_id": 5382,
"author_profile": "https://Stackoverflow.com/users/5382",
"pm_score": 9,
"selected": false,
"text": "String[] fruits = new String[] { \"Orange\", \"Apple\", \"Pear\", \"Strawberry\" };\n\nfor (String fruit : fruits) {\n // fruit is an element of the `fruits` array.\n}\n for (int i = 0; i < fruits.length; i++) {\n String fruit = fruits[i];\n // fruit is an element of the `fruits` array.\n}\n for(Iterator<String> i = someList.iterator(); i.hasNext(); ) {\n String item = i.next();\n System.out.println(item);\n}\n"
},
{
"answer_id": 85933,
"author": "Ryan Delucchi",
"author_id": 9931,
"author_profile": "https://Stackoverflow.com/users/9931",
"pm_score": 5,
"selected": false,
"text": "T[] java.lang.Iterable<T> Iterable<T> Iterator<T> iterator() Collection<T> Collection<T> Iterable<T>"
},
{
"answer_id": 7956673,
"author": "MRocklin",
"author_id": 616616,
"author_profile": "https://Stackoverflow.com/users/616616",
"pm_score": 7,
"selected": false,
"text": "char[] grades = ....\nfor(int i = 0; i < grades.length; i++) { // for i goes from 0 to grades.length\n System.out.print(grades[i]); // Print grades[i]\n}\n for(char grade : grades) { // foreach grade in grades\n System.out.print(grade); // print that grade\n}\n"
},
{
"answer_id": 12722557,
"author": "oneConsciousness",
"author_id": 1503768,
"author_profile": "https://Stackoverflow.com/users/1503768",
"pm_score": 4,
"selected": false,
"text": "// In this loop it is assumed that the list starts with index 0\nfor(int i=0; i<list.length; i++){\n\n}\n"
},
{
"answer_id": 19828685,
"author": "PrivateName",
"author_id": 2923930,
"author_profile": "https://Stackoverflow.com/users/2923930",
"pm_score": 5,
"selected": false,
"text": "for (type obj:array) {...}\n String[] s = {\"Java\", \"Coffe\", \"Is\", \"Cool\"};\nfor (String str:s /*s is the array*/) {\n System.out.println(str);\n}\n Java\nCoffe\nIs\nCool\n for for (double b:s) // Invalid-double is not String\n for for (int i = 0; i < s.length-1 /*-1 because of the 0 index */; i++) {\n if (i==1) //1 because once again I say the 0 index\n s[i]=\"2 is cool\";\n else\n s[i] = \"hello\";\n}\n hello\n2 is cool\nhello\nhello\n"
},
{
"answer_id": 22114571,
"author": "aliteralmind",
"author_id": 2736496,
"author_profile": "https://Stackoverflow.com/users/2736496",
"pm_score": 8,
"selected": false,
"text": "java.util.Iterator for (int i : intList) {\n System.out.println(\"An element in the list: \" + i);\n}\n Iterator<Integer> intItr = intList.iterator();\nwhile (intItr.hasNext()) {\n System.out.println(\"An element in the list: \" + intItr.next());\n}\n Iterator ConcurrentModificationException for (int i = 0; i < array.length; i++) {\n if(i < 5) {\n // Do something special\n } else {\n // Do other stuff\n }\n}\n int idx = -1;\nfor (int i : intArray) {\n idx++;\n ...\n}\n for for int Integer [C:\\java_code\\]java TimeIteratorVsIndexIntArray 1000000\nTest A: 358,597,622 nanoseconds\nTest B: 269,167,681 nanoseconds\nB faster by 89,429,941 nanoseconds (24.438799231635727% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntArray 1000000\nTest A: 377,461,823 nanoseconds\nTest B: 278,694,271 nanoseconds\nB faster by 98,767,552 nanoseconds (25.666236154695838% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntArray 1000000\nTest A: 288,953,495 nanoseconds\nTest B: 207,050,523 nanoseconds\nB faster by 81,902,972 nanoseconds (27.844689860906513% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntArray 1000000\nTest A: 375,373,765 nanoseconds\nTest B: 283,813,875 nanoseconds\nB faster by 91,559,890 nanoseconds (23.891659337194227% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntArray 1000000\nTest A: 375,790,818 nanoseconds\nTest B: 220,770,915 nanoseconds\nB faster by 155,019,903 nanoseconds (40.75164734599769% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntArray 1000000\nTest A: 326,373,762 nanoseconds\nTest B: 202,555,566 nanoseconds\nB faster by 123,818,196 nanoseconds (37.437545972215744% faster)\n Integer List Integers List<Integer> intList = Arrays.asList(new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100});\n int[] List<Integer> length size() [C:\\java_code\\]java TimeIteratorVsIndexIntegerList 1000000\nTest A: 3,429,929,976 nanoseconds\nTest B: 5,262,782,488 nanoseconds\nA faster by 1,832,852,512 nanoseconds (34.326681820485675% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntegerList 1000000\nTest A: 2,907,391,427 nanoseconds\nTest B: 3,957,718,459 nanoseconds\nA faster by 1,050,327,032 nanoseconds (26.038700083921256% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntegerList 1000000\nTest A: 2,566,004,688 nanoseconds\nTest B: 4,221,746,521 nanoseconds\nA faster by 1,655,741,833 nanoseconds (38.71935684115413% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntegerList 1000000\nTest A: 2,770,945,276 nanoseconds\nTest B: 3,829,077,158 nanoseconds\nA faster by 1,058,131,882 nanoseconds (27.134122749113843% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntegerList 1000000\nTest A: 3,467,474,055 nanoseconds\nTest B: 5,183,149,104 nanoseconds\nA faster by 1,715,675,049 nanoseconds (32.60101667104192% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntList 1000000\nTest A: 3,439,983,933 nanoseconds\nTest B: 3,509,530,312 nanoseconds\nA faster by 69,546,379 nanoseconds (1.4816434912159906% faster)\n\n[C:\\java_code\\]java TimeIteratorVsIndexIntList 1000000\nTest A: 3,451,101,466 nanoseconds\nTest B: 5,057,979,210 nanoseconds\nA faster by 1,606,877,744 nanoseconds (31.269164666060377% faster)\n import java.text.NumberFormat;\nimport java.util.Locale;\n\n/**\n <P>{@code java TimeIteratorVsIndexIntArray 1000000}</P>\n\n @see <CODE><A HREF="https://stackoverflow.com/questions/180158/how-do-i-time-a-methods-execution-in-java">https://stackoverflow.com/questions/180158/how-do-i-time-a-methods-execution-in-java</A></CODE>\n **/\npublic class TimeIteratorVsIndexIntArray {\n\n public static final NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);\n\n public static final void main(String[] tryCount_inParamIdx0) {\n int testCount;\n\n // Get try-count from a command-line parameter\n try {\n testCount = Integer.parseInt(tryCount_inParamIdx0[0]);\n }\n catch(ArrayIndexOutOfBoundsException | NumberFormatException x) {\n throw new IllegalArgumentException(\"Missing or invalid command line parameter: The number of testCount for each test. \" + x);\n }\n\n //Test proper...START\n int[] intArray = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100};\n\n long lStart = System.nanoTime();\n for(int i = 0; i < testCount; i++) {\n testIterator(intArray);\n }\n\n long lADuration = outputGetNanoDuration(\"A\", lStart);\n\n lStart = System.nanoTime();\n for(int i = 0; i < testCount; i++) {\n testFor(intArray);\n }\n\n long lBDuration = outputGetNanoDuration(\"B\", lStart);\n\n outputGetABTestNanoDifference(lADuration, lBDuration, \"A\", \"B\");\n }\n\n private static final void testIterator(int[] int_array) {\n int total = 0;\n for(int i = 0; i < int_array.length; i++) {\n total += int_array[i];\n }\n }\n\n private static final void testFor(int[] int_array) {\n int total = 0;\n for(int i : int_array) {\n total += i;\n }\n }\n //Test proper...END\n\n //Timer testing utilities...START\n public static final long outputGetNanoDuration(String s_testName, long l_nanoStart) {\n long lDuration = System.nanoTime() - l_nanoStart;\n System.out.println(\"Test \" + s_testName + \": \" + nf.format(lDuration) + \" nanoseconds\");\n return lDuration;\n }\n\n public static final long outputGetABTestNanoDifference(long l_aDuration, long l_bDuration, String s_aTestName, String s_bTestName) {\n long lDiff = -1;\n double dPct = -1.0;\n String sFaster = null;\n if(l_aDuration > l_bDuration) {\n lDiff = l_aDuration - l_bDuration;\n dPct = 100.00 - (l_bDuration * 100.0 / l_aDuration + 0.5);\n sFaster = \"B\";\n }\n else {\n lDiff = l_bDuration - l_aDuration;\n dPct = 100.00 - (l_aDuration * 100.0 / l_bDuration + 0.5);\n sFaster = \"A\";\n }\n System.out.println(sFaster + \" faster by \" + nf.format(lDiff) + \" nanoseconds (\" + dPct + \"% faster)\");\n return lDiff;\n }\n\n //Timer testing utilities...END\n\n}\n"
},
{
"answer_id": 23171818,
"author": "Jrovalle",
"author_id": 3551958,
"author_profile": "https://Stackoverflow.com/users/3551958",
"pm_score": 5,
"selected": false,
"text": "List<String> messages = Arrays.asList(\"First\", \"Second\", \"Third\");\n\nvoid forTest(){\n messages.forEach(System.out::println);\n}\n First\nSecond\nThird\n"
},
{
"answer_id": 32857986,
"author": "Manohar",
"author_id": 2039852,
"author_profile": "https://Stackoverflow.com/users/2039852",
"pm_score": 3,
"selected": false,
"text": "for void cancelAll(Collection<TimerTask> list) {\n for (Iterator<TimerTask> i = list.iterator(); i.hasNext();)\n i.next().cancel();\n}\n void cancelAll(Collection<TimerTask> list) {\n for (TimerTask t : list)\n t.cancel();\n}\n for (TimerTask t : list)\n"
},
{
"answer_id": 33232565,
"author": "akhil_mittal",
"author_id": 1216775,
"author_profile": "https://Stackoverflow.com/users/1216775",
"pm_score": 6,
"selected": false,
"text": "Iterable List<String> someList = new ArrayList<String>();\nsomeList.add(\"Apple\");\nsomeList.add(\"Ball\");\nfor (String item : someList) {\n System.out.println(item);\n}\n\n// Is translated to:\n\nfor(Iterator<String> stringIterator = someList.iterator(); stringIterator.hasNext(); ) {\n String item = stringIterator.next();\n System.out.println(item);\n}\n T[] String[] someArray = new String[2];\nsomeArray[0] = \"Apple\";\nsomeArray[1] = \"Ball\";\n\nfor(String item2 : someArray) {\n System.out.println(item2);\n}\n\n// Is translated to:\nfor (int i = 0; i < someArray.length; i++) {\n String item2 = someArray[i];\n System.out.println(item2);\n}\n someList.stream().forEach(System.out::println);\nArrays.stream(someArray).forEach(System.out::println);\n"
},
{
"answer_id": 40283536,
"author": "Santhosh Rajkumar",
"author_id": 6037775,
"author_profile": "https://Stackoverflow.com/users/6037775",
"pm_score": 3,
"selected": false,
"text": "public static Boolean Add_Tag(int totalsize)\n{\n List<String> fullst = new ArrayList<String>();\n for(int k=0; k<totalsize; k++)\n {\n fullst.addAll();\n }\n}\n"
},
{
"answer_id": 40857220,
"author": "L Joey",
"author_id": 5332814,
"author_profile": "https://Stackoverflow.com/users/5332814",
"pm_score": 3,
"selected": false,
"text": "Iterable interface for-each for-each for-each public class ForEachTest {\n\n public static void main(String[] args) {\n\n List<String> list = new ArrayList<String>();\n list.add(\"111\");\n list.add(\"222\");\n\n for (String str : list) {\n System.out.println(str);\n }\n }\n}\n javap public static void main(java.lang.String[]);\n flags: ACC_PUBLIC, ACC_STATIC\n Code:\n stack=2, locals=4, args_size=1\n 0: new #16 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #18 // Method java/util/ArrayList.\"<init>\":()V\n 7: astore_1\n 8: aload_1\n 9: ldc #19 // String 111\n 11: invokeinterface #21, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 16: pop\n 17: aload_1\n 18: ldc #27 // String 222\n 20: invokeinterface #21, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 25: pop\n 26: aload_1\n 27: invokeinterface #29, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n for-each Iterator Iterable interface Exception for-each"
},
{
"answer_id": 44018004,
"author": "Alexander Drobyshevsky",
"author_id": 1693748,
"author_profile": "https://Stackoverflow.com/users/1693748",
"pm_score": 4,
"selected": false,
"text": "List<String> someList = new ArrayList<String>();\n someList.stream().forEach(listItem -> {\n System.out.println(listItem);\n});\n someList.parallelStream().forEach(listItem -> {\n System.out.println(listItem);\n});\n"
},
{
"answer_id": 48497277,
"author": "Rei Brown",
"author_id": 8352967,
"author_profile": "https://Stackoverflow.com/users/8352967",
"pm_score": 1,
"selected": false,
"text": "List<String> someList = new ArrayList<>(); //has content\nsomeList.forEach(System.out::println);\n"
},
{
"answer_id": 49015283,
"author": "stackFan",
"author_id": 3315482,
"author_profile": "https://Stackoverflow.com/users/3315482",
"pm_score": 3,
"selected": false,
"text": "Iterator<String> iterator = someList.iterator();\n\nwhile (iterator.hasNext()) {\n String item = iterator.next();\n System.out.println(item);\n}\n someList someList.stream().forEach(System.out::println);\n"
},
{
"answer_id": 50135519,
"author": "gomisha",
"author_id": 5719544,
"author_profile": "https://Stackoverflow.com/users/5719544",
"pm_score": 3,
"selected": false,
"text": "int [] intArray = {1, 3, 5, 7, 9};\nfor(int currentValue : intArray) {\n System.out.println(currentValue);\n}\n 1\n3\n5\n7\n9\n String [] myStrings = {\n \"alpha\",\n \"beta\",\n \"gamma\",\n \"delta\"\n};\n\nfor(String currentString : myStrings) {\n System.out.println(currentString);\n}\n alpha\nbeta\ngamma\ndelta\n List<String> myList = new ArrayList<String>();\nmyList.add(\"alpha\");\nmyList.add(\"beta\");\nmyList.add(\"gamma\");\nmyList.add(\"delta\");\n\nfor(String currentItem : myList) {\n System.out.println(currentItem);\n}\n alpha\nbeta\ngamma\ndelta\n Set<String> mySet = new HashSet<String>();\nmySet.add(\"alpha\");\nmySet.add(\"alpha\");\nmySet.add(\"beta\");\nmySet.add(\"gamma\");\nmySet.add(\"gamma\");\nmySet.add(\"delta\");\n\nfor(String currentItem : mySet) {\n System.out.println(currentItem);\n}\n alpha\ndelta\nbeta\ngamma\n"
},
{
"answer_id": 50966962,
"author": "Du-Lacoste",
"author_id": 3600553,
"author_profile": "https://Stackoverflow.com/users/3600553",
"pm_score": 4,
"selected": false,
"text": "foreach List<String> items = new ArrayList<>();\nitems.add(\"A\");\nitems.add(\"B\");\nitems.add(\"C\");\nitems.add(\"D\");\nitems.add(\"E\");\n\nfor(String item : items) {\n System.out.println(item);\n}\n forEach // Output: A,B,C,D,E\nitems.forEach(item->System.out.println(item));\n // Output: A,B,C,D,E\nitems.forEach(System.out::println);\n"
},
{
"answer_id": 52098209,
"author": "vivekkurien",
"author_id": 3356847,
"author_profile": "https://Stackoverflow.com/users/3356847",
"pm_score": 4,
"selected": false,
"text": "List<String> someList = new ArrayList<String>();\nsomeList.add(\"A\");\nsomeList.add(\"B\");\nsomeList.add(\"C\");\n\nsomeList.forEach(listItem -> System.out.println(listItem))\n someList.forEach(listItem-> {\n System.out.println(listItem); \n});\n Map<String, String> mapList = new HashMap<>();\n mapList.put(\"Key1\", \"Value1\");\n mapList.put(\"Key2\", \"Value2\");\n mapList.put(\"Key3\", \"Value3\");\n\nmapList.forEach((key,value)->System.out.println(\"Key: \" + key + \" Value : \" + value));\n mapList.forEach((key,value)->{\n System.out.println(\"Key : \" + key + \" Value : \" + value);\n});\n"
},
{
"answer_id": 59667941,
"author": "mightyWOZ",
"author_id": 4413098,
"author_profile": "https://Stackoverflow.com/users/4413098",
"pm_score": 3,
"selected": false,
"text": "-XD-printflat javac -XD-printflat -d src/ MyFile.java\n\n//-d is used to specify the directory for output java file\n import java.util.*;\n\npublic class Temp{\n\n private static void forEachArray(){\n int[] arr = new int[]{1,2,3,4,5};\n for(int i: arr){\n System.out.print(i);\n }\n }\n\n private static void forEachList(){\n List<Integer> list = Arrays.asList(1,2,3,4,5);\n for(Integer i: list){\n System.out.print(i);\n }\n }\n}\n compiled import java.util.*;\n\npublic class Temp {\n\n public Temp() {\n super();\n }\n\n private static void forEachArray() {\n int[] arr = new int[]{1, 2, 3, 4, 5};\n for (/*synthetic*/ int[] arr$ = arr, len$ = arr$.length, i$ = 0; i$ < len$; ++i$) {\n int i = arr$[i$];\n {\n System.out.print(i);\n }\n }\n }\n\n private static void forEachList() {\n List list = Arrays.asList(new Integer[]{Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3), Integer.valueOf(4), Integer.valueOf(5)});\n for (/*synthetic*/ Iterator i$ = list.iterator(); i$.hasNext(); ) {\n Integer i = (Integer)i$.next();\n {\n System.out.print(i);\n }\n }\n }\n}\n"
},
{
"answer_id": 65906872,
"author": "nabayram",
"author_id": 14692626,
"author_profile": "https://Stackoverflow.com/users/14692626",
"pm_score": 1,
"selected": false,
"text": "for (Iterator<String> i = someList.iterator(); i.hasNext(); ) {\n String x = i.next();\n System.out.println(x);\n}\n"
},
{
"answer_id": 66815146,
"author": "Java-Dev",
"author_id": 10428563,
"author_profile": "https://Stackoverflow.com/users/10428563",
"pm_score": 1,
"selected": false,
"text": "import java.util.ArrayList;\nimport java.util.List;\n\npublic class ForLoopDemo {\n\n public static void main(String[] args) {\n\n List<String> someList = new ArrayList<String>();\n\n someList.add(\"monkey\");\n someList.add(\"donkey\");\n someList.add(\"skeleton key\");\n\n // Iteration using For Each loop\n System.out.println(\"Iteration using a For Each loop:\");\n for (String item : someList) {\n System.out.println(item);\n }\n\n // Iteration using a normal For loop\n System.out.println(\"\\nIteration using normal For loop: \");\n for (int index = 0; index < someList.size(); index++) {\n System.out.println(someList.get(index));\n }\n }\n}\n"
},
{
"answer_id": 71194990,
"author": "IsraelCena",
"author_id": 9877306,
"author_profile": "https://Stackoverflow.com/users/9877306",
"pm_score": 0,
"selected": false,
"text": "int[] numbers = {1,2,3,4,5};\n\nArrays.stream(numbers).forEach(System.out::println);\n 1\n2\n3\n4\n5\n\nThe process finished with exit code 0\n int[] numbers import java.util.Arrays;"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5074/"
] |
85,223
|
<p>Of course most languages have library functions for this, but suppose I want to do it myself.</p>
<p>Suppose that the float is given like in a C or Java program (except for the 'f' or 'd' suffix), for example "<code>4.2e1</code>", "<code>.42e2</code>" or simply "<code>42</code>". In general, we have the "integer part" before the decimal point, the "fractional part" after the decimal point, and the "exponent". All three are integers.</p>
<p><strong>It is easy to find and process the individual digits, but how do you compose them into a value of type <code>float</code> or <code>double</code> without losing precision?</strong></p>
<p>I'm thinking of multiplying the integer part with 10^<em>n</em>, where <em>n</em> is the number of digits in the fractional part, and then adding the fractional part to the integer part and subtracting <em>n</em> from the exponent. This effectively turns <code>4.2e1</code> into <code>42e0</code>, for example. Then I could use the <code>pow</code> function to compute 10^<em>exponent</em> and multiply the result with the new integer part. The question is, does this method guarantee maximum precision throughout?</p>
<p>Any thoughts on this?</p>
|
[
{
"answer_id": 85526,
"author": "user7116",
"author_id": 7116,
"author_profile": "https://Stackoverflow.com/users/7116",
"pm_score": 5,
"selected": false,
"text": "/* use this to start your atof implementation */\n\n/* atoi - christopher.watford@gmail.com */\n/* PUBLIC DOMAIN */\nlong atoi(const char *value) {\n unsigned long ival = 0, c, n = 1, i = 0, oval;\n for( ; c = value[i]; ++i) /* chomp leading spaces */\n if(!isspace(c)) break;\n if(c == '-' || c == '+') { /* chomp sign */\n n = (c != '-' ? n : -1);\n i++;\n }\n while(c = value[i++]) { /* parse number */\n if(!isdigit(c)) return 0;\n ival = (ival * 10) + (c - '0'); /* mult/accum */\n if((n > 0 && ival > LONG_MAX)\n || (n < 0 && ival > (LONG_MAX + 1UL))) {\n /* report overflow/underflow */\n errno = ERANGE;\n return (n > 0 ? LONG_MAX : LONG_MIN);\n }\n }\n return (n>0 ? (long)ival : -(long)ival);\n}\n"
},
{
"answer_id": 11253898,
"author": "J D",
"author_id": 13924,
"author_profile": "https://Stackoverflow.com/users/13924",
"pm_score": 1,
"selected": false,
"text": "int64 int int64 int64"
},
{
"answer_id": 11705617,
"author": "aka.nice",
"author_id": 1396822,
"author_profile": "https://Stackoverflow.com/users/1396822",
"pm_score": 2,
"selected": false,
"text": "if(biasedExponent >= 0)\n return integerMantissa * (10^biasedExponent);\nelse\n return integerMantissa / (10^(-biasedExponent));\n 10^8 > 2^24 > 10^7\n 5^11 > 2^24 > 5^10\n 10^16 > 2^53 > 10^15\n5^23 > 2^53 > 5^22\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85223",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14637/"
] |
85,272
|
<p>Anyone can read the GoF book to learn what design patterns are and how to use them, but what is the process for figuring out when a design pattern solves a problem? Does the knowledge of the pattern drive the design, or is there a way to figure out how a pattern can be used to change a design?</p>
<p>In other words, are there patterns for Patterns?</p>
|
[
{
"answer_id": 279828,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 4,
"selected": false,
"text": "TYPE_t ary[SIZE] = // ... gets initialized somehow\nsize_t ix ; // Your index variable\n\nfor(ix=0; ix < SIZE; ix++){\n if (ary[ix] == item) {\n return ix ;\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7565/"
] |
85,275
|
<p>I'm working on a game where I create a random map of provinces (a la Risk or Diplomacy). To create that map, I'm first generating a series of semi-random points, then figuring the Delaunay triangulations of those points. </p>
<p>With that done, I am now looking to create a Voronoi diagram of the points to serve as a starting point for the province borders. My data at this point (no pun intended) consists of the original series of points and a collection of the Delaunay triangles.</p>
<p>I've seen a number of ways to do this on the web, but most of them are tied up with how the Delaunay was derived. I'd love to find something that doesn't need to be integrated to the Delaunay, but can work based off the data alone. Failing that, I'm looking for something comprehensible to a relative geometry newbie, as opposed to optimal speed. Thanks!</p>
|
[
{
"answer_id": 85484,
"author": "Alexandra Franks",
"author_id": 16203,
"author_profile": "https://Stackoverflow.com/users/16203",
"pm_score": 3,
"selected": false,
"text": "for yloop = 0 to height-1\n for xloop = 0 to width-1\n\n // Generate maximal value\n closest_distance = width * height\n\n for point = 0 to number_of_points-1\n // calls function to calc distance\n point_distance = distance(point, xloop, yloop)\n\n if point_distance < closest_distance\n closest_point = point\n end if\n next\n\n // place result in array of point types\n points[xloop, yloop] = point\n\n next\nnext\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85275",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8365/"
] |
85,282
|
<p>In C# you can make a block inside of a method that is not attached to any other statement.</p>
<pre><code> public void TestMethod()
{
{
string x = "test";
string y = x;
{
int z = 42;
int zz = z;
}
}
}
</code></pre>
<p>This code compiles and runs just as if the braces inside the main method weren't there. Also notice the block inside of a block.</p>
<p>Is there a scenario where this would be valuable? I haven't found any yet, but am curious to hear of other people's findings.</p>
|
[
{
"answer_id": 85323,
"author": "Anthony",
"author_id": 5599,
"author_profile": "https://Stackoverflow.com/users/5599",
"pm_score": 2,
"selected": false,
"text": "if (someCondition)\n SimpleStatement();\n\nif (SomeCondition)\n{\n BlockOfStatements();\n}\n"
},
{
"answer_id": 85433,
"author": "Tim Erickson",
"author_id": 8787,
"author_profile": "https://Stackoverflow.com/users/8787",
"pm_score": 0,
"selected": false,
"text": "public void TestMethod()\n{\n //do something with some strings\n string x = \"test\";\n string y = x;\n\n //do something else with some ints\n int z = 42;\n int zz = z;\n}\n"
},
{
"answer_id": 86275,
"author": "BlackTigerX",
"author_id": 8411,
"author_profile": "https://Stackoverflow.com/users/8411",
"pm_score": 2,
"selected": false,
"text": " int a = 10;\n Console.WriteLine(a);\n\n int a = 20;\n Console.WriteLine(a);\n {\n int a = 10;\n Console.WriteLine(a);\n }\n {\n int a = 20;\n Console.WriteLine(a);\n }\n {\n //Process a large object and extract some data\n }\n //large object is out of scope here and will be garbage collected, \n //you can now perform other operations with the extracted data that can take a long time, \n //without holding the large object in memory\n\n //do processing with extracted data\n"
},
{
"answer_id": 86351,
"author": "Keith",
"author_id": 905,
"author_profile": "https://Stackoverflow.com/users/905",
"pm_score": 1,
"selected": false,
"text": "switch( value )\n{\n case const1: \n int i = GetValueSomeHow();\n //do something\n return i.ToString();\n\n case const2:\n int i = GetADifferentValue();\n //this will throw an exception - i is already declared\n ...\n switch( value )\n{\n case const1: \n {\n int i = GetValueSomeHow();\n //do something\n return i.ToString();\n }\n\n case const2:\n {\n int i = GetADifferentValue();\n //no exception now\n return SomeFunctionOfInt( i );\n }\n ...\n"
},
{
"answer_id": 13864283,
"author": "Servy",
"author_id": 1159478,
"author_profile": "https://Stackoverflow.com/users/1159478",
"pm_score": 1,
"selected": false,
"text": "if"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3289/"
] |
85,283
|
<p>I'm writting a financial C# application which receive messages from the network, translate them into different object according to the message type and finaly apply the application business logic on them.</p>
<p>The point is that after the business logic is applied, I'm very sure I will never need this instance again. Rather than to wait for the garbage collector to free them, I'd like to explicitly "delete" them.</p>
<p>Is there a better way to do so in C#, should I use a pool of object to reuse always the same set of instance or is there a better strategy.</p>
<p>The goal being to avoid the garbage collection to use any CPU during a time critical process.</p>
|
[
{
"answer_id": 87982,
"author": "Eddie Velasquez",
"author_id": 12851,
"author_profile": "https://Stackoverflow.com/users/12851",
"pm_score": 2,
"selected": false,
"text": "public class MyClass: IDisposable\n{\n private bool _disposed;\n\n public void Dispose()\n {\n Dispose( true );\n GC.SuppressFinalize( this );\n }\n\n protected virtual void Dispose( bool disposing )\n {\n if( _disposed ) \n return;\n\n if( disposing )\n {\n // Dispose managed resources here\n }\n\n _disposed = true;\n }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8315/"
] |
85,353
|
<p>What is the best (or as good as possible) general SVN ignore pattern to use? </p>
<p>There are a number of different IDE, editor, compiler, plug-in, platform, etc. specific files and some file types that "overlap" (i.e. desirable for some types projects and not for others). </p>
<p><strong>There are however, a large number of file types that you just never want included in source control automatically regardless the specifics of your development environment.</strong></p>
<p>The answer to this question would serve as a good starting point for any project - only requiring them to add the few environment specific items they need. It could be adapted for other Version Control Systems (VCS) as well.</p>
|
[
{
"answer_id": 85371,
"author": "icelava",
"author_id": 2663,
"author_profile": "https://Stackoverflow.com/users/2663",
"pm_score": 3,
"selected": false,
"text": "*/bin */obj *.user *.suo\n"
},
{
"answer_id": 85440,
"author": "noah",
"author_id": 12034,
"author_profile": "https://Stackoverflow.com/users/12034",
"pm_score": 1,
"selected": false,
"text": "bin\n.*\n"
},
{
"answer_id": 843183,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 6,
"selected": false,
"text": "*.o *.lo .la ## .*.rej .rej .~ ~ .# .DS_Store thumbs.db Thumbs.db *.bak *.class *.exe *.dll *.mine *.obj *.ncb *.lib *.log *.idb *.pdb *.ilk .msi .res *.pch *.suo *.exp ~. cvs CVS .CVS .cvs release Release debug Debug ignore Ignore bin Bin obj Obj *.csproj.user *.user _ReSharper.* *.resharper.user\n *.o *.lo .la ## .*.rej .rej .~ ~ .# .DS_Store thumbs.db Thumbs.db *.bak\n*.class *.exe *.dll *.mine *.obj *.ncb *.lib *.log *.idb *.pdb *.ilk .msi .res *.pch *.suo *.exp ~. cvs\nCVS .CVS .cvs release Release debug\nDebug ignore Ignore bin Bin obj Obj\n*.csproj.user *.user _ReSharper.* *.resharper.user\n"
},
{
"answer_id": 6902355,
"author": "Dalmas",
"author_id": 533552,
"author_profile": "https://Stackoverflow.com/users/533552",
"pm_score": 1,
"selected": false,
"text": "ipch *.sdf"
},
{
"answer_id": 7764856,
"author": "Richard Dingwall",
"author_id": 91551,
"author_profile": "https://Stackoverflow.com/users/91551",
"pm_score": 0,
"selected": false,
"text": "*.crunchsolution.* *.crunchproject.*\n"
},
{
"answer_id": 17672499,
"author": "Holger Bille",
"author_id": 1967424,
"author_profile": "https://Stackoverflow.com/users/1967424",
"pm_score": 0,
"selected": false,
"text": "*.stackdump core.*\n"
},
{
"answer_id": 39466037,
"author": "koppor",
"author_id": 873282,
"author_profile": "https://Stackoverflow.com/users/873282",
"pm_score": 0,
"selected": false,
"text": "# Created by https://www.gitignore.io/api/microsoftoffice,windows\n\n### MicrosoftOffice ###\n*.tmp\n\n# Word temporary\n~$*.doc*\n\n# Excel temporary\n~$*.xls*\n\n# Excel Backup File\n*.xlk\n\n# PowerPoint temporary\n~$*.ppt*\n\n# Visio autosave temporary files\n*.~vsdx\n\n\n### Windows ###\n# Windows image file caches\nThumbs.db\nehthumbs.db\n\n# Folder config file\nDesktop.ini\n\n# Recycle Bin used on file shares\n$RECYCLE.BIN/\n\n# Windows Installer files\n*.cab\n*.msi\n*.msm\n*.msp\n\n# Windows shortcuts\n*.lnk\n"
},
{
"answer_id": 39466162,
"author": "koppor",
"author_id": 873282,
"author_profile": "https://Stackoverflow.com/users/873282",
"pm_score": 0,
"selected": false,
"text": "# Created by https://www.gitignore.io/api/microsoftoffice,windows\n\n### MicrosoftOffice ###\n*.tmp\n\n# Word temporary\n~$*.doc*\n\n# Excel temporary\n~$*.xls*\n\n# Excel Backup File\n*.xlk\n\n# PowerPoint temporary\n~$*.ppt*\n\n# Visio autosave temporary files\n*.~vsdx\n\n\n### Windows ###\n# Windows image file caches\nThumbs.db\nehthumbs.db\n\n# Folder config file\nDesktop.ini\n\n# Recycle Bin used on file shares\n$RECYCLE.BIN/\n\n# Windows Installer files\n*.cab\n*.msi\n*.msm\n*.msp\n\n# Windows shortcuts\n*.lnk\n svn:global-ignore"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2233/"
] |
85,370
|
<p>My strongest lead is that the code who deals with the incoming XMLs is actually receiving an invalid/incomplete file hence failing the DOM parsing. Any suggestions?</p>
|
[
{
"answer_id": 85448,
"author": "Hank",
"author_id": 7610,
"author_profile": "https://Stackoverflow.com/users/7610",
"pm_score": 2,
"selected": false,
"text": "doc.selectSingleNode(\"//some/element/in/a/structure\");\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6992/"
] |
85,373
|
<p>In SQL Server, how do I "floor" a DATETIME to the second/minute/hour/day/year?</p>
<p>Let's say that I have a date of <strong>2008-09-17 12:56:53.430</strong>, then the output of flooring should be:</p>
<ul>
<li>Year: 2008-01-01 00:00:00.000</li>
<li>Month: 2008-09-01 00:00:00.000</li>
<li>Day: 2008-09-17 00:00:00.000</li>
<li>Hour: 2008-09-17 12:00:00.000</li>
<li>Minute: 2008-09-17 12:56:00.000</li>
<li>Second: 2008-09-17 12:56:53.000</li>
</ul>
|
[
{
"answer_id": 85379,
"author": "Portman",
"author_id": 1690,
"author_profile": "https://Stackoverflow.com/users/1690",
"pm_score": 8,
"selected": true,
"text": "declare @datetime datetime;\nset @datetime = getdate();\nselect @datetime;\nselect dateadd(year,datediff(year,0,@datetime),0);\nselect dateadd(month,datediff(month,0,@datetime),0);\nselect dateadd(day,datediff(day,0,@datetime),0);\nselect dateadd(hour,datediff(hour,0,@datetime),0);\nselect dateadd(minute,datediff(minute,0,@datetime),0);\nselect dateadd(second,datediff(second,'2000-01-01',@datetime),'2000-01-01');\nselect dateadd(week,datediff(week,0,@datetime),-1); --Beginning of week is Sunday\nselect dateadd(week,datediff(week,0,@datetime),0); --Beginning of week is Monday\n"
},
{
"answer_id": 86499,
"author": "Chris Wuestefeld",
"author_id": 10082,
"author_profile": "https://Stackoverflow.com/users/10082",
"pm_score": 5,
"selected": false,
"text": "SELECT CAST(FLOOR(CAST(CURRENT_TIMESTAMP AS float)) AS DATETIME)\n"
},
{
"answer_id": 561614,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "date_trunc()\n"
},
{
"answer_id": 10212540,
"author": "Moe Cazzell",
"author_id": 1341767,
"author_profile": "https://Stackoverflow.com/users/1341767",
"pm_score": 4,
"selected": false,
"text": "cast(cast(getdate() as date) as datetime)\n getdate() cast(floor(cast(getdate() as float)) as datetime)"
},
{
"answer_id": 17860749,
"author": "Dan Atkinson",
"author_id": 31532,
"author_profile": "https://Stackoverflow.com/users/31532",
"pm_score": 3,
"selected": false,
"text": "IF OBJECT_ID('fn_FloorDate') IS NOT NULL DROP FUNCTION fn_FloorDate\nSET ANSI_NULLS OFF\nGO\nSET QUOTED_IDENTIFIER ON\nGO\nCREATE FUNCTION [dbo].[fn_FloorDate] (\n @Date DATETIME = NULL,\n @DatePart VARCHAR(6) = 'day'\n)\nRETURNS DATETIME\nAS\nBEGIN\n IF (@Date IS NULL)\n SET @Date = GETDATE();\n\n RETURN\n CASE\n WHEN LOWER(@DatePart) = 'year' THEN DATEADD(YEAR, DATEDIFF(YEAR, 0, @Date), 0)\n WHEN LOWER(@DatePart) = 'month' THEN DATEADD(MONTH, DATEDIFF(MONTH, 0, @Date), 0)\n WHEN LOWER(@DatePart) = 'day' THEN DATEADD(DAY, DATEDIFF(DAY, 0, @Date), 0)\n WHEN LOWER(@DatePart) = 'hour' THEN DATEADD(HOUR, DATEDIFF(HOUR, 0, @Date), 0)\n WHEN LOWER(@DatePart) = 'minute' THEN DATEADD(MINUTE, DATEDIFF(MINUTE, 0, @Date), 0)\n WHEN LOWER(@DatePart) = 'second' THEN DATEADD(SECOND, DATEDIFF(SECOND, '2000-01-01', @Date), '2000-01-01')\n ELSE DATEADD(DAY, DATEDIFF(DAY, 0, @Date), 0)\n END;\nEND\n DECLARE @date DATETIME;\nSET @date = '2008-09-17 12:56:53.430';\n\nSELECT\n @date AS [Now],--2008-09-17 12:56:53.430\n dbo.fn_FloorDate(@date, 'year') AS [Year],--2008-01-01 00:00:00.000\n dbo.fn_FloorDate(default, default) AS [NoParams],--2013-11-05 00:00:00.000\n dbo.fn_FloorDate(@date, default) AS [ShouldBeDay],--2008-09-17 00:00:00.000\n dbo.fn_FloorDate(@date, 'month') AS [Month],--2008-09-01 00:00:00.000\n dbo.fn_FloorDate(@date, 'day') AS [Day],--2008-09-17 00:00:00.000\n dbo.fn_FloorDate(@date, 'hour') AS [Hour],--2008-09-17 12:00:00.000\n dbo.fn_FloorDate(@date, 'minute') AS [Minute],--2008-09-17 12:56:00.000\n dbo.fn_FloorDate(@date, 'second') AS [Second];--2008-09-17 12:56:53.000\n"
},
{
"answer_id": 26166191,
"author": "Sean",
"author_id": 4103350,
"author_profile": "https://Stackoverflow.com/users/4103350",
"pm_score": 1,
"selected": false,
"text": "select convert(datetime,convert(varchar,CURRENT_TIMESTAMP,101))\n"
},
{
"answer_id": 37059540,
"author": "pinaldave",
"author_id": 892707,
"author_profile": "https://Stackoverflow.com/users/892707",
"pm_score": 0,
"selected": false,
"text": "----Last Day of Previous Month\nSELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))\nLastDay_PreviousMonth\n----Last Day of Current Month\nSELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+1,0))\nLastDay_CurrentMonth\n----Last Day of Next Month\nSELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+2,0))\nLastDay_NextMonth\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1690/"
] |
85,451
|
<p>Which is better to use for timing in Python? time.clock() or time.time()? Which one provides more accuracy?</p>
<p>for example:</p>
<pre><code>start = time.clock()
... do something
elapsed = (time.clock() - start)
</code></pre>
<p>vs.</p>
<pre><code>start = time.time()
... do something
elapsed = (time.time() - start)
</code></pre>
|
[
{
"answer_id": 85489,
"author": "Vinko Vrsalovic",
"author_id": 5190,
"author_profile": "https://Stackoverflow.com/users/5190",
"pm_score": 4,
"selected": false,
"text": "clock() clock() time() time()"
},
{
"answer_id": 85511,
"author": "PierreBdR",
"author_id": 7136,
"author_profile": "https://Stackoverflow.com/users/7136",
"pm_score": 6,
"selected": false,
"text": "time.clock() time.clock() time.time() time.time() time.clock()"
},
{
"answer_id": 85536,
"author": "dF.",
"author_id": 3002,
"author_profile": "https://Stackoverflow.com/users/3002",
"pm_score": 5,
"selected": false,
"text": "time.time() time.clock() timeit"
},
{
"answer_id": 2246226,
"author": "Seba",
"author_id": 271241,
"author_profile": "https://Stackoverflow.com/users/271241",
"pm_score": 4,
"selected": false,
"text": "time.time() time.clock() time.time() time.clock()"
},
{
"answer_id": 21178451,
"author": "bestwolf1983",
"author_id": 3205257,
"author_profile": "https://Stackoverflow.com/users/3205257",
"pm_score": 4,
"selected": false,
"text": "time() clock() clock() time() using time():\n\n1 requests, response time: 14.1749382019 ms\n2 requests, response time: 8.01301002502 ms\n3 requests, response time: 8.01491737366 ms\n4 requests, response time: 8.41021537781 ms\n5 requests, response time: 8.38804244995 ms\n using clock(): 1 requests, response time: 10.0 ms\n2 requests, response time: 0.0 ms \n3 requests, response time: 0.0 ms\n4 requests, response time: 10.0 ms\n5 requests, response time: 0.0 ms \n6 requests, response time: 0.0 ms\n7 requests, response time: 0.0 ms \n8 requests, response time: 0.0 ms\n"
},
{
"answer_id": 21374146,
"author": "Hill",
"author_id": 3239341,
"author_profile": "https://Stackoverflow.com/users/3239341",
"pm_score": -1,
"selected": false,
"text": ">>> start = time.time(); time.sleep(0.5); (time.time() - start)\n0.5005500316619873\n >>> start = time.time(); time.sleep(0.5); (time.time() - start)\n0.5\n"
},
{
"answer_id": 35929913,
"author": "Nurul Akter Towhid",
"author_id": 4294015,
"author_profile": "https://Stackoverflow.com/users/4294015",
"pm_score": 3,
"selected": false,
"text": "import time\n\ndef t_time():\n start=time.time()\n time.sleep(0.1)\n return (time.time()-start)\n\n\ndef t_clock():\n start=time.clock()\n time.sleep(0.1)\n return (time.clock()-start)\n\n\n\n\ncounter_time=0\ncounter_clock=0\n\nfor i in range(1,100):\n counter_time += t_time()\n\n for i in range(1,100):\n counter_clock += t_clock()\n\nprint \"time() =\",counter_time/100\nprint \"clock() =\",counter_clock/100\n time() = 0.0993799996376\n\nclock() = 0.0993572257367\n"
},
{
"answer_id": 40677139,
"author": "dsgdfg",
"author_id": 2133240,
"author_profile": "https://Stackoverflow.com/users/2133240",
"pm_score": 1,
"selected": false,
"text": "subject time import timeit\nimport time\n\nclock_list = []\ntime_list = []\n\ntest1 = \"\"\"\ndef test(v=time.clock()):\n s = time.clock() - v\n\"\"\"\n\ntest2 = \"\"\"\ndef test(v=time.time()):\n s = time.time() - v\n\"\"\"\ndef test_it(Range) :\n for i in range(Range) :\n clk = timeit.timeit(test1, number=10000)\n clock_list.append(clk)\n tml = timeit.timeit(test2, number=10000)\n time_list.append(tml)\n\ntest_it(100)\n\nprint \"Clock Min: %f Max: %f Average: %f\" %(min(clock_list), max(clock_list), sum(clock_list)/float(len(clock_list)))\nprint \"Time Min: %f Max: %f Average: %f\" %(min(time_list), max(time_list), sum(time_list)/float(len(time_list)))\n time.clock() time.time() time.clock() max 32BIT FLOAT"
},
{
"answer_id": 49667496,
"author": "Chris_Rands",
"author_id": 6260170,
"author_profile": "https://Stackoverflow.com/users/6260170",
"pm_score": 3,
"selected": false,
"text": "time.clock() time.perf_counter() time.process_time() time.perf_counter_ns() time.process_time_ns() time.time_ns() time.clock_gettime_ns(clock_id) time.clock_settime_ns(clock_id, time:int) time.monotonic_ns() time.perf_counter_ns() time.process_time_ns() time.time_ns() timeit"
},
{
"answer_id": 62115682,
"author": "xjcl",
"author_id": 2111778,
"author_profile": "https://Stackoverflow.com/users/2111778",
"pm_score": 2,
"selected": false,
"text": "time.clock() print(time.clock()); time.sleep(10); print(time.clock())\n# Linux : 0.0382 0.0384 # see Processor Time\n# Windows: 26.1224 36.1566 # see Wall-Clock Time\n time.process_time() time.perf_counter() time.time() time.monotonic() time.perf_counter()"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85451",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16148/"
] |
85,457
|
<p>I am trying to inherit from my generated datacontext in LinqToSQL - something like this </p>
<pre><code>public class myContext : dbDataContext {
public System.Data.Linq.Table<User>() Users {
return (from x in base.Users() where x.DeletedOn.HasValue == false select x);
}
}
</code></pre>
<p>But my Linq statement returns IQueryable which cannot cast to Table - does anyone know a way to limit the contents of a Linq.Table - I am trying to be certain that anywhere my Users table is accessed, it doesn't return those marked deleted. Perhaps I am going about this all wrong - any suggestions would be greatly appreciated.</p>
<p>Hal</p>
|
[
{
"answer_id": 85507,
"author": "Scott Nichols",
"author_id": 4299,
"author_profile": "https://Stackoverflow.com/users/4299",
"pm_score": 1,
"selected": false,
"text": "Users.OfType<ActiveUsers>\n"
},
{
"answer_id": 85989,
"author": "Scott Nichols",
"author_id": 4299,
"author_profile": "https://Stackoverflow.com/users/4299",
"pm_score": 3,
"selected": true,
"text": "CREATE VIEW ActiveUsers as SELECT * FROM Users WHERE IsDeleted = 0\n"
},
{
"answer_id": 89144,
"author": "liammclennan",
"author_id": 2785,
"author_profile": "https://Stackoverflow.com/users/2785",
"pm_score": 1,
"selected": false,
"text": "from item in All\nwhere ...\nselect item\n public IQueryable<T> All\n{\n get { return MyDataContext.GetTable<T>.Where(entity => !entity.DeletedOn.HasValue); }\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16416/"
] |
85,459
|
<p>I have a series of PDFs named sequentially like so:</p>
<ul>
<li>01_foo.pdf</li>
<li>02_bar.pdf</li>
<li>03_baz.pdf</li>
<li>etc.</li>
</ul>
<p>Using Ruby, is it possible to combine these into one big PDF while keeping them in sequence? I don't mind installing any necessary gems to do the job.</p>
<p>If this isn't possible in Ruby, how about another language? No commercial components, if possible.</p>
<hr>
<p><strong>Update:</strong> <a href="https://stackoverflow.com/questions/85459/is-it-possible-to-combine-a-series-of-pdfs-into-one-using-ruby#85618">Jason Navarrete's suggestion</a> lead to the perfect solution:</p>
<p>Place the PDF files needing to be combined in a directory along with <a href="http://www.accesspdf.com/pdftk/" rel="nofollow noreferrer">pdftk</a> (or make sure pdftk is in your PATH), then run the following script:</p>
<pre><code>pdfs = Dir["[0-9][0-9]_*"].sort.join(" ")
`pdftk #{pdfs} output combined.pdf`
</code></pre>
<p>Or I could even do it as a one-liner from the command-line:</p>
<pre><code>ruby -e '`pdftk #{Dir["[0-9][0-9]_*"].sort.join(" ")} output combined.pdf`'
</code></pre>
<p>Great suggestion Jason, perfect solution, thanks. <strong>Give him an up-vote people</strong>.</p>
|
[
{
"answer_id": 85576,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 2,
"selected": false,
"text": "system()"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1944/"
] |
85,479
|
<p>Can someone give an example of a good time to actually use "unsafe" and "fixed" in C# code? I've played with it before, but never actually found a good use for it. </p>
<p>Consider this code...</p>
<pre><code>fixed (byte* pSrc = src, pDst = dst) {
//Code that copies the bytes in a loop
}
</code></pre>
<p>compared to simply using...</p>
<pre><code>Array.Copy(source, target, source.Length);
</code></pre>
<p>The second is the code found in the .NET Framework, the first a part of the code copied from the Microsoft website, <a href="http://msdn.microsoft.com/en-us/library/28k1s2k6(VS.80).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/28k1s2k6(VS.80).aspx</a>.</p>
<p>The built in Array.Copy() is dramatically faster than using Unsafe code. This might just because the second is just better written and the first is just an example, but what kinds of situations would you really even need to use Unsafe/Fixed code for anything? Or is this poor web developer messing with something above his head?</p>
|
[
{
"answer_id": 85774,
"author": "Rune",
"author_id": 7948,
"author_profile": "https://Stackoverflow.com/users/7948",
"pm_score": 5,
"selected": false,
"text": "unsafe\n{\n BitmapData bmData = bm.LockBits(...)\n byte *bits = (byte*)pixels.ToPointer();\n // Do stuff with bits\n}\n"
},
{
"answer_id": 488202,
"author": "ShuggyCoUk",
"author_id": 12748,
"author_profile": "https://Stackoverflow.com/users/12748",
"pm_score": 3,
"selected": false,
"text": "public static unsafe int UInt32ToInt32Bits(uint x)\n{\n return *((int*)(void*)&x);\n}\n // from the Jenkins one at a time hash function\nprivate static unsafe void Hash(byte* data, int len, ref uint hash)\n{\n for (int i = 0; i < len; i++)\n {\n hash += data[i];\n hash += (hash << 10);\n hash ^= (hash >> 6);\n }\n}\n\npublic unsafe static void HashCombine(ref uint sofar, long data)\n{\n byte* dataBytes = (byte*)(void*)&data;\n AddToHash(dataBytes, sizeof(long), ref sofar);\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
85,481
|
<p>Say I've got this table (SQL Server 2005):</p>
<pre><code>Id => integer
MyField => XML
</code></pre>
<p><b>Id MyField</b> </p>
<pre><code>1 < Object>< Type>AAA< /Type>< Value>10< /Value>< /Object>< Object>< Type>BBB< /Type><Value>20< /Value>< /Object>
2 < Object>< Type>AAA< /Type>< Value>15< /Value>< /Object>
3 < Object>< Type>AAA< /Type>< Value>20< /Value>< /Object>< Object>< Type>BBB< /Type>< Value>30< /Value>< /Object>
</code></pre>
<p>I need a TSQL query which would return something like this:</p>
<pre><code>Id AAA BBB
1 10 20
2 15 NULL
3 20 30
</code></pre>
<p>Note that I won't know if advance how many <code>'Type'</code> (eg AAA, BBB, CCC,DDD, etc.) there will be in the xml string.</p>
|
[
{
"answer_id": 85535,
"author": "Darren Kopp",
"author_id": 77,
"author_profile": "https://Stackoverflow.com/users/77",
"pm_score": 1,
"selected": false,
"text": "select id, MyField.query('/Object/Type[.=\"AAA\"]/Value') as AAA, MyField.query('/Object/Type[.=\"BBB\"]/Value) AS BBB\n"
},
{
"answer_id": 182780,
"author": "Josef",
"author_id": 5581,
"author_profile": "https://Stackoverflow.com/users/5581",
"pm_score": 0,
"selected": false,
"text": "CROSS APPLY declare @y table (rowid int, xmlblock xml)\ninsert into @y values(1,'<Object><Type>AAA</Type><Value>10</Value></Object><Object><Type>BBB</Type><Value>20</Value></Object>')\ninsert into @y values(2,'<Object><Type>AAA</Type><Value>15</Value></Object>')\ninsert into @y values(3,'<Object><Type>AAA</Type><Value>20</Value></Object><Object><Type>BBB</Type><Value>30</Value></Object>')\n\nselect y.rowid, t.b.value('Type[1]', 'nvarchar(5)'), t.b.value('Value[1]', 'int')\nfrom @y y CROSS APPLY XmlBlock.nodes('//Object') t(b)\n Value Type BBB"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15928/"
] |
85,486
|
<p>I'm trying to add an SVN repository to Eclipse. </p>
<p>I've installed <a href="http://subclipse.tigris.org/" rel="noreferrer">Subclipse</a>, and it seems to be working fine. But, when I try to "add a new SVN repository", I input this, for example:</p>
<p><em><a href="http://svn.python.org/projects/peps/trunk" rel="noreferrer">http://svn.python.org/projects/peps/trunk</a></em></p>
<p>I get this:</p>
<blockquote>
<p>Error validating location: "org.tigris.subversion.javahl.ClientException: RA layer request failed
svn: OPTIONS of '<a href="http://svn.python.org/projects/peps/trunk" rel="noreferrer">http://svn.python.org/projects/peps/trunk</a>': could not connect to server (<a href="http://svn.python.org" rel="noreferrer">http://svn.python.org</a>)
"
Keep location anyway?</p>
</blockquote>
<p>I know that my Eclipse can connect to the Internet, because I downloaded Subclipse earlier (I had to change my proxy settings). </p>
<p>I get a similar message for other SVN locations I've tried to add. </p>
<p>What is the solution?</p>
|
[
{
"answer_id": 85619,
"author": "bengineerd",
"author_id": 10428,
"author_profile": "https://Stackoverflow.com/users/10428",
"pm_score": 2,
"selected": false,
"text": "$ svn checkout http://svn.python.org/projects/peps/trunk\n"
},
{
"answer_id": 85852,
"author": "Mike Tunnicliffe",
"author_id": 13956,
"author_profile": "https://Stackoverflow.com/users/13956",
"pm_score": 1,
"selected": false,
"text": "Subclipse 1.4.0\nSubversion Client Adapter 1.5.0.1\nSVNKit Client Adapter 1.5.0.1\nSVNKit Library 1.2.0.4502\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1179/"
] |
85,487
|
<p>How do I perform a reverse DNS lookup, that is how do I resolve an IP address to its DNS hostname in Perl?</p>
|
[
{
"answer_id": 85573,
"author": "Joakim",
"author_id": 16432,
"author_profile": "https://Stackoverflow.com/users/16432",
"pm_score": 4,
"selected": false,
"text": "use Socket;\n$iaddr = inet_aton(\"127.0.0.1\"); # or whatever address\n$name = gethostbyaddr($iaddr, AF_INET);\n"
},
{
"answer_id": 85640,
"author": "Jeff",
"author_id": 10157,
"author_profile": "https://Stackoverflow.com/users/10157",
"pm_score": 5,
"selected": false,
"text": "use Net::DNS;\nmy $res = Net::DNS::Resolver->new;\n\n# create the reverse lookup DNS name (note that the octets in the IP address need to be reversed).\nmy $IP = \"209.85.173.103\";\nmy $target_IP = join('.', reverse split(/\\./, $IP)).\".in-addr.arpa\";\n\nmy $query = $res->query(\"$target_IP\", \"PTR\");\n\nif ($query) {\n foreach my $rr ($query->answer) {\n next unless $rr->type eq \"PTR\";\n print $rr->rdatastr, \"\\n\";\n }\n} else {\n warn \"query failed: \", $res->errorstring, \"\\n\";\n}\n"
},
{
"answer_id": 97636,
"author": "Jagmal",
"author_id": 4406,
"author_profile": "https://Stackoverflow.com/users/4406",
"pm_score": 0,
"selected": false,
"text": "$ip = \"XXX.XXX.XXX.XXX\" # IPV4 address.\nmy @numbers = split (/\\./, $ip);\nif (scalar(@numbers) != 4)\n{\n print \"$ip is not a valid IP address.\\n\";\n next;\n}\nmy $ip_addr = pack(\"C4\", @numbers);\n# First element of the array returned by gethostbyaddr is host name.\nmy ($name) = (gethostbyaddr($ip_addr, 2))[0];\n"
},
{
"answer_id": 1373424,
"author": "Kai Carver",
"author_id": 153144,
"author_profile": "https://Stackoverflow.com/users/153144",
"pm_score": 2,
"selected": false,
"text": "perl -MSocket -E 'say scalar gethostbyaddr(inet_aton(\"79.81.152.79\"), AF_INET)'\n"
},
{
"answer_id": 12810035,
"author": "John Boone",
"author_id": 1733284,
"author_profile": "https://Stackoverflow.com/users/1733284",
"pm_score": 2,
"selected": false,
"text": "perl -MSocket -E 'say scalar gethostbyaddr(inet_aton(\"69.89.27.250\"), AF_INET)'\n perl -MSocket -E \"say scalar gethostbyaddr(inet_aton(\\\"69.89.27.250\\\"), AF_INET)\"\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16432/"
] |
85,500
|
<p>First time working with UpdatePanels in .NET. </p>
<p>I have an updatepanel with a trigger pointed to an event on a FormView control. The UpdatePanel holds a ListView with related data from a separate database.</p>
<p>When the UpdatePanel refreshes, it needs values from the FormView control so that on the server it can use them to query the database.</p>
<p>For the life if me, I can't figure out how to get those values. The event I'm triggering from has them, but I want the updatepanel to refresh asynchronously. How do I pass values to the load event on the panel?</p>
<p>Googled this ad nauseum and can't seem to get to an answer here. A link or an explanation would be immensely helpful..</p>
<p>Jeff</p>
|
[
{
"answer_id": 86520,
"author": "StingyJack",
"author_id": 16391,
"author_profile": "https://Stackoverflow.com/users/16391",
"pm_score": 3,
"selected": true,
"text": "<html xmlns=\"http://www.w3.org/1999/xhtml\" >\n<head runat=\"server\">\n <title>Untitled Page</title>\n <script type=\"text/javascript\" src=\"AjaxHelper.js\"></script>\n</head>\n<body>\n <form id=\"form1\" runat=\"server\">\n <div>\n <asp:TextBox ID=\"txtSearchValue\" runat=\"server\"></asp:TextBox>\n <input id=\"btnSearch\" type=\"button\" value=\"Search by partial full name\" onclick=\"doSearch()\"/>\n\n <igtbl:ultrawebgrid id=\"uwgUsers\" runat=\"server\" \n//infragistics grid crap\n </igtbl:ultrawebgrid>--%>\n </div>\n </form>\n</body>\n</html>\n //this is tied to the button click. It takes care of input cleanup and calling the AJAX method\nfunction doSearch(){\n var eleVal; \n var eleBtn;\n eleVal = document.getElementById('txtSearchValue').value;\n eleBtn = document.getElementById('btnSearch');\n eleVal = trim(eleVal);\n if (eleVal.length > 0) {\n eleBtn.value = 'Searching...';\n eleBtn.disabled = true;\n refreshGridData(eleVal);\n }\n else {\n alert(\"Please enter a value to search with. Unabated searches are not permitted.\");\n }\n}\n\n//This is the function that will go out and get the data and call load the Grid on AJAX call \n//return.\nfunction refreshGridData(searchString){\n\n if (searchString =='undefined'){\n searchString = \"\";\n }\n\n var xhr; \n var gridData;\n var url;\n\n url = \"DefaultHandler.ashx?partialUserFullName=\" + escape(searchString);\n xhr = GetXMLHttpRequestObject();\n\n xhr.onreadystatechange = function() {\n if (xhr.readystate==4) {\n gridData = eval(xhr.responseText);\n if (gridData.length > 0) {\n //clear and fill the grid\n clearAndPopulateGrid(gridData);\n }\n else {\n //display appropriate message\n }\n } //if (xhr.readystate==4) {\n } //xhr.onreadystatechange = function() {\n\n xhr.open(\"GET\", url, true);\n xhr.send(null);\n}\n\n//this does the grid clearing and population, and enables the search button when complete.\nfunction clearAndPopulateGrid(jsonObject) {\n\n var grid = igtbl_getGridById('uwgUsers');\n var eleBtn;\n eleBtn = document.getElementById('btnSearch');\n\n //clear the rows\n for (x = grid.Rows.length; x >= 0; x--) {\n grid.Rows.remove(x, false);\n }\n\n //add the new ones\n for (x = 0; x < jsonObject.length; x++) {\n var newRow = igtbl_addNew(grid.Id, 0, false, false);\n //the cells should not be referenced by index value, so a name lookup should be implemented\n newRow.getCell(0).setValue(jsonObject[x][1]); \n newRow.getCell(1).setValue(jsonObject[x][2]);\n newRow.getCell(2).setValue(jsonObject[x][3]);\n }\n\n grid = null;\n\n eleBtn.disabled = false;\n eleBtn.value = \"Search by partial full name\";\n}\n\n\n// this function will return the XMLHttpRequest Object for the current browser\nfunction GetXMLHttpRequestObject() {\n\n var XHR; //the object to return\n var ua = navigator.userAgent.toLowerCase(); //gets the useragent text\n try\n {\n //determine the browser type\n if (!window.ActiveXObject)\n { //Non IE Browsers\n XHR = new XMLHttpRequest(); \n }\n else \n {\n if (ua.indexOf('msie 5') == -1)\n { //IE 5.x\n XHR = new ActiveXObject(\"Msxml2.XMLHTTP\");\n }\n else\n { //IE 6.x and up \n XHR = new ActiveXObject(\"Microsoft.XMLHTTP\"); \n }\n } //end if (!window.ActiveXObject)\n\n if (XHR == null)\n {\n throw \"Unable to instantiate the XMLHTTPRequest object.\";\n }\n }\n catch (e)\n {\n alert(\"This browser does not appear to support AJAX functionality. error: \" + e.name\n + \" description: \" + e.message);\n }\n return XHR;\n} //end function GetXMLHttpRequestObject()\n\nfunction trim(stringToTrim){\n return stringToTrim.replace(/^\\s\\s*/, '').replace(/\\s\\s*$/, '');\n}\n Imports System.Web\nImports System.Web.Services\nImports System.Data\nImports System.Data.SqlClient\n\nPublic Class DefaultHandler\n Implements System.Web.IHttpHandler\n\n Private Const CONN_STRING As String = \"Data Source=;Initial Catalog=;User ID=;Password=;\"\n\n Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest\n\n context.Response.ContentType = \"text/plain\"\n context.Response.Expires = -1\n\n Dim strPartialUserName As String\n Dim strReturnValue As String = String.Empty\n\n If context.Request.QueryString(\"partialUserFullName\") Is Nothing = False Then\n strPartialUserName = context.Request.QueryString(\"partialUserFullName\").ToString()\n\n If String.IsNullOrEmpty(strPartialUserName) = False Then\n strReturnValue = SearchAndReturnJSResult(strPartialUserName)\n End If\n End If\n\n context.Response.Write(strReturnValue)\n\n End Sub\n\n\n Private Function SearchAndReturnJSResult(ByVal partialUserName As String) As String\n\n Dim strReturnValue As New StringBuilder()\n Dim conn As SqlConnection\n Dim strSQL As New StringBuilder()\n Dim objParam As SqlParameter\n Dim da As SqlDataAdapter\n Dim ds As New DataSet()\n Dim dr As DataRow\n\n 'define sql\n strSQL.Append(\" SELECT \")\n strSQL.Append(\" [id] \")\n strSQL.Append(\" ,([first_name] + ' ' + [last_name]) \")\n strSQL.Append(\" ,[email] \")\n strSQL.Append(\" FROM [person] (NOLOCK) \")\n strSQL.Append(\" WHERE [last_name] LIKE @lastName\")\n\n 'clean up the partial user name for use in a like search\n If partialUserName.EndsWith(\"%\", StringComparison.InvariantCultureIgnoreCase) = False Then\n partialUserName = partialUserName & \"%\"\n End If\n\n If partialUserName.StartsWith(\"%\", StringComparison.InvariantCultureIgnoreCase) = False Then\n partialUserName = partialUserName.Insert(0, \"%\")\n End If\n\n 'create the oledb parameter... parameterized queries perform far better on repeatable\n 'operations\n objParam = New SqlParameter(\"@lastName\", SqlDbType.VarChar, 100)\n objParam.Value = partialUserName\n\n conn = New SqlConnection(CONN_STRING)\n da = New SqlDataAdapter(strSQL.ToString(), conn)\n da.SelectCommand.Parameters.Add(objParam)\n\n Try 'to get a dataset. \n da.Fill(ds)\n Catch sqlex As SqlException\n 'Throw an appropriate exception if you can add details that will help understand the problem.\n Throw New DataException(\"Unable to retrieve the results from the user search.\", sqlex)\n Finally\n If conn.State = ConnectionState.Open Then\n conn.Close()\n End If\n conn.Dispose()\n da.Dispose()\n End Try\n\n 'make sure we have a return value\n If ds Is Nothing OrElse ds.Tables(0) Is Nothing OrElse ds.Tables(0).Rows.Count <= 0 Then\n Return String.Empty\n End If\n\n 'This converts the table into JS array. \n strReturnValue.Append(\"[\")\n\n For Each dr In ds.Tables(0).Rows\n strReturnValue.Append(\"['\" & CStr(dr(\"username\")) & \"','\" & CStr(dr(\"userfullname\")) & \"','\" & CStr(dr(\"useremail\")) & \"'],\")\n Next\n\n strReturnValue.Remove(strReturnValue.Length - 1, 1)\n strReturnValue.Append(\"]\")\n\n 'de-allocate what can be deallocated. Setting to Nothing for smaller types may\n 'incur performance hit because of a forced allocation to nothing before they are deallocated\n 'by garbage collection.\n ds.Dispose()\n strSQL.Length = 0\n\n Return strReturnValue.ToString()\n\n End Function\n\n\n ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable\n Get\n Return False\n End Get\n End Property\n\nEnd Class\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16426/"
] |
85,553
|
<p>MSDN says that you should use structs when you need lightweight objects. Are there any other scenarios when a struct is preferable over a class?</p>
<p>Some people might have forgotten that:</p>
<ol>
<li><em>structs</em> can have methods.</li>
<li><em>structs</em> cannot be inherited.</li>
</ol>
<p>I understand the technical differences between structs and classes, I just don't have a good feel for <strong>when</strong> to use a struct.</p>
|
[
{
"answer_id": 470416,
"author": "Andrei Rînea",
"author_id": 1796,
"author_profile": "https://Stackoverflow.com/users/1796",
"pm_score": 6,
"selected": false,
"text": "public struct ThreeDimensionalPoint\n{\n public readonly int X, Y, Z;\n public ThreeDimensionalPoint(int x, int y, int z)\n {\n this.X = x;\n this.Y = y;\n this.Z = z;\n }\n\n public override string ToString()\n {\n return \"(X=\" + this.X + \", Y=\" + this.Y + \", Z=\" + this.Z + \")\";\n }\n\n public override int GetHashCode()\n {\n return (this.X + 2) ^ (this.Y + 2) ^ (this.Z + 2);\n }\n\n public override bool Equals(object obj)\n {\n if (!(obj is ThreeDimensionalPoint))\n return false;\n ThreeDimensionalPoint other = (ThreeDimensionalPoint)obj;\n return this == other;\n }\n\n public static bool operator ==(ThreeDimensionalPoint p1, ThreeDimensionalPoint p2)\n {\n return p1.X == p2.X && p1.Y == p2.Y && p1.Z == p2.Z;\n }\n\n public static bool operator !=(ThreeDimensionalPoint p1, ThreeDimensionalPoint p2)\n {\n return !(p1 == p2);\n }\n}\n"
},
{
"answer_id": 60475290,
"author": "Eduardas Šlutas",
"author_id": 7838447,
"author_profile": "https://Stackoverflow.com/users/7838447",
"pm_score": 3,
"selected": false,
"text": "public class TestClass\n{\n public long ID { get; set; }\n public string FirstName { get; set; }\n public string LastName { get; set; }\n}\n public struct TestStruct\n{\n public long ID { get; set; }\n public string FirstName { get; set; }\n public string LastName { get; set; }\n}\n BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18362\nIntel Core i5-8250U CPU 1.60GHz (Kaby Lake R), 1 CPU, 8 logical and 4 physical cores\n.NET Core SDK=3.1.101\n[Host] : .NET Core 3.1.1 (CoreCLR 4.700.19.60701, CoreFX 4.700.19.60801), X64 RyuJIT [AttachedDebugger]\nDefaultJob : .NET Core 3.1.1 (CoreCLR 4.700.19.60701, CoreFX 4.700.19.60801), X64 RyuJIT\n\n\n| Method | Mean | Error | StdDev | Ratio | RatioSD | Rank | Gen 0 | Gen 1 | Gen 2 | Allocated |\n|--------------- |---------------:|--------------:|--------------:|----------:|--------:|-----:|---------:|------:|------:|----------:|\n\n| UseStruct | 0.0000 ns | 0.0000 ns | 0.0000 ns | 0.000 | 0.00 | 1 | - | - | - | - |\n| UseClass | 8.1425 ns | 0.1873 ns | 0.1839 ns | 1.000 | 0.00 | 2 | 0.0127 | - | - | 40 B |\n| Use100Struct | 36.9359 ns | 0.4026 ns | 0.3569 ns | 4.548 | 0.12 | 3 | - | - | - | - |\n| Use100Class | 759.3495 ns | 14.8029 ns | 17.0471 ns | 93.144 | 3.24 | 4 | 1.2751 | - | - | 4000 B |\n| Use10000Struct | 3,002.1976 ns | 25.4853 ns | 22.5920 ns | 369.664 | 8.91 | 5 | - | - | - | - |\n| Use10000Class | 76,529.2751 ns | 1,570.9425 ns | 2,667.5795 ns | 9,440.182 | 346.76 | 6 | 127.4414 | - | - | 400000 B |\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/781/"
] |
85,559
|
<p>I have a problem in my project with the .designer which as everyone know is autogenerated and I ahvent changed at all. One day I was working fine, I did a back up and next day boom! the project suddenly stops working and sends a message that the designer cant procees a code line... and due to this I get more errores (2 in my case), I even had a back up from the day it was working and is useless too, I get the same error, I tryed in my laptop and the same problem comes. How can I delete the "FitTrack"? The incredible part is that while I was trying on the laptop the errors on the desktop were gone in front of my eyes, one and one second later the other one (but still have the warning from the designer and cant see the form), I closed and open it again and again I have the errors...</p>
<p>The error is:</p>
<pre><code>Warning 1 The designer cannot process the code at line 27:
Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11
The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again. C:\Documents and Settings\Alan Cardero\Desktop\Reportes Liquidacion\Reportes Liquidacion\Reportes Liquidacion\Form1.Designer.vb 28 0
</code></pre>
|
[
{
"answer_id": 85602,
"author": "Quintin Robinson",
"author_id": 12707,
"author_profile": "https://Stackoverflow.com/users/12707",
"pm_score": 1,
"selected": false,
"text": "If(Not DesignMode) Then Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11\n Public Sub New()\n InitializeComponent()\n\n AddHandler Me.Load, New EventHandler(AddressOf Form1_Load)\nEnd Sub\n\nPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)\n If (Not DesignMode) Then Me.CrystalReportViewer1.ReportSource = Me.CrystalReport11\nEnd Sub\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
85,577
|
<p>I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas?</p>
|
[
{
"answer_id": 85632,
"author": "Sylvain Defresne",
"author_id": 5353,
"author_profile": "https://Stackoverflow.com/users/5353",
"pm_score": 1,
"selected": false,
"text": "arping"
},
{
"answer_id": 86541,
"author": "akiva",
"author_id": 65724,
"author_profile": "https://Stackoverflow.com/users/65724",
"pm_score": -1,
"selected": false,
"text": "ifconfig import os\nmyPipe = os.popen2(\"/sbin/ifconfig\",\"a\")\nprint(myPipe[1].read())\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11760/"
] |
85,622
|
<p>Most precompiled Windows binaries are made with the MSYS+gcc toolchain. It uses MSVCRT runtime, which is incompatible with Visual C++ 2005/2008.</p>
<p>So, how to go about and compile Cairo 1.6.4 (or later) for Visual C++ only. Including dependencies (png,zlib,pixman).</p>
|
[
{
"answer_id": 96168,
"author": "jfs",
"author_id": 6223,
"author_profile": "https://Stackoverflow.com/users/6223",
"pm_score": 0,
"selected": false,
"text": "config.h"
},
{
"answer_id": 6704146,
"author": "Sergeq",
"author_id": 846031,
"author_profile": "https://Stackoverflow.com/users/846031",
"pm_score": 1,
"selected": false,
"text": "sed \"s/^if \\([A-Z_]*\\)$/ifeq ($(\\1), 1)/\" src\\Makefile.sources\n _lround sed \"s/#define _cairo_lround lround/static inline long cairo_const\n_cairo_lround(double r) { return (long)floor(r + .5); }/\"` \n"
},
{
"answer_id": 33718258,
"author": "jingyu9575",
"author_id": 1997315,
"author_profile": "https://Stackoverflow.com/users/1997315",
"pm_score": 2,
"selected": false,
"text": ". (my_cairo_build_root)\n├─cairo\n├─libpng\n├─pixman\n└─zlib\n libpng\\projects\\vstudio\\zlib.props <ZLibSrcDir> ..\\..\\..\\..\\zlib <WindowsSDKDesktopARMSupport> true false libpng\\projects\\vstudio\\vstudio.sln Debug libpng Release Library libpng pixman\\Makefile.win32.common CFG_CFLAGS = -MD -O2 CFG_CFLAGS = -MT -O2 @mkdir @\"mkdir\" cmd mkdir mkdir cd /d my_cairo_build_root\ncd pixman\\pixman\nmake -f Makefile.win32\nmake -f Makefile.win32 CFG=debug\n cairo\\build\\Makefile.win32.common CFG_CFLAGS = -MD -O2 CFG_CFLAGS = -MT -O2 CAIRO_LIBS += $(LIBPNG_PATH)/libpng.lib CAIRO_LIBS += $(LIBPNG_PATH)/lib/$(CFG)/libpng16.lib libpng\\projects\\vstudio\\Debug libpng\\lib\\ debug libpng\\projects\\vstudio\\Release Library libpng\\lib\\ release CAIRO_LIBS += $(ZLIB_PATH)/zdll.lib CAIRO_LIBS += $(LIBPNG_PATH)/lib/$(CFG)/zlib.lib @mkdir -p $(CFG)/`dirname $<` @\"mkdir\" -p $(CFG)/$<\n@\"rmdir\" $(CFG)/$<\n cairo\\build\\Makefile.win32.features-h @echo @\"echo\" link.exe C:\\GnuWin\\bin\\link.exe link_.exe cd /d my_cairo_build_root\ncd cairo\nmake -f Makefile.win32 CFG=debug\nmake -f Makefile.win32 CFG=release\n \"Built successfully!\" C:\\GnuWin\\bin\\link.exe include cairo\\cairo-version.h cairo\\src\\cairo-version.h cairo\\src\\*.h cairo\\src\\cairo-version.h cairo\\src\\$(Configuration) libpng\\lib\\$(Configuration) $(Configuration) Debug Release cairo\\src\\debug\\cairo.dll libpng\\lib\\debug\\libpng16.dll PATH #include <cairo.h> #ifndef NDEBUG\n# pragma comment(lib, \"cairo\")\n#else\n#define CAIRO_WIN32_STATIC_BUILD\n# pragma comment(lib, \"cairo-static\")\n# pragma comment(lib, \"libpng16\")\n# pragma comment(lib, \"zlib\")\n#endif\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14455/"
] |
85,649
|
<p>How do I remove a USB drive using the Win32 API? I do a lot of work on embedded systems and on one of these I have to copy my programs on a USB stick and insert it into the target hardware.</p>
<p>Since I mostly work on the console I don't like to use the mouse and click on the small task-bar icon hundred times a day. </p>
<p>I'd love to write a little program to do exactly that so I can put it into my makefiles, but I haven't found any API call that does the same thing.</p>
<p>Any ideas?</p>
|
[
{
"answer_id": 85678,
"author": "Grant Wagner",
"author_id": 9254,
"author_profile": "https://Stackoverflow.com/users/9254",
"pm_score": 3,
"selected": false,
"text": "sync -e [drive_letter]"
},
{
"answer_id": 85694,
"author": "Kris Kumler",
"author_id": 4281,
"author_profile": "https://Stackoverflow.com/users/4281",
"pm_score": 5,
"selected": true,
"text": "CM_Request_Device_Eject()"
},
{
"answer_id": 85723,
"author": "jop",
"author_id": 11830,
"author_profile": "https://Stackoverflow.com/users/11830",
"pm_score": 2,
"selected": false,
"text": "DismountNtmsMedia"
},
{
"answer_id": 64381851,
"author": "VictorV",
"author_id": 6119813,
"author_profile": "https://Stackoverflow.com/users/6119813",
"pm_score": 0,
"selected": false,
"text": "#include<SetupAPI.h>\n#include <windows.h> \n#include<initguid.h>\n#include <newdev.h>\n#include <Cfgmgr32.h>\n\n#pragma comment(lib, \"Cfgmgr32.lib\")\n#pragma comment(lib, \"Setupapi.lib\")\n#pragma comment(lib, \"Newdev.lib\")\n\nint RemoveDevice(const GUID *guid, const wchar_t *hwID) {\n HDEVINFO m_hDevInfo;\n SP_DEVICE_INTERFACE_DATA spdid;\n SP_DEVINFO_DATA spdd;\n DWORD dwSize;\n BYTE Buf[1024];\n PSP_DEVICE_INTERFACE_DETAIL_DATA pspdidd =\n (PSP_DEVICE_INTERFACE_DETAIL_DATA)Buf;\n\n printf(\"try to remove device::%ws\\n\", hwID);\n\n m_hDevInfo = SetupDiGetClassDevs(guid, NULL, NULL, DIGCF_PRESENT| DIGCF_DEVICEINTERFACE);\n if (m_hDevInfo == INVALID_HANDLE_VALUE)\n {\n printf(\"GetClassDevs Failed!\\n\");\n return 0;\n }\n spdid.cbSize = sizeof(spdid);\n for (int i = 0; SetupDiEnumDeviceInterfaces(m_hDevInfo, NULL, guid, i, &spdid); i++) {\n dwSize = 0;\n SetupDiGetDeviceInterfaceDetail(m_hDevInfo,\n &spdid, NULL, 0, &dwSize, NULL);\n if (dwSize != 0 && dwSize <= sizeof(Buf)) {\n pspdidd->cbSize = sizeof(*pspdidd); // 5 Bytes!\n\n ZeroMemory((PVOID)&spdd, sizeof(spdd));\n spdd.cbSize = sizeof(spdd);\n\n long res =\n SetupDiGetDeviceInterfaceDetail(m_hDevInfo, &\n spdid, pspdidd,\n dwSize, &dwSize,\n &spdd);\n if (res) {\n OLECHAR* guidString;\n OLECHAR* guidString2;\n StringFromCLSID(&spdd.ClassGuid, &guidString);\n StringFromCLSID(&spdid.InterfaceClassGuid, &guidString2);\n printf(\"%d, %ws, %ws, %ws\\n\", spdd.DevInst, pspdidd->DevicePath, guidString, guidString2);\n CoTaskMemFree(guidString);\n CoTaskMemFree(guidString2);\n if (!memcmp(pspdidd->DevicePath, hwID, 2 * lstrlenW(hwID))) {\n DEVINST DevInstParent = 0;\n res = CM_Get_Parent(&DevInstParent, spdd.DevInst, 0);\n for (long tries = 0; tries < 10; tries++) {\n // sometimes we need some tries...\n WCHAR VetoNameW[MAX_PATH];\n PNP_VETO_TYPE VetoType = PNP_VetoTypeUnknown;\n VetoNameW[0] = 0;\n\n res = CM_Request_Device_EjectW(DevInstParent,\n &VetoType, VetoNameW, MAX_PATH, 0);\n if ((res == CR_SUCCESS &&\n VetoType == PNP_VetoTypeUnknown)) {\n printf(\"remove %ws success!\\n\", pspdidd->DevicePath);\n SetupDiDestroyDeviceInfoList(m_hDevInfo);\n return 1;\n }\n Sleep(500); // required to give the next tries a chance!\n }\n break;\n }\n }\n }\n }\n printf(\"Remove Device Failed!\\n\");\n SetupDiDestroyDeviceInfoList(m_hDevInfo);\n return 0;\n}\n\nint main(){\n GUID GUID_DEVINTERFACE_USB_HUB;\n CLSIDFromString(L\"F18A0E88-C30C-11D0-8815-00A0C906BED8\", &GUID_DEVINTERFACE_USB_HUB);\n\n RemoveDevice(&GUID_DEVINTERFACE_USB_HUB, L\"\\\\\\\\?\\\\usb#root_hub30\");\n return 0;\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15955/"
] |
85,675
|
<p>I have two tables I would like to complare. One of the columns is type CLOB. I would like to do something like this:</p>
<pre><code>select key, clob_value source_table
minus
select key, clob_value target_table
</code></pre>
<p>Unfortunately, Oracle can't perform minus operations on clobs. How can I do this?</p>
|
[
{
"answer_id": 85716,
"author": "hamishmcn",
"author_id": 3590,
"author_profile": "https://Stackoverflow.com/users/3590",
"pm_score": 2,
"selected": false,
"text": "select key, to_hash_str_val(glob_value) from source_table\nminus\nselect key, to_hash_str_val(glob_value) from target_table\n"
},
{
"answer_id": 85730,
"author": "Nick Craver",
"author_id": 13249,
"author_profile": "https://Stackoverflow.com/users/13249",
"pm_score": 5,
"selected": true,
"text": "dbms_lob.compare( \nlob_1 IN BLOB, \nlob_2 IN BLOB, \namount IN INTEGER := 18446744073709551615, \noffset_1 IN INTEGER := 1, \noffset_2 IN INTEGER := 1) \nRETURN INTEGER; \n Select key, glob_value \nFrom source_table Left Join target_table \n On source_table.key = target_table.key \nWhere target_table.glob_value is Null \n Or dbms_lob.compare(source_table.glob_value, target_table.glob_value) <> 0\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16484/"
] |
85,699
|
<p>I'm building a group calendar application that needs to support recurring events, but all the solutions I've come up with to handle these events seem like a hack. I can limit how far ahead one can look, and then generate all the events at once. Or I can store the events as repeating and dynamically display them when one looks ahead on the calendar, but I'll have to convert them to a normal event if someone wants to change the details on a particular instance of the event.</p>
<p>I'm sure there's a better way to do this, but I haven't found it yet. What's the best way to model recurring events, where you can change details of or delete particular event instances?</p>
<p>(I'm using Ruby, but please don't let that constrain your answer. If there's a Ruby-specific library or something, though, that's good to know.)</p>
|
[
{
"answer_id": 85909,
"author": "Purfideas",
"author_id": 4615,
"author_profile": "https://Stackoverflow.com/users/4615",
"pm_score": 2,
"selected": false,
"text": "#!/usr/bin/ruby\nrequire 'date'\n\nstart_date = Date.parse('2008-01-01')\nend_date = Date.parse('2008-04-01')\nwday = 5 # friday\n\n(start_date..end_date).select{|d| d.wday == wday}.map{|d| d.to_s}.inspect\n # =>\"[\\\"2008-01-04\\\", \\\"2008-01-11\\\", \\\"2008-01-18\\\", \\\"2008-01-25\\\", \\\"2008-02-01\\\", \\\"2008-02-08\\\", \\\"2008-02-15\\\", \\\"2008-02-22\\\", \\\"2008-02-29\\\", \\\"2008-03-07\\\", \\\"2008-03-14\\\", \\\"2008-03-21\\\", \\\"2008-03-28\\\"]\"\n"
},
{
"answer_id": 4001814,
"author": "Vee",
"author_id": 459940,
"author_profile": "https://Stackoverflow.com/users/459940",
"pm_score": 4,
"selected": false,
"text": "form.schedule :as => :recurring before_filter IceCube events task.schedule IceCube task.schedule.next_suggestion"
},
{
"answer_id": 26770786,
"author": "fozua",
"author_id": 2753345,
"author_profile": "https://Stackoverflow.com/users/2753345",
"pm_score": 0,
"selected": false,
"text": "TableID: 1 Name: cycleA \nStartTime: 6 November 2014 (I kept thenumber of milliseconds), \nEndTime: 6 November 2015 (if it is repeated forever, and you can keep the value -1) \nCycletype: WeekLy.\n TableID: 1 \nName, cycleB \nStartTime, 27 November 2014 \nEndTime,November 6 2015 \nCycletype, WeekLy\nForeignkey, 1 (pointingto the table recycle paternal events).\n public static List<Map<String, Object>> recurringData(Context context,\n long start, long end) { // 重复事件的模板处理,生成虚拟事件(根据日期段)\n long a = System.currentTimeMillis();\n List<Map<String, Object>> finalDataList = new ArrayList<Map<String, Object>>();\n\n List<Map<String, Object>> tDataList = BillsDao.selectTemplateBillRuleByBE(context); //RuleTable,just select recurringEvent\n for (Map<String, Object> iMap : tDataList) {\n\n int _id = (Integer) iMap.get(\"_id\");\n long bk_billDuedate = (Long) iMap.get(\"ep_billDueDate\"); // 相当于事件的开始日期 Start\n long bk_billEndDate = (Long) iMap.get(\"ep_billEndDate\"); // 重复事件的截止日期 End\n int bk_billRepeatType = (Integer) iMap.get(\"ep_recurringType\"); // recurring Type \n\n long startDate = 0; // 进一步精确判断日记起止点,保证了该段时间断获取的数据不未空,减少不必要的处理\n long endDate = 0;\n\n if (bk_billEndDate == -1) { // 永远重复事件的处理\n\n if (end >= bk_billDuedate) {\n endDate = end;\n startDate = (bk_billDuedate <= start) ? start : bk_billDuedate; // 进一步判断日记起止点,这样就保证了该段时间断获取的数据不未空\n }\n\n } else {\n\n if (start <= bk_billEndDate && end >= bk_billDuedate) { // 首先判断起止时间是否落在重复区间,表示该段时间有重复事件\n endDate = (bk_billEndDate >= end) ? end : bk_billEndDate;\n startDate = (bk_billDuedate <= start) ? start : bk_billDuedate; // 进一步判断日记起止点,这样就保证了该段时间断获取的数据不未空\n }\n }\n\n Calendar calendar = Calendar.getInstance();\n calendar.setTimeInMillis(bk_billDuedate); // 设置重复的开始日期\n\n long virtualLong = bk_billDuedate; // 虚拟时间,后面根据规则累加计算\n List<Map<String, Object>> virtualDataList = new ArrayList<Map<String, Object>>();// 虚拟事件\n\n if (virtualLong == startDate) { // 所要求的时间,小于等于父本时间,说明这个是父事件数据,即第一条父本数据\n\n Map<String, Object> bMap = new HashMap<String, Object>();\n bMap.putAll(iMap);\n bMap.put(\"indexflag\", 1); // 1表示父本事件\n virtualDataList.add(bMap);\n }\n\n long before_times = 0; // 计算从要求时间start到重复开始时间的次数,用于定位第一次发生在请求时间段落的时间点\n long remainder = -1;\n if (bk_billRepeatType == 1) {\n\n before_times = (startDate - bk_billDuedate) / (7 * DAYMILLIS);\n remainder = (startDate - bk_billDuedate) % (7 * DAYMILLIS);\n\n } else if (bk_billRepeatType == 2) {\n\n before_times = (startDate - bk_billDuedate) / (14 * DAYMILLIS);\n remainder = (startDate - bk_billDuedate) % (14 * DAYMILLIS);\n\n } else if (bk_billRepeatType == 3) {\n\n before_times = (startDate - bk_billDuedate) / (28 * DAYMILLIS);\n remainder = (startDate - bk_billDuedate) % (28 * DAYMILLIS);\n\n } else if (bk_billRepeatType == 4) {\n\n before_times = (startDate - bk_billDuedate) / (15 * DAYMILLIS);\n remainder = (startDate - bk_billDuedate) % (15 * DAYMILLIS);\n\n } else if (bk_billRepeatType == 5) {\n\n do { // 该段代码根据日历处理每天重复事件,当事件比较多的时候效率比较低\n\n Calendar calendarCloneCalendar = (Calendar) calendar\n .clone();\n int currentMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n calendarCloneCalendar.add(Calendar.MONTH, 1);\n int nextMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n\n if (currentMonthDay > nextMonthDay) {\n calendar.add(Calendar.MONTH, 1 + 1);\n virtualLong = calendar.getTimeInMillis();\n } else {\n calendar.add(Calendar.MONTH, 1);\n virtualLong = calendar.getTimeInMillis();\n }\n\n } while (virtualLong < startDate);\n\n } else if (bk_billRepeatType == 6) {\n\n do { // 该段代码根据日历处理每天重复事件,当事件比较多的时候效率比较低\n\n Calendar calendarCloneCalendar = (Calendar) calendar\n .clone();\n int currentMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n calendarCloneCalendar.add(Calendar.MONTH, 2);\n int nextMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n\n if (currentMonthDay > nextMonthDay) {\n calendar.add(Calendar.MONTH, 2 + 2);\n virtualLong = calendar.getTimeInMillis();\n } else {\n calendar.add(Calendar.MONTH, 2);\n virtualLong = calendar.getTimeInMillis();\n }\n\n } while (virtualLong < startDate);\n\n } else if (bk_billRepeatType == 7) {\n\n do { // 该段代码根据日历处理每天重复事件,当事件比较多的时候效率比较低\n\n Calendar calendarCloneCalendar = (Calendar) calendar\n .clone();\n int currentMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n calendarCloneCalendar.add(Calendar.MONTH, 3);\n int nextMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n\n if (currentMonthDay > nextMonthDay) {\n calendar.add(Calendar.MONTH, 3 + 3);\n virtualLong = calendar.getTimeInMillis();\n } else {\n calendar.add(Calendar.MONTH, 3);\n virtualLong = calendar.getTimeInMillis();\n }\n\n } while (virtualLong < startDate);\n\n } else if (bk_billRepeatType == 8) {\n\n do {\n calendar.add(Calendar.YEAR, 1);\n virtualLong = calendar.getTimeInMillis();\n } while (virtualLong < startDate);\n\n }\n\n if (remainder == 0 && virtualLong != startDate) { // 当整除的时候,说明当月的第一天也是虚拟事件,判断排除为父本,然后添加。不处理,一个月第一天事件会丢失\n before_times = before_times - 1;\n }\n\n if (bk_billRepeatType == 1) { // 单独处理天事件,计算出第一次出现在时间段的事件时间\n\n virtualLong = bk_billDuedate + (before_times + 1) * 7\n * (DAYMILLIS);\n calendar.setTimeInMillis(virtualLong);\n\n } else if (bk_billRepeatType == 2) {\n\n virtualLong = bk_billDuedate + (before_times + 1) * (2 * 7)\n * DAYMILLIS;\n calendar.setTimeInMillis(virtualLong);\n } else if (bk_billRepeatType == 3) {\n\n virtualLong = bk_billDuedate + (before_times + 1) * (4 * 7)\n * DAYMILLIS;\n calendar.setTimeInMillis(virtualLong);\n } else if (bk_billRepeatType == 4) {\n\n virtualLong = bk_billDuedate + (before_times + 1) * (15)\n * DAYMILLIS;\n calendar.setTimeInMillis(virtualLong);\n }\n\n while (startDate <= virtualLong && virtualLong <= endDate) { // 插入虚拟事件\n Map<String, Object> bMap = new HashMap<String, Object>();\n bMap.putAll(iMap);\n bMap.put(\"ep_billDueDate\", virtualLong);\n bMap.put(\"indexflag\", 2); // 2表示虚拟事件\n virtualDataList.add(bMap);\n\n if (bk_billRepeatType == 1) {\n\n calendar.add(Calendar.DAY_OF_MONTH, 7);\n\n } else if (bk_billRepeatType == 2) {\n\n calendar.add(Calendar.DAY_OF_MONTH, 2 * 7);\n\n } else if (bk_billRepeatType == 3) {\n\n calendar.add(Calendar.DAY_OF_MONTH, 4 * 7);\n\n } else if (bk_billRepeatType == 4) {\n\n calendar.add(Calendar.DAY_OF_MONTH, 15);\n\n } else if (bk_billRepeatType == 5) {\n\n Calendar calendarCloneCalendar = (Calendar) calendar\n .clone();\n int currentMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n calendarCloneCalendar.add(Calendar.MONTH,\n 1);\n int nextMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n\n if (currentMonthDay > nextMonthDay) {\n calendar.add(Calendar.MONTH, 1\n + 1);\n } else {\n calendar.add(Calendar.MONTH, 1);\n }\n\n }else if (bk_billRepeatType == 6) {\n\n Calendar calendarCloneCalendar = (Calendar) calendar\n .clone();\n int currentMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n calendarCloneCalendar.add(Calendar.MONTH,\n 2);\n int nextMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n\n if (currentMonthDay > nextMonthDay) {\n calendar.add(Calendar.MONTH, 2\n + 2);\n } else {\n calendar.add(Calendar.MONTH, 2);\n }\n\n }else if (bk_billRepeatType == 7) {\n\n Calendar calendarCloneCalendar = (Calendar) calendar\n .clone();\n int currentMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n calendarCloneCalendar.add(Calendar.MONTH,\n 3);\n int nextMonthDay = calendarCloneCalendar\n .get(Calendar.DAY_OF_MONTH);\n\n if (currentMonthDay > nextMonthDay) {\n calendar.add(Calendar.MONTH, 3\n + 3);\n } else {\n calendar.add(Calendar.MONTH, 3);\n }\n\n } else if (bk_billRepeatType == 8) {\n\n calendar.add(Calendar.YEAR, 1);\n\n }\n virtualLong = calendar.getTimeInMillis();\n\n }\n\n finalDataList.addAll(virtualDataList);\n\n }// 遍历模板结束,产生结果为一个父本加若干虚事件的list\n\n /*\n * 开始处理重复特例事件特例事件,并且来时合并\n */\n List<Map<String, Object>>oDataList = BillsDao.selectBillItemByBE(context, start, end);\n Log.v(\"mtest\", \"特例结果大小\" +oDataList );\n\n\n List<Map<String, Object>> delectDataListf = new ArrayList<Map<String, Object>>(); // finalDataList要删除的结果\n List<Map<String, Object>> delectDataListO = new ArrayList<Map<String, Object>>(); // oDataList要删除的结果\n\n\n for (Map<String, Object> fMap : finalDataList) { // 遍历虚拟事件\n\n int pbill_id = (Integer) fMap.get(\"_id\");\n long pdue_date = (Long) fMap.get(\"ep_billDueDate\");\n\n for (Map<String, Object> oMap : oDataList) {\n\n int cbill_id = (Integer) oMap.get(\"billItemHasBillRule\");\n long cdue_date = (Long) oMap.get(\"ep_billDueDate\");\n int bk_billsDelete = (Integer) oMap.get(\"ep_billisDelete\");\n\n if (cbill_id == pbill_id) {\n\n if (bk_billsDelete == 2) {// 改变了duedate的特殊事件\n long old_due = (Long) oMap.get(\"ep_billItemDueDateNew\");\n\n if (old_due == pdue_date) {\n\n delectDataListf.add(fMap);//该改变事件在时间范围内,保留oMap\n\n }\n\n } else if (bk_billsDelete == 1) {\n\n if (cdue_date == pdue_date) {\n\n delectDataListf.add(fMap);\n delectDataListO.add(oMap);\n\n }\n\n } else {\n\n if (cdue_date == pdue_date) {\n delectDataListf.add(fMap);\n }\n\n }\n\n }\n }// 遍历特例事件结束\n\n }// 遍历虚拟事件结束\n // Log.v(\"mtest\", \"delectDataListf的大小\"+delectDataListf.size());\n // Log.v(\"mtest\", \"delectDataListO的大小\"+delectDataListO.size());\n finalDataList.removeAll(delectDataListf);\n oDataList.removeAll(delectDataListO);\n finalDataList.addAll(oDataList);\n List<Map<String, Object>> mOrdinaryList = BillsDao.selectOrdinaryBillRuleByBE(context, start, end);\n finalDataList.addAll(mOrdinaryList);\n // Log.v(\"mtest\", \"finalDataList的大小\"+finalDataList.size());\n long b = System.currentTimeMillis();\n Log.v(\"mtest\", \"算法耗时\"+(b-a));\n\n return finalDataList;\n} \n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85699",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6262/"
] |
85,701
|
<p>I have a database field that contains a raw date field (stored as character data), such as </p>
<blockquote>
<p>Friday, September 26, 2008 8:30 PM Eastern Daylight Time</p>
</blockquote>
<p>I can parse this as a Date easily, with SimpleDateFormat</p>
<pre><code>DateFormat dbFormatter = new SimpleDateFormat("EEEE, MMMM dd, yyyy hh:mm aa zzzz");
Date scheduledDate = dbFormatter.parse(rawDate);
</code></pre>
<p>What I'd like to do is extract a TimeZone object from this string. The default TimeZone in the JVM that this application runs in is GMT, so I can't use <code>.getTimezoneOffset()</code> from the <code>Date</code> parsed above (because it will return the default TimeZone).</p>
<p>Besides tokenizing the raw string and finding the start position of the Timezone string (since I know the format will always be <code>EEEE, MMMM dd, yyyy hh:mm aa zzzz</code>) is there a way using the DateFormat/SimpleDateFormat/Date/Calendar API to extract a TimeZone object - which will have the same TimeZone as the String I've parsed apart with <code>DateFormat.parse()</code>?</p>
<p>One thing that bugs me about <code>Date</code> vs <code>Calendar</code> in the Java API is that <code>Calendar</code> is supposed to replace <code>Date</code> in all places... but then they decided, oh hey let's still use <code>Date</code>'s in the <code>DateFormat</code> classes.</p>
|
[
{
"answer_id": 86183,
"author": "Ed Thomas",
"author_id": 8256,
"author_profile": "https://Stackoverflow.com/users/8256",
"pm_score": 2,
"selected": false,
"text": " DateFormat dbFormatter = new SimpleDateFormat(\"EEEE, MMMM dd, yyyy hh:mm aa zzzz\");\n dbFormatter.setTimeZone(TimeZone.getTimeZone(\"America/Chicago\"));\n Date scheduledDate = dbFormatter.parse(\"Friday, September 26, 2008 8:30 PM Eastern Daylight Time\");\n System.out.println(scheduledDate);\n System.out.println(dbFormatter.format(scheduledDate));\n TimeZone tz = dbFormatter.getTimeZone();\n System.out.println(tz.getDisplayName());\n dbFormatter.setTimeZone(TimeZone.getTimeZone(\"America/Chicago\"));\n System.out.println(dbFormatter.format(scheduledDate));\n Fri Sep 26 20:30:00 CDT 2008\nFriday, September 26, 2008 08:30 PM Eastern Standard Time\nEastern Standard Time\nFriday, September 26, 2008 08:30 PM Central Daylight Time\n"
},
{
"answer_id": 86229,
"author": "Roland Schneider",
"author_id": 16515,
"author_profile": "https://Stackoverflow.com/users/16515",
"pm_score": 0,
"selected": false,
"text": "import java.text.DateFormat;\nimport java.text.ParseException;\nimport java.text.SimpleDateFormat;\n\npublic class TimeZoneExtracter {\n\n public static final void main(String[] args) throws ParseException {\n DateFormat dbFormatter = new SimpleDateFormat(\"EEEE, MMMM dd, yyyy hh:mm aa zzzz\");\n System.out.println(dbFormatter.getTimeZone());\n dbFormatter.parse(\"Fr, September 26, 2008 8:30 PM Eastern Daylight Time\");\n System.out.println(dbFormatter.getTimeZone());\n }\n\n}\n"
},
{
"answer_id": 86303,
"author": "matt b",
"author_id": 4249,
"author_profile": "https://Stackoverflow.com/users/4249",
"pm_score": 1,
"selected": false,
"text": "String testString = \"Friday, September 26, 2008 8:30 PM Pacific Standard Time\";\nDateFormat df = new SimpleDateFormat(\"EEEE, MMMM dd, yyyy hh:mm aa zzzz\");\n\nSystem.out.println(\"The default TimeZone is: \" + TimeZone.getDefault().getDisplayName());\n\nSystem.out.println(\"DateFormat timezone before parse: \" + df.getTimeZone().getDisplayName());\n\nDate date = df.parse(testString);\n\nSystem.out.println(\"Parsed [\" + testString + \"] to Date: \" + date);\n\nSystem.out.println(\"DateFormat timezone after parse: \" + df.getTimeZone().getDisplayName());\n DateFormat.getTimeZone() parse() setTimeZone() parse() getTimeZone()"
},
{
"answer_id": 86411,
"author": "Mike Pone",
"author_id": 16404,
"author_profile": "https://Stackoverflow.com/users/16404",
"pm_score": 0,
"selected": false,
"text": " String rawDate = \"Friday, September 26, 2008 8:30 PM Eastern Daylight Time\";\n DateFormat dbFormatter = new SimpleDateFormat(\"EEEE, MMMM dd, yyyy hh:mm aa zzzz\");\n Date scheduledDate = dbFormatter.parse(rawDate);\n\n System.out.println(rawDate); \n System.out.println(scheduledDate); \n System.out.println(dbFormatter.getTimeZone().getDisplayName());\n Friday, September 26, 2008 8:30 PM Eastern Daylight Time\nFri Sep 26 20:30:00 CDT 2008\nEastern Standard Time\n"
},
{
"answer_id": 40254182,
"author": "Basil Bourque",
"author_id": 642706,
"author_profile": "https://Stackoverflow.com/users/642706",
"pm_score": 1,
"selected": false,
"text": "ZonedDateTime.parse( \n \"Friday, September 26, 2008 8:30 PM Eastern Daylight Time\" , \n DateTimeFormatter.ofPattern( \"EEEE, MMMM d, uuuu h:m a zzzz\" ) \n).getZone()\n DateTimeFormatter DateTimeFormatter f = DateTimeFormatter.ofPattern( \"EEEE, MMMM d, uuuu h:m a zzzz\" );\n Locale f = f.withLocale( Locale.US );\n ZonedDateTime String input = \"Friday, September 26, 2008 8:30 PM Eastern Daylight Time\" ;\nZonedDateTime zdt = ZonedDateTime.parse( input , f );\n ZonedDateTime ZoneId ZoneId ZoneId z = zdt.getZone();\n Eastern Daylight Time continent/region America/Montreal Africa/Casablanca Pacific/Auckland EST IST java.util.Date Calendar SimpleDateFormat Interval YearWeek YearQuarter"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4249/"
] |
85,702
|
<p>I want to have a "select-only" <code>ComboBox</code> that provides a list of items for the user to select from. Typing should be disabled in the text portion of the <code>ComboBox</code> control.</p>
<p>My initial googling of this turned up an overly complex, misguided suggestion to capture the <code>KeyPress</code> event.</p>
|
[
{
"answer_id": 85706,
"author": "Cory Engebretson",
"author_id": 3406,
"author_profile": "https://Stackoverflow.com/users/3406",
"pm_score": 10,
"selected": true,
"text": "stateComboBox.DropDownStyle = ComboBoxStyle.DropDownList;\n"
},
{
"answer_id": 26005210,
"author": "invertigo",
"author_id": 1241244,
"author_profile": "https://Stackoverflow.com/users/1241244",
"pm_score": 6,
"selected": false,
"text": "DropDownStyle InitializeComponent() this.comboBoxBatch.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\n"
},
{
"answer_id": 35766958,
"author": "Abhishek Jaiswal",
"author_id": 5275530,
"author_profile": "https://Stackoverflow.com/users/5275530",
"pm_score": 2,
"selected": false,
"text": "COMBOBOXID.DropDownStyle = ComboBoxStyle.DropDownList;\n"
},
{
"answer_id": 41678049,
"author": "Diogo Rodrigues",
"author_id": 3952930,
"author_profile": "https://Stackoverflow.com/users/3952930",
"pm_score": 1,
"selected": false,
"text": "VB.NET\nPrivate Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress\n e.Handled = True\nEnd Sub\n\n\n\nC#\nPrivate void ComboBox1_KeyPress(object sender, KeyPressEventArgs e)\n{\n e.Handled = true;\n}\n"
},
{
"answer_id": 71539504,
"author": "lava",
"author_id": 7706354,
"author_profile": "https://Stackoverflow.com/users/7706354",
"pm_score": 2,
"selected": false,
"text": "cmb_type.DropDownStyle=ComboBoxStyle.DropDownList\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3406/"
] |
85,724
|
<p>I've got an Active Directory synchronization tool (.NET 2.0 / C#) written as a Windows Service that I've been working on for a while and have recently been tasked with adding the ability to drive events based on changes in group membership. The basic scenario is that users are synchronized with a security database and, when group membership changes, the users need to have their access rights changed (ie. if I am now a member of "IT Staff" then I should automatically receive access to the server room, if I am removed from that group then I should automatically lose access to the server room).</p>
<p>The problem is that when doing a DirectorySynchronization against groups you receive back the group that has had a member added/removed, and from there when you grab the members list you get back the list of all members in that group currently not just the members that have been added or removed. This leads me to quite an efficiency problem - that being that in order to know if a user has been added or removed I will have to keep locally a list of each group and all members and compare that against the current list to see who has been added (not in local list), and who has been deleted (in local list, not in current members list). </p>
<p>I'm debating just storing the group membership details in a DataSet in memory and writing to disk each time I've processed new membership changes. That way if the service stops/crashes or the machine is rebooted I can still get to the current state of the Active Directory within the security database by comparing the last information on disk to that from the current group membership list. However, this seems terrible inefficient - running through every member in the group to compare against what is in the dataset and then writing out changes to disk each time there are changes to the list.</p>
<p>Has anyone dealt with this scenario before? Is there some way that I haven't found to retrieve only a delta of group members? What would you do in this situation to ensure that you never miss any changes while taking the smallest performance hit possible?</p>
<p><strong>Edit:</strong> The AD might contain 500 users, it might contain 200,000 users - it depends on the customer, and on top of that how many groups the average user is a member of</p>
|
[
{
"answer_id": 86141,
"author": "Claus Thomsen",
"author_id": 15555,
"author_profile": "https://Stackoverflow.com/users/15555",
"pm_score": 2,
"selected": false,
"text": " EventLog myLog = new EventLog(\"Security\");\n\n // set event handler\n myLog.EntryWritten += new EntryWrittenEventHandler(OnEntryWritten);\n myLog.EnableRaisingEvents = true;\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85724",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12063/"
] |
85,726
|
<p>Is it possible to convert floating point exceptions (signals) into C++ exceptions on x86 Linux?</p>
<p>This is for debugging purposes, so nonportability and imperfection is okay (e.g., if it isn't 100% guaranteed that all destructors are called).</p>
|
[
{
"answer_id": 88829,
"author": "jwfearn",
"author_id": 10559,
"author_profile": "https://Stackoverflow.com/users/10559",
"pm_score": 3,
"selected": false,
"text": "fetestexcept feraiseexcept feclearexcept"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16480/"
] |
85,761
|
<p>I have an external variable coming in as a string and I would like to do a switch/case on it. How do I do that in xquery?</p>
|
[
{
"answer_id": 85780,
"author": "Sixty4Bit",
"author_id": 1681,
"author_profile": "https://Stackoverflow.com/users/1681",
"pm_score": 2,
"selected": false,
"text": "let $str := \"kitchen\"\nlet $room := element {$str} {}\n return typeswitch($room)\n case element(bathroom) return \"loo\"\n case element(kitchen) return \"scullery\"\n default return \"just a room\"\n"
},
{
"answer_id": 171837,
"author": "Oliver Hallam",
"author_id": 19995,
"author_profile": "https://Stackoverflow.com/users/19995",
"pm_score": 2,
"selected": false,
"text": "if ($room eq \"bathroom\") then \"loo\"\nelse if ($room eq \"kitchen\") then \"scullery\"\nelse \"just a room\"\n"
},
{
"answer_id": 2083615,
"author": "Rafal Rusin",
"author_id": 252891,
"author_profile": "https://Stackoverflow.com/users/252891",
"pm_score": 1,
"selected": false,
"text": "declare function a:fn($i) {\ntypeswitch ($i)\n case element(a:elemen1, xs:untyped) return 'a' \n case element(a:elemen2, xs:untyped) return 'b' \n default return \"error;\"\n};\n"
},
{
"answer_id": 2262130,
"author": "Oliver Hallam",
"author_id": 19995,
"author_profile": "https://Stackoverflow.com/users/19995",
"pm_score": 2,
"selected": false,
"text": "switch ($room) \n case \"bathroom\" return \"loo\"\n case \"kitchen\" return \"scullery\"\n default return \"just a room\"\n"
},
{
"answer_id": 2767036,
"author": "jonathan robie",
"author_id": 332581,
"author_profile": "https://Stackoverflow.com/users/332581",
"pm_score": 6,
"selected": true,
"text": "switch ($animal) \n case \"Cow\" return \"Moo\"\n case \"Cat\" return \"Meow\"\n case \"Duck\" return \"Quack\"\n default return \"What's that odd noise?\" \n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85761",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1681/"
] |
85,770
|
<p>here is the input i am getting from my flash file </p>
<p>process.php?Q2=898&Aa=Grade1&Tim=0%3A0%3A12&Q1=908&Bb=lkj&Q4=jhj&Q3=08&Cc=North%20America&Q0=1</p>
<p>and in php i use this code
foreach ($_GET as $field => $label)
{
$datarray[]=$_GET[$field];</p>
<pre><code>echo "$field :";
echo $_GET[$field];;
echo "<br>";
</code></pre>
<p>i get this out put</p>
<p>Q2 :898
Aa :Grade1
Tim :0:0:12
Q1 :908
Bb :lkj
Q4 :jhj
Q3 :08
Cc :North America
Q0 :1</p>
<p>now my question is how do i sort it alphabaticaly so it should look like this
Aa :Grade1
Bb :lkj
Cc :North America
Q0 :1
Q1 :908</p>
<p>and so on....before i can insert it into the DB</p>
|
[
{
"answer_id": 85792,
"author": "terminus",
"author_id": 9232,
"author_profile": "https://Stackoverflow.com/users/9232",
"pm_score": 4,
"selected": true,
"text": "ksort($_GET);\n $_GET"
},
{
"answer_id": 85841,
"author": "micahwittman",
"author_id": 11181,
"author_profile": "https://Stackoverflow.com/users/11181",
"pm_score": 0,
"selected": false,
"text": "function knatsort(&$karr){\n $kkeyarr = array_keys($karr);\n natsort($kkeyarr);\n $ksortedarr = array();\n foreach($kkeyarr as $kcurrkey){\n $ksortedarr[$kcurrkey] = $karr[$kcurrkey];\n }\n $karr = $ksortedarr;\n return true;\n}\n foreach ($_GET as $key => $value) {\n echo $key.' - '.$value.'<br/>';\n}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16458/"
] |
85,773
|
<p>My source code needs to support both .NET version 1.1 and 2.0 ... how do I test for the different versions & what is the best way to deal with this situation.</p>
<p>I'm wondering if I should have the two sections of code inline, in separate classes, methods etc. What do you think?</p>
|
[
{
"answer_id": 85902,
"author": "Scott Dorman",
"author_id": 1559,
"author_profile": "https://Stackoverflow.com/users/1559",
"pm_score": 2,
"selected": true,
"text": "#if NET11\n// .NET 1.1 code\n#elif NET20\n// .NET 2.0 code\n#endif\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4491/"
] |
85,804
|
<p>Is there a better way to forcefully disconnect all users from an Oracle 10g database schema than restarting the Oracle database services?</p>
<p>We have several developers using SQL Developer connecting to the same schema on a single Oracle 10g server. The problem is that when we want to drop the schema to rebuild it, inevitably someone is still connected and we cannot drop the database schema or the user while someone is still connected.</p>
<p>By the same token, we do not want to drop all connections to other schemas because other people may still be connected and testing with those schemas.</p>
<p>Anyone know of a quick way to resolve this?</p>
|
[
{
"answer_id": 86739,
"author": "Sten Vesterli",
"author_id": 9363,
"author_profile": "https://Stackoverflow.com/users/9363",
"pm_score": 8,
"selected": true,
"text": "select sid,serial# from v$session where username = '<your_schema>' and program = 'SQL Developer' os_user alter system kill session '<sid>,<serial#>' alter system kill session '39,1232' select 'alter system kill session ''' || sid || ',' || serial# || ''';' from v$session where username = '<your_schema>' alter system kill session '375,64855'; alter system kill session '346,53146';"
},
{
"answer_id": 9417191,
"author": "LinuxQuestions.org",
"author_id": 1213280,
"author_profile": "https://Stackoverflow.com/users/1213280",
"pm_score": 0,
"selected": false,
"text": "disconnect; \n\nconn tiger/scott as sysdba;\n"
},
{
"answer_id": 16643855,
"author": "Chand Priyankara",
"author_id": 251491,
"author_profile": "https://Stackoverflow.com/users/251491",
"pm_score": 4,
"selected": false,
"text": "SELECT s.inst_id,\n s.sid,\n s.serial#,\n p.spid,\n s.username,\n s.program\nFROM gv$session s\n JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id\nWHERE s.type != 'BACKGROUND';\n ALTER SYSTEM KILL SESSION '<put above s.sid here>,<put above s.serial# here>';\n"
},
{
"answer_id": 20495895,
"author": "RLapinski",
"author_id": 1948391,
"author_profile": "https://Stackoverflow.com/users/1948391",
"pm_score": 3,
"selected": false,
"text": "DECLARE\n lc_username VARCHAR2 (32) := 'user-name-to-kill-here';\nBEGIN\n FOR ln_cur IN (SELECT sid, serial# FROM v$session WHERE username = lc_username)\n LOOP\n EXECUTE IMMEDIATE ('ALTER SYSTEM KILL SESSION ''' || ln_cur.sid || ',' || ln_cur.serial# || ''' IMMEDIATE');\n END LOOP;\nEND;\n/\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85804",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15766/"
] |
85,815
|
<p>How do you tell if a function in JavaScript is defined?</p>
<p>I want to do something like this</p>
<pre><code>function something_cool(text, callback) {
alert(text);
if( callback != null ) callback();
}
</code></pre>
<p>But it gets me a</p>
<blockquote>
<p>callback is not a function</p>
</blockquote>
<p>error when callback is not defined.</p>
|
[
{
"answer_id": 85822,
"author": "Tom Ritter",
"author_id": 8435,
"author_profile": "https://Stackoverflow.com/users/8435",
"pm_score": 10,
"selected": true,
"text": "typeof callback === \"function\"\n"
},
{
"answer_id": 85825,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 3,
"selected": false,
"text": "if (typeof(callback) == 'function')\n"
},
{
"answer_id": 85838,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "typeof(callback) == \"function\"\n"
},
{
"answer_id": 85849,
"author": "Brian",
"author_id": 16457,
"author_profile": "https://Stackoverflow.com/users/16457",
"pm_score": 2,
"selected": false,
"text": "if (!(typeof(callback)=='undefined')) {...}\n"
},
{
"answer_id": 85899,
"author": "ConroyP",
"author_id": 2287,
"author_profile": "https://Stackoverflow.com/users/2287",
"pm_score": 2,
"selected": false,
"text": "function something_cool(text, callback){\n alert(text);\n if(typeof(callback)=='function'){ \n callback(); \n };\n}\n"
},
{
"answer_id": 85946,
"author": "Robin like the bird",
"author_id": 14405,
"author_profile": "https://Stackoverflow.com/users/14405",
"pm_score": 4,
"selected": false,
"text": "if (callback && typeof(callback) == \"function\")\n false undefined null 0 false null"
},
{
"answer_id": 85973,
"author": "Jason Bunting",
"author_id": 1790,
"author_profile": "https://Stackoverflow.com/users/1790",
"pm_score": 8,
"selected": false,
"text": "function isFunction(possibleFunction) {\n return typeof(possibleFunction) === typeof(Function);\n}\n typeof"
},
{
"answer_id": 88475,
"author": "Andrew Hedges",
"author_id": 11577,
"author_profile": "https://Stackoverflow.com/users/11577",
"pm_score": 2,
"selected": false,
"text": "if ('function' === typeof callback) ...\n"
},
{
"answer_id": 3762574,
"author": "patriciorocca",
"author_id": 427890,
"author_profile": "https://Stackoverflow.com/users/427890",
"pm_score": 3,
"selected": false,
"text": "function isFunctionDefined(functionName) {\n if(eval(\"typeof(\" + functionName + \") == typeof(Function)\")) {\n return true;\n }\n}\n\nif (isFunctionDefined('myFunction')) {\n myFunction(foo);\n}\n"
},
{
"answer_id": 10524738,
"author": "eWolf",
"author_id": 96603,
"author_profile": "https://Stackoverflow.com/users/96603",
"pm_score": 2,
"selected": false,
"text": "callback instanceof Function\n"
},
{
"answer_id": 23370622,
"author": "Russell Ormes",
"author_id": 2969567,
"author_profile": "https://Stackoverflow.com/users/2969567",
"pm_score": 3,
"selected": false,
"text": "function isFunction(possibleFunction) {\n return (typeof(possibleFunction) == typeof(Function));\n}\n ReferenceError: possibleFunction is not defined var possibleFunction = possibleFunction || {};\nif (!isFunction(possibleFunction)) return false;\n"
},
{
"answer_id": 28120634,
"author": "Quentin Engles",
"author_id": 1451600,
"author_profile": "https://Stackoverflow.com/users/1451600",
"pm_score": 3,
"selected": false,
"text": "try{\n callback();\n}catch(e){};\n finally"
},
{
"answer_id": 28202317,
"author": "Sudheer Aedama",
"author_id": 1332911,
"author_profile": "https://Stackoverflow.com/users/1332911",
"pm_score": 1,
"selected": false,
"text": "_.isFunction(callback);\n"
},
{
"answer_id": 30647198,
"author": "miguelmpn",
"author_id": 2641352,
"author_profile": "https://Stackoverflow.com/users/2641352",
"pm_score": 1,
"selected": false,
"text": "if(typeof jQuery.fn.datepicker !== \"undefined\")\n"
},
{
"answer_id": 34863212,
"author": "Samir Alajmovic",
"author_id": 1645369,
"author_profile": "https://Stackoverflow.com/users/1645369",
"pm_score": -1,
"selected": false,
"text": "function something_cool(text, callback){\n callback && callback();\n}\n"
},
{
"answer_id": 36669851,
"author": "VentyCZ",
"author_id": 2178127,
"author_profile": "https://Stackoverflow.com/users/2178127",
"pm_score": 2,
"selected": false,
"text": "_.isFunction = function(obj) {\n return typeof obj == 'function' || false;\n};\n"
},
{
"answer_id": 46743214,
"author": "Nick Tsai",
"author_id": 4767939,
"author_profile": "https://Stackoverflow.com/users/4767939",
"pm_score": 1,
"selected": false,
"text": "callback() callback = (typeof callback === \"function\") ? callback : function(){};\n function something_cool(text, callback) {\n // Initialize arguments\n callback = (typeof callback === \"function\") ? callback : function(){};\n\n alert(text);\n\n if (text==='waitAnotherAJAX') {\n anotherAJAX(callback);\n } else {\n callback();\n }\n}\n"
},
{
"answer_id": 46743451,
"author": "inf3rno",
"author_id": 607033,
"author_profile": "https://Stackoverflow.com/users/607033",
"pm_score": 0,
"selected": false,
"text": "eval var global = (function (){\n return this;\n})();\n\nif (typeof(global.f) != \"function\")\n global.f = function f1_shim (){\n // commonly used by polyfill libs\n };\n global.f instanceof Function Function typeof typeof f alert if (typeof(f) == \"function\")\n if (global.f === f)\n console.log(\"f is a global function\");\n else\n console.log(\"f is a local function\");\n function something_cool(text, callback) {\n alert(text);\n if( callback != null ) callback();\n}\n callback !== undefined callback != null"
},
{
"answer_id": 48353446,
"author": "TexWiller",
"author_id": 457043,
"author_profile": "https://Stackoverflow.com/users/457043",
"pm_score": 0,
"selected": false,
"text": "function myFunction() {\n var x=1;\n } //direct way\n if( (typeof window.myFunction)=='function')\n alert('myFunction is function')\n else\n alert('myFunction is not defined'); //byString\n var strFunctionName='myFunction'\n if( (typeof window[strFunctionName])=='function')\n alert(s+' is function');\n else\n alert(s+' is not defined');"
},
{
"answer_id": 57274441,
"author": "David Spector",
"author_id": 2184308,
"author_profile": "https://Stackoverflow.com/users/2184308",
"pm_score": 0,
"selected": false,
"text": "A=function() {...} // first definition\n...\nif (typeof A==='function')\n oldA=A;\nA=function() {...oldA()...} // new definition\n"
},
{
"answer_id": 57876373,
"author": "Patrick Ogbuitepu",
"author_id": 11969299,
"author_profile": "https://Stackoverflow.com/users/11969299",
"pm_score": 0,
"selected": false,
"text": "if( cb && typeof( eval( cb ) ) === \"function\" ){\n eval( cb + \"()\" );\n}\n"
},
{
"answer_id": 68829303,
"author": "Michel Casabianca",
"author_id": 1294047,
"author_profile": "https://Stackoverflow.com/users/1294047",
"pm_score": -1,
"selected": false,
"text": "function isFunction(name) {\n return eval(`typeof ${name} === typeof Function`);\n}\n"
},
{
"answer_id": 71755388,
"author": "Darren G",
"author_id": 10302934,
"author_profile": "https://Stackoverflow.com/users/10302934",
"pm_score": 2,
"selected": false,
"text": "function something_cool(text, callback) {\n alert(text);\n callback?.();\n}\n callback callback null undefined callback"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8351/"
] |
85,816
|
<p>I've got just one page that I want to force to be accessed as an HTTPS page (PHP on Apache). How do I do this without making the whole directory require HTTPS? Or, if you submit a form to an HTTPS page from an HTTP page, does it send it by HTTPS instead of HTTP?</p>
<p>Here is my example:</p>
<pre><code>http://www.example.com/some-page.php
</code></pre>
<p>I want it to only be accessed through:</p>
<pre><code>https://www.example.com/some-page.php
</code></pre>
<p>Sure, I can put all of the links to this page pointed at the HTTPS version, but that doesn't stop some fool from accessing it through HTTP on purpose...</p>
<p>One thing I thought was putting a redirect in the header of the PHP file to check to be sure that they are accessing the HTTPS version:</p>
<pre><code>if($_SERVER["SCRIPT_URI"] == "http://www.example.com/some-page.php"){
header('Location: https://www.example.com/some-page.php');
}
</code></pre>
<p>But that can't be the right way, can it?</p>
|
[
{
"answer_id": 85835,
"author": "thebigjc",
"author_id": 16507,
"author_profile": "https://Stackoverflow.com/users/16507",
"pm_score": 6,
"selected": false,
"text": "<Location /buyCrap.php>\nRewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}\n</Location>\n"
},
{
"answer_id": 85846,
"author": "DGM",
"author_id": 14253,
"author_profile": "https://Stackoverflow.com/users/14253",
"pm_score": 2,
"selected": false,
"text": "$_SERVER['HTTPS']"
},
{
"answer_id": 4520249,
"author": "Jeff",
"author_id": 552545,
"author_profile": "https://Stackoverflow.com/users/552545",
"pm_score": 3,
"selected": false,
"text": "// Force HTTPS for security\nif($_SERVER[\"HTTPS\"] != \"on\") {\n $pageURL = \"Location: https://\";\n if ($_SERVER[\"SERVER_PORT\"] != \"80\") {\n $pageURL .= $_SERVER[\"SERVER_NAME\"] . \":\" . $_SERVER[\"SERVER_PORT\"] . $_SERVER[\"REQUEST_URI\"];\n } else {\n $pageURL .= $_SERVER[\"SERVER_NAME\"] . $_SERVER[\"REQUEST_URI\"];\n }\n header($pageURL);\n}\n"
},
{
"answer_id": 12145293,
"author": "Jacob Swartwood",
"author_id": 777919,
"author_profile": "https://Stackoverflow.com/users/777919",
"pm_score": 5,
"selected": false,
"text": "// Use HTTP Strict Transport Security to force client to use secure connections only\n$use_sts = true;\n\n// iis sets HTTPS to 'off' for non-SSL requests\nif ($use_sts && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {\n header('Strict-Transport-Security: max-age=31536000');\n} elseif ($use_sts) {\n header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], true, 301);\n // we are in cleartext at the moment, prevent further execution and output\n die();\n}\n"
},
{
"answer_id": 14072023,
"author": "itsazzad",
"author_id": 540144,
"author_profile": "https://Stackoverflow.com/users/540144",
"pm_score": 3,
"selected": false,
"text": "RewriteEngine On \nRewriteCond %{SERVER_PORT} 80 \nRewriteRule ^(.*)$ https://www.example.com/$1 [R,L]\n RewriteEngine On \nRewriteCond %{SERVER_PORT} 80 \nRewriteCond %{REQUEST_URI} somefolder \nRewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]\n"
},
{
"answer_id": 26090961,
"author": "Spell",
"author_id": 3774510,
"author_profile": "https://Stackoverflow.com/users/3774510",
"pm_score": -1,
"selected": false,
"text": "<?php \n// Require https\nif ($_SERVER['HTTPS'] != \"on\") {\n $url = \"https://\". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];\n header(\"Location: $url\");\n exit;\n}\n?>\n"
},
{
"answer_id": 27556415,
"author": "syvex",
"author_id": 766172,
"author_profile": "https://Stackoverflow.com/users/766172",
"pm_score": 3,
"selected": false,
"text": "function isSecure() {\n return (\n (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')\n || $_SERVER['SERVER_PORT'] == 443\n || (\n (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')\n || (!empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on')\n )\n );\n}\n\nfunction requireHTTPS() {\n if (!isSecure()) {\n header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], TRUE, 301);\n exit;\n }\n}\n"
},
{
"answer_id": 30655191,
"author": "JSG",
"author_id": 1642731,
"author_profile": "https://Stackoverflow.com/users/1642731",
"pm_score": 3,
"selected": false,
"text": "RewriteEngine On\nRewriteCond %{SERVER_PORT} 80\nRewriteRule ^(.*)$ https://example.com/$1 [R,L]\n if(empty($_SERVER[\"HTTPS\"])){ // SOMETHING IS FISHY\n}\n\nif(strstr($_SERVER['HTTP_HOST'],\"mywebsite.com\") === FALSE){// Something is FISHY\n}\n if($_SERVER[\"HTTPS\"] !== \"on\"){// Something is fishy\n}\n HOST_URI HTTP_USER_AGENT"
},
{
"answer_id": 31000510,
"author": "MatHatrik",
"author_id": 4614534,
"author_profile": "https://Stackoverflow.com/users/4614534",
"pm_score": 4,
"selected": false,
"text": "RewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}\n"
},
{
"answer_id": 38579223,
"author": "Esteban Gallego",
"author_id": 4545688,
"author_profile": "https://Stackoverflow.com/users/4545688",
"pm_score": -1,
"selected": false,
"text": "if(empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == \"off\"){\n $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];\n enter code hereheader('HTTP/1.1 301 Moved Permanently');\n header('Location: ' . $redirect);\n exit();\n}\n"
},
{
"answer_id": 38741015,
"author": "Antonio",
"author_id": 6090211,
"author_profile": "https://Stackoverflow.com/users/6090211",
"pm_score": 1,
"selected": false,
"text": "RewriteEngine On\nRewriteCond %{HTTPS} off\nRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n"
},
{
"answer_id": 38997081,
"author": "bourax webmaster",
"author_id": 2923903,
"author_profile": "https://Stackoverflow.com/users/2923903",
"pm_score": 1,
"selected": false,
"text": "if($_SERVER[\"HTTPS\"] != \"on\")\n{\n header(\"Location: https://\" . $_SERVER[\"HTTP_HOST\"] . $_SERVER[\"REQUEST_URI\"]);\n exit();\n}\n"
},
{
"answer_id": 39238967,
"author": "Tarik",
"author_id": 5105831,
"author_profile": "https://Stackoverflow.com/users/5105831",
"pm_score": 1,
"selected": false,
"text": "if (stripos(substr($_SERVER[SCRIPT_URI], 0, 5), \"https\") === false) {\n header(\"location:https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]\");\n echo \"<meta http-equiv='refresh' content='0; url=https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]'>\";\n exit;\n}\n"
},
{
"answer_id": 43251052,
"author": "Tschallacka",
"author_id": 1356107,
"author_profile": "https://Stackoverflow.com/users/1356107",
"pm_score": 1,
"selected": false,
"text": "<httpProtocol>\n <customHeaders>\n <add name=\"Strict-Transport-Security\" value=\"max-age=31536000\"/>\n </customHeaders>\n</httpProtocol>\n<rewrite>\n <rules>\n <rule name=\"HTTP to HTTPS redirect\" stopProcessing=\"true\">\n <match url=\"(.*)\" />\n <conditions>\n <add input=\"{HTTPS}\" pattern=\"off\" ignoreCase=\"true\" />\n </conditions>\n <action type=\"Redirect\" redirectType=\"Found\" url=\"https://{HTTP_HOST}/{R:1}\" />\n </rule>\n </rules>\n</rewrite>\n <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration>\n <system.webServer>\n <httpProtocol>\n <customHeaders>\n <add name=\"Strict-Transport-Security\" value=\"max-age=31536000\"/>\n </customHeaders>\n </httpProtocol>\n <rewrite>\n <rules>\n <rule name=\"HTTP to HTTPS redirect\" stopProcessing=\"true\">\n <match url=\"(.*)\" />\n <conditions>\n <add input=\"{HTTPS}\" pattern=\"off\" ignoreCase=\"true\" />\n </conditions>\n <action type=\"Redirect\" redirectType=\"Found\" url=\"https://{HTTP_HOST}/{R:1}\" />\n </rule>\n </rules>\n </rewrite>\n </system.webServer>\n</configuration>\n"
},
{
"answer_id": 49874887,
"author": "Héouais Mongars",
"author_id": 9575477,
"author_profile": "https://Stackoverflow.com/users/9575477",
"pm_score": 0,
"selected": false,
"text": "$protocol = $_SERVER[\"HTTP_CF_VISITOR\"];\n\nif (!strstr($protocol, 'https')){\n header(\"Location: https://\" . $_SERVER[\"HTTP_HOST\"] . $_SERVER[\"REQUEST_URI\"]);\n exit();\n}\n"
},
{
"answer_id": 53017189,
"author": "Jay",
"author_id": 9492841,
"author_profile": "https://Stackoverflow.com/users/9492841",
"pm_score": 3,
"selected": false,
"text": "$is_https=false;\nif (isset($_SERVER['HTTPS'])) $is_https=$_SERVER['HTTPS'];\nif ($is_https !== \"on\")\n{\n header(\"Location: https://\".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);\n exit(1);\n}\n RewriteCond %{HTTPS} !=on\nRewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n"
},
{
"answer_id": 62680152,
"author": "squiremaldoon",
"author_id": 13735231,
"author_profile": "https://Stackoverflow.com/users/13735231",
"pm_score": 2,
"selected": false,
"text": "\n<?php\n\nif(!isset($_SERVER[\"HTTPS\"]) || $_SERVER[\"HTTPS\"] != \"on\") {\n header(\"Location: https://\" . $_SERVER[\"HTTP_HOST\"] . $_SERVER[\"REQUEST_URI\"], true, 301);\n //Prevent the rest of the script from executing.\n exit;\n}\n?>\n\n"
},
{
"answer_id": 65564968,
"author": "Sumithran",
"author_id": 6562458,
"author_profile": "https://Stackoverflow.com/users/6562458",
"pm_score": 1,
"selected": false,
"text": "X-Forwarded-Proto ### Force HTTPS\nRewriteCond %{HTTP:X-Forwarded-Proto} !https\nRewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]\n"
},
{
"answer_id": 68150501,
"author": "MRRaja",
"author_id": 2357497,
"author_profile": "https://Stackoverflow.com/users/2357497",
"pm_score": 1,
"selected": false,
"text": "if(location.protocol!=='https:'){location.replace(`https:${location.href.substring(location.protocol.length)}`);}\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
85,880
|
<p>Currently I'm doing some unit tests which are executed from bash. Unit tests are initialized, executed and cleaned up in a bash script. This script usualy contains an init(), execute() and cleanup() functions. But they are not mandatory. I'd like to test if they are or are not defined.</p>
<p>I did this previously by greping and seding the source, but it seemed wrong. Is there a more elegant way to do this?</p>
<p>Edit: The following sniplet works like a charm:</p>
<pre><code>fn_exists()
{
LC_ALL=C type $1 | grep -q 'shell function'
}
</code></pre>
|
[
{
"answer_id": 85903,
"author": "JBB",
"author_id": 12332,
"author_profile": "https://Stackoverflow.com/users/12332",
"pm_score": 9,
"selected": true,
"text": "[[ $(type -t foo) == function ]] && echo \"Foo exists\" type $ LC_ALL=C type foo\nbash: type: foo: not found\n\n$ LC_ALL=C type ls\nls is aliased to `ls --color=auto'\n\n$ which type\n\n$ LC_ALL=C type type\ntype is a shell builtin\n\n$ LC_ALL=C type -t rvm\nfunction\n\n$ if [ -n \"$(LC_ALL=C type -t rvm)\" ] && [ \"$(LC_ALL=C type -t rvm)\" = function ]; then echo rvm is a function; else echo rvm is NOT a function; fi\nrvm is a function\n"
},
{
"answer_id": 85932,
"author": "Allan Wind",
"author_id": 9706,
"author_profile": "https://Stackoverflow.com/users/9706",
"pm_score": 7,
"selected": false,
"text": "declare -F $ fn_exists() { declare -F \"$1\" > /dev/null; }\n\n$ unset f\n$ fn_exists f && echo yes || echo no\nno\n\n$ f() { return; }\n$ fn_exist f && echo yes || echo no\nyes\n"
},
{
"answer_id": 1540824,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "fn_exists()\n{\n type $1 2>/dev/null | grep -q 'is a function'\n}\n fn_exists test_function\nif [ $? -eq 0 ]; then\n echo 'Function exists!'\nelse\n echo 'Function does not exist...'\nfi\n"
},
{
"answer_id": 1540934,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "fn_exists()\n{\n type $1 >/dev/null 2>&1;\n}\n"
},
{
"answer_id": 2253065,
"author": "jonathanserafini",
"author_id": 238290,
"author_profile": "https://Stackoverflow.com/users/238290",
"pm_score": 4,
"selected": false,
"text": "test_declare () {\n a () { echo 'a' ;}\n\n declare -f a > /dev/null\n}\n\ntest_type () {\n a () { echo 'a' ;}\n type a | grep -q 'is a function'\n}\n\necho 'declare'\ntime for i in $(seq 1 1000); do test_declare; done\necho 'type'\ntime for i in $(seq 1 100); do test_type; done\n real 0m0.064s\nuser 0m0.040s\nsys 0m0.020s\ntype\n\nreal 0m2.769s\nuser 0m1.620s\nsys 0m1.130s\n"
},
{
"answer_id": 3121473,
"author": "Noah Spurrier",
"author_id": 319432,
"author_profile": "https://Stackoverflow.com/users/319432",
"pm_score": 0,
"selected": false,
"text": "test_function () {\n ! type -f $1 >/dev/null 2>&1 && type -t $1 >/dev/null 2>&1\n}\n"
},
{
"answer_id": 9002012,
"author": "Grégory Joseph",
"author_id": 302789,
"author_profile": "https://Stackoverflow.com/users/302789",
"pm_score": 4,
"selected": false,
"text": "fn_exists() {\n # appended double quote is an ugly trick to make sure we do get a string -- if $1 is not a known command, type does not output anything\n [ `type -t $1`\"\" == 'function' ]\n}\n if ! fn_exists $FN; then\n echo \"Hey, $FN does not exist ! Duh.\"\n exit 2\nfi\n"
},
{
"answer_id": 9466683,
"author": "b1r3k",
"author_id": 216172,
"author_profile": "https://Stackoverflow.com/users/216172",
"pm_score": 2,
"selected": false,
"text": "function is_executable()\n{\n typeset TYPE_RESULT=\"`type -t $1`\"\n\n if [ \"$TYPE_RESULT\" == 'function' ]; then\n return 0\n else\n return 1\n fi\n}\n"
},
{
"answer_id": 9529981,
"author": "Orwellophile",
"author_id": 912236,
"author_profile": "https://Stackoverflow.com/users/912236",
"pm_score": 6,
"selected": false,
"text": "-f #!/bin/sh\n\nfunction_exists() {\n declare -f -F $1 > /dev/null\n return $?\n}\n\nfunction_exists function_name && echo Exists || echo No such function\n fname=`declare -f -F $1`\n[ -n \"$fname\" ] && echo Declare -f says $fname exists || echo Declare -f says $1 does not exist\n fname=`declare -f -F $1`\nerrorlevel=$?\n(( ! errorlevel )) && echo Errorlevel says $1 exists || echo Errorlevel says $1 does not exist\n[ -n \"$fname\" ] && echo Declare -f says $fname exists || echo Declare -f says $1 does not exist\n"
},
{
"answer_id": 10788804,
"author": "Scott",
"author_id": 1422241,
"author_profile": "https://Stackoverflow.com/users/1422241",
"pm_score": 3,
"selected": false,
"text": "isFunction() { [[ \"$(declare -Ff \"$1\")\" ]]; }\n isFunction some_name && echo yes || echo no\n isFunction() { declare -Ff \"$1\" >/dev/null; }\n"
},
{
"answer_id": 35117169,
"author": "Yunus",
"author_id": 3746411,
"author_profile": "https://Stackoverflow.com/users/3746411",
"pm_score": 2,
"selected": false,
"text": "fn_exists()\n{\n [[ $(type -t $1) == function ]] && return 0\n}\n isFunc () \n{ \n [[ $(type -t $1) == function ]]\n}\n\n$ isFunc isFunc\n$ echo $?\n0\n$ isFunc dfgjhgljhk\n$ echo $?\n1\n$ isFunc psgrep && echo yay\nyay\n$\n"
},
{
"answer_id": 40693218,
"author": "jarno",
"author_id": 4414935,
"author_profile": "https://Stackoverflow.com/users/4414935",
"pm_score": 3,
"selected": false,
"text": "#!/bin/bash\n\ntest_declare () {\n declare -f f > /dev/null\n}\n\ntest_declare2 () {\n declare -F f > /dev/null\n}\n\ntest_type () {\n type -t f | grep -q 'function'\n}\n\ntest_type2 () {\n [[ $(type -t f) = function ]]\n}\n\nfuncs=(test_declare test_declare2 test_type test_type2)\n\ntest () {\n for i in $(seq 1 1000); do $1; done\n}\n\nf () {\necho 'This is a test function.'\necho 'This has more than one command.'\nreturn 0\n}\npost='(f is function)'\n\nfor j in 1 2 3; do\n\n for func in ${funcs[@]}; do\n echo $func $post\n time test $func\n echo exit code $?; echo\n done\n\n case $j in\n 1) unset -f f\n post='(f unset)'\n ;;\n 2) f='string'\n post='(f is string)'\n ;;\n esac\ndone\n declare -F f"
},
{
"answer_id": 46691003,
"author": "qneill",
"author_id": 468252,
"author_profile": "https://Stackoverflow.com/users/468252",
"pm_score": 2,
"selected": false,
"text": "$ fn_exists() { test x$(type -t $1) = xfunction; }\n$ fn_exists func1 && echo yes || echo no\nno\n$ func1() { echo hi from func1; }\n$ func1\nhi from func1\n$ fn_exists func1 && echo yes || echo no\nyes\n"
},
{
"answer_id": 66111119,
"author": "it3xl",
"author_id": 390940,
"author_profile": "https://Stackoverflow.com/users/390940",
"pm_score": 2,
"selected": false,
"text": "my_function [[ \"$(type -t my_function)\" == 'function' ]] && my_function;\n# or\n[[ \"$(declare -fF my_function)\" ]] && my_function;\n func=my_function [[ \"$(type -t $func)\" == 'function' ]] && $func;\n# or\n[[ \"$(declare -fF $func)\" ]] && $func;\n || && [[ \"$(type -t my_function)\" != 'function' ]] || my_function;\n[[ ! \"$(declare -fF my_function)\" ]] || my_function;\n\nfunc=my_function\n[[ \"$(type -t $func)\" != 'function' ]] || $func;\n[[ ! \"$(declare -fF $func)\" ]] || $func;\n set -e || return # Set a strict mode for script execution. The essence here is \"-e\"\nset -euf +x -o pipefail\n\nfunction run_if_exists(){\n my_function=$1\n\n [[ \"$(type -t $my_function)\" == 'function' ]] || return;\n\n $my_function\n}\n\nrun_if_exists non_existing_function\necho \"you will never reach this code\"\n set -e\nfunction run_if_exists(){\n return 1;\n}\nrun_if_exists\n || { true; return; } || return; [[ \"$(type -t my_function)\" == 'function' ]] || { true; return; }\n"
},
{
"answer_id": 73969344,
"author": "k_vishwanath",
"author_id": 6341379,
"author_profile": "https://Stackoverflow.com/users/6341379",
"pm_score": 0,
"selected": false,
"text": "fn_exists() { type -t $1 >/dev/null && echo 'exists'; }\nfn_exists() { declare -F $1 >/dev/null && echo 'exists'; }\nfn_exists() { typeset -F $1 >/dev/null && echo 'exists'; }\nfn_exists() { compgen -A function $1 >/dev/null && echo 'exists'; }\n"
}
] |
2008/09/17
|
[
"https://Stackoverflow.com/questions/85880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9232/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.