Tuesday, February 11, 2014

Github - eGit: How to add the user for current Repository

In eGit, when you try to commit, then default author and email Id appears every time, which you want to change to some other user and emailid. So, to make it happen following are the ways:

1) Open the current Repository in gitShell:
>git config user.name "Your Name Here"
>git config user.email your@email.com

This will make the relevant changes in ~/.git/config file


2) You can directly edit ~/.git/config file and add the following lines:
[user]
name = Kuldeep Dhole
email = dkuldeep11@github.com


Monday, February 10, 2014

Python: Replace All Occurrences in String

Problem:

str = "never asserted as the ''only'' sufficient condition for ''Q'', other factors could account for ''Q'' (while ''P'' was false).<ref>{{cite web |url = http://www.fallacyfiles.org/afthecon.html |title = Fallacy Files |work = http://www.fallacyfiles.org |publisher  = Fallacy Files |accessdate = 9 May 2013}}</ref>To put it differently"


Replace <ref&gt.*</ref> by ''

Solution:

import re

str = re.sub(r'<ref&gt.*</ref>', "", str)

print str

Python: SyntaxError: Non-ASCII character '\xe2' in file but no encoding declared

UTF-8 coding style

Error Case:

text = u"{{Use dmy dates|date=June 2013}}'''Affirming the consequent''', sometimes called '''converse error''' or '''fallacy of the converse''', is a [[formal fallacy]] of inferring the [[converse (logic)|converse]] from the original statement. The corresponding argument has the general [[argument form|form]]:#If ''P'', then ''Q''.#''Q''.#Therefore, ''P''.An argument of this form is [[validity|invalid]], i.e., the conclusion can be false even when statements 1 and 2 are true.  Since ''P'' was never asserted as the ''only'' sufficient condition for ''Q'', other factors could account for ''Q'' (while ''P'' was false).<ref>{{cite web |url = http://www.fallacyfiles.org/afthecon.html |title = Fallacy Files |work = http://www.fallacyfiles.org |publisher  = Fallacy Files |accessdate = 9 May 2013}}</ref>To put it differently, if ''P'' implies ''Q'', the '''only''' inference that can be made is ''non-Q'' implies ''non-P''.  (''Non-P'' and ''non-Q'' designate the opposite propositions to ''P'' and ''Q''.)  Symbolically:(''P'' ⇒ ''Q'') ⇔ (''non-Q'' ⇒ ''non-P'')The name ''affirming the [[consequent]]'' derives from the premise ''Q'', which affirms the "then" clause of the [[indicative conditional|conditional]] premise.==Examples==One way to demonstrate the invalidity of this argument form is with a counterexample with true premises but an obviously false conclusion.  For example::If [[Bill Gates]] owns [[United States Bullion Depository|Fort Knox]], then he is [[Wealth|rich]].:Bill Gates is rich.:Therefore, Bill Gates owns Fort Knox.Owning Fort Knox is not the ''only'' way to be rich.  Any number of other ways exist to be rich.However, one can affirm with certainty that "if Bill Gates is not rich" (''non-Q'') then "Bill Gates does not own Fort Knox" (''non-P'').Arguments of the same form can sometimes seem superficially convincing, as in the following example::If I have the [[flu]], then I have a [[sore throat]].:I have a sore throat.:Therefore, I have the flu.But having the flu is not the ''only'' cause of a sore throat since many illnesses cause sore throat, such as the [[common cold]] or [[strep throat]].==See also==*[[Modus ponens]]*[[Modus tollens]]*[[Post hoc ergo propter hoc]]*[[Denying the antecedent]]*[[Fallacy of the undistributed middle]]*[[Inference to the best explanation]]*[[ELIZA effect]]*[[Confusion of the inverse]]==References=={{reflist}}{{Formal fallacy}}[[Category:Propositional fallacies]]{{logic-stub|date=November 2008}}"

print text

>>SyntaxError: Non-ASCII character '\xe2' in file but no encoding declared 


Solution:
Just add the coding standard line at the beginning:
# -*-coding: utf-8 -*-


Finally it works:

# -*-coding: utf-8 -*-

text = u"{{Use dmy dates|date=June 2013}}'''Affirming the consequent''', sometimes called '''converse error''' or '''fallacy of the converse''', is a [[formal fallacy]] of inferring the [[converse (logic)|converse]] from the original statement. The corresponding argument has the general [[argument form|form]]:#If ''P'', then ''Q''.#''Q''.#Therefore, ''P''.An argument of this form is [[validity|invalid]], i.e., the conclusion can be false even when statements 1 and 2 are true.  Since ''P'' was never asserted as the ''only'' sufficient condition for ''Q'', other factors could account for ''Q'' (while ''P'' was false).<ref>{{cite web |url = http://www.fallacyfiles.org/afthecon.html |title = Fallacy Files |work = http://www.fallacyfiles.org |publisher  = Fallacy Files |accessdate = 9 May 2013}}</ref>To put it differently, if ''P'' implies ''Q'', the '''only''' inference that can be made is ''non-Q'' implies ''non-P''.  (''Non-P'' and ''non-Q'' designate the opposite propositions to ''P'' and ''Q''.)  Symbolically:(''P'' ⇒ ''Q'') ⇔ (''non-Q'' ⇒ ''non-P'')The name ''affirming the [[consequent]]'' derives from the premise ''Q'', which affirms the "then" clause of the [[indicative conditional|conditional]] premise.==Examples==One way to demonstrate the invalidity of this argument form is with a counterexample with true premises but an obviously false conclusion.  For example::If [[Bill Gates]] owns [[United States Bullion Depository|Fort Knox]], then he is [[Wealth|rich]].:Bill Gates is rich.:Therefore, Bill Gates owns Fort Knox.Owning Fort Knox is not the ''only'' way to be rich.  Any number of other ways exist to be rich.However, one can affirm with certainty that "if Bill Gates is not rich" (''non-Q'') then "Bill Gates does not own Fort Knox" (''non-P'').Arguments of the same form can sometimes seem superficially convincing, as in the following example::If I have the [[flu]], then I have a [[sore throat]].:I have a sore throat.:Therefore, I have the flu.But having the flu is not the ''only'' cause of a sore throat since many illnesses cause sore throat, such as the [[common cold]] or [[strep throat]].==See also==*[[Modus ponens]]*[[Modus tollens]]*[[Post hoc ergo propter hoc]]*[[Denying the antecedent]]*[[Fallacy of the undistributed middle]]*[[Inference to the best explanation]]*[[ELIZA effect]]*[[Confusion of the inverse]]==References=={{reflist}}{{Formal fallacy}}[[Category:Propositional fallacies]]{{logic-stub|date=November 2008}}"

print text


Tuesday, February 4, 2014

Write To A File Simple Way

#!/usr/bin/python 
# Open a file 
fo = open("foo.txt", "w")
fo.write( "Python is a great language.\nYeah its great!!\n");
 # Close opend file 
fo.close()




Saturday, February 1, 2014