qid
int64
1
74.7M
question
stringlengths
22
28.7k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
24
26.4k
response_k
stringlengths
25
24.2k
632,181
I've created a custom workflow which creates a task item when the workflow is kicked off. [alt text http://img19.imageshack.us/img19/2862/screenshot310200942100p.png](http://img19.imageshack.us/img19/2862/screenshot310200942100p.png) I've also created a few custom content types for the document library and task list. For the document library: First, I add a document library and configure it to allow custom content types. Then I add my content type, which is based off the document content type. After, I add a workflow under workflow settings. Here, I select my custom workflow, give it a name and tell sharepoint to create a New task list to store the tasks in. For the task list: Now that I have a sharepoint created task list, I go there and allow custom content types and make sure "Send e-mail when ownership is assigned?" is set to Yes. Then I add my two custom content types which are both based off a workflow task content type. Thats all I should do. When I start my workflow, it does add the approval task (I'm using a CreateTaskWithContentType activity which is named createApprovalTask), but no email is sent out for the created task. The code I'm using in the createApprovalTask activity is: ``` // make a new GUID for this task createApprovalTask_TaskId = Guid.NewGuid(); // set simple properties of task createApprovalTask.TaskProperties.AssignedTo = "a valid domain\user"; createApprovalTask.TaskProperties.Title = "Review Contract: " + approvalWorkflowActivated_WorkflowProperties.Item.DisplayName; createApprovalTask.TaskProperties.SendEmailNotification = true; ``` If I create a document library and use one of Sharepoint's built-in workflows (Approval for example), and tell it to create a task list for it, when an item is added to that list, it sends out the email correctly. So, the setting for the outgoing mail server are correct, as we're receiving other emails just fine. I'm using a SendEmail activity right after the createApprovalTask activity to send an email back to the submitter telling them we've received their approval request. The code for that is something similar to: ``` sendApprovalRecievedEmail.Body = emailBody; sendApprovalRecievedEmail.Subject = emailSubject; sendApprovalRecievedEmail.To = emailTo; sendApprovalRecievedEmail.From = emailFrom; ``` This works, so the submitter receives their custom email, but the task owner never receives the task item email.
2009/03/10
[ "https://Stackoverflow.com/questions/632181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34253/" ]
you have to make sharepoint outgoing email settings properly. example is shown in below link <http://sharepoint-amila.blogspot.com/2008/02/outgoin-email-settings.html> if you need to send an email through the c#.net code you can use below method to send emails in custom workflows. SPUtility.SendEmail Method (Microsoft.SharePoint.Utilities) example is shown in below link <http://www.sharepoint-amila.blogspot.com/>
Is it possible to point out a SharePoint user by "domain\user" like you do with createApprovalTask.TaskProperties.AssignedTo? Isnt the ID required? "id;#domain\username"
632,181
I've created a custom workflow which creates a task item when the workflow is kicked off. [alt text http://img19.imageshack.us/img19/2862/screenshot310200942100p.png](http://img19.imageshack.us/img19/2862/screenshot310200942100p.png) I've also created a few custom content types for the document library and task list. For the document library: First, I add a document library and configure it to allow custom content types. Then I add my content type, which is based off the document content type. After, I add a workflow under workflow settings. Here, I select my custom workflow, give it a name and tell sharepoint to create a New task list to store the tasks in. For the task list: Now that I have a sharepoint created task list, I go there and allow custom content types and make sure "Send e-mail when ownership is assigned?" is set to Yes. Then I add my two custom content types which are both based off a workflow task content type. Thats all I should do. When I start my workflow, it does add the approval task (I'm using a CreateTaskWithContentType activity which is named createApprovalTask), but no email is sent out for the created task. The code I'm using in the createApprovalTask activity is: ``` // make a new GUID for this task createApprovalTask_TaskId = Guid.NewGuid(); // set simple properties of task createApprovalTask.TaskProperties.AssignedTo = "a valid domain\user"; createApprovalTask.TaskProperties.Title = "Review Contract: " + approvalWorkflowActivated_WorkflowProperties.Item.DisplayName; createApprovalTask.TaskProperties.SendEmailNotification = true; ``` If I create a document library and use one of Sharepoint's built-in workflows (Approval for example), and tell it to create a task list for it, when an item is added to that list, it sends out the email correctly. So, the setting for the outgoing mail server are correct, as we're receiving other emails just fine. I'm using a SendEmail activity right after the createApprovalTask activity to send an email back to the submitter telling them we've received their approval request. The code for that is something similar to: ``` sendApprovalRecievedEmail.Body = emailBody; sendApprovalRecievedEmail.Subject = emailSubject; sendApprovalRecievedEmail.To = emailTo; sendApprovalRecievedEmail.From = emailFrom; ``` This works, so the submitter receives their custom email, but the task owner never receives the task item email.
2009/03/10
[ "https://Stackoverflow.com/questions/632181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34253/" ]
Unfortunately, our mail servers were blocking the emails for some reason. I wasted a good 2 1/2 days searching around for this problem...and it turns out our IT department didn't have their sh\*t together. Thanks everyone.
Is it possible to point out a SharePoint user by "domain\user" like you do with createApprovalTask.TaskProperties.AssignedTo? Isnt the ID required? "id;#domain\username"
632,181
I've created a custom workflow which creates a task item when the workflow is kicked off. [alt text http://img19.imageshack.us/img19/2862/screenshot310200942100p.png](http://img19.imageshack.us/img19/2862/screenshot310200942100p.png) I've also created a few custom content types for the document library and task list. For the document library: First, I add a document library and configure it to allow custom content types. Then I add my content type, which is based off the document content type. After, I add a workflow under workflow settings. Here, I select my custom workflow, give it a name and tell sharepoint to create a New task list to store the tasks in. For the task list: Now that I have a sharepoint created task list, I go there and allow custom content types and make sure "Send e-mail when ownership is assigned?" is set to Yes. Then I add my two custom content types which are both based off a workflow task content type. Thats all I should do. When I start my workflow, it does add the approval task (I'm using a CreateTaskWithContentType activity which is named createApprovalTask), but no email is sent out for the created task. The code I'm using in the createApprovalTask activity is: ``` // make a new GUID for this task createApprovalTask_TaskId = Guid.NewGuid(); // set simple properties of task createApprovalTask.TaskProperties.AssignedTo = "a valid domain\user"; createApprovalTask.TaskProperties.Title = "Review Contract: " + approvalWorkflowActivated_WorkflowProperties.Item.DisplayName; createApprovalTask.TaskProperties.SendEmailNotification = true; ``` If I create a document library and use one of Sharepoint's built-in workflows (Approval for example), and tell it to create a task list for it, when an item is added to that list, it sends out the email correctly. So, the setting for the outgoing mail server are correct, as we're receiving other emails just fine. I'm using a SendEmail activity right after the createApprovalTask activity to send an email back to the submitter telling them we've received their approval request. The code for that is something similar to: ``` sendApprovalRecievedEmail.Body = emailBody; sendApprovalRecievedEmail.Subject = emailSubject; sendApprovalRecievedEmail.To = emailTo; sendApprovalRecievedEmail.From = emailFrom; ``` This works, so the submitter receives their custom email, but the task owner never receives the task item email.
2009/03/10
[ "https://Stackoverflow.com/questions/632181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34253/" ]
Unfortunately, our mail servers were blocking the emails for some reason. I wasted a good 2 1/2 days searching around for this problem...and it turns out our IT department didn't have their sh\*t together. Thanks everyone.
you have to make sharepoint outgoing email settings properly. example is shown in below link <http://sharepoint-amila.blogspot.com/2008/02/outgoin-email-settings.html> if you need to send an email through the c#.net code you can use below method to send emails in custom workflows. SPUtility.SendEmail Method (Microsoft.SharePoint.Utilities) example is shown in below link <http://www.sharepoint-amila.blogspot.com/>
16,237,561
I have a list of cases containing agencies. All agencies contain tasks which have a status assigned to it. 0 = complete, 1 = ongoing and 2 = overdue. I am trying to show for all cases if there is any tasks overdue. At the moment my query shows the status as 1, even though there are some tasks overdue. SQL FIDDLE HERE <http://sqlfiddle.com/#!2/a4394/3> I don't know what I need to change in order to pull out the correct data. Any ideas? Any help would be greatly appreciated!!
2013/04/26
[ "https://Stackoverflow.com/questions/16237561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2187103/" ]
Your query is right, the problem is that you're getting info from multiple tables but, you don't have enough records in all of them, basically you have IDs on your `cases_agency_association` table up to 6, and the records from your `cases_task_association` table where the `status` is 2, all have IDs greater than 6...
Would not this solve your basic problem: ``` select * from `cases_task_association` where status =2; ``` This is without the joins etc, but the query above is the base for providing all cases that are overdue and not completed.
16,237,561
I have a list of cases containing agencies. All agencies contain tasks which have a status assigned to it. 0 = complete, 1 = ongoing and 2 = overdue. I am trying to show for all cases if there is any tasks overdue. At the moment my query shows the status as 1, even though there are some tasks overdue. SQL FIDDLE HERE <http://sqlfiddle.com/#!2/a4394/3> I don't know what I need to change in order to pull out the correct data. Any ideas? Any help would be greatly appreciated!!
2013/04/26
[ "https://Stackoverflow.com/questions/16237561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2187103/" ]
Ignoring that you're writing a MySQL-only `SELECT`, your joins are wrong; you're joining `cc.case_ID` on `caa.ID` when you actually want `caa.case_ID`: ``` SELECT cc . * , a.ID, MAX(cta.status) AS current_status FROM cases_complete cc, agencies a, cases_agency_association caa, cases_task_association cta WHERE cc.case_ID = caa.case_ID AND caa.agency_ID = a.ID AND cta.agency_association_ID = caa.ID GROUP BY cc.case_ID ``` However @meewoK's approach, and the comment about not abusing `GROUP BY` are both worth thinking through from the point of view of coming up with something clearer, more maintainable, and hopefully more portable / future compatible as well.
Would not this solve your basic problem: ``` select * from `cases_task_association` where status =2; ``` This is without the joins etc, but the query above is the base for providing all cases that are overdue and not completed.
16,237,561
I have a list of cases containing agencies. All agencies contain tasks which have a status assigned to it. 0 = complete, 1 = ongoing and 2 = overdue. I am trying to show for all cases if there is any tasks overdue. At the moment my query shows the status as 1, even though there are some tasks overdue. SQL FIDDLE HERE <http://sqlfiddle.com/#!2/a4394/3> I don't know what I need to change in order to pull out the correct data. Any ideas? Any help would be greatly appreciated!!
2013/04/26
[ "https://Stackoverflow.com/questions/16237561", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2187103/" ]
Ignoring that you're writing a MySQL-only `SELECT`, your joins are wrong; you're joining `cc.case_ID` on `caa.ID` when you actually want `caa.case_ID`: ``` SELECT cc . * , a.ID, MAX(cta.status) AS current_status FROM cases_complete cc, agencies a, cases_agency_association caa, cases_task_association cta WHERE cc.case_ID = caa.case_ID AND caa.agency_ID = a.ID AND cta.agency_association_ID = caa.ID GROUP BY cc.case_ID ``` However @meewoK's approach, and the comment about not abusing `GROUP BY` are both worth thinking through from the point of view of coming up with something clearer, more maintainable, and hopefully more portable / future compatible as well.
Your query is right, the problem is that you're getting info from multiple tables but, you don't have enough records in all of them, basically you have IDs on your `cases_agency_association` table up to 6, and the records from your `cases_task_association` table where the `status` is 2, all have IDs greater than 6...
2,024
> > On the night of 9/10 July, the Western Allies mounted an amphibious > invasion of Sicily. Three days later, Hitler summoned Günther von > Kluge and Erich von Manstein to his Wolfsschanze headquarters in East > Prussia and declared his intention to "temporarily" call off [Operation Zitadelle](https://en.wikipedia.org/wiki/Operation_Citadel). **Von Manstein attempted to dissuade him, arguing that > Zitadelle was on the brink of victory: "on no account should we let go > of the enemy until the mobile reserves which he had committed were > decisively beaten"**. In an unusual reversal of their roles, Hitler gave > von Manstein a few more days to continue the offensive, but on 17 > July, he ordered a withdrawal and canceled the operation. He then > ordered the entire SS Panzer Corps to be transferred to Italy.[87] > > > While Hitler often made notoriously poor judgments for all the wrong reasons, did he make the right decision for Germany (for the wrong reason) in this specific isolated case? Was Zitadelle really on the brink of victory as Von Manstein believed?
2012/05/12
[ "https://history.stackexchange.com/questions/2024", "https://history.stackexchange.com", "https://history.stackexchange.com/users/852/" ]
Hitler was right in this instance. It was Manstein that extended the battle too far. The "official" reason for the offensive, was to recapture the city of Kursk. That was within the reach of the Germans. The REAL purpose of the offensive was to cut off the Russian salient, of which Kursk was the tip. The reason this didn't work was that the Russians concentrated their defense lines at the BASE of salient (south and north of Orel and Belgorod), on either side, instead of concentrating their forces at Kursk, where they could be cut off. What Manstein should have done was to "snap off" Kursk at the tip of the salient, then "declare victory and go home." What he actually did was to WIDEN the front by moving the German forces east to Prokhorovka. This turned the battle from one of decision (which favored the Germans) to one of attrition (which favored the Russians), who could trade their more numerous tanks for German vehicles at a rate of about one to one. This was because Manstein had let the Kursk operation deteriorate from the [1] "set piece battle" to a "meeting engagement" in which Germany had no advantage. So Hitler was right to stop the Kursk operation, with or without regard to what was happening in Italy. [1] <https://english.stackexchange.com/questions/48646/what-is-the-meaning-and-origin-of-set-piece-battle>
The whole operation was doomed from the start because the Allies at Bletchley Park had deciphered the German plans for the attack. The British gave the Russians ample warning time of this, although the Russians already knew about it as they had spies of their own within British intelligence. <http://www.colossus-computer.com/colossus1.html> Given that the Russians had several weeks forewarning, they amassed tanks, guns and soldiers in great number and prepared many layers of defence lines to defeat the German assault. Had the Germans never launched Zitadelle they would have preserved their precious tanks and probably prolonged the war although the end result would have been the same. Hitler made the right decision on this occasion, by calling the operation off, but he should have done so sooner.
2,024
> > On the night of 9/10 July, the Western Allies mounted an amphibious > invasion of Sicily. Three days later, Hitler summoned Günther von > Kluge and Erich von Manstein to his Wolfsschanze headquarters in East > Prussia and declared his intention to "temporarily" call off [Operation Zitadelle](https://en.wikipedia.org/wiki/Operation_Citadel). **Von Manstein attempted to dissuade him, arguing that > Zitadelle was on the brink of victory: "on no account should we let go > of the enemy until the mobile reserves which he had committed were > decisively beaten"**. In an unusual reversal of their roles, Hitler gave > von Manstein a few more days to continue the offensive, but on 17 > July, he ordered a withdrawal and canceled the operation. He then > ordered the entire SS Panzer Corps to be transferred to Italy.[87] > > > While Hitler often made notoriously poor judgments for all the wrong reasons, did he make the right decision for Germany (for the wrong reason) in this specific isolated case? Was Zitadelle really on the brink of victory as Von Manstein believed?
2012/05/12
[ "https://history.stackexchange.com/questions/2024", "https://history.stackexchange.com", "https://history.stackexchange.com/users/852/" ]
Hitler was right in this instance. It was Manstein that extended the battle too far. The "official" reason for the offensive, was to recapture the city of Kursk. That was within the reach of the Germans. The REAL purpose of the offensive was to cut off the Russian salient, of which Kursk was the tip. The reason this didn't work was that the Russians concentrated their defense lines at the BASE of salient (south and north of Orel and Belgorod), on either side, instead of concentrating their forces at Kursk, where they could be cut off. What Manstein should have done was to "snap off" Kursk at the tip of the salient, then "declare victory and go home." What he actually did was to WIDEN the front by moving the German forces east to Prokhorovka. This turned the battle from one of decision (which favored the Germans) to one of attrition (which favored the Russians), who could trade their more numerous tanks for German vehicles at a rate of about one to one. This was because Manstein had let the Kursk operation deteriorate from the [1] "set piece battle" to a "meeting engagement" in which Germany had no advantage. So Hitler was right to stop the Kursk operation, with or without regard to what was happening in Italy. [1] <https://english.stackexchange.com/questions/48646/what-is-the-meaning-and-origin-of-set-piece-battle>
I think he was only partially right and this is because the units transferred were SS units. In the east, the SS fought both its racial and ideological enemies (the Bolshevik Jewry; which was mostly propaganda, but people believed it). There it was in its element, both as regards the savagery of fighting and the atrocities inflicted on the civilian population. In light of later massive surrendering of Germans to the western Allies, but stiff resistance against the Russians, no SS unit should probably ever have been transferred from the East, except for rest and refit.
2,024
> > On the night of 9/10 July, the Western Allies mounted an amphibious > invasion of Sicily. Three days later, Hitler summoned Günther von > Kluge and Erich von Manstein to his Wolfsschanze headquarters in East > Prussia and declared his intention to "temporarily" call off [Operation Zitadelle](https://en.wikipedia.org/wiki/Operation_Citadel). **Von Manstein attempted to dissuade him, arguing that > Zitadelle was on the brink of victory: "on no account should we let go > of the enemy until the mobile reserves which he had committed were > decisively beaten"**. In an unusual reversal of their roles, Hitler gave > von Manstein a few more days to continue the offensive, but on 17 > July, he ordered a withdrawal and canceled the operation. He then > ordered the entire SS Panzer Corps to be transferred to Italy.[87] > > > While Hitler often made notoriously poor judgments for all the wrong reasons, did he make the right decision for Germany (for the wrong reason) in this specific isolated case? Was Zitadelle really on the brink of victory as Von Manstein believed?
2012/05/12
[ "https://history.stackexchange.com/questions/2024", "https://history.stackexchange.com", "https://history.stackexchange.com/users/852/" ]
Hitler was right in this instance. It was Manstein that extended the battle too far. The "official" reason for the offensive, was to recapture the city of Kursk. That was within the reach of the Germans. The REAL purpose of the offensive was to cut off the Russian salient, of which Kursk was the tip. The reason this didn't work was that the Russians concentrated their defense lines at the BASE of salient (south and north of Orel and Belgorod), on either side, instead of concentrating their forces at Kursk, where they could be cut off. What Manstein should have done was to "snap off" Kursk at the tip of the salient, then "declare victory and go home." What he actually did was to WIDEN the front by moving the German forces east to Prokhorovka. This turned the battle from one of decision (which favored the Germans) to one of attrition (which favored the Russians), who could trade their more numerous tanks for German vehicles at a rate of about one to one. This was because Manstein had let the Kursk operation deteriorate from the [1] "set piece battle" to a "meeting engagement" in which Germany had no advantage. So Hitler was right to stop the Kursk operation, with or without regard to what was happening in Italy. [1] <https://english.stackexchange.com/questions/48646/what-is-the-meaning-and-origin-of-set-piece-battle>
I believe that the underlying intention of the High command was never to close the kursk salient with 2 pincers. This has been lauded as gospel for ages and ages and stands in the way of Mansteins thinking. I believe that the Soviet High command make a key strategic error when they positioned the bulk of their armour too close to the Northern pincer. The Northern "Pincer" was not the main pincer, in fact it's firepower was more defensive in charachter with all Ferdinands placed there and the defensive Hagen position available to fall back to which they did in good order. (Model had soaked up significant attacks at the Meat grinder of Rshev with the 9th army and the expectation was that he was to do it again) So essentially one sees what actually occurred in the Invasion of France in 1940 with a sickle through the ardennes now being the Southern Pincer. von Manstein having the core of the firepower, the massive SS corps and Gross Deutschlkand etc down South. Unlike the fiction of Prokhoroka being a Soviet victory it wasn't the 5th Guards etc was wasted...the Soviets actually had committed all reserves in the South and the German Armoured formations were both intact and had reserves. There was no substantive threat to the Eastern flank as those Soviet reserves had already been committed and slaughtered. Whilst Von Manstein had 3 additional panzer divisions in reserve. Its quiet clear that a break through could have been made and given that the rest of the Soviet armoured reserve units were out of position trying to break through against Model in the North. They would not have been able to turn South and get to von Manstein in time. The effect would have been a hammer blow comming up from the South against the soviet armoured units and pressed them against Models Hagen line (Anvil). The distance involved was open tank country...German tanks were being repaired at such a rate that in fact there was almost no difference between tank avaialability on the 13th than there was 5 days earlier...If Von Manstein could snatch a victory at Kharkiv outnumbered 8:1 what he would have done at Kursk could certainly have been within his grasp. As more and more detail comes out of the battle we realize that the Soviets were simply lieing lieing at infinitum Stalin had prepared the script before the battle even started. Hitler essentially pulled out as he did at the Invasion of France where Guderian didn't stop at Sedan but kept up the charge to Dunkirk where Adolf again made the wrong call.
2,024
> > On the night of 9/10 July, the Western Allies mounted an amphibious > invasion of Sicily. Three days later, Hitler summoned Günther von > Kluge and Erich von Manstein to his Wolfsschanze headquarters in East > Prussia and declared his intention to "temporarily" call off [Operation Zitadelle](https://en.wikipedia.org/wiki/Operation_Citadel). **Von Manstein attempted to dissuade him, arguing that > Zitadelle was on the brink of victory: "on no account should we let go > of the enemy until the mobile reserves which he had committed were > decisively beaten"**. In an unusual reversal of their roles, Hitler gave > von Manstein a few more days to continue the offensive, but on 17 > July, he ordered a withdrawal and canceled the operation. He then > ordered the entire SS Panzer Corps to be transferred to Italy.[87] > > > While Hitler often made notoriously poor judgments for all the wrong reasons, did he make the right decision for Germany (for the wrong reason) in this specific isolated case? Was Zitadelle really on the brink of victory as Von Manstein believed?
2012/05/12
[ "https://history.stackexchange.com/questions/2024", "https://history.stackexchange.com", "https://history.stackexchange.com/users/852/" ]
Hitler was right in this instance. It was Manstein that extended the battle too far. The "official" reason for the offensive, was to recapture the city of Kursk. That was within the reach of the Germans. The REAL purpose of the offensive was to cut off the Russian salient, of which Kursk was the tip. The reason this didn't work was that the Russians concentrated their defense lines at the BASE of salient (south and north of Orel and Belgorod), on either side, instead of concentrating their forces at Kursk, where they could be cut off. What Manstein should have done was to "snap off" Kursk at the tip of the salient, then "declare victory and go home." What he actually did was to WIDEN the front by moving the German forces east to Prokhorovka. This turned the battle from one of decision (which favored the Germans) to one of attrition (which favored the Russians), who could trade their more numerous tanks for German vehicles at a rate of about one to one. This was because Manstein had let the Kursk operation deteriorate from the [1] "set piece battle" to a "meeting engagement" in which Germany had no advantage. So Hitler was right to stop the Kursk operation, with or without regard to what was happening in Italy. [1] <https://english.stackexchange.com/questions/48646/what-is-the-meaning-and-origin-of-set-piece-battle>
Kursk was an exercise in futility by July of 1943. Giving the Soviets 4-5 months to prepare the defenses around Kursk made the whole operation a waste of resources and time. What Germany SHOULD HAVE done was to spend 1943 on the defensive as Guderian recommended. "How many people do you think even know where Kursk is? It's a matter of profound indifference to the world whether we hold Kursk or not..." But what about handing the initiatives to the Allies? That can be solved trivially. All Hitler had to do to prevent the Soviet from launching a massive attack in the summer, was to pretend that he was going to do an all out attack on Kursk (which was widely expected, as anyone with a map could see the value of such an attack). And then did what he always did, delay the attack and delay, and delay, until the best of the campaigning season is over. Given his track record of delaying his offensives repeatedly, no one would doubt that the planned attack was coming. But to answer the original question. Was Hitler right to cancel? Yes. He shouldn't even have authorized the offensive. While Manstein was making decent progress in the South. Model's northern arm was totally spent (by the time Hitler made his decision). Given the weather that followed (pelting rain) it would have been unlikely that Manstein could have broken through all the way to link up with Model. And even if he was able to do that, there was no real reason to believe there would have been enough German troops to prevent the Russian from reaching the newly cut off in the Kursk pocket. The problem was, the Soviet still had significant reserve left (the Steppe Front), and the Germans didn't.
2,024
> > On the night of 9/10 July, the Western Allies mounted an amphibious > invasion of Sicily. Three days later, Hitler summoned Günther von > Kluge and Erich von Manstein to his Wolfsschanze headquarters in East > Prussia and declared his intention to "temporarily" call off [Operation Zitadelle](https://en.wikipedia.org/wiki/Operation_Citadel). **Von Manstein attempted to dissuade him, arguing that > Zitadelle was on the brink of victory: "on no account should we let go > of the enemy until the mobile reserves which he had committed were > decisively beaten"**. In an unusual reversal of their roles, Hitler gave > von Manstein a few more days to continue the offensive, but on 17 > July, he ordered a withdrawal and canceled the operation. He then > ordered the entire SS Panzer Corps to be transferred to Italy.[87] > > > While Hitler often made notoriously poor judgments for all the wrong reasons, did he make the right decision for Germany (for the wrong reason) in this specific isolated case? Was Zitadelle really on the brink of victory as Von Manstein believed?
2012/05/12
[ "https://history.stackexchange.com/questions/2024", "https://history.stackexchange.com", "https://history.stackexchange.com/users/852/" ]
The whole operation was doomed from the start because the Allies at Bletchley Park had deciphered the German plans for the attack. The British gave the Russians ample warning time of this, although the Russians already knew about it as they had spies of their own within British intelligence. <http://www.colossus-computer.com/colossus1.html> Given that the Russians had several weeks forewarning, they amassed tanks, guns and soldiers in great number and prepared many layers of defence lines to defeat the German assault. Had the Germans never launched Zitadelle they would have preserved their precious tanks and probably prolonged the war although the end result would have been the same. Hitler made the right decision on this occasion, by calling the operation off, but he should have done so sooner.
I think he was only partially right and this is because the units transferred were SS units. In the east, the SS fought both its racial and ideological enemies (the Bolshevik Jewry; which was mostly propaganda, but people believed it). There it was in its element, both as regards the savagery of fighting and the atrocities inflicted on the civilian population. In light of later massive surrendering of Germans to the western Allies, but stiff resistance against the Russians, no SS unit should probably ever have been transferred from the East, except for rest and refit.
2,024
> > On the night of 9/10 July, the Western Allies mounted an amphibious > invasion of Sicily. Three days later, Hitler summoned Günther von > Kluge and Erich von Manstein to his Wolfsschanze headquarters in East > Prussia and declared his intention to "temporarily" call off [Operation Zitadelle](https://en.wikipedia.org/wiki/Operation_Citadel). **Von Manstein attempted to dissuade him, arguing that > Zitadelle was on the brink of victory: "on no account should we let go > of the enemy until the mobile reserves which he had committed were > decisively beaten"**. In an unusual reversal of their roles, Hitler gave > von Manstein a few more days to continue the offensive, but on 17 > July, he ordered a withdrawal and canceled the operation. He then > ordered the entire SS Panzer Corps to be transferred to Italy.[87] > > > While Hitler often made notoriously poor judgments for all the wrong reasons, did he make the right decision for Germany (for the wrong reason) in this specific isolated case? Was Zitadelle really on the brink of victory as Von Manstein believed?
2012/05/12
[ "https://history.stackexchange.com/questions/2024", "https://history.stackexchange.com", "https://history.stackexchange.com/users/852/" ]
The whole operation was doomed from the start because the Allies at Bletchley Park had deciphered the German plans for the attack. The British gave the Russians ample warning time of this, although the Russians already knew about it as they had spies of their own within British intelligence. <http://www.colossus-computer.com/colossus1.html> Given that the Russians had several weeks forewarning, they amassed tanks, guns and soldiers in great number and prepared many layers of defence lines to defeat the German assault. Had the Germans never launched Zitadelle they would have preserved their precious tanks and probably prolonged the war although the end result would have been the same. Hitler made the right decision on this occasion, by calling the operation off, but he should have done so sooner.
I believe that the underlying intention of the High command was never to close the kursk salient with 2 pincers. This has been lauded as gospel for ages and ages and stands in the way of Mansteins thinking. I believe that the Soviet High command make a key strategic error when they positioned the bulk of their armour too close to the Northern pincer. The Northern "Pincer" was not the main pincer, in fact it's firepower was more defensive in charachter with all Ferdinands placed there and the defensive Hagen position available to fall back to which they did in good order. (Model had soaked up significant attacks at the Meat grinder of Rshev with the 9th army and the expectation was that he was to do it again) So essentially one sees what actually occurred in the Invasion of France in 1940 with a sickle through the ardennes now being the Southern Pincer. von Manstein having the core of the firepower, the massive SS corps and Gross Deutschlkand etc down South. Unlike the fiction of Prokhoroka being a Soviet victory it wasn't the 5th Guards etc was wasted...the Soviets actually had committed all reserves in the South and the German Armoured formations were both intact and had reserves. There was no substantive threat to the Eastern flank as those Soviet reserves had already been committed and slaughtered. Whilst Von Manstein had 3 additional panzer divisions in reserve. Its quiet clear that a break through could have been made and given that the rest of the Soviet armoured reserve units were out of position trying to break through against Model in the North. They would not have been able to turn South and get to von Manstein in time. The effect would have been a hammer blow comming up from the South against the soviet armoured units and pressed them against Models Hagen line (Anvil). The distance involved was open tank country...German tanks were being repaired at such a rate that in fact there was almost no difference between tank avaialability on the 13th than there was 5 days earlier...If Von Manstein could snatch a victory at Kharkiv outnumbered 8:1 what he would have done at Kursk could certainly have been within his grasp. As more and more detail comes out of the battle we realize that the Soviets were simply lieing lieing at infinitum Stalin had prepared the script before the battle even started. Hitler essentially pulled out as he did at the Invasion of France where Guderian didn't stop at Sedan but kept up the charge to Dunkirk where Adolf again made the wrong call.
2,024
> > On the night of 9/10 July, the Western Allies mounted an amphibious > invasion of Sicily. Three days later, Hitler summoned Günther von > Kluge and Erich von Manstein to his Wolfsschanze headquarters in East > Prussia and declared his intention to "temporarily" call off [Operation Zitadelle](https://en.wikipedia.org/wiki/Operation_Citadel). **Von Manstein attempted to dissuade him, arguing that > Zitadelle was on the brink of victory: "on no account should we let go > of the enemy until the mobile reserves which he had committed were > decisively beaten"**. In an unusual reversal of their roles, Hitler gave > von Manstein a few more days to continue the offensive, but on 17 > July, he ordered a withdrawal and canceled the operation. He then > ordered the entire SS Panzer Corps to be transferred to Italy.[87] > > > While Hitler often made notoriously poor judgments for all the wrong reasons, did he make the right decision for Germany (for the wrong reason) in this specific isolated case? Was Zitadelle really on the brink of victory as Von Manstein believed?
2012/05/12
[ "https://history.stackexchange.com/questions/2024", "https://history.stackexchange.com", "https://history.stackexchange.com/users/852/" ]
The whole operation was doomed from the start because the Allies at Bletchley Park had deciphered the German plans for the attack. The British gave the Russians ample warning time of this, although the Russians already knew about it as they had spies of their own within British intelligence. <http://www.colossus-computer.com/colossus1.html> Given that the Russians had several weeks forewarning, they amassed tanks, guns and soldiers in great number and prepared many layers of defence lines to defeat the German assault. Had the Germans never launched Zitadelle they would have preserved their precious tanks and probably prolonged the war although the end result would have been the same. Hitler made the right decision on this occasion, by calling the operation off, but he should have done so sooner.
Kursk was an exercise in futility by July of 1943. Giving the Soviets 4-5 months to prepare the defenses around Kursk made the whole operation a waste of resources and time. What Germany SHOULD HAVE done was to spend 1943 on the defensive as Guderian recommended. "How many people do you think even know where Kursk is? It's a matter of profound indifference to the world whether we hold Kursk or not..." But what about handing the initiatives to the Allies? That can be solved trivially. All Hitler had to do to prevent the Soviet from launching a massive attack in the summer, was to pretend that he was going to do an all out attack on Kursk (which was widely expected, as anyone with a map could see the value of such an attack). And then did what he always did, delay the attack and delay, and delay, until the best of the campaigning season is over. Given his track record of delaying his offensives repeatedly, no one would doubt that the planned attack was coming. But to answer the original question. Was Hitler right to cancel? Yes. He shouldn't even have authorized the offensive. While Manstein was making decent progress in the South. Model's northern arm was totally spent (by the time Hitler made his decision). Given the weather that followed (pelting rain) it would have been unlikely that Manstein could have broken through all the way to link up with Model. And even if he was able to do that, there was no real reason to believe there would have been enough German troops to prevent the Russian from reaching the newly cut off in the Kursk pocket. The problem was, the Soviet still had significant reserve left (the Steppe Front), and the Germans didn't.
2,024
> > On the night of 9/10 July, the Western Allies mounted an amphibious > invasion of Sicily. Three days later, Hitler summoned Günther von > Kluge and Erich von Manstein to his Wolfsschanze headquarters in East > Prussia and declared his intention to "temporarily" call off [Operation Zitadelle](https://en.wikipedia.org/wiki/Operation_Citadel). **Von Manstein attempted to dissuade him, arguing that > Zitadelle was on the brink of victory: "on no account should we let go > of the enemy until the mobile reserves which he had committed were > decisively beaten"**. In an unusual reversal of their roles, Hitler gave > von Manstein a few more days to continue the offensive, but on 17 > July, he ordered a withdrawal and canceled the operation. He then > ordered the entire SS Panzer Corps to be transferred to Italy.[87] > > > While Hitler often made notoriously poor judgments for all the wrong reasons, did he make the right decision for Germany (for the wrong reason) in this specific isolated case? Was Zitadelle really on the brink of victory as Von Manstein believed?
2012/05/12
[ "https://history.stackexchange.com/questions/2024", "https://history.stackexchange.com", "https://history.stackexchange.com/users/852/" ]
Kursk was an exercise in futility by July of 1943. Giving the Soviets 4-5 months to prepare the defenses around Kursk made the whole operation a waste of resources and time. What Germany SHOULD HAVE done was to spend 1943 on the defensive as Guderian recommended. "How many people do you think even know where Kursk is? It's a matter of profound indifference to the world whether we hold Kursk or not..." But what about handing the initiatives to the Allies? That can be solved trivially. All Hitler had to do to prevent the Soviet from launching a massive attack in the summer, was to pretend that he was going to do an all out attack on Kursk (which was widely expected, as anyone with a map could see the value of such an attack). And then did what he always did, delay the attack and delay, and delay, until the best of the campaigning season is over. Given his track record of delaying his offensives repeatedly, no one would doubt that the planned attack was coming. But to answer the original question. Was Hitler right to cancel? Yes. He shouldn't even have authorized the offensive. While Manstein was making decent progress in the South. Model's northern arm was totally spent (by the time Hitler made his decision). Given the weather that followed (pelting rain) it would have been unlikely that Manstein could have broken through all the way to link up with Model. And even if he was able to do that, there was no real reason to believe there would have been enough German troops to prevent the Russian from reaching the newly cut off in the Kursk pocket. The problem was, the Soviet still had significant reserve left (the Steppe Front), and the Germans didn't.
I think he was only partially right and this is because the units transferred were SS units. In the east, the SS fought both its racial and ideological enemies (the Bolshevik Jewry; which was mostly propaganda, but people believed it). There it was in its element, both as regards the savagery of fighting and the atrocities inflicted on the civilian population. In light of later massive surrendering of Germans to the western Allies, but stiff resistance against the Russians, no SS unit should probably ever have been transferred from the East, except for rest and refit.
2,024
> > On the night of 9/10 July, the Western Allies mounted an amphibious > invasion of Sicily. Three days later, Hitler summoned Günther von > Kluge and Erich von Manstein to his Wolfsschanze headquarters in East > Prussia and declared his intention to "temporarily" call off [Operation Zitadelle](https://en.wikipedia.org/wiki/Operation_Citadel). **Von Manstein attempted to dissuade him, arguing that > Zitadelle was on the brink of victory: "on no account should we let go > of the enemy until the mobile reserves which he had committed were > decisively beaten"**. In an unusual reversal of their roles, Hitler gave > von Manstein a few more days to continue the offensive, but on 17 > July, he ordered a withdrawal and canceled the operation. He then > ordered the entire SS Panzer Corps to be transferred to Italy.[87] > > > While Hitler often made notoriously poor judgments for all the wrong reasons, did he make the right decision for Germany (for the wrong reason) in this specific isolated case? Was Zitadelle really on the brink of victory as Von Manstein believed?
2012/05/12
[ "https://history.stackexchange.com/questions/2024", "https://history.stackexchange.com", "https://history.stackexchange.com/users/852/" ]
Kursk was an exercise in futility by July of 1943. Giving the Soviets 4-5 months to prepare the defenses around Kursk made the whole operation a waste of resources and time. What Germany SHOULD HAVE done was to spend 1943 on the defensive as Guderian recommended. "How many people do you think even know where Kursk is? It's a matter of profound indifference to the world whether we hold Kursk or not..." But what about handing the initiatives to the Allies? That can be solved trivially. All Hitler had to do to prevent the Soviet from launching a massive attack in the summer, was to pretend that he was going to do an all out attack on Kursk (which was widely expected, as anyone with a map could see the value of such an attack). And then did what he always did, delay the attack and delay, and delay, until the best of the campaigning season is over. Given his track record of delaying his offensives repeatedly, no one would doubt that the planned attack was coming. But to answer the original question. Was Hitler right to cancel? Yes. He shouldn't even have authorized the offensive. While Manstein was making decent progress in the South. Model's northern arm was totally spent (by the time Hitler made his decision). Given the weather that followed (pelting rain) it would have been unlikely that Manstein could have broken through all the way to link up with Model. And even if he was able to do that, there was no real reason to believe there would have been enough German troops to prevent the Russian from reaching the newly cut off in the Kursk pocket. The problem was, the Soviet still had significant reserve left (the Steppe Front), and the Germans didn't.
I believe that the underlying intention of the High command was never to close the kursk salient with 2 pincers. This has been lauded as gospel for ages and ages and stands in the way of Mansteins thinking. I believe that the Soviet High command make a key strategic error when they positioned the bulk of their armour too close to the Northern pincer. The Northern "Pincer" was not the main pincer, in fact it's firepower was more defensive in charachter with all Ferdinands placed there and the defensive Hagen position available to fall back to which they did in good order. (Model had soaked up significant attacks at the Meat grinder of Rshev with the 9th army and the expectation was that he was to do it again) So essentially one sees what actually occurred in the Invasion of France in 1940 with a sickle through the ardennes now being the Southern Pincer. von Manstein having the core of the firepower, the massive SS corps and Gross Deutschlkand etc down South. Unlike the fiction of Prokhoroka being a Soviet victory it wasn't the 5th Guards etc was wasted...the Soviets actually had committed all reserves in the South and the German Armoured formations were both intact and had reserves. There was no substantive threat to the Eastern flank as those Soviet reserves had already been committed and slaughtered. Whilst Von Manstein had 3 additional panzer divisions in reserve. Its quiet clear that a break through could have been made and given that the rest of the Soviet armoured reserve units were out of position trying to break through against Model in the North. They would not have been able to turn South and get to von Manstein in time. The effect would have been a hammer blow comming up from the South against the soviet armoured units and pressed them against Models Hagen line (Anvil). The distance involved was open tank country...German tanks were being repaired at such a rate that in fact there was almost no difference between tank avaialability on the 13th than there was 5 days earlier...If Von Manstein could snatch a victory at Kharkiv outnumbered 8:1 what he would have done at Kursk could certainly have been within his grasp. As more and more detail comes out of the battle we realize that the Soviets were simply lieing lieing at infinitum Stalin had prepared the script before the battle even started. Hitler essentially pulled out as he did at the Invasion of France where Guderian didn't stop at Sedan but kept up the charge to Dunkirk where Adolf again made the wrong call.
44,724,523
I am trying to upload some files into a Neo4j database using python. I am using Python 2.7.6 and haved successfully installed neo4j-driver and py2neo modues: ``` $ sudo pip install neo4j-driver Downloading/unpacking neo4j-driver Downloading neo4j-driver-1.3.1.tar.gz (167kB): 167kB downloaded Running setup.py (path:/tmp/pip_build_root/neo4j-driver/setup.py) egg_info for package neo4j-driver warning: no previously-included files matching '*.class' found anywhere in distribution warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.pyo' found anywhere in distribution warning: no previously-included files matching '*.so' found anywhere in distribution warning: no previously-included files matching '*.dll' found anywhere in distribution warning: no previously-included files matching '__pycache__' found anywhere in distribution no previously-included directories found matching 'test' Installing collected packages: neo4j-driver Running setup.py install for neo4j-driver building 'neo4j.bolt._io' extension x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c neo4j/bolt/_io.c -o build/temp.linux-x86_64-2.7/neo4j/bolt/_io.o x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/neo4j/bolt/_io.o -o build/lib.linux-x86_64-2.7/neo4j/bolt/_io.so building 'neo4j.packstream._packer' extension x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c neo4j/packstream/_packer.c -o build/temp.linux-x86_64-2.7/neo4j/packstream/_packer.o x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/neo4j/packstream/_packer.o -o build/lib.linux-x86_64-2.7/neo4j/packstream/_packer.so building 'neo4j.packstream._unpacker' extension x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c neo4j/packstream/_unpacker.c -o build/temp.linux-x86_64-2.7/neo4j/packstream/_unpacker.o x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/neo4j/packstream/_unpacker.o -o build/lib.linux-x86_64-2.7/neo4j/packstream/_unpacker.so warning: no previously-included files matching '*.class' found anywhere in distribution warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '*.pyo' found anywhere in distribution warning: no previously-included files matching '*.so' found anywhere in distribution warning: no previously-included files matching '*.dll' found anywhere in distribution warning: no previously-included files matching '__pycache__' found anywhere in distribution no previously-included directories found matching 'test' Could not find .egg-info directory in install record for neo4j-driver Successfully installed neo4j-driver Cleaning up... $ sudo pip install py2neo Downloading/unpacking py2neo Downloading py2neo-3.1.2.tar.gz (100kB): 100kB downloaded Running setup.py (path:/tmp/pip_build_root/py2neo/setup.py) egg_info for package py2neo warning: no previously-included files found matching 'CONTRIBUTING.md' warning: no previously-included files found matching 'README.md' warning: no previously-included files matching '*' found under directory 'test' warning: no previously-included files matching '*' found under directory 'test_ext' Installing collected packages: py2neo Running setup.py install for py2neo warning: no previously-included files found matching 'CONTRIBUTING.md' warning: no previously-included files found matching 'README.md' warning: no previously-included files matching '*' found under directory 'test' warning: no previously-included files matching '*' found under directory 'test_ext' Installing neokit script to /usr/local/bin Installing geoff script to /usr/local/bin Installing py2neo script to /usr/local/bin Could not find .egg-info directory in install record for py2neo Successfully installed py2neo Cleaning up... ``` but there are complaints of no module called `core` ``` $ python Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from py2neo.core import Graph Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named core >>> ``` Anyone else had this issue?
2017/06/23
[ "https://Stackoverflow.com/questions/44724523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1268941/" ]
The [py2neo docs](http://py2neo.org/2.0/essentials.html) says you should use: ``` from py2neo import Graph ``` instead of: ``` from py2neo.core import Graph ``` That is: remove the `.core` from the above code line. Take a look in [this link](http://py2neo.org/2.0/essentials.html#the-graph).
You installed the official **Python Driver for Neo4j**. (And never install with sudo, use a virtual environment.) `sudo pip install neo4j-driver` and then complain about **py2neo** ... `from py2neo import Graph` **The API Documentation for the official Python Driver 4.0 for Neo4j:** <https://neo4j.com/docs/api/python-driver/4.0/>
65,939,488
I want to deploy a Synapse pipeline which contains a Spark Job definition, activities etc. with an terraform script or an ARM template. But i don't find any documentation for this. I found for data factory pipeline : <https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_factory_pipeline> but not equivalent documentation for Synapse. Same issue with ARM documentation (<https://learn.microsoft.com/fr-fr/azure/templates/>). I don't want to use the Workspace of Azure Synapse. Is the documentation available ? Thanks for your support
2021/01/28
[ "https://Stackoverflow.com/questions/65939488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15099549/" ]
Why not simplify: ```js var x = `This is an example url http://www.longurl.com/?a=example@gmail.com&x=y1 and this must me a example url http:// www.longurl.com/?a=example@gmail.com&x=y1 (with an arbitrary number of spaces between the protocol and the beginning of the url) here is a mailto:a@b.c?subject=aaa%20bbb and some more text So https://www.google.com/search?q=bla or ftp://aaa:bbb@server.com could appear` function getMatch(str) { var urlRegex = /((mailto:|ftp:\/\/|https?:\/\/)\S+?)[^\s]+/ig; return str.match(urlRegex); } console.log(getMatch(x)); ```
Supposing an URL always start with `http` and can not have an empty space, a solution would be: `http[^ ]+` `[^ ]+` will match one or more non white-space characters.
56,306,079
so I have this code to calculate the value of the variable chance and print it there are no error codes but when it gets to the print statement no matter what compiler I use to compile it nothing appears in the output There is no error so I don't have anything to go off of ``` import math luck = 54 justice = 0 compassion = 1 bravery = 1 truth = 2 coreType = "Legendary" baseChance = 0.01 element = "Light" import math valid = True if coreType == "Common": coreRarity = 1 elif coreType == "Rare": coreRarity = 1.5 elif coreType == "Legendary": coreRarity = 3 else: print("Invalid core type") valid = False if justice > compassion and justice > truth and justice > bravery: idea = "justice" elif compassion > justice and compassion > truth and compassion > bravery: idea = "compassion" elif truth > compassion and truth > justice and truth > bravery: idea = truth elif bravery > compassion and bravery > truth and bravery > justice: idea = "bravery" else: idea = "all" if idea == "justice" and (element == "Light" or element == "Shadow"): boost = justice elif idea == "truth" and (element == "Ice" or element == "Wind"): boost = truth elif idea == "compassion" and (element == "Earth" or element == "Lightning"): boost = compassion elif idea == "bravery" and (element == "Fire" or element == "Water"): boost = bravery elif idea == "all": boost = bravery #basicly the above determines what the highest idea is and sets it but if the highest is all it means they are all the same so It doesn't matter one one the boost's value is cause its all the same if valid == True: chance = math.max(math.sqrt(luck*0.01*1.3)+0.95,1)*0.01*(0.01*(100+5*idea)*coreRarity*baseChance) if coreType == "common": chance =* 0.25 print(chance) ``` It's supposed to print the value of chance but prints nothing
2019/05/25
[ "https://Stackoverflow.com/questions/56306079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11555030/" ]
You have two issues with your code: * `chance =* 0.25` should be `chance *= 0.25` ([here](https://www.tutorialspoint.com/python/assignment_operators_example.htm) is a list of all assignmet operators) * the module `math` doesn't have a `max` attribute, so I would recommend you trying `max()` instead of `math.max()` That beeing said try replacing your current `if` statement (the one at the end) with this one: ``` if valid == True: chance = max(math.sqrt(luck*0.01*1.3)+0.95,1)*0.01*(0.01*(100+5*idea)*coreRarity*baseChance) if coreType == "common": chance *= 0.25 print(chance) ``` Hope this helps
There's a lot of ways this code can be improved: **Setting coreRarity** - This code below: ``` valid = True if coreType == "Common": coreRarity = 1 elif coreType == "Rare": coreRarity = 1.5 elif coreType == "Legendary": coreRarity = 3 else: print("Invalid core type") valid = False ``` can be made into a dictionary lookup ``` coreRarityDict = { "Common": 1, "Rare": 1.5, "Legendary": 3 } ``` To set `valid` and `coreRarity` uses readable dictionary methods ``` valid = coreType in coreRarityDict if valid: coreRarity = coreRarityDict[coreType] # dictionary lookup else: print("Invalid core type") ``` **Setting idea** - The next part: ``` if justice > compassion and justice > truth and justice > bravery: idea = "justice" elif compassion > justice and compassion > truth and compassion > bravery: idea = "compassion" elif truth > compassion and truth > justice and truth > bravery: idea = truth elif bravery > compassion and bravery > truth and bravery > justice: idea = "bravery" else: idea = "all" ``` The logic here is basically boils down to which is the (strict) maximum of `justice, compassion, truth, bravery`. If there is a ties for the maximum, set idea to "all". Note `idea = truth` looks like it should be `idea = "truth"` Again let's use a dictionary ``` ideasDict = { "justice": justice, "compassion": compassion, "truth": truth, "bravery": bravery, } ``` To set idea we want the key with the strict largest value See - [Getting key with maximum value in dictionary?](https://stackoverflow.com/questions/268272/getting-key-with-maximum-value-in-dictionary) ``` idea = max(ideasDict, key=lambda x: ideasDict[x]) ``` To check for ties we can count the number of times this idea value occurs in our dictionary - see [Python 2.7 Counting number of dictionary items with given value](https://stackoverflow.com/questions/13462365/python-2-7-counting-number-of-dictionary-items-with-given-value) ``` sum(1 for x in ideasDict.values() if x == idea) ``` Combining this, ``` idea = max(ideasDict, key=lambda x: ideasDict[x]) idea_freq = sum(1 for x in ideasDict.values() if x == idea) if idea_freq > 1: idea = "all" ``` **Setting boost** - This code ``` if idea == "justice" and (element == "Light" or element == "Shadow"): boost = justice elif idea == "truth" and (element == "Ice" or element == "Wind"): boost = truth elif idea == "compassion" and (element == "Earth" or element == "Lightning"): boost = compassion elif idea == "bravery" and (element == "Fire" or element == "Water"): boost = bravery elif idea == "all": boost = bravery #basically the above determines what the highest idea is and sets it but if the highest is all it means they are all the same so It doesn't matter one one the boost's value is cause its all the same ``` Notice you are repeating `if idea == "xx": boost = xx` Reusing the dictionary the code would look like ``` if idea == "justice" and (element == "Light" or element == "Shadow"): boost = ideasDict[idea] elif idea == "truth" and (element == "Ice" or element == "Wind"): boost = ideasDict[idea] elif idea == "compassion" and (element == "Earth" or element == "Lightning"): boost = ideasDict[idea] elif idea == "bravery" and (element == "Fire" or element == "Water"): boost = ideasDict[idea] elif idea == "all": boost = bravery #basically the above determines what the highest idea is and sets it but if the highest is all it means they are all the same so It doesn't matter one one the boost's value is cause its all the same ``` That's a lot of repeating `boost = ideasDict[idea]`! Let's simplify further! Note the `elif` can just be made as an `if` as your conditions are non-overlapping: `idea` can't be both `== "justice"` and `== "truth"`. Let's use a dictionary again ``` elementsBoostDict = { "justice": ["Light", "Shadow"], "compassion": ["Ice", "Wind"], "truth": ["Earth", "Lightning"], "bravery": ["Fire", "Water"], } if idea == "all": boost = bravery elif element in elementsBoostDict[idea]: boost = ideasDict[idea] ``` Notice `boost` may not be set e.g `idea == "justice"` and `element == "ice"` and `boost` is not used anywhere else in your code? Is this intended? **Calculating chance** - this is your code ``` if valid == True: chance = math.max(math.sqrt(luck*0.01*1.3)+0.95,1)*0.01*(0.01*(100+5*idea)*coreRarity*baseChance) if coreType == "common": chance =* 0.25 print(chance) ``` Note `idea` is a string (I get error `TypeError: unsupported operand type(s) for +: 'int' and 'str'` after previously correcting to `idea = "truth"`) and should be replaced by it's relative value. The line `if valid == True:` can be simplified to `if valid:` Your chance calculation includes a lot of hard coded numbers and can be simplified `0.01*0.01 = 0.0001`. Let's move this into a function with some defaults. Also as `luck` is a percentage we'll use `luck=0.54` and remove the multiplication by `0.01`. ``` def chance_calc(coreType, coreRarity, idea, luck=0.54, baseChance=0.01): temp = math.max(math.sqrt(luck * 1.3) + 0.95, 1) chance = temp * 0.0001 * (100 + 5 * ideasDict[idea]) * coreRarity * baseChance if coreType == "common": chance *= 0.25 return chance ``` **Final code** ``` import math justice = 0 compassion = 1 bravery = 1 truth = 2 coreType = "Legendary" element = "Light" coreRarityDict = { "Common": 1, "Rare": 1.5, "Legendary": 3 } ideasDict= { "justice": justice, "compassion": compassion, "truth": truth, "bravery": bravery, } elementsBoost = { "justice": ["Light", "Shadow"], "compassion": ["Ice", "Wind"], "truth": ["Earth", "Lightning"], "bravery": ["Fire", "Water"], } # set coreRarity valid = coreType in coreRarityDict if valid: coreRarity = coreRarityDict[coreType] else: print("Invalid core type") # set idea idea = max(ideasDict, key=lambda x: ideasDict[x]) idea_freq = sum(1 for x in ideasDict.values() if x == idea) if idea_freq > 1: idea = "all" # set boost if idea == "all": boost = bravery elif element in elementsBoost[idea]: boost = ideasDict[idea] def chance_calc(coreType, coreRarity, idea, luck=0.54, baseChance=0.01): temp = math.max(math.sqrt(luck * 1.3) + 0.95, 1) chance = temp * 0.0001 * (100 + 5 * ideasDict[idea]) * coreRarity * baseChance if coreType == "common": chance *= 0.25 return chance if valid: chance = chance_calc(coreType, coreRarity, idea) print(chance) # result 0.0005899919528666251 ``` **Final thoughts and post mortem** There's a high chance I changed what you intended or made some error. Using a structured data type like a dictionary has the benefit of simplifying code and provides methods we can use. An alternative could be using classes which could combine `ideasDict` and `elementsBoost`. If idea is "all" then `ideasDict[idea]` will return `None` and `chance_calc` will return an error. `boost` is not used If `ideasDict[idea]` is big enough the chance may be bigger than 1. The chance calculation looks like it could be improved. A good idea might be to write down a bunch of combinations of `justice, compassion, bravery, truth, coreType, element` and what chance you would like for each and then try to write a function that gets close to this.
38,407,396
I want to do form validation for all three tags and after validation, enable the submit button until validation is done not to enable submit button. ``` <html> <head> <link rel="stylesheet" href="css/bootstrap.css" /> <link rel="stylesheet" href="css/datepicker.css" /> <link rel="stylesheet" href="css/mystyle.css" /> <script src="js/jquery-2.2.2.js"></script> <script src="js/bootstrap-datepicker.js"></script> <script src="js/moment.js"></script> </head> <body> <form id="report-form"> <div id="report-pane" class="row"> <div class="col-xs-1"> <label>Report:</label> </div> <div class="col-xs-2"> <select class="form-control" id="report"> <option value="" selected>Select Report</option> <option id="rep1" value="10">Report 1</option> <option id="rep2" value="20">Report 2</option> <option id="rep3" value="30">Report 3</option> </select> </div> </div> <!--Date Section--> <div id="date-pane" class="row"> <!--Script for datepicker--> <script type="text/javascript"> $(function() { var now = new Date(); var yearsold = new Date(); yearsold.setFullYear((now.getFullYear() - 2)); $('.datepicker').datepicker({ format: 'mm/dd/yyyy', startDate: yearsold, endDate: now }); var defaultDate = moment().format('DD/MM/YYYY'); $("#datePicker1").val(defaultDate); $("#datePicker2").val(defaultDate); }); </script> <div class="col-xs-1"> <label>Start Date:</label> </div> <div class='col-sm-3'> <input class="datepicker form-control" type="text" id="datePicker1" /> </div> <div class="col-xs-1"> <label>End Date:</label> </div> <div class='col-sm-3'> <input class="datepicker form-control" type="text" id="datePicker2" /> </div> </div> <div id="button-pane" class="row"> <div class="col-lg-12"> <!-- <button class="btn btn-primary">Generate Report</button>--> <input type="submit" id="requestBtn" class="btn btn-primary" value="Generate Report"></input> </div> </div> <script type="text/javascript"> $(document).ready(function() { // Validation Function Needed }); </script> </form> <script src="js/bootstrap.js"></script> </body> </html> ``` Enable the submit button only if all the form validation is done Example [![Sample Visual](https://i.stack.imgur.com/7cd2O.png)](https://i.stack.imgur.com/7cd2O.png)
2016/07/16
[ "https://Stackoverflow.com/questions/38407396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5845221/" ]
``` $(document).ready(function () { $('#ccSelectForm').validate({ rules: { inputEmail: { required: true, email: true }, inputEmailConfirm: { equalTo: '#inputEmail' } } }); $('#ccSelectForm input').on('keyup blur', function () { if ($('#ccSelectForm').valid()) { $('button.btn').prop('disabled', false); } else { $('button.btn').prop('disabled', 'disabled'); } }); ``` }); [Check this link](http://jsfiddle.net/p628Y/1/)
i think you want something like this ``` $(document).ready(function() { // before validation $("#submit").attr("disabled","disabled"); // after validation $("#submit").removeAttr("disabled"); }); ```
38,407,396
I want to do form validation for all three tags and after validation, enable the submit button until validation is done not to enable submit button. ``` <html> <head> <link rel="stylesheet" href="css/bootstrap.css" /> <link rel="stylesheet" href="css/datepicker.css" /> <link rel="stylesheet" href="css/mystyle.css" /> <script src="js/jquery-2.2.2.js"></script> <script src="js/bootstrap-datepicker.js"></script> <script src="js/moment.js"></script> </head> <body> <form id="report-form"> <div id="report-pane" class="row"> <div class="col-xs-1"> <label>Report:</label> </div> <div class="col-xs-2"> <select class="form-control" id="report"> <option value="" selected>Select Report</option> <option id="rep1" value="10">Report 1</option> <option id="rep2" value="20">Report 2</option> <option id="rep3" value="30">Report 3</option> </select> </div> </div> <!--Date Section--> <div id="date-pane" class="row"> <!--Script for datepicker--> <script type="text/javascript"> $(function() { var now = new Date(); var yearsold = new Date(); yearsold.setFullYear((now.getFullYear() - 2)); $('.datepicker').datepicker({ format: 'mm/dd/yyyy', startDate: yearsold, endDate: now }); var defaultDate = moment().format('DD/MM/YYYY'); $("#datePicker1").val(defaultDate); $("#datePicker2").val(defaultDate); }); </script> <div class="col-xs-1"> <label>Start Date:</label> </div> <div class='col-sm-3'> <input class="datepicker form-control" type="text" id="datePicker1" /> </div> <div class="col-xs-1"> <label>End Date:</label> </div> <div class='col-sm-3'> <input class="datepicker form-control" type="text" id="datePicker2" /> </div> </div> <div id="button-pane" class="row"> <div class="col-lg-12"> <!-- <button class="btn btn-primary">Generate Report</button>--> <input type="submit" id="requestBtn" class="btn btn-primary" value="Generate Report"></input> </div> </div> <script type="text/javascript"> $(document).ready(function() { // Validation Function Needed }); </script> </form> <script src="js/bootstrap.js"></script> </body> </html> ``` Enable the submit button only if all the form validation is done Example [![Sample Visual](https://i.stack.imgur.com/7cd2O.png)](https://i.stack.imgur.com/7cd2O.png)
2016/07/16
[ "https://Stackoverflow.com/questions/38407396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5845221/" ]
``` $(document).ready(function () { $('#ccSelectForm').validate({ rules: { inputEmail: { required: true, email: true }, inputEmailConfirm: { equalTo: '#inputEmail' } } }); $('#ccSelectForm input').on('keyup blur', function () { if ($('#ccSelectForm').valid()) { $('button.btn').prop('disabled', false); } else { $('button.btn').prop('disabled', 'disabled'); } }); ``` }); [Check this link](http://jsfiddle.net/p628Y/1/)
If you insist on Jq custom logic is needed, ``` var validationCallBk = function(){ var report = $('#report').val(); var startDate = $('#datePicker1').val(); var endDate = $('#datePicker2').val(); if(report != '' && startDate == somevaliddate && endDate == somevaliddate) //enable btn else //disable btn }; $('#report').on('change',validationCallBk); //use the datepicker on select event and call validationCallBk ```
747,561
I'm having trouble figuring out the limits. What messes me up is that the limit approaches infinity. Usually it approaches a specific number. Is that a trick to solve problems like these? So for example, use the root test to find convergence/divergence. (n!)^n/(n^n)^7. n=1 and it's to infinity
2014/04/10
[ "https://math.stackexchange.com/questions/747561", "https://math.stackexchange.com", "https://math.stackexchange.com/users/136944/" ]
${\root n\of{a\_n}}=n!/n^7\to\infty$, so $\sum a\_n$ diverges.
$$\sum\_{n=1}^{\infty}=\dfrac{(n!)^n}{(n^n)^7}$$ so,we let $a\_n=\dfrac{(n!)^n}{(n^n)^7}.$ To use the root test,we take $$L=\lim\_{n\rightarrow \infty}\sqrt[n]{\left|a\_n\right|}$$ $$L=\lim\_{n\rightarrow \infty}\sqrt[n]{\dfrac{(n!)^n}{(n^n)^7}}$$ $$L=\lim\_{n\rightarrow \infty}\dfrac{(n!)}{(n)^7}$$ And as n! increases much faser than $n^7$ as $n\rightarrow\infty$ $$L=\infty$$ As $L\ne0$, The series diverges.
788,671
I am assuming the following ways to copy a file with in a NFS share: **Process 1:** * The client requests for the data to be copied from NFS share (if cache is not there) and the chunks of data are asynchronously copied to memory of the NFS client which then asynchronously send it to the NFS filer again to copy to new location. * The NFS filer receives the chunks of data asynchronously in the memory and writes it to the new location. * In this process, though there is network involved while reading and also writing, due to asynchronous read & write, the latency for one overall read-write operation will be same as latency for read-write operation of overall data. Hence, reading from local hard disk and writing to NFS is almost same as reading from NFS and write to NFS. In the first step, if cache is already there, the reading can be very quick. **Process 2:** * The client send request to initiate the data copy operation to NFS server, along with the location from where it has to read and where it has to write (seems it is not). * The server does the rest, read-write operations using it's own memory. Hence, no network involved. And hence, can have better performance (unless there is no latency at the network end) But it is likely not the way. Please correct me at every point, if I am wrong. Also, does the memory involves at every operation, I mean when it sends data across network, the data is first sent to memory (data buffer) from disk and then from memory (data buffer) to data buffer (on the other side of the network), but not from data buffer to disk on the other side of the network right?
2016/07/08
[ "https://serverfault.com/questions/788671", "https://serverfault.com", "https://serverfault.com/users/292068/" ]
NFSv4.2 does have a offload-copy operation which can do server-to-server copy without proxying data trough the client. Modern linux kernels (> 3.13?) supports that. I don't know about other servers. **UPDATE** By linux kernel 4.7 server side copy is not supported by linux servers <https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/nfsd/nfs4xdr.c?id=refs/tags/v4.7-rc6#n1797> **UPDATE 2** With kernel version 5.6 the server side copy is added to the NFSD implementation <https://lkml.org/lkml/2020/2/7/687>
The `"copy a file"` operation is not a basic file-system operation such as `read`, `write`, `open`, `close`, and similar operations. See [this page for a good explanation](http://www.tldp.org/LDP/khg/HyperNews/get/fs/vfstour.html) of the operations a filesystem has to support. And that's all file systems - whether it's `ext4`, `btrfs`, or `nfsv4`. Note that there's no way to know why a process opens file A, opens file B, reads from file A, then writes to file B. So, in general there's no way to "short-circuit" and optimize the copying of a file so that the data doesn't have to cross the network twice in the case of both file A and file B being on NFS file systems, even if they're shared from the same NFS server. Many operating systems do provide system calls [such as `sendfile()`](http://man7.org/linux/man-pages/man2/sendfile.2.html), which do efficiently copy data by removing the need to copy the data to and from user space, and in theory that could be done at the file system level for copying files, but even then there would have to be restrictions similar to that on the `rename()` operation - such a hypothetical `copyfile()` operation would likely have to be restricted to short-circuiting only those copies within a single file system. To do otherwise would make a complex mess - what to do if file A and file B are on the same NFS server, a client wants to copy from one to the other, but file A is on an ext4 file system and file B is on another XFS file system?
12,432,663
I have looked in the standard library and on StackOverflow, and have not found a similar question. So, is there a way to do the following without rolling my own function? Bonus points if someone writes a beautiful function if there is no built in way. ``` def stringPercentToFloat(stringPercent) # ??? return floatPercent p1 = "99%" p2 = "99.5%" print stringPercentToFloat(p1) print stringPercentToFloat(p2) >>>> 0.99 >>>> 0.995 ```
2012/09/14
[ "https://Stackoverflow.com/questions/12432663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476403/" ]
I wrote the following method that should always return the output to the exact same accuracy as the input, with no floating point errors such as in the other answers. ``` def percent_to_float(s): s = str(float(s.rstrip("%"))) i = s.find(".") if i == -1: return int(s) / 100 if s.startswith("-"): return -percent_to_float(s.lstrip("-")) s = s.replace(".", "") i -= 2 if i < 0: return float("." + "0" * abs(i) + s) else: return float(s[:i] + "." + s[i:]) ``` Explanation ----------- 1. Strip the "%" from the end. 2. If percent has no ".", simply return it divided by 100. 3. If percent is negative, strip the "-" and re-call function, then convert the result back to a negative and return it. 4. Remove the decimal place. 5. Decrement `i` (the index the decimal place was at) by 2, because we want to shift the decimal place 2 spaces to the left. 6. If `i` is negative, then we need to pad with zeros. * **Example:** Suppose the input is "1.33%". To be able to shift the decimal place 2 spaces to the left, we would need to pad with a zero. 7. Convert to a float. --- Test case ([Try it online](https://repl.it/@HatScripts/percenttofloat)): ``` from unittest.case import TestCase class ParsePercentCase(TestCase): tests = { "150%" : 1.5, "100%" : 1, "99%" : 0.99, "99.999%" : 0.99999, "99.5%" : 0.995, "95%" : 0.95, "90%" : 0.9, "50%" : 0.5, "66.666%" : 0.66666, "42%" : 0.42, "20.5%" : 0.205, "20%" : 0.2, "10%" : 0.1, "3.141592653589793%": 0.03141592653589793, "1%" : 0.01, "0.1%" : 0.001, "0.01%" : 0.0001, "0%" : 0, } tests = sorted(tests.items(), key=lambda x: -x[1]) def test_parse_percent(self): for percent_str, expected in self.tests: parsed = percent_to_float(percent_str) self.assertEqual(expected, parsed, percent_str) def test_parse_percent_negative(self): negative_tests = [("-" + s, -f) for s, f in self.tests] for percent_str, expected in negative_tests: parsed = percent_to_float(percent_str) self.assertEqual(expected, parsed, percent_str) ```
Another way: `float(stringPercent[:-1]) / 100`
12,432,663
I have looked in the standard library and on StackOverflow, and have not found a similar question. So, is there a way to do the following without rolling my own function? Bonus points if someone writes a beautiful function if there is no built in way. ``` def stringPercentToFloat(stringPercent) # ??? return floatPercent p1 = "99%" p2 = "99.5%" print stringPercentToFloat(p1) print stringPercentToFloat(p2) >>>> 0.99 >>>> 0.995 ```
2012/09/14
[ "https://Stackoverflow.com/questions/12432663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476403/" ]
Use `strip('%')` , as: ``` In [9]: "99.5%".strip('%') Out[9]: '99.5' #convert this to float using float() and divide by 100 In [10]: def p2f(x): ....: return float(x.strip('%'))/100 ....: In [12]: p2f("99%") Out[12]: 0.98999999999999999 In [13]: p2f("99.5%") Out[13]: 0.995 ```
I wrote the following method that should always return the output to the exact same accuracy as the input, with no floating point errors such as in the other answers. ``` def percent_to_float(s): s = str(float(s.rstrip("%"))) i = s.find(".") if i == -1: return int(s) / 100 if s.startswith("-"): return -percent_to_float(s.lstrip("-")) s = s.replace(".", "") i -= 2 if i < 0: return float("." + "0" * abs(i) + s) else: return float(s[:i] + "." + s[i:]) ``` Explanation ----------- 1. Strip the "%" from the end. 2. If percent has no ".", simply return it divided by 100. 3. If percent is negative, strip the "-" and re-call function, then convert the result back to a negative and return it. 4. Remove the decimal place. 5. Decrement `i` (the index the decimal place was at) by 2, because we want to shift the decimal place 2 spaces to the left. 6. If `i` is negative, then we need to pad with zeros. * **Example:** Suppose the input is "1.33%". To be able to shift the decimal place 2 spaces to the left, we would need to pad with a zero. 7. Convert to a float. --- Test case ([Try it online](https://repl.it/@HatScripts/percenttofloat)): ``` from unittest.case import TestCase class ParsePercentCase(TestCase): tests = { "150%" : 1.5, "100%" : 1, "99%" : 0.99, "99.999%" : 0.99999, "99.5%" : 0.995, "95%" : 0.95, "90%" : 0.9, "50%" : 0.5, "66.666%" : 0.66666, "42%" : 0.42, "20.5%" : 0.205, "20%" : 0.2, "10%" : 0.1, "3.141592653589793%": 0.03141592653589793, "1%" : 0.01, "0.1%" : 0.001, "0.01%" : 0.0001, "0%" : 0, } tests = sorted(tests.items(), key=lambda x: -x[1]) def test_parse_percent(self): for percent_str, expected in self.tests: parsed = percent_to_float(percent_str) self.assertEqual(expected, parsed, percent_str) def test_parse_percent_negative(self): negative_tests = [("-" + s, -f) for s, f in self.tests] for percent_str, expected in negative_tests: parsed = percent_to_float(percent_str) self.assertEqual(expected, parsed, percent_str) ```
12,432,663
I have looked in the standard library and on StackOverflow, and have not found a similar question. So, is there a way to do the following without rolling my own function? Bonus points if someone writes a beautiful function if there is no built in way. ``` def stringPercentToFloat(stringPercent) # ??? return floatPercent p1 = "99%" p2 = "99.5%" print stringPercentToFloat(p1) print stringPercentToFloat(p2) >>>> 0.99 >>>> 0.995 ```
2012/09/14
[ "https://Stackoverflow.com/questions/12432663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476403/" ]
Use `strip('%')` , as: ``` In [9]: "99.5%".strip('%') Out[9]: '99.5' #convert this to float using float() and divide by 100 In [10]: def p2f(x): ....: return float(x.strip('%'))/100 ....: In [12]: p2f("99%") Out[12]: 0.98999999999999999 In [13]: p2f("99.5%") Out[13]: 0.995 ```
``` float(stringPercent.strip('%')) / 100.0 ```
12,432,663
I have looked in the standard library and on StackOverflow, and have not found a similar question. So, is there a way to do the following without rolling my own function? Bonus points if someone writes a beautiful function if there is no built in way. ``` def stringPercentToFloat(stringPercent) # ??? return floatPercent p1 = "99%" p2 = "99.5%" print stringPercentToFloat(p1) print stringPercentToFloat(p2) >>>> 0.99 >>>> 0.995 ```
2012/09/14
[ "https://Stackoverflow.com/questions/12432663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476403/" ]
Based on the answer from @WKPlus this solution takes into account the locales where the decimal point is either a point `.` or a comma `,` ``` float("-3,5%".replace(',','.')[:-1]) / 100 ```
Another way: `float(stringPercent[:-1]) / 100`
12,432,663
I have looked in the standard library and on StackOverflow, and have not found a similar question. So, is there a way to do the following without rolling my own function? Bonus points if someone writes a beautiful function if there is no built in way. ``` def stringPercentToFloat(stringPercent) # ??? return floatPercent p1 = "99%" p2 = "99.5%" print stringPercentToFloat(p1) print stringPercentToFloat(p2) >>>> 0.99 >>>> 0.995 ```
2012/09/14
[ "https://Stackoverflow.com/questions/12432663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476403/" ]
Use `strip('%')` , as: ``` In [9]: "99.5%".strip('%') Out[9]: '99.5' #convert this to float using float() and divide by 100 In [10]: def p2f(x): ....: return float(x.strip('%'))/100 ....: In [12]: p2f("99%") Out[12]: 0.98999999999999999 In [13]: p2f("99.5%") Out[13]: 0.995 ```
Simply replace the `%` by `e-2` before parsing to `float` : ``` float("99.5%".replace('%', 'e-2')) ``` It's safer since the result will still be correct if there's no `%` used.
12,432,663
I have looked in the standard library and on StackOverflow, and have not found a similar question. So, is there a way to do the following without rolling my own function? Bonus points if someone writes a beautiful function if there is no built in way. ``` def stringPercentToFloat(stringPercent) # ??? return floatPercent p1 = "99%" p2 = "99.5%" print stringPercentToFloat(p1) print stringPercentToFloat(p2) >>>> 0.99 >>>> 0.995 ```
2012/09/14
[ "https://Stackoverflow.com/questions/12432663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476403/" ]
Simply replace the `%` by `e-2` before parsing to `float` : ``` float("99.5%".replace('%', 'e-2')) ``` It's safer since the result will still be correct if there's no `%` used.
Based on the answer from @WKPlus this solution takes into account the locales where the decimal point is either a point `.` or a comma `,` ``` float("-3,5%".replace(',','.')[:-1]) / 100 ```
12,432,663
I have looked in the standard library and on StackOverflow, and have not found a similar question. So, is there a way to do the following without rolling my own function? Bonus points if someone writes a beautiful function if there is no built in way. ``` def stringPercentToFloat(stringPercent) # ??? return floatPercent p1 = "99%" p2 = "99.5%" print stringPercentToFloat(p1) print stringPercentToFloat(p2) >>>> 0.99 >>>> 0.995 ```
2012/09/14
[ "https://Stackoverflow.com/questions/12432663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476403/" ]
``` float(stringPercent.strip('%')) / 100.0 ```
Based on the answer from @WKPlus this solution takes into account the locales where the decimal point is either a point `.` or a comma `,` ``` float("-3,5%".replace(',','.')[:-1]) / 100 ```
12,432,663
I have looked in the standard library and on StackOverflow, and have not found a similar question. So, is there a way to do the following without rolling my own function? Bonus points if someone writes a beautiful function if there is no built in way. ``` def stringPercentToFloat(stringPercent) # ??? return floatPercent p1 = "99%" p2 = "99.5%" print stringPercentToFloat(p1) print stringPercentToFloat(p2) >>>> 0.99 >>>> 0.995 ```
2012/09/14
[ "https://Stackoverflow.com/questions/12432663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476403/" ]
Use `strip('%')` , as: ``` In [9]: "99.5%".strip('%') Out[9]: '99.5' #convert this to float using float() and divide by 100 In [10]: def p2f(x): ....: return float(x.strip('%'))/100 ....: In [12]: p2f("99%") Out[12]: 0.98999999999999999 In [13]: p2f("99.5%") Out[13]: 0.995 ```
Another way: `float(stringPercent[:-1]) / 100`
12,432,663
I have looked in the standard library and on StackOverflow, and have not found a similar question. So, is there a way to do the following without rolling my own function? Bonus points if someone writes a beautiful function if there is no built in way. ``` def stringPercentToFloat(stringPercent) # ??? return floatPercent p1 = "99%" p2 = "99.5%" print stringPercentToFloat(p1) print stringPercentToFloat(p2) >>>> 0.99 >>>> 0.995 ```
2012/09/14
[ "https://Stackoverflow.com/questions/12432663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476403/" ]
``` float(stringPercent.strip('%')) / 100.0 ```
I wrote the following method that should always return the output to the exact same accuracy as the input, with no floating point errors such as in the other answers. ``` def percent_to_float(s): s = str(float(s.rstrip("%"))) i = s.find(".") if i == -1: return int(s) / 100 if s.startswith("-"): return -percent_to_float(s.lstrip("-")) s = s.replace(".", "") i -= 2 if i < 0: return float("." + "0" * abs(i) + s) else: return float(s[:i] + "." + s[i:]) ``` Explanation ----------- 1. Strip the "%" from the end. 2. If percent has no ".", simply return it divided by 100. 3. If percent is negative, strip the "-" and re-call function, then convert the result back to a negative and return it. 4. Remove the decimal place. 5. Decrement `i` (the index the decimal place was at) by 2, because we want to shift the decimal place 2 spaces to the left. 6. If `i` is negative, then we need to pad with zeros. * **Example:** Suppose the input is "1.33%". To be able to shift the decimal place 2 spaces to the left, we would need to pad with a zero. 7. Convert to a float. --- Test case ([Try it online](https://repl.it/@HatScripts/percenttofloat)): ``` from unittest.case import TestCase class ParsePercentCase(TestCase): tests = { "150%" : 1.5, "100%" : 1, "99%" : 0.99, "99.999%" : 0.99999, "99.5%" : 0.995, "95%" : 0.95, "90%" : 0.9, "50%" : 0.5, "66.666%" : 0.66666, "42%" : 0.42, "20.5%" : 0.205, "20%" : 0.2, "10%" : 0.1, "3.141592653589793%": 0.03141592653589793, "1%" : 0.01, "0.1%" : 0.001, "0.01%" : 0.0001, "0%" : 0, } tests = sorted(tests.items(), key=lambda x: -x[1]) def test_parse_percent(self): for percent_str, expected in self.tests: parsed = percent_to_float(percent_str) self.assertEqual(expected, parsed, percent_str) def test_parse_percent_negative(self): negative_tests = [("-" + s, -f) for s, f in self.tests] for percent_str, expected in negative_tests: parsed = percent_to_float(percent_str) self.assertEqual(expected, parsed, percent_str) ```
12,432,663
I have looked in the standard library and on StackOverflow, and have not found a similar question. So, is there a way to do the following without rolling my own function? Bonus points if someone writes a beautiful function if there is no built in way. ``` def stringPercentToFloat(stringPercent) # ??? return floatPercent p1 = "99%" p2 = "99.5%" print stringPercentToFloat(p1) print stringPercentToFloat(p2) >>>> 0.99 >>>> 0.995 ```
2012/09/14
[ "https://Stackoverflow.com/questions/12432663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1476403/" ]
Simply replace the `%` by `e-2` before parsing to `float` : ``` float("99.5%".replace('%', 'e-2')) ``` It's safer since the result will still be correct if there's no `%` used.
I wrote the following method that should always return the output to the exact same accuracy as the input, with no floating point errors such as in the other answers. ``` def percent_to_float(s): s = str(float(s.rstrip("%"))) i = s.find(".") if i == -1: return int(s) / 100 if s.startswith("-"): return -percent_to_float(s.lstrip("-")) s = s.replace(".", "") i -= 2 if i < 0: return float("." + "0" * abs(i) + s) else: return float(s[:i] + "." + s[i:]) ``` Explanation ----------- 1. Strip the "%" from the end. 2. If percent has no ".", simply return it divided by 100. 3. If percent is negative, strip the "-" and re-call function, then convert the result back to a negative and return it. 4. Remove the decimal place. 5. Decrement `i` (the index the decimal place was at) by 2, because we want to shift the decimal place 2 spaces to the left. 6. If `i` is negative, then we need to pad with zeros. * **Example:** Suppose the input is "1.33%". To be able to shift the decimal place 2 spaces to the left, we would need to pad with a zero. 7. Convert to a float. --- Test case ([Try it online](https://repl.it/@HatScripts/percenttofloat)): ``` from unittest.case import TestCase class ParsePercentCase(TestCase): tests = { "150%" : 1.5, "100%" : 1, "99%" : 0.99, "99.999%" : 0.99999, "99.5%" : 0.995, "95%" : 0.95, "90%" : 0.9, "50%" : 0.5, "66.666%" : 0.66666, "42%" : 0.42, "20.5%" : 0.205, "20%" : 0.2, "10%" : 0.1, "3.141592653589793%": 0.03141592653589793, "1%" : 0.01, "0.1%" : 0.001, "0.01%" : 0.0001, "0%" : 0, } tests = sorted(tests.items(), key=lambda x: -x[1]) def test_parse_percent(self): for percent_str, expected in self.tests: parsed = percent_to_float(percent_str) self.assertEqual(expected, parsed, percent_str) def test_parse_percent_negative(self): negative_tests = [("-" + s, -f) for s, f in self.tests] for percent_str, expected in negative_tests: parsed = percent_to_float(percent_str) self.assertEqual(expected, parsed, percent_str) ```
40,721,107
I am working on some task which requires from me to solve the following algorithmic problem: --- - You Have collection of items (their weights): [w1, w2, ..., wn] - And You have a bag which weight is: W - It is Needed to fill the bag maximally (fill as much as possible) with the subset of given items. --- So this **is not** "Knapsack 0/1" problem, as we deal only with weights (we have only one parameter for item). Therefore I assume that it might have a solution (Knapsack is NP-complete) or some kind of algorithm which gives approximately correct result. Please don't suggest me "greedy algorithms", because I believe that there should be an algorithm which gives better results. I think that it should be an algorithm which uses "dynamic programming". Thank you in advance :)
2016/11/21
[ "https://Stackoverflow.com/questions/40721107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1085722/" ]
In this particular instance you get maximum benefit by minimizing the free space in the bag and therefore by considering *weight as a value*. This problem is commonly referred to as [subset sum problem](http://marcodiiga.github.io/knapsack-problem) and is a particular case of knapsack problems family. The DP relation looks like the following [![enter image description here](https://i.stack.imgur.com/AiqMc.png)](https://i.stack.imgur.com/AiqMc.png) where at each step you try to find the maximum value (which does not exceed the bag's capacity) among the previous elements set plus the new element A C++ implementation of the subset sum problem to answer the question "can I fill the bag entirely given these elements?" and driver follows ``` bool ssp(const vector<int>& v, const int& N) { vector<vector<int>> m( v.size() + 1 /* 1-based */, vector<int>(N + 1 /* 1-based */, 0) ); // The line above also took care of the initialization for base // cases f(i,0) = 0 and f(0,b) = 0 for (int i = 1; i <= v.size(); ++i) { // For each subset of elements for (int b = 1; b <= N; ++b) { // For each subcapacity int opt1 = m[i - 1][b]; int opt2 = -1; if (b - v[i - 1] >= 0) { // No caching to keep this readable opt2 = m[i - 1][b - v[i - 1]] + v[i - 1]; if (opt2 > b) opt2 = -1; // Not allowed } m[i][b] = max(opt1, opt2); } } return (m[v.size()][N] == N); } int main() { const vector<int> v = { 1, 3, 7, 4 }; const int N = 11; cout << "Subset sum problem can be solved with the given input: " << boolalpha << ssp(v, N); // true return 0; } ``` The complexity is `O(N⋅I)` where `I` is the number of elements in the starting set. This is a pseudopolynomial complexity. Source: [Knapsack problem](http://marcodiiga.github.io/knapsack-problem)
The described problem in fact is not the [0-1-Knapsack problem](https://en.wikipedia.org/wiki/Knapsack_problem), but a special case thereof, also called the Maximum Subset Sum problem, which is desribed [here](https://en.wikipedia.org/wiki/Subset_sum_problem). It is `NP`-complete, which means that it is not easier than 0-1-Knapsack complexity-wise. That being said, it can be solved by any optimization algorithm intended for the 0-1-Knapsack problem by setting the item profits equal to their weights. In total, it can be solved to optimality using the following dynamic programming algorithm; `s[i]` denotes the size if the `i`-th item and `m` is an integer-valued state space where `m[i,s]` denotes the maximum value attainable by using items from the item rage `{0,...i}`. ``` for j from 0 to W do: m[0, j] := 0 for i from 1 to n do: for j from 0 to W do: if s[i] > j then: m[i, j] := m[i-1, j] else: m[i, j] := max(m[i-1, j], m[i-1, j-s[i]] + s[i]) ``` As they are mentioned in the original question, the following greedy algorithm yields a 2-approximation, which is a modification of a similar algorithm for the Knapsack problem. ``` 1. select any subset of the items such that there is no other item which can be feasibly chosen 2. select the largest item 3. out of 1. and 2., choose the subset which yields the larger total size ```
40,721,107
I am working on some task which requires from me to solve the following algorithmic problem: --- - You Have collection of items (their weights): [w1, w2, ..., wn] - And You have a bag which weight is: W - It is Needed to fill the bag maximally (fill as much as possible) with the subset of given items. --- So this **is not** "Knapsack 0/1" problem, as we deal only with weights (we have only one parameter for item). Therefore I assume that it might have a solution (Knapsack is NP-complete) or some kind of algorithm which gives approximately correct result. Please don't suggest me "greedy algorithms", because I believe that there should be an algorithm which gives better results. I think that it should be an algorithm which uses "dynamic programming". Thank you in advance :)
2016/11/21
[ "https://Stackoverflow.com/questions/40721107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1085722/" ]
The described problem in fact is not the [0-1-Knapsack problem](https://en.wikipedia.org/wiki/Knapsack_problem), but a special case thereof, also called the Maximum Subset Sum problem, which is desribed [here](https://en.wikipedia.org/wiki/Subset_sum_problem). It is `NP`-complete, which means that it is not easier than 0-1-Knapsack complexity-wise. That being said, it can be solved by any optimization algorithm intended for the 0-1-Knapsack problem by setting the item profits equal to their weights. In total, it can be solved to optimality using the following dynamic programming algorithm; `s[i]` denotes the size if the `i`-th item and `m` is an integer-valued state space where `m[i,s]` denotes the maximum value attainable by using items from the item rage `{0,...i}`. ``` for j from 0 to W do: m[0, j] := 0 for i from 1 to n do: for j from 0 to W do: if s[i] > j then: m[i, j] := m[i-1, j] else: m[i, j] := max(m[i-1, j], m[i-1, j-s[i]] + s[i]) ``` As they are mentioned in the original question, the following greedy algorithm yields a 2-approximation, which is a modification of a similar algorithm for the Knapsack problem. ``` 1. select any subset of the items such that there is no other item which can be feasibly chosen 2. select the largest item 3. out of 1. and 2., choose the subset which yields the larger total size ```
It look like [Spoj problem](https://www.spoj.com/ABC2019/problems/ACMNEW1/). And my solusion to solve: ``` #include <bits/stdc++.h> using namespace std; int TimTongLonNhatCoGioiHan(int*arr, int songuoichoi, int gioihan){ int hmm = (int)(songuoichoi*songuoichoi/2); int map[hmm]; int dem = 0, i, j, ox = songuoichoi - 1, oy = 0, result = 0, sum; for(i = ox; i > oy; --i){ for(j = oy; j < ox; ++j){ map[dem] = arr[i] + arr[j]; // tinh tong lon nhat cua 3 so for(int k = 0; k < songuoichoi; ++k){ if(k == j || k == i) continue; sum = map[dem] + arr[k]; if(sum > result && sum <= gioihan) result = sum; } dem++; } -- ox; } return result; } int main() { int sophantu = 0, songuoichoi = 0, gioihan = 0; cin>>sophantu; while(sophantu-->0){ cin>>songuoichoi; int i = 0; int arrCanNang[songuoichoi]; for(; i<songuoichoi; ++i){ cin>>arrCanNang[i]; } cin>>gioihan; cout<<TimTongLonNhatCoGioiHan(arrCanNang, songuoichoi, gioihan)<<"\n"; } return 0; } ``` For simple, you can create a matrix [w1, w2, ..., wn] x [w1, w2, ..., wn], put sum(Wi, Wj), foreach k and find MAX sum(Wi, Wj) + Wk.
40,721,107
I am working on some task which requires from me to solve the following algorithmic problem: --- - You Have collection of items (their weights): [w1, w2, ..., wn] - And You have a bag which weight is: W - It is Needed to fill the bag maximally (fill as much as possible) with the subset of given items. --- So this **is not** "Knapsack 0/1" problem, as we deal only with weights (we have only one parameter for item). Therefore I assume that it might have a solution (Knapsack is NP-complete) or some kind of algorithm which gives approximately correct result. Please don't suggest me "greedy algorithms", because I believe that there should be an algorithm which gives better results. I think that it should be an algorithm which uses "dynamic programming". Thank you in advance :)
2016/11/21
[ "https://Stackoverflow.com/questions/40721107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1085722/" ]
In this particular instance you get maximum benefit by minimizing the free space in the bag and therefore by considering *weight as a value*. This problem is commonly referred to as [subset sum problem](http://marcodiiga.github.io/knapsack-problem) and is a particular case of knapsack problems family. The DP relation looks like the following [![enter image description here](https://i.stack.imgur.com/AiqMc.png)](https://i.stack.imgur.com/AiqMc.png) where at each step you try to find the maximum value (which does not exceed the bag's capacity) among the previous elements set plus the new element A C++ implementation of the subset sum problem to answer the question "can I fill the bag entirely given these elements?" and driver follows ``` bool ssp(const vector<int>& v, const int& N) { vector<vector<int>> m( v.size() + 1 /* 1-based */, vector<int>(N + 1 /* 1-based */, 0) ); // The line above also took care of the initialization for base // cases f(i,0) = 0 and f(0,b) = 0 for (int i = 1; i <= v.size(); ++i) { // For each subset of elements for (int b = 1; b <= N; ++b) { // For each subcapacity int opt1 = m[i - 1][b]; int opt2 = -1; if (b - v[i - 1] >= 0) { // No caching to keep this readable opt2 = m[i - 1][b - v[i - 1]] + v[i - 1]; if (opt2 > b) opt2 = -1; // Not allowed } m[i][b] = max(opt1, opt2); } } return (m[v.size()][N] == N); } int main() { const vector<int> v = { 1, 3, 7, 4 }; const int N = 11; cout << "Subset sum problem can be solved with the given input: " << boolalpha << ssp(v, N); // true return 0; } ``` The complexity is `O(N⋅I)` where `I` is the number of elements in the starting set. This is a pseudopolynomial complexity. Source: [Knapsack problem](http://marcodiiga.github.io/knapsack-problem)
It look like [Spoj problem](https://www.spoj.com/ABC2019/problems/ACMNEW1/). And my solusion to solve: ``` #include <bits/stdc++.h> using namespace std; int TimTongLonNhatCoGioiHan(int*arr, int songuoichoi, int gioihan){ int hmm = (int)(songuoichoi*songuoichoi/2); int map[hmm]; int dem = 0, i, j, ox = songuoichoi - 1, oy = 0, result = 0, sum; for(i = ox; i > oy; --i){ for(j = oy; j < ox; ++j){ map[dem] = arr[i] + arr[j]; // tinh tong lon nhat cua 3 so for(int k = 0; k < songuoichoi; ++k){ if(k == j || k == i) continue; sum = map[dem] + arr[k]; if(sum > result && sum <= gioihan) result = sum; } dem++; } -- ox; } return result; } int main() { int sophantu = 0, songuoichoi = 0, gioihan = 0; cin>>sophantu; while(sophantu-->0){ cin>>songuoichoi; int i = 0; int arrCanNang[songuoichoi]; for(; i<songuoichoi; ++i){ cin>>arrCanNang[i]; } cin>>gioihan; cout<<TimTongLonNhatCoGioiHan(arrCanNang, songuoichoi, gioihan)<<"\n"; } return 0; } ``` For simple, you can create a matrix [w1, w2, ..., wn] x [w1, w2, ..., wn], put sum(Wi, Wj), foreach k and find MAX sum(Wi, Wj) + Wk.
4,484
*Disclaimer: I am going to mention the investment company that I am using, but I am not related in any way with this company, is just to exemplify my question.* --- I am currently using [foliofn.com](http://www.foliofn.com). They charge $290 per year, for unlimited window trading. You can trade ETF, Mutual Funds, Stocks and others. I am trying to find what is my effect percentage fee for my investment. If I pay 290 per year, and I have 10K in investments (example), the normal calculation will be 290/10,000 = 0.029 = 2.9% Now, the problem is that I have heard that mutual funds have their own fees, so if I have a mutual fund on my portfolio, then how I will make this calculation? I guess there are two questions in this essay: (1) Is my assumption of $290/10K = 2.9% correct? (2) How do I calculate additional fees within my portfolio to know my effective fee rate? Thanks.
2010/11/13
[ "https://money.stackexchange.com/questions/4484", "https://money.stackexchange.com", "https://money.stackexchange.com/users/1635/" ]
Because most people aren't willing to sacrifice their ability to live in the US for 100k. Remember that you can't pull this off multiple times easily. So as a one and done kind of deal, 100k isn't a great trade for the right to live in tthe US or whatever country you have roots in, particularly once you factor in: * If you have 100k in credit on cards, you are likely well-employed with some savings * you can't easily convert that credit to cash. Sure, you can try to buy gift cards and whatnot, but they may not be accepted at Casa de Honduras Hotel for Refugees, and it's not like you can pay with the cc cards- once you stop paying and go on the lam, they'll cut you off.
Quality of life, success and happiness are three factors that are self define by each individual. Most of the time all three factors go hand by hand with your ability to generate wealth and save. Actually, a recent study showed that there were more happy families with savings than with expensive products (car, jewelry and others). These 3 factors, will be very difficult to maintain after someone commit such action. First, because you will fear every interaction with the origin of the money. Second, because every individual has a notion of wrong doing. Third, for the reasons that Jaydles express. Also, most cards, will call you and stop the cards ability to give money, if they see an abusive pattern. Ether, skipping your country has some adverse psychological impact in the family and individual that most of the time 100K is not enough to motivate such change. Thanks for reading. Geo
4,484
*Disclaimer: I am going to mention the investment company that I am using, but I am not related in any way with this company, is just to exemplify my question.* --- I am currently using [foliofn.com](http://www.foliofn.com). They charge $290 per year, for unlimited window trading. You can trade ETF, Mutual Funds, Stocks and others. I am trying to find what is my effect percentage fee for my investment. If I pay 290 per year, and I have 10K in investments (example), the normal calculation will be 290/10,000 = 0.029 = 2.9% Now, the problem is that I have heard that mutual funds have their own fees, so if I have a mutual fund on my portfolio, then how I will make this calculation? I guess there are two questions in this essay: (1) Is my assumption of $290/10K = 2.9% correct? (2) How do I calculate additional fees within my portfolio to know my effective fee rate? Thanks.
2010/11/13
[ "https://money.stackexchange.com/questions/4484", "https://money.stackexchange.com", "https://money.stackexchange.com/users/1635/" ]
It's harder than you think. Once card companies start seeing your debt to credit line ratios climb, they will slash your credit lines quickly. Also, cash credit lines are always much smaller, so in reality, such a scheme would require you to buy goods that can be converted to cash, which dilutes your gains and makes it more likely that you're going to get detected and busted. Think of the other problems. Where do you store your ill-gotten gains? How do you get the money out of the country? How will your actions affect your family and friends? Also, most people are basically good people -- the prospect of defrauding $100k, leaving family and friends behind and living some anonymous life in a third world country isn't an appealing one. If you are criminally inclined, building up a great credit history is not very practical -- most criminals are by nature reactive and want quick results.
Because most people aren't willing to sacrifice their ability to live in the US for 100k. Remember that you can't pull this off multiple times easily. So as a one and done kind of deal, 100k isn't a great trade for the right to live in tthe US or whatever country you have roots in, particularly once you factor in: * If you have 100k in credit on cards, you are likely well-employed with some savings * you can't easily convert that credit to cash. Sure, you can try to buy gift cards and whatnot, but they may not be accepted at Casa de Honduras Hotel for Refugees, and it's not like you can pay with the cc cards- once you stop paying and go on the lam, they'll cut you off.
4,484
*Disclaimer: I am going to mention the investment company that I am using, but I am not related in any way with this company, is just to exemplify my question.* --- I am currently using [foliofn.com](http://www.foliofn.com). They charge $290 per year, for unlimited window trading. You can trade ETF, Mutual Funds, Stocks and others. I am trying to find what is my effect percentage fee for my investment. If I pay 290 per year, and I have 10K in investments (example), the normal calculation will be 290/10,000 = 0.029 = 2.9% Now, the problem is that I have heard that mutual funds have their own fees, so if I have a mutual fund on my portfolio, then how I will make this calculation? I guess there are two questions in this essay: (1) Is my assumption of $290/10K = 2.9% correct? (2) How do I calculate additional fees within my portfolio to know my effective fee rate? Thanks.
2010/11/13
[ "https://money.stackexchange.com/questions/4484", "https://money.stackexchange.com", "https://money.stackexchange.com/users/1635/" ]
It's harder than you think. Once card companies start seeing your debt to credit line ratios climb, they will slash your credit lines quickly. Also, cash credit lines are always much smaller, so in reality, such a scheme would require you to buy goods that can be converted to cash, which dilutes your gains and makes it more likely that you're going to get detected and busted. Think of the other problems. Where do you store your ill-gotten gains? How do you get the money out of the country? How will your actions affect your family and friends? Also, most people are basically good people -- the prospect of defrauding $100k, leaving family and friends behind and living some anonymous life in a third world country isn't an appealing one. If you are criminally inclined, building up a great credit history is not very practical -- most criminals are by nature reactive and want quick results.
Quality of life, success and happiness are three factors that are self define by each individual. Most of the time all three factors go hand by hand with your ability to generate wealth and save. Actually, a recent study showed that there were more happy families with savings than with expensive products (car, jewelry and others). These 3 factors, will be very difficult to maintain after someone commit such action. First, because you will fear every interaction with the origin of the money. Second, because every individual has a notion of wrong doing. Third, for the reasons that Jaydles express. Also, most cards, will call you and stop the cards ability to give money, if they see an abusive pattern. Ether, skipping your country has some adverse psychological impact in the family and individual that most of the time 100K is not enough to motivate such change. Thanks for reading. Geo
4,484
*Disclaimer: I am going to mention the investment company that I am using, but I am not related in any way with this company, is just to exemplify my question.* --- I am currently using [foliofn.com](http://www.foliofn.com). They charge $290 per year, for unlimited window trading. You can trade ETF, Mutual Funds, Stocks and others. I am trying to find what is my effect percentage fee for my investment. If I pay 290 per year, and I have 10K in investments (example), the normal calculation will be 290/10,000 = 0.029 = 2.9% Now, the problem is that I have heard that mutual funds have their own fees, so if I have a mutual fund on my portfolio, then how I will make this calculation? I guess there are two questions in this essay: (1) Is my assumption of $290/10K = 2.9% correct? (2) How do I calculate additional fees within my portfolio to know my effective fee rate? Thanks.
2010/11/13
[ "https://money.stackexchange.com/questions/4484", "https://money.stackexchange.com", "https://money.stackexchange.com/users/1635/" ]
Even if you could get it with no major hassle, $100,000 is just **not that much money**. In a cheap third world country, as an expat you're looking at spending about $800-$2000/month, plus unexpected expenses. Locals live on less, but very few of us would be happy with the lifestyle of a Honduran or Thai farmer. Your 100k will last 4-10 years. This is hardly a great deal considering you're cutting off ties back home and almost becoming a fugitive. With USD going down the drain (e.g. in Thailand it went down 25% in 3 years), this period would probably be even shorter. Of course, you could work in the new country, but if you do then you don't need 100k to start with. The initial amount may improve your security, but from that standpoint being able to go back and work in your home country is worth more.
Quality of life, success and happiness are three factors that are self define by each individual. Most of the time all three factors go hand by hand with your ability to generate wealth and save. Actually, a recent study showed that there were more happy families with savings than with expensive products (car, jewelry and others). These 3 factors, will be very difficult to maintain after someone commit such action. First, because you will fear every interaction with the origin of the money. Second, because every individual has a notion of wrong doing. Third, for the reasons that Jaydles express. Also, most cards, will call you and stop the cards ability to give money, if they see an abusive pattern. Ether, skipping your country has some adverse psychological impact in the family and individual that most of the time 100K is not enough to motivate such change. Thanks for reading. Geo
4,484
*Disclaimer: I am going to mention the investment company that I am using, but I am not related in any way with this company, is just to exemplify my question.* --- I am currently using [foliofn.com](http://www.foliofn.com). They charge $290 per year, for unlimited window trading. You can trade ETF, Mutual Funds, Stocks and others. I am trying to find what is my effect percentage fee for my investment. If I pay 290 per year, and I have 10K in investments (example), the normal calculation will be 290/10,000 = 0.029 = 2.9% Now, the problem is that I have heard that mutual funds have their own fees, so if I have a mutual fund on my portfolio, then how I will make this calculation? I guess there are two questions in this essay: (1) Is my assumption of $290/10K = 2.9% correct? (2) How do I calculate additional fees within my portfolio to know my effective fee rate? Thanks.
2010/11/13
[ "https://money.stackexchange.com/questions/4484", "https://money.stackexchange.com", "https://money.stackexchange.com/users/1635/" ]
I take it the premise of the question is that we're assuming the person isn't worried about the morals. He's a criminal out for a quick buck. And I guess we're assuming that wherever you go, they wouldn't arrest you and extradite you back to the U.S. As others have noted, you can't just walk into a bank the day you graduate high school or get out of prison or whatever and get a credit line of $100,000. You have to build up to that with an income and a pattern of responsible behavior over a period of many years. I don't have the statistics handy but I'd guess most people never reach a credit limit on credit cards of $100,000. Maybe many people could get that on a home equity line of credit, but again, you'd have to build up that equity in your house first, and that would take many years. Then, while $100,000 sounds like a lot of money, how long could you really live on that? Even in a country with low cost of living, it's not like you could live in luxury for the rest of your life. If you can get that kind of credit limit, you probably are used to living on a healthy income. Sure, you could get a similar lifestyle for less in some other countries, but not for THAT much less. If you know a place where for $10,000 a year you can live a life that would cost $100,000 per year in the U.S., I'd like to know about it. Even living a relatively frugal life, I doubt the money would last more than 4 or 5 years. And then what are you going to do? If you come back to the U.S. you'd presumably be promptly arrested. You could get a job in your new country, but you could have done that without first stealing $100,000. Frankly, if you're the sort of person who can get a $100,000 credit limit, you probably can live a lot better in the U.S. by continuing to work and play by the rules than you could by stealing $100,000 and fleeing to Haiti or Eritrea. You might say, okay, $100,000 isn't really enough. What if I could get a $1 million credit limit? But if you have the income and credit rating to get a $1 million credit limit, you probably are making at least several hundred thousand per year, probably a million or more, and again, you're better off to continue to play by the rules. The only way that I see that a scam like this would really work is if you could get a credit limit way out of proportion to any income you could earn legitimately. Like somehow if you could convince the bank to give you a credit limit of $1 million even though you only make $15,000 a year. But that would be a scam in itself. That's why I think the only time you do hear of people trying something like this is when they USED to make a lot of money but have lost it. Like someone has a multi-million dollar business that goes broke, he now has nothing, so before the bank figures it out he maxes out all his credit and runs off.
Quality of life, success and happiness are three factors that are self define by each individual. Most of the time all three factors go hand by hand with your ability to generate wealth and save. Actually, a recent study showed that there were more happy families with savings than with expensive products (car, jewelry and others). These 3 factors, will be very difficult to maintain after someone commit such action. First, because you will fear every interaction with the origin of the money. Second, because every individual has a notion of wrong doing. Third, for the reasons that Jaydles express. Also, most cards, will call you and stop the cards ability to give money, if they see an abusive pattern. Ether, skipping your country has some adverse psychological impact in the family and individual that most of the time 100K is not enough to motivate such change. Thanks for reading. Geo
4,484
*Disclaimer: I am going to mention the investment company that I am using, but I am not related in any way with this company, is just to exemplify my question.* --- I am currently using [foliofn.com](http://www.foliofn.com). They charge $290 per year, for unlimited window trading. You can trade ETF, Mutual Funds, Stocks and others. I am trying to find what is my effect percentage fee for my investment. If I pay 290 per year, and I have 10K in investments (example), the normal calculation will be 290/10,000 = 0.029 = 2.9% Now, the problem is that I have heard that mutual funds have their own fees, so if I have a mutual fund on my portfolio, then how I will make this calculation? I guess there are two questions in this essay: (1) Is my assumption of $290/10K = 2.9% correct? (2) How do I calculate additional fees within my portfolio to know my effective fee rate? Thanks.
2010/11/13
[ "https://money.stackexchange.com/questions/4484", "https://money.stackexchange.com", "https://money.stackexchange.com/users/1635/" ]
It's harder than you think. Once card companies start seeing your debt to credit line ratios climb, they will slash your credit lines quickly. Also, cash credit lines are always much smaller, so in reality, such a scheme would require you to buy goods that can be converted to cash, which dilutes your gains and makes it more likely that you're going to get detected and busted. Think of the other problems. Where do you store your ill-gotten gains? How do you get the money out of the country? How will your actions affect your family and friends? Also, most people are basically good people -- the prospect of defrauding $100k, leaving family and friends behind and living some anonymous life in a third world country isn't an appealing one. If you are criminally inclined, building up a great credit history is not very practical -- most criminals are by nature reactive and want quick results.
Even if you could get it with no major hassle, $100,000 is just **not that much money**. In a cheap third world country, as an expat you're looking at spending about $800-$2000/month, plus unexpected expenses. Locals live on less, but very few of us would be happy with the lifestyle of a Honduran or Thai farmer. Your 100k will last 4-10 years. This is hardly a great deal considering you're cutting off ties back home and almost becoming a fugitive. With USD going down the drain (e.g. in Thailand it went down 25% in 3 years), this period would probably be even shorter. Of course, you could work in the new country, but if you do then you don't need 100k to start with. The initial amount may improve your security, but from that standpoint being able to go back and work in your home country is worth more.
4,484
*Disclaimer: I am going to mention the investment company that I am using, but I am not related in any way with this company, is just to exemplify my question.* --- I am currently using [foliofn.com](http://www.foliofn.com). They charge $290 per year, for unlimited window trading. You can trade ETF, Mutual Funds, Stocks and others. I am trying to find what is my effect percentage fee for my investment. If I pay 290 per year, and I have 10K in investments (example), the normal calculation will be 290/10,000 = 0.029 = 2.9% Now, the problem is that I have heard that mutual funds have their own fees, so if I have a mutual fund on my portfolio, then how I will make this calculation? I guess there are two questions in this essay: (1) Is my assumption of $290/10K = 2.9% correct? (2) How do I calculate additional fees within my portfolio to know my effective fee rate? Thanks.
2010/11/13
[ "https://money.stackexchange.com/questions/4484", "https://money.stackexchange.com", "https://money.stackexchange.com/users/1635/" ]
It's harder than you think. Once card companies start seeing your debt to credit line ratios climb, they will slash your credit lines quickly. Also, cash credit lines are always much smaller, so in reality, such a scheme would require you to buy goods that can be converted to cash, which dilutes your gains and makes it more likely that you're going to get detected and busted. Think of the other problems. Where do you store your ill-gotten gains? How do you get the money out of the country? How will your actions affect your family and friends? Also, most people are basically good people -- the prospect of defrauding $100k, leaving family and friends behind and living some anonymous life in a third world country isn't an appealing one. If you are criminally inclined, building up a great credit history is not very practical -- most criminals are by nature reactive and want quick results.
I take it the premise of the question is that we're assuming the person isn't worried about the morals. He's a criminal out for a quick buck. And I guess we're assuming that wherever you go, they wouldn't arrest you and extradite you back to the U.S. As others have noted, you can't just walk into a bank the day you graduate high school or get out of prison or whatever and get a credit line of $100,000. You have to build up to that with an income and a pattern of responsible behavior over a period of many years. I don't have the statistics handy but I'd guess most people never reach a credit limit on credit cards of $100,000. Maybe many people could get that on a home equity line of credit, but again, you'd have to build up that equity in your house first, and that would take many years. Then, while $100,000 sounds like a lot of money, how long could you really live on that? Even in a country with low cost of living, it's not like you could live in luxury for the rest of your life. If you can get that kind of credit limit, you probably are used to living on a healthy income. Sure, you could get a similar lifestyle for less in some other countries, but not for THAT much less. If you know a place where for $10,000 a year you can live a life that would cost $100,000 per year in the U.S., I'd like to know about it. Even living a relatively frugal life, I doubt the money would last more than 4 or 5 years. And then what are you going to do? If you come back to the U.S. you'd presumably be promptly arrested. You could get a job in your new country, but you could have done that without first stealing $100,000. Frankly, if you're the sort of person who can get a $100,000 credit limit, you probably can live a lot better in the U.S. by continuing to work and play by the rules than you could by stealing $100,000 and fleeing to Haiti or Eritrea. You might say, okay, $100,000 isn't really enough. What if I could get a $1 million credit limit? But if you have the income and credit rating to get a $1 million credit limit, you probably are making at least several hundred thousand per year, probably a million or more, and again, you're better off to continue to play by the rules. The only way that I see that a scam like this would really work is if you could get a credit limit way out of proportion to any income you could earn legitimately. Like somehow if you could convince the bank to give you a credit limit of $1 million even though you only make $15,000 a year. But that would be a scam in itself. That's why I think the only time you do hear of people trying something like this is when they USED to make a lot of money but have lost it. Like someone has a multi-million dollar business that goes broke, he now has nothing, so before the bank figures it out he maxes out all his credit and runs off.
49,074,058
Hy everyone, my Visual Studio (2017) shows me an error in my Xamarin Forms project. I have developed an application (that uses some external packeges) and, from quite some time, i have an error that says: > > Error NU1201: Project "projectname".App.Android is not compatible with xamarinios10 (Xamarin.iOS,Version=v1.0)/win-x86. Project "projectname".App.Android supports: monoandroid80 (MonoAndroid,Version=v8.0) > > > I can't understand why i get this error, that seems to influence the installation of NuGet packages in the iOS project (it fails everytime). The execution of the Android app doesn't have any problem, i can't try the iOS one at the moment, i am waiting for the key. If someone had ever seen this error i'd like to have some help, thank you!
2018/03/02
[ "https://Stackoverflow.com/questions/49074058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9229947/" ]
Solved by myself, somehow Visual Studio had added some kind of dependecy in the iOS project to the Android one, making it (obviously) incompatible. Visual Studio initialiy blocked me from removing it, i had to remove the dependency manually from the iOS ".csproj" and reload the solution. Hope it helps if this happenes to someone else.
I got same issue because I tried to import a package designed for Android , not for iOS .
38,572,127
I'm a newbie to data warehousing and I've been reading articles and watching videos on the principles but I'm a bit confused as to how I would take the design below and convert it into a star schema. In all the examples I've seen the fact table references the dim tables, so I'm assuming the questionId and responseId would be part of the fact table? Any advice would be much appreciated. [![enter image description here](https://i.stack.imgur.com/ivAAj.png)](https://i.stack.imgur.com/ivAAj.png)
2016/07/25
[ "https://Stackoverflow.com/questions/38572127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/260246/" ]
I can't see the image at the moment (blocked by my firewall @ the office). but I'll try to give you some ideas. The general idea is to organize your measurable 'facts' into what are called fact tables. There are 3 main types of facts, but that is a topic for a different day (but I'd be happy to go into this if needed). Each of these facts are what you'd see in the center of typical 'star schema'. The other attributes within the fact tables are typically FK references to the dimension tables. Regarding dimensions, these are groups of attributes that share commonality (the most notable being a calendar dimension). This is important because when you're doing analysis across multiple facts the dimensions are what you use to connect them. If you consider this simple example: A product is ordered and then shipped. We could have 2 transaction facts (one that contains the qty ordered - measure, type of product ordered - dimension, and transaction date - dimension). We'd also have a transaction fact for the product shipping ( qty shipped - measure, product type - dimension, and ship date - dimension). This simple schema could be used to answer questions like 'how many products by product type last quarter were ordered but not shipped'. Hopefully this helps you get started.
Usually a fact table is used to aggregate measures - which are always numeric. Examples would be: sales dollars, distances, weights, number of items sold. The type of data you drew here doesn't have any cut and dry "measure" so you need to decide what you want to measure. Is the number of answers per question? Is it how many responses per sample? This is often called an Event Fact table (if you want to search for other examples). And you need some sort of reporting requirements before you can turn it into a star schema. So it isn't an easy answer...
38,572,127
I'm a newbie to data warehousing and I've been reading articles and watching videos on the principles but I'm a bit confused as to how I would take the design below and convert it into a star schema. In all the examples I've seen the fact table references the dim tables, so I'm assuming the questionId and responseId would be part of the fact table? Any advice would be much appreciated. [![enter image description here](https://i.stack.imgur.com/ivAAj.png)](https://i.stack.imgur.com/ivAAj.png)
2016/07/25
[ "https://Stackoverflow.com/questions/38572127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/260246/" ]
I can't see the image at the moment (blocked by my firewall @ the office). but I'll try to give you some ideas. The general idea is to organize your measurable 'facts' into what are called fact tables. There are 3 main types of facts, but that is a topic for a different day (but I'd be happy to go into this if needed). Each of these facts are what you'd see in the center of typical 'star schema'. The other attributes within the fact tables are typically FK references to the dimension tables. Regarding dimensions, these are groups of attributes that share commonality (the most notable being a calendar dimension). This is important because when you're doing analysis across multiple facts the dimensions are what you use to connect them. If you consider this simple example: A product is ordered and then shipped. We could have 2 transaction facts (one that contains the qty ordered - measure, type of product ordered - dimension, and transaction date - dimension). We'd also have a transaction fact for the product shipping ( qty shipped - measure, product type - dimension, and ship date - dimension). This simple schema could be used to answer questions like 'how many products by product type last quarter were ordered but not shipped'. Hopefully this helps you get started.
It's so easy :) Responses is fact, all other is dimensions. And your schema is now star designed, because you can directly connect fact with all dimensions. Example, when you need to redesign its structure where addresses stored in separate table and related with sample. You must add address table id into responses table for get star schema.
49,046,773
For my Android project, I need global singleton Cache object to access data about a user through the app. A problem occurs when an app goes into the background and after some time of using other apps I try to open app variables in Cache objects are null. Everything is okay when I kill the app and open it again. I'm using dependency injection to access Cache object. Why doesn't app start again if that happened? Is there some annotation to keep cache variable even in low memory conditions? This is my Cache class ``` class Cache { var categories : Array<BaseResponse.Category>? = null var user : BaseResponse.User? = null var options : BaseResponse.OptionsMap? = null var order: MenuOrderDataModel? = null } ``` This is Storage module for DI ``` @Module class StorageModule { @Singleton @Provides fun getSharedPrefs(context: Context): SharedPreferences { return PreferenceManager.getDefaultSharedPreferences(context) } @Singleton @Provides fun getCache() : Cache = Cache() } ``` I inject object `@Inject lateinit var cache: Cache` and then populate with user data in splash screen. Edit - added code snippets from Application and launch activity ``` class MyApp : Application() { val component: ApplicationComponent by lazy { DaggerApplicationComponent .builder() .appModule(AppModule(this)) .build() } companion object { @JvmStatic lateinit var myapp: MyApp } override fun onCreate() { super.onCreate() myapp= this Fabric.with(this, Crashlytics()) } } ``` Splash activity: ``` class SplashActivity : AppCompatActivity(), View.OnClickListener { @Inject lateinit var viewModel : ISplashViewModel private lateinit var disposable : Disposable override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_splash) MyApp.myapp.component.inject(this) } ```
2018/03/01
[ "https://Stackoverflow.com/questions/49046773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3984177/" ]
You're getting crashes because you initialize those variables in one Activity, and expect it to be set always, in the other Activity. But Android doesn't work like that, you can easily end up crashing because after low memory condition happens, only the *current* Activity gets recreated at first, previous Activity is recreated on back navigation, and all static variables are nulled out (because the process is technically restarted). Try it out: * **put your application in background with HOME button** * click the **TERMINATE button on Logcat tab** [![terminate button](https://i.stack.imgur.com/n3o3n.png)](https://i.stack.imgur.com/n3o3n.png) * then **re-launch the app from the launcher.** You'll experience this phenomenon. ***In Android Studio 4.0, after you use `Run` from Android Studio instead of starting the app from launcher, the Terminate button SOMETIMES works a bit differently and MIGHT force-stop your app making it forget your task state on your attempt. In that case, just try again, launching the app from launcher. It will work on your second try.*** You can also trigger the "Terminate Application" behavior from the terminal, as per <https://codelabs.developers.google.com/codelabs/android-lifecycles/#6>, it looks like this: ``` $ adb shell am kill your.app.package.name ``` --- In the new Logcat (Android Studio Electric Eel and above), the "terminate process" button is removed, and was moved into the Device Monitor tab ("Kill Process"). [![enter image description here](https://i.stack.imgur.com/q8lGk.png)](https://i.stack.imgur.com/q8lGk.png) --- Solution: check for nulls and re-initialize things in a base activity (or in LiveData.onActive), or use `onSaveInstanceState`.
I would like to expand on @EpicPandaForce answer with implementation details using savedInstanceState and SavedStateHandle. 
Official documentation: <https://developer.android.com/topic/libraries/architecture/viewmodel/viewmodel-savedstate> Note that I’m using Koin for dependency injection. Inject your viewModel inside your Activity as stateViewModel: `val viewModel: MyActivityViewModel by stateViewModel(state = { Bundle() })` That way you can inject SavedStateHandle inside ViewModel and handle storing and restoring data inside it. Override onPause method in your Activity that will be opened after the process is killed so you can storeState at that moment. ``` override fun onPause() { super.onPause() viewModel.storeState() } ``` Store all properties you don’t want to become null after the process is killed. An object has to be parcelable. `savedStateHandle.set(STATE_KEY, yourProperty)` In the onCreate method, you will check if savedInstanceState is not null so you can restore the state. ``` override fun onCreate(savedInstanceState: Bundle?) { setTheme(R.style.AppTheme) super.onCreate(savedInstanceState) if (savedInstanceState != null) { viewModel.restoreState() } } ``` Reinit your property and remove that value from savedStateHandle ``` fun restoreState() { yourProperty = savedStateHandle.get<Any>(STATE_KEY) savedStateHandle.remove<Any>(STATE_KEY) } ```
67,713
Suppose I have a regular rectangular weighted grid with multiple agents and obstacles. Agents cannot be in grid sites that contain obstacles, and for simplicity assume multiple agents can be in the same grid site. If I select a single location on the grid and want to find the nearest agent to that location, a good solution is easy: I can simply do a breadth-first (BF) search. However, suppose I have *n* target locations and *m*>=*n* agents. I want to visit the target locations with *n* agents simultaneously. I do not care which agent goes to which location, but the total distance travelled must be minimal. Or, to rephrase, I'm attempting to find a distance-weighted maximum matching for two sets of nodes on a graph. One solution would be to calculate the shortest path from all agents to all targets and then do a bipartite matching. Since the graph may be disconnected by obstacles, this could result in needless multiple sampling of the entire grid space of a connected region. This hardly seems optimal. (Solution 1) I propose the following 'algorithm' (Solution 2): 1. from each target location start a BF search until there is one agent in every target's searched space 2. if the number of unique agents in the searched spaces is less than *n*, continue searching from all target locations 3. if a matching between targets and agents in their respective searched spaces is not possible with full target covering, continue searching from the ~~target locations where covering was not possible and all other target sites that share agents with the uncovered target sites~~ all target locations. 4. the first matching that fulfils step 3 is the solution now I have two questions: 1. is solution 2 optimal, i.e. is it guaranteed that I will select precisely those agents with the least total distance to their assigned targets? I.e. am I not neglecting any agents by not continuing the search for long enough? 2. *if* solution 2 *is* optimal, are there any further ways of reducing the computational complexity?
2016/12/21
[ "https://cs.stackexchange.com/questions/67713", "https://cs.stackexchange.com", "https://cs.stackexchange.com/users/63459/" ]
Read the following paper on the generalization of your problem with "makespan" as the objective. The proposed algorithm should work even if $m\neq n$. H. Ma and S. Koenig. "Optimal Target Assignment and Path Finding for Teams of Agents." <http://idm-lab.org/bib/abstracts/papers/aamas16a.pdf>
No, your proposed algorithm is not correct: it might output a matching that is sub-optimal. Here is a counter example. We have three agents, A, B, and C. We have three targets, T, U, and V. Here are the distances: Distances to T: A: 1, B: 100, C: 101 Distances to U: A: 2, B: 1, C: 3 Distances to V: A: 101, B: 1, C: 100 In the first round of your algorithm, you'll discover the AT, BU, and BV distances, but no complete matching is possible, so you'll continue searching. In the second round, you'll discover the BT, AU, and CV distances. Now a complete matching is possible, and A-T B-U C-V is the minimal matching given the information so far, so your algorithm will output that assignment, for a total cost of 102. However, this isn't the optimal answer; the optimal answer is A-T C-U B-V, for a total cost of 5. So in this example, your algorithm outputs the wrong answer. --- In general, if you have a candidate algorithm like this and you want to know whether it is correct, a good strategy is to test it with random testing. Implement your proposed algorithm, and implement a (slower) golden-reference algorithm that is known to be correct. Now generate a million random small test cases (i.e., random inputs), and run both implementations on each and check that both implementations give the same answer in all cases. If you find any mismatch, you know your algorithm is incorrect and it's back to the drawing board. If you don't find any mismatches, that doesn't prove your algorithm is correct -- but the procedure is still helpful for catching some buggy ideas.
37,378,863
I'm trying to create my first SSAS Tabular model. I'm following the steps mentioned in following tutorial: <https://msdn.microsoft.com/en-us/library/hh231690.aspx> While trying to load the tables to the model, I get the following error: > > Blockquote > > > "!! Relationship: dbo.DimCustomer[GeographyKey]->dbo.DimGeography[GeographyKey] * Status: error * Reason:Object reference not set to an instance of an object. !! Relationship: dbo.FactInternetSales[CustomerKey]->dbo.DimCustomer[CustomerKey] * Status: error * Reason:Object reference not set to an instance of an object. !! Relationship: dbo.FactInternetSales[OrderDateKey]->dbo.DimDate[DateKey] * Status: error * Reason:Object reference not set to an instance of an object. !! Relationship: dbo.FactInternetSales[DueDateKey]->dbo.DimDate[DateKey] * Status: error * Reason:Object reference not set to an instance of an object. !! Relationship: dbo.FactInternetSales[ShipDateKey]->dbo.DimDate[DateKey] * Status: error * Reason:Object reference not set to an instance of an object. !! Relationship: dbo.FactInternetSales[ProductKey]->dbo.DimProduct[ProductKey] * Status: error * Reason:Object reference not set to an instance of an object." > > Blockquote > > > What shall I do to get rid of this error message? I'm using SQL Server 2014 and Visual Studio 2015 (SSDT).
2016/05/22
[ "https://Stackoverflow.com/questions/37378863", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6368443/" ]
this is because SSAS can not process data. I guess it's because of your impersonation setting in your connection. check your connection setting and test it again.
This is probably because your `model.bim` is closed when you're trying to deploy. Change this to having the model open and try again.
25,557,491
I need to match every line where if the line has "event4" then also must have "event70" or "event71", if it doesnt have "event4", match it also. Using Regular expresions. Input: ``` event4,event56,event70 event5, event72 No event number event4,event56 ``` Rows expected to be matched: ``` event4,event56,event70 event5, event72 No event number ``` Regex: ``` preg_match( "/(?:event4,(.*(event70|event71)+)|.*)/", $text, $matches, PREG_OFFSET_CAPTURE); ``` Now is matching all of the rows.
2014/08/28
[ "https://Stackoverflow.com/questions/25557491", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3988152/" ]
As discussed in the comments of the answer by JWK: The images seem to be landscape instead of portrait. Some applications that show an image read extra information from the exif profile of the image to determine the orientation. This was causing some confusion because ImageMagick does not automatically use the information from the exif profile. This can be forced with the auto-orient option. The command should be changed to this: ``` convert source.jpg -auto-orient -resize 200x out.jpg ``` The 200x can also be written as 200 but using 200x or x200 shows better if the width or the height should be resized.
I got this solved. Turned out that the image information of my portrait source file was somehow messed up. I ran the `identify portrait_source.jpg` command and noticed that it had the width and height wrong ( `4320 x 3240` instead of `3240 × 4320`). So basically, ImageMagick thought it was looking at a landscape oriented file when really it was a portrait oriented file. All other programs (OSX Finder, Preview) showed the image in portrait orientation. Simply opening the image in Preview and saving it fixed the image information and after that the resize worked as expected. So, if you run into an issue similar to mine, make sure to check the image information on your source image. I have no idea why the information was wrong in the first place. I used a photo made with a digital camera.
19,428,229
i have this code: ``` List<EditText> someList = new ArrayList<EditText>(); //Let's say we'd like to add 10 EditTexts for(int i = 0; i < 10; i++){ EditText t1 = new EditText(); //The EditText you'd like to add to the list t1.setText("lol"); //Give the EditText the value 'lol' someList.add(t1); //Add the EditText to the list } //Go over the list and get the values for(EditText t : someList){ String val = t.getText(); //Get the value for the temp EditText variable t } ``` i would like to know how can i get the arraylist text with an index number? like: `somelist[2]`
2013/10/17
[ "https://Stackoverflow.com/questions/19428229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1549219/" ]
Something like this should do the trick: ``` int index = 2; EditText et = someList.get(index); Log.d(TAG, et.getText()); ```
try this : ``` EditText t = someList.get(2); String text=t.getText().toString(); ```
19,428,229
i have this code: ``` List<EditText> someList = new ArrayList<EditText>(); //Let's say we'd like to add 10 EditTexts for(int i = 0; i < 10; i++){ EditText t1 = new EditText(); //The EditText you'd like to add to the list t1.setText("lol"); //Give the EditText the value 'lol' someList.add(t1); //Add the EditText to the list } //Go over the list and get the values for(EditText t : someList){ String val = t.getText(); //Get the value for the temp EditText variable t } ``` i would like to know how can i get the arraylist text with an index number? like: `somelist[2]`
2013/10/17
[ "https://Stackoverflow.com/questions/19428229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1549219/" ]
try this : ``` EditText t = someList.get(2); String text=t.getText().toString(); ```
try this ``` EditText text2=someList.get(2); ```
19,428,229
i have this code: ``` List<EditText> someList = new ArrayList<EditText>(); //Let's say we'd like to add 10 EditTexts for(int i = 0; i < 10; i++){ EditText t1 = new EditText(); //The EditText you'd like to add to the list t1.setText("lol"); //Give the EditText the value 'lol' someList.add(t1); //Add the EditText to the list } //Go over the list and get the values for(EditText t : someList){ String val = t.getText(); //Get the value for the temp EditText variable t } ``` i would like to know how can i get the arraylist text with an index number? like: `somelist[2]`
2013/10/17
[ "https://Stackoverflow.com/questions/19428229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1549219/" ]
try this : ``` EditText t = someList.get(2); String text=t.getText().toString(); ```
use this: ``` somelist.get(2); ``` this will return the edittext at the position 2.
19,428,229
i have this code: ``` List<EditText> someList = new ArrayList<EditText>(); //Let's say we'd like to add 10 EditTexts for(int i = 0; i < 10; i++){ EditText t1 = new EditText(); //The EditText you'd like to add to the list t1.setText("lol"); //Give the EditText the value 'lol' someList.add(t1); //Add the EditText to the list } //Go over the list and get the values for(EditText t : someList){ String val = t.getText(); //Get the value for the temp EditText variable t } ``` i would like to know how can i get the arraylist text with an index number? like: `somelist[2]`
2013/10/17
[ "https://Stackoverflow.com/questions/19428229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1549219/" ]
Something like this should do the trick: ``` int index = 2; EditText et = someList.get(index); Log.d(TAG, et.getText()); ```
try this ``` EditText text2=someList.get(2); ```
19,428,229
i have this code: ``` List<EditText> someList = new ArrayList<EditText>(); //Let's say we'd like to add 10 EditTexts for(int i = 0; i < 10; i++){ EditText t1 = new EditText(); //The EditText you'd like to add to the list t1.setText("lol"); //Give the EditText the value 'lol' someList.add(t1); //Add the EditText to the list } //Go over the list and get the values for(EditText t : someList){ String val = t.getText(); //Get the value for the temp EditText variable t } ``` i would like to know how can i get the arraylist text with an index number? like: `somelist[2]`
2013/10/17
[ "https://Stackoverflow.com/questions/19428229", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1549219/" ]
Something like this should do the trick: ``` int index = 2; EditText et = someList.get(index); Log.d(TAG, et.getText()); ```
use this: ``` somelist.get(2); ``` this will return the edittext at the position 2.
9,173,533
``` <html> <head> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ alert('hi'+$("input:text").val()); $("input:not(:empty)").val("sdfdf"); }); }); </script> </head> <body> <input type="text" value="aa" /> <input type="text" value="" /> <input type="text" value="aa" /> <button>Click me</button> </body> </html> ``` i am trying to access empty textboxex using jquery and assigning a value hello to it.. but it's not working . thanks in advance
2012/02/07
[ "https://Stackoverflow.com/questions/9173533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1194147/" ]
[`:empty`](http://api.jquery.com/empty-selector/) checks for whether an element has child elements. `input` elements cannot have child elements. If you want to test that the `input` element's value is blank: ``` $(document).ready(function(){ $("button").click(function(){ $("input").filter(function() { return this.value.length !== 0; }).val("sdfdf"); }); }); ``` There we get all of the `input` elements, and then filter it so only the ones whose `value` property isn't `""` are included.
> > jQuery(':empty') > Description: Select all elements that have no children (including text > nodes). > > > From <http://api.jquery.com/empty-selector/>. Thus `:empty` does not do what you think it does. Have a look at this answer <https://stackoverflow.com/a/1299468/138023> for a solution.
9,173,533
``` <html> <head> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ alert('hi'+$("input:text").val()); $("input:not(:empty)").val("sdfdf"); }); }); </script> </head> <body> <input type="text" value="aa" /> <input type="text" value="" /> <input type="text" value="aa" /> <button>Click me</button> </body> </html> ``` i am trying to access empty textboxex using jquery and assigning a value hello to it.. but it's not working . thanks in advance
2012/02/07
[ "https://Stackoverflow.com/questions/9173533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1194147/" ]
You could use another selector for your task: ``` $("input[value='']").val("sdfdf"); ```
> > jQuery(':empty') > Description: Select all elements that have no children (including text > nodes). > > > From <http://api.jquery.com/empty-selector/>. Thus `:empty` does not do what you think it does. Have a look at this answer <https://stackoverflow.com/a/1299468/138023> for a solution.
9,173,533
``` <html> <head> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ alert('hi'+$("input:text").val()); $("input:not(:empty)").val("sdfdf"); }); }); </script> </head> <body> <input type="text" value="aa" /> <input type="text" value="" /> <input type="text" value="aa" /> <button>Click me</button> </body> </html> ``` i am trying to access empty textboxex using jquery and assigning a value hello to it.. but it's not working . thanks in advance
2012/02/07
[ "https://Stackoverflow.com/questions/9173533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1194147/" ]
> > jQuery(':empty') > Description: Select all elements that have no children (including text > nodes). > > > From <http://api.jquery.com/empty-selector/>. Thus `:empty` does not do what you think it does. Have a look at this answer <https://stackoverflow.com/a/1299468/138023> for a solution.
You could use an .each with this inside: ``` if( $(this).val().length === 0 ) { $(this).parents('p').addClass('warning'); } ```
9,173,533
``` <html> <head> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ alert('hi'+$("input:text").val()); $("input:not(:empty)").val("sdfdf"); }); }); </script> </head> <body> <input type="text" value="aa" /> <input type="text" value="" /> <input type="text" value="aa" /> <button>Click me</button> </body> </html> ``` i am trying to access empty textboxex using jquery and assigning a value hello to it.. but it's not working . thanks in advance
2012/02/07
[ "https://Stackoverflow.com/questions/9173533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1194147/" ]
[`:empty`](http://api.jquery.com/empty-selector/) checks for whether an element has child elements. `input` elements cannot have child elements. If you want to test that the `input` element's value is blank: ``` $(document).ready(function(){ $("button").click(function(){ $("input").filter(function() { return this.value.length !== 0; }).val("sdfdf"); }); }); ``` There we get all of the `input` elements, and then filter it so only the ones whose `value` property isn't `""` are included.
You could use another selector for your task: ``` $("input[value='']").val("sdfdf"); ```
9,173,533
``` <html> <head> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ alert('hi'+$("input:text").val()); $("input:not(:empty)").val("sdfdf"); }); }); </script> </head> <body> <input type="text" value="aa" /> <input type="text" value="" /> <input type="text" value="aa" /> <button>Click me</button> </body> </html> ``` i am trying to access empty textboxex using jquery and assigning a value hello to it.. but it's not working . thanks in advance
2012/02/07
[ "https://Stackoverflow.com/questions/9173533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1194147/" ]
[`:empty`](http://api.jquery.com/empty-selector/) checks for whether an element has child elements. `input` elements cannot have child elements. If you want to test that the `input` element's value is blank: ``` $(document).ready(function(){ $("button").click(function(){ $("input").filter(function() { return this.value.length !== 0; }).val("sdfdf"); }); }); ``` There we get all of the `input` elements, and then filter it so only the ones whose `value` property isn't `""` are included.
You could use an .each with this inside: ``` if( $(this).val().length === 0 ) { $(this).parents('p').addClass('warning'); } ```
9,173,533
``` <html> <head> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ alert('hi'+$("input:text").val()); $("input:not(:empty)").val("sdfdf"); }); }); </script> </head> <body> <input type="text" value="aa" /> <input type="text" value="" /> <input type="text" value="aa" /> <button>Click me</button> </body> </html> ``` i am trying to access empty textboxex using jquery and assigning a value hello to it.. but it's not working . thanks in advance
2012/02/07
[ "https://Stackoverflow.com/questions/9173533", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1194147/" ]
You could use another selector for your task: ``` $("input[value='']").val("sdfdf"); ```
You could use an .each with this inside: ``` if( $(this).val().length === 0 ) { $(this).parents('p').addClass('warning'); } ```
25,479,156
I have just started a Sharepoint, I would need items listed in Sharepoint 2013. Please let me know is any rest service available to access data from sharepoint which I can store in my local db. Please suggest me what are the best way to access data from it. Thanks, Laxmilal Menaria
2014/08/25
[ "https://Stackoverflow.com/questions/25479156", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1444686/" ]
Yes it is perfectly fine to have hbase as your backend. What I am doing to get this done,( I have a online community and forum running on my website ) 1.Writing C# code to access the Hbase using thrift, very easy and simple to get this done. (Thrift is a cross language binding platform, to HBase Java is only the first class citizen!) 2.Managing the HBase cluster(have it on Amazon) using the Amazon EMI 3.Using ganglia to monitor Hbase Some Extra tips: So you can organize the web application like this 1. You can set up your webservers on Amazon Web Services or IBMWebSphere 2. You can set up your own HBase cluster using cloudera or use AmazonEC2 again here. 3. Communication between web server and Hbase master node happens via thrift client. 4. You can generate thrift code in your own desired programming language Here are some links that helped me A)[Thrift Client](http://hbase.apache.org/0.94/apidocs/org/apache/hadoop/hbase/thrift/doc-files/Hbase.html#Fn_Hbase_getRowWithColumns "Thrift Client"), B)[Filtering options](http://hbase.apache.org/book/thrift.html) Along with this I refer to HBase administrative cookbook by Yifeng Jiang and HBase reference guide by Lars George in case I dont get answers on web. Filtering options provided by HBase are fast and accurate. Let's say if you use HBase for storing your product details, you can have sub-stores and have a column in your Product table, which tells to which store a product may belong and use Filters to get products for a specific store.
I think you should read the article below: "Apache HBase Do’s and Don’ts" <http://blog.cloudera.com/blog/2011/04/hbase-dos-and-donts/>
46,393,578
I am trying to set Outlook appointments from a `userform` in `Excel`. The code works if I am referencing cells. How do I reference boxes in a `userform`? I also need to add to the code recipients for the meeting which I would reference from a different list worksheet. Here is the code that references the cells in Excel which works by clicking a button in the worksheet: ``` Sub AddAppointments() ' Create the Outlook session Set myOutlook = CreateObject("Outlook.Application") ' Start at row 2 r = 2 Do Until Trim(Cells(r, 1).Value) = "" ' Create the AppointmentItem Set myApt = myOutlook.CreateItem(1) ' Set the appointment properties myApt.Subject = Cells(r, 1).Value myApt.Location = Cells(r, 2).Value myApt.Start = Cells(r, 3).Value myApt.Duration = Cells(r, 4).Value ' If Busy Status is not specified, default to 2 (Busy) If Trim(Cells(r, 5).Value) = "" Then myApt.BusyStatus = 2 Else myApt.BusyStatus = Cells(r, 5).Value End If If Cells(r, 6).Value > 0 Then myApt.ReminderSet = True myApt.ReminderMinutesBeforeStart = Cells(r, 6).Value Else myApt.ReminderSet = False End If myApt.Body = Cells(r, 7).Value myApt.Display r = r + 1 Loop End Sub ``` This is my attempt at changing the code to reference boxes in a userform: ``` Private Sub Cmdappointment_Click() Dim outlookapp As Object 'the mail item is the contents inside a mail Dim mitem As AppointmentItem 'created outlook app Set outlookapp = CreateObject("outlook.Application") 'it will open a new application Set outlookapp = New Outlook.Application 'Set mail item Set mitem = outlookapp.CreateItem(olMailItem) Do Until userform2.TextBox4.Value = "" ' Create the AppointmentItem Set myApt = myOutlook.CreateItem(1) ' Set the appointment properties On Error Resume Next mitem myApt.Subject = Me.texbox4.Value myApt.Location = Me.texbox3.Value myApt.Start = Me.ComboBox1.Value myApt.Duration = Me.ComboBox2.Value ' If Busy Status is not specified, default to 2 (Busy) If Me.ComboBox3.Value = "" Then myApt.BusyStatus = 2 Else myApt.BusyStatus = Me.ComboBox3.Value End If If Me.TextBox1.Value > 0 Then myApt.ReminderSet = True myApt.ReminderMinutesBeforeStart = Me.TextBox1.Value Else myApt.ReminderSet = False End If myApt.Body = Me.TextBox2.Value myApt.Display End With Loop End Sub ```
2017/09/24
[ "https://Stackoverflow.com/questions/46393578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8577284/" ]
As you are fetching an associative array you can simply output the array keys as the header row: ``` $header = false; // a way to track if we've output the header. while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) { if ($header == false) { // this is the first iteration of the while loop so output the header. print '<thead><tr>'; foreach (array_keys($row) as $key) { print '<th>'.($key !== null ? htmlentities($key, ENT_QUOTES) : '').'</th>'; } print '</tr></thead>'; $header = true; // make sure we don't output the header again. } // output all the data rows. print '<tr>'; foreach ($row as $item) { print '<td>'.($item !== null ? htmlentities($item, ENT_QUOTES) : '').'</td>'; } print '</tr>'; } ```
You can query `ALL_TAB_COLUMNS` table to get all columns of a specific table in Oracle. ``` select COLUMN_NAME from ALL_TAB_COLUMNS where TABLE_NAME='MYTABLE'; ```
46,393,578
I am trying to set Outlook appointments from a `userform` in `Excel`. The code works if I am referencing cells. How do I reference boxes in a `userform`? I also need to add to the code recipients for the meeting which I would reference from a different list worksheet. Here is the code that references the cells in Excel which works by clicking a button in the worksheet: ``` Sub AddAppointments() ' Create the Outlook session Set myOutlook = CreateObject("Outlook.Application") ' Start at row 2 r = 2 Do Until Trim(Cells(r, 1).Value) = "" ' Create the AppointmentItem Set myApt = myOutlook.CreateItem(1) ' Set the appointment properties myApt.Subject = Cells(r, 1).Value myApt.Location = Cells(r, 2).Value myApt.Start = Cells(r, 3).Value myApt.Duration = Cells(r, 4).Value ' If Busy Status is not specified, default to 2 (Busy) If Trim(Cells(r, 5).Value) = "" Then myApt.BusyStatus = 2 Else myApt.BusyStatus = Cells(r, 5).Value End If If Cells(r, 6).Value > 0 Then myApt.ReminderSet = True myApt.ReminderMinutesBeforeStart = Cells(r, 6).Value Else myApt.ReminderSet = False End If myApt.Body = Cells(r, 7).Value myApt.Display r = r + 1 Loop End Sub ``` This is my attempt at changing the code to reference boxes in a userform: ``` Private Sub Cmdappointment_Click() Dim outlookapp As Object 'the mail item is the contents inside a mail Dim mitem As AppointmentItem 'created outlook app Set outlookapp = CreateObject("outlook.Application") 'it will open a new application Set outlookapp = New Outlook.Application 'Set mail item Set mitem = outlookapp.CreateItem(olMailItem) Do Until userform2.TextBox4.Value = "" ' Create the AppointmentItem Set myApt = myOutlook.CreateItem(1) ' Set the appointment properties On Error Resume Next mitem myApt.Subject = Me.texbox4.Value myApt.Location = Me.texbox3.Value myApt.Start = Me.ComboBox1.Value myApt.Duration = Me.ComboBox2.Value ' If Busy Status is not specified, default to 2 (Busy) If Me.ComboBox3.Value = "" Then myApt.BusyStatus = 2 Else myApt.BusyStatus = Me.ComboBox3.Value End If If Me.TextBox1.Value > 0 Then myApt.ReminderSet = True myApt.ReminderMinutesBeforeStart = Me.TextBox1.Value Else myApt.ReminderSet = False End If myApt.Body = Me.TextBox2.Value myApt.Display End With Loop End Sub ```
2017/09/24
[ "https://Stackoverflow.com/questions/46393578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8577284/" ]
As you are fetching an associative array you can simply output the array keys as the header row: ``` $header = false; // a way to track if we've output the header. while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) { if ($header == false) { // this is the first iteration of the while loop so output the header. print '<thead><tr>'; foreach (array_keys($row) as $key) { print '<th>'.($key !== null ? htmlentities($key, ENT_QUOTES) : '').'</th>'; } print '</tr></thead>'; $header = true; // make sure we don't output the header again. } // output all the data rows. print '<tr>'; foreach ($row as $item) { print '<td>'.($item !== null ? htmlentities($item, ENT_QUOTES) : '').'</td>'; } print '</tr>'; } ```
OCI8 has meta data calls like `oci_num_fields()` and `oci_field_name()`. They can be used like: ``` $s = oci_parse($c, "select * from employees"); if (!$s) { $m = oci_error($c); trigger_error('Could not parse statement: '. $m['message'], E_USER_ERROR); } $r = oci_execute($s); if (!$r) { $m = oci_error($s); trigger_error('Could not execute statement: '. $m['message'], E_USER_ERROR); } echo "<table border='1'>\n"; $ncols = oci_num_fields($s); echo "<tr>\n"; for ($i = 1; $i <= $ncols; ++$i) { $colname = oci_field_name($s, $i); echo " <th><b>".htmlspecialchars($colname,ENT_QUOTES|ENT_SUBSTITUTE)."</b></th>\n"; } echo "</tr>\n"; while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) { echo "<tr>\n"; foreach ($row as $item) { echo "<td>"; echo $item!==null?htmlspecialchars($item, ENT_QUOTES|ENT_SUBSTITUTE):"&nbsp;"; echo "</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; ```
19,322
I am working on a reporting application and we fetch several records based on their start/end date ranges. Users can choose to leave both start and/or end dates blank. Examples: ``` Example 1 - Date: 1/15/2010 to 2/3/2011 Example 2 - Date: [blank] to 2/3/2011 Example 3 - Date: 1/1/2010 to [blank] Example 4 - Date: [blank] to [blank] ``` Example 1 reports on all records between Jan 1st 2010 and Feb 3rd 2011. Example 2 reports on any records that ended before Feb 3rd 2011. Example 3 reports on any records that started after Jan 1st 2011. Example 4 reports on all records. What is the best thing to say for those [blank] spots? "Beginning of Time" and "Infinite Future" are *technically* not correct -- because you could set ended date to blank and start date to 1/1/1970 and get a record that ended in the 1980's - not exactly the 'infinite future' -- Also "Beginning of Time" and "Infinite Future" are quite long in terms of space.
2012/03/27
[ "https://ux.stackexchange.com/questions/19322", "https://ux.stackexchange.com", "https://ux.stackexchange.com/users/13495/" ]
You can have a single field that opens a date range. Once the user finished selecting dates - it appears on a single field. This way you can use: 1. 1/15/2010 to 2/3/2011 2. until 2/3/2011 3. from 1/1/2010 4. All time
You aren't really *referring* to the beginning and end of time here. You just mean from the beginning of the data set to the end of the data set. We solve this in one of two ways in our products, depending largely on the familiarity of the user with the dataset being reported on: **Option 1** 1. 1/15/2010 to 2/3/2011 2. Before 2/3/2011 (could also be "Up to 2/3/2011" or "2/3/2011 and earlier") 3. After 1/1/2010 (could also be "Since 1/1/2010" or "1/1/2010 and later") 4. *No value in either field* The exact wording you choose should depend on things like whether your search is date-inclusive or exclusive. **Option 2** Auto-fill the beginning and end dates with the actual first and last dates represented in the dataset, so that it becomes: 1. 1/15/2010 to 2/3/2011 2. 1/1/2009 to 2/3/2011 3. 1/1/2010 to 3/28/2011 (you may choose to use the word "today" instead of the current date for clarity) 4. 1/1/2009 to 3/28/2011 This option only makes sense if the users understand that the 1/1/2009 is the beginning of the dataset; that's something that you'd need to decide based on what the data represents.
9,216,278
I have made one console application for email notification in c#. Can i convert this console application in to window service? Thanks.
2012/02/09
[ "https://Stackoverflow.com/questions/9216278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1157791/" ]
In visual studio, create a "Windows Service" project instead of a "Console Application". Look in the code that gets generated for you. There will be an OnStart() and OnStop() method. Those are the methods that will be called when your service is started and stopped. Put your code in those methods and you will have a Windows Service.
When I go about this, I write the application in a class that does not consider its self a console application. By that I mean I dont write to the Console. I use log4net to write everything to... just log to Info. Use the console app to call the application class and in the app.config you can have an appender for console logging... so you get the console output. In the windows service this will just write to a file or not at all for the Info level logging. Its important to note the differences between a console app and a service... a service is not interactive and you can not input anything, so you app must consider this. For the windows service use the same class, but use the windows service project to start it. ApplicationLogic: Has all the logic to run the application. Can take the arguments to make the app run the way it needs to, but does not interact with the console (can, but it would be bad design). Writes everything to logging (log4net maybe). ConsoleApp: Is a wrapper around ApplicationLogic that can prompt the user for what ever it needs, can prompt for input and send it to ApplicationLogic. Has a log4net console appender if you need to see the output from ApplicationLogic. WindowsService: Is a wrapper around ApplicationLogic. Has predetermined logic to keep it looping and running the Application logic. Logs to a file, no console output.
9,216,278
I have made one console application for email notification in c#. Can i convert this console application in to window service? Thanks.
2012/02/09
[ "https://Stackoverflow.com/questions/9216278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1157791/" ]
In visual studio, create a "Windows Service" project instead of a "Console Application". Look in the code that gets generated for you. There will be an OnStart() and OnStop() method. Those are the methods that will be called when your service is started and stopped. Put your code in those methods and you will have a Windows Service.
Contrary to some of the suggestions made by other answers, you probably can't do what you want using a Windows Service. It can't display the "notification" you expect because services can't display any kind of user interface. The appropriate solution is to create a regular application that runs in the background without showing any windows. You can't do this with a console application (well, you *can*, but let's not overcomplicate things) because each time you run it, the console window will be displayed. But if you create a standard Windows application (either a Windows Forms or WPF application) then just don't create a window, everything will work out just fine. You'll probably want to create and place an icon into the taskbar's notification area, which will handle displaying the notification upon the arrival of email. If you're creating a WinForms application, this can be done easily by using the [`NotifyIcon` component](http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx). Something like (warning, written without the aid of a compiler!): ``` static class Program { [STAThread] static void Main() { // Standard infrastructure code Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Create a context menu and add item(s) to it ContextMenu mnu = new ContextMenu(); MenuItem mnuExit = new MenuItem("E&xit"); mnu.MenuItems.Add(mnuExit); mnuExit.Click += mnuExit_Click); // Create the NotifyIcon NotifyIcon ni = new NotifyIcon(); ni.Icon = new Icon(GetType(), "icon.ico"); ni.Text = "Email Notifier"; ni.ContextMenu = mnu; ni.Visible = true; // Run the application Application.Run(); // Before exiting, remove the NotifyIcon from the taskbar ni.Visible = false; } private static void mnuExit_Click(object Sender, EventArgs e) { Application.Exit(); } } ```
9,216,278
I have made one console application for email notification in c#. Can i convert this console application in to window service? Thanks.
2012/02/09
[ "https://Stackoverflow.com/questions/9216278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1157791/" ]
Contrary to some of the suggestions made by other answers, you probably can't do what you want using a Windows Service. It can't display the "notification" you expect because services can't display any kind of user interface. The appropriate solution is to create a regular application that runs in the background without showing any windows. You can't do this with a console application (well, you *can*, but let's not overcomplicate things) because each time you run it, the console window will be displayed. But if you create a standard Windows application (either a Windows Forms or WPF application) then just don't create a window, everything will work out just fine. You'll probably want to create and place an icon into the taskbar's notification area, which will handle displaying the notification upon the arrival of email. If you're creating a WinForms application, this can be done easily by using the [`NotifyIcon` component](http://msdn.microsoft.com/en-us/library/system.windows.forms.notifyicon.aspx). Something like (warning, written without the aid of a compiler!): ``` static class Program { [STAThread] static void Main() { // Standard infrastructure code Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Create a context menu and add item(s) to it ContextMenu mnu = new ContextMenu(); MenuItem mnuExit = new MenuItem("E&xit"); mnu.MenuItems.Add(mnuExit); mnuExit.Click += mnuExit_Click); // Create the NotifyIcon NotifyIcon ni = new NotifyIcon(); ni.Icon = new Icon(GetType(), "icon.ico"); ni.Text = "Email Notifier"; ni.ContextMenu = mnu; ni.Visible = true; // Run the application Application.Run(); // Before exiting, remove the NotifyIcon from the taskbar ni.Visible = false; } private static void mnuExit_Click(object Sender, EventArgs e) { Application.Exit(); } } ```
When I go about this, I write the application in a class that does not consider its self a console application. By that I mean I dont write to the Console. I use log4net to write everything to... just log to Info. Use the console app to call the application class and in the app.config you can have an appender for console logging... so you get the console output. In the windows service this will just write to a file or not at all for the Info level logging. Its important to note the differences between a console app and a service... a service is not interactive and you can not input anything, so you app must consider this. For the windows service use the same class, but use the windows service project to start it. ApplicationLogic: Has all the logic to run the application. Can take the arguments to make the app run the way it needs to, but does not interact with the console (can, but it would be bad design). Writes everything to logging (log4net maybe). ConsoleApp: Is a wrapper around ApplicationLogic that can prompt the user for what ever it needs, can prompt for input and send it to ApplicationLogic. Has a log4net console appender if you need to see the output from ApplicationLogic. WindowsService: Is a wrapper around ApplicationLogic. Has predetermined logic to keep it looping and running the Application logic. Logs to a file, no console output.

No dataset card yet

New: Create and edit this dataset card directly on the website!

Contribute a Dataset Card
Downloads last month
275
Add dataset card