text:
Q: nHibernate trying to update instead of insert a new object I am using nHibernate attributes which generates this...
  <class name="xxx.Message.MtMessage, xxx" lazy="false" table="tblCore_MtMessage">
    <id name="MtMessageId">
      <generator class="identity" />
    </id>
    <property name="MtMessageStatus" />
    <property name="ApplicationMessageId" />
    <property name="IsPremium" />
    <property name="Tariff" />
    <property name="ExpiryTimeMinutes" />
    <property name="PhoneNetwork" />
    <property name="MessageText" />
    <property name="ToNumber" />
    <property name="FromNumber" />
    <property name="IsCompleted" />
    <property name="UpdateDate" />
    <many-to-one name="Category" class="xxx.Category, xxx" column="CategoryId" not-null="true" cascade="None" />
    <many-to-one name="Aggregator" class="xxx.AbstractAggregator, xxx" column="AggregatorId" cascade="None" />
    <many-to-one name="Aggregator" class="xxx.AbstractAggregator, xxx" column="AggregatorId" cascade="None" />
    <many-to-one name="Application" class="xxx.Application, xxx" column="ApplicationId" cascade="None" />
    <many-to-one name="Application" class="xxx.Application, xxx" column="ApplicationId" cascade="None" />
    <bag name="Segments" lazy="false" inverse="true" cascade="None">
      <key column="MtMessageId" />
      <one-to-many class="xxx.Message.MtSegment, xxx" />
    </bag>
  </class>

  <class name="xxx.Message.MoMessage, xxx" lazy="false" table="tblCore_MoMessage">
    <id name="MoMessageId">
      <generator class="identity" />
    </id>
    <property name="MoMessageStatus" />
    <property name="PhoneNetwork" />
    <property name="MessageText" />
    <property name="ToNumber" />
    <property name="FromNumber" />
    <property name="IsCompleted" />
    <property name="UpdateDate" />
    <list name="Segments" lazy="false" inverse="true" cascade="None">
      <key column="MoMessageId" />
      <index column="SegmentNumber" />
      <one-to-many class="xxx.Message.MoSegment, xxx" />
    </list>
  </class>

For some reason, when I create a new MoMessage and call ISession.Save() on it nHibernate tries to UPDATE instead of INSERT.  I have no problem saving the MtMessage.  I have tried changing the list for a bag as thats the only real difference, that didn't work.  Anyone got any pointers where to start looking???
Here's a big of logging that may help
2010-09-09 18:53:54,015 DEBUG xxx.NHibernate.ReceiveMoUow - Saving message[Id:0,Type:MO,To:89000,From:447000000000,Network:O2,Status:New,Text:Hi mum]
2010-09-09 18:53:54,031 DEBUG xxx.Persist.NHibernateConnection - CreateSession(Commit)
2010-09-09 18:53:54,031 DEBUG NHibernate.Impl.SessionImpl - [session-id=408ca207-0ed1-487f-b57b-ae6a072a4d3f] opened session at timestamp: 634196552340, for session factory: [/0754517161044239b072f9d048fcb17f]
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - put criteria=PhoneNumber = 447000000000 and IsEnabled = True alias=this0_
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - returning alias=this_ for criteria=PhoneNumber = 447000000000 and IsEnabled = True
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - returning alias=this_ for criteria=PhoneNumber = 447000000000 and IsEnabled = True
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - getCriteria for path=Application crit=
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - getCriteria for path=Application.RedirectApplication crit=
2010-09-09 18:53:54,031 DEBUG NHibernate.SqlCommand.SqlSelectBuilder - The initial capacity was set too low at: 12 for the SelectSqlBuilder that needed a capacity of: 16 for the table dbo.tblCore_PhoneDiverts this_
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - Opened new IDbCommand, open IDbCommands: 1
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - Building an IDbCommand object for the SqlString: SELECT this_.PhoneNumber as PhoneNum1_9_2_, this_.DivertName as DivertName9_2_, this_.IsEnabled as IsEnabled9_2_, this_.UpdateDate as UpdateDate9_2_, this_.ApplicationId as Applicat5_9_2_, applicatio2_.ApplicationId as Applicat1_3_0_, applicatio2_.ApplicationName as Applicat2_3_0_, applicatio2_.ValidationKey as Validati3_3_0_, applicatio2_.ApplicationWebInterfaceUrl as Applicat4_3_0_, applicatio2_.IpAddress as IpAddress3_0_, applicatio2_.ApplicationWebInterfaceVersion as Applicat6_3_0_, applicatio2_.ShouldSend as ShouldSend3_0_, applicatio2_.ShouldRedirect as ShouldRe8_3_0_, applicatio2_.ShouldDumpMessage as ShouldDu9_3_0_, applicatio2_.UpdateDate as UpdateDate3_0_, applicatio2_.RedirectApplicationId as Redirec11_3_0_, applicatio3_.ApplicationId as Applicat1_3_1_, applicatio3_.ApplicationName as Applicat2_3_1_, applicatio3_.ValidationKey as Validati3_3_1_, applicatio3_.ApplicationWebInterfaceUrl as Applicat4_3_1_, applicatio3_.IpAddress as IpAddress3_1_, applicatio3_.ApplicationWebInterfaceVersion as Applicat6_3_1_, applicatio3_.ShouldSend as ShouldSend3_1_, applicatio3_.ShouldRedirect as ShouldRe8_3_1_, applicatio3_.ShouldDumpMessage as ShouldDu9_3_1_, applicatio3_.UpdateDate as UpdateDate3_1_, applicatio3_.RedirectApplicationId as Redirec11_3_1_ FROM dbo.tblCore_PhoneDiverts this_ left outer join dbo.tblCore_Applications applicatio2_ on this_.ApplicationId=applicatio2_.ApplicationId left outer join dbo.tblCore_Applications applicatio3_ on applicatio2_.RedirectApplicationId=applicatio3_.ApplicationId WHERE this_.PhoneNumber = ? and this_.IsEnabled = ?
2010-09-09 18:53:54,031 DEBUG NHibernate.Engine.QueryParameters - BindParameters(Named:NHibernate.Type.StringType) 447000000000 -> [0]
2010-09-09 18:53:54,031 DEBUG NHibernate.Type.StringType - binding '447000000000' to parameter: 0
2010-09-09 18:53:54,031 DEBUG NHibernate.Engine.QueryParameters - BindParameters(Named:NHibernate.Type.BooleanType) True -> [1]
2010-09-09 18:53:54,031 DEBUG NHibernate.Type.BooleanType - binding 'True' to parameter: 1
2010-09-09 18:53:54,031 INFO  NHibernate.Loader.Loader - SELECT this_.PhoneNumber as PhoneNum1_9_2_, this_.DivertName as DivertName9_2_, this_.IsEnabled as IsEnabled9_2_, this_.UpdateDate as UpdateDate9_2_, this_.ApplicationId as Applicat5_9_2_, applicatio2_.ApplicationId as Applicat1_3_0_, applicatio2_.ApplicationName as Applicat2_3_0_, applicatio2_.ValidationKey as Validati3_3_0_, applicatio2_.ApplicationWebInterfaceUrl as Applicat4_3_0_, applicatio2_.IpAddress as IpAddress3_0_, applicatio2_.ApplicationWebInterfaceVersion as Applicat6_3_0_, applicatio2_.ShouldSend as ShouldSend3_0_, applicatio2_.ShouldRedirect as ShouldRe8_3_0_, applicatio2_.ShouldDumpMessage as ShouldDu9_3_0_, applicatio2_.UpdateDate as UpdateDate3_0_, applicatio2_.RedirectApplicationId as Redirec11_3_0_, applicatio3_.ApplicationId as Applicat1_3_1_, applicatio3_.ApplicationName as Applicat2_3_1_, applicatio3_.ValidationKey as Validati3_3_1_, applicatio3_.ApplicationWebInterfaceUrl as Applicat4_3_1_, applicatio3_.IpAddress as IpAddress3_1_, applicatio3_.ApplicationWebInterfaceVersion as Applicat6_3_1_, applicatio3_.ShouldSend as ShouldSend3_1_, applicatio3_.ShouldRedirect as ShouldRe8_3_1_, applicatio3_.ShouldDumpMessage as ShouldDu9_3_1_, applicatio3_.UpdateDate as UpdateDate3_1_, applicatio3_.RedirectApplicationId as Redirec11_3_1_ FROM dbo.tblCore_PhoneDiverts this_ left outer join dbo.tblCore_Applications applicatio2_ on this_.ApplicationId=applicatio2_.ApplicationId left outer join dbo.tblCore_Applications applicatio3_ on applicatio2_.RedirectApplicationId=applicatio3_.ApplicationId WHERE this_.PhoneNumber = @p0 and this_.IsEnabled = @p1
2010-09-09 18:53:54,031 DEBUG NHibernate.SQL - SELECT this_.PhoneNumber as PhoneNum1_9_2_, this_.DivertName as DivertName9_2_, this_.IsEnabled as IsEnabled9_2_, this_.UpdateDate as UpdateDate9_2_, this_.ApplicationId as Applicat5_9_2_, applicatio2_.ApplicationId as Applicat1_3_0_, applicatio2_.ApplicationName as Applicat2_3_0_, applicatio2_.ValidationKey as Validati3_3_0_, applicatio2_.ApplicationWebInterfaceUrl as Applicat4_3_0_, applicatio2_.IpAddress as IpAddress3_0_, applicatio2_.ApplicationWebInterfaceVersion as Applicat6_3_0_, applicatio2_.ShouldSend as ShouldSend3_0_, applicatio2_.ShouldRedirect as ShouldRe8_3_0_, applicatio2_.ShouldDumpMessage as ShouldDu9_3_0_, applicatio2_.UpdateDate as UpdateDate3_0_, applicatio2_.RedirectApplicationId as Redirec11_3_0_, applicatio3_.ApplicationId as Applicat1_3_1_, applicatio3_.ApplicationName as Applicat2_3_1_, applicatio3_.ValidationKey as Validati3_3_1_, applicatio3_.ApplicationWebInterfaceUrl as Applicat4_3_1_, applicatio3_.IpAddress as IpAddress3_1_, applicatio3_.ApplicationWebInterfaceVersion as Applicat6_3_1_, applicatio3_.ShouldSend as ShouldSend3_1_, applicatio3_.ShouldRedirect as ShouldRe8_3_1_, applicatio3_.ShouldDumpMessage as ShouldDu9_3_1_, applicatio3_.UpdateDate as UpdateDate3_1_, applicatio3_.RedirectApplicationId as Redirec11_3_1_ FROM dbo.tblCore_PhoneDiverts this_ left outer join dbo.tblCore_Applications applicatio2_ on this_.ApplicationId=applicatio2_.ApplicationId left outer join dbo.tblCore_Applications applicatio3_ on applicatio2_.RedirectApplicationId=applicatio3_.ApplicationId WHERE this_.PhoneNumber = @p0 and this_.IsEnabled = @p1;@p0 = '447000000000', @p1 = True
2010-09-09 18:53:54,031 DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - ExecuteReader took 1 ms
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - Opened IDataReader, open IDataReaders: 1
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Loader - processing result set
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Loader - done processing result set (0 rows)
2010-09-09 18:53:54,031 DEBUG NHibernate.Driver.NHybridDataReader - running NHybridDataReader.Dispose()
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - Closed IDataReader, open IDataReaders :0
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - DataReader was closed after 1 ms
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - Closed IDbCommand, open IDbCommands: 0
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.ConnectionManager - aggressively releasing database connection
2010-09-09 18:53:54,031 DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Loader - total objects hydrated: 0
2010-09-09 18:53:54,031 DEBUG NHibernate.Engine.StatefulPersistenceContext - initializing non-lazy collections
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.ConnectionManager - after autocommit
2010-09-09 18:53:54,031 DEBUG NHibernate.Impl.SessionImpl - transaction completion
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.ConnectionManager - aggressively releasing database connection
2010-09-09 18:53:54,031 DEBUG NHibernate.Impl.SessionImpl - [session-id=408ca207-0ed1-487f-b57b-ae6a072a4d3f] running ISession.Dispose()
2010-09-09 18:53:54,031 DEBUG NHibernate.Impl.SessionImpl - [session-id=408ca207-0ed1-487f-b57b-ae6a072a4d3f] executing real Dispose(True)
2010-09-09 18:53:54,031 DEBUG NHibernate.Impl.SessionImpl - closing session
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - running BatcherImpl.Dispose(true)
2010-09-09 18:53:54,031 DEBUG xxx.Persist.NHibernateConnection - CreateSession(Commit)
2010-09-09 18:53:54,031 DEBUG NHibernate.Impl.SessionImpl - [session-id=fce26533-bf6c-4f93-b75e-61a8c88c1e87] opened session at timestamp: 634196552340, for session factory: [/0754517161044239b072f9d048fcb17f]
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - put criteria=PhoneNetwork = O2 and IsEnabled = True alias=this0_
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - returning alias=this_ for criteria=PhoneNetwork = O2 and IsEnabled = True
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - returning alias=this_ for criteria=PhoneNetwork = O2 and IsEnabled = True
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - getCriteria for path=Application crit=
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Criteria.CriteriaQueryTranslator - getCriteria for path=Application.RedirectApplication crit=
2010-09-09 18:53:54,031 DEBUG NHibernate.SqlCommand.SqlSelectBuilder - The initial capacity was set too low at: 12 for the SelectSqlBuilder that needed a capacity of: 16 for the table dbo.tblCore_NetworkDiverts this_
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - Opened new IDbCommand, open IDbCommands: 1
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - Building an IDbCommand object for the SqlString: SELECT this_.PhoneNetwork as PhoneNet1_13_2_, this_.IsEnabled as IsEnabled13_2_, this_.UpdateDate as UpdateDate13_2_, this_.ApplicationId as Applicat4_13_2_, applicatio2_.ApplicationId as Applicat1_3_0_, applicatio2_.ApplicationName as Applicat2_3_0_, applicatio2_.ValidationKey as Validati3_3_0_, applicatio2_.ApplicationWebInterfaceUrl as Applicat4_3_0_, applicatio2_.IpAddress as IpAddress3_0_, applicatio2_.ApplicationWebInterfaceVersion as Applicat6_3_0_, applicatio2_.ShouldSend as ShouldSend3_0_, applicatio2_.ShouldRedirect as ShouldRe8_3_0_, applicatio2_.ShouldDumpMessage as ShouldDu9_3_0_, applicatio2_.UpdateDate as UpdateDate3_0_, applicatio2_.RedirectApplicationId as Redirec11_3_0_, applicatio3_.ApplicationId as Applicat1_3_1_, applicatio3_.ApplicationName as Applicat2_3_1_, applicatio3_.ValidationKey as Validati3_3_1_, applicatio3_.ApplicationWebInterfaceUrl as Applicat4_3_1_, applicatio3_.IpAddress as IpAddress3_1_, applicatio3_.ApplicationWebInterfaceVersion as Applicat6_3_1_, applicatio3_.ShouldSend as ShouldSend3_1_, applicatio3_.ShouldRedirect as ShouldRe8_3_1_, applicatio3_.ShouldDumpMessage as ShouldDu9_3_1_, applicatio3_.UpdateDate as UpdateDate3_1_, applicatio3_.RedirectApplicationId as Redirec11_3_1_ FROM dbo.tblCore_NetworkDiverts this_ left outer join dbo.tblCore_Applications applicatio2_ on this_.ApplicationId=applicatio2_.ApplicationId left outer join dbo.tblCore_Applications applicatio3_ on applicatio2_.RedirectApplicationId=applicatio3_.ApplicationId WHERE this_.PhoneNetwork = ? and this_.IsEnabled = ?
2010-09-09 18:53:54,031 DEBUG NHibernate.Engine.QueryParameters - BindParameters(Named:NHibernate.Type.PersistentEnumType) O2 -> [0]
2010-09-09 18:53:54,031 DEBUG NHibernate.Type.PersistentEnumType - binding '0' to parameter: 0
2010-09-09 18:53:54,031 DEBUG NHibernate.Engine.QueryParameters - BindParameters(Named:NHibernate.Type.BooleanType) True -> [1]
2010-09-09 18:53:54,031 DEBUG NHibernate.Type.BooleanType - binding 'True' to parameter: 1
2010-09-09 18:53:54,031 INFO  NHibernate.Loader.Loader - SELECT this_.PhoneNetwork as PhoneNet1_13_2_, this_.IsEnabled as IsEnabled13_2_, this_.UpdateDate as UpdateDate13_2_, this_.ApplicationId as Applicat4_13_2_, applicatio2_.ApplicationId as Applicat1_3_0_, applicatio2_.ApplicationName as Applicat2_3_0_, applicatio2_.ValidationKey as Validati3_3_0_, applicatio2_.ApplicationWebInterfaceUrl as Applicat4_3_0_, applicatio2_.IpAddress as IpAddress3_0_, applicatio2_.ApplicationWebInterfaceVersion as Applicat6_3_0_, applicatio2_.ShouldSend as ShouldSend3_0_, applicatio2_.ShouldRedirect as ShouldRe8_3_0_, applicatio2_.ShouldDumpMessage as ShouldDu9_3_0_, applicatio2_.UpdateDate as UpdateDate3_0_, applicatio2_.RedirectApplicationId as Redirec11_3_0_, applicatio3_.ApplicationId as Applicat1_3_1_, applicatio3_.ApplicationName as Applicat2_3_1_, applicatio3_.ValidationKey as Validati3_3_1_, applicatio3_.ApplicationWebInterfaceUrl as Applicat4_3_1_, applicatio3_.IpAddress as IpAddress3_1_, applicatio3_.ApplicationWebInterfaceVersion as Applicat6_3_1_, applicatio3_.ShouldSend as ShouldSend3_1_, applicatio3_.ShouldRedirect as ShouldRe8_3_1_, applicatio3_.ShouldDumpMessage as ShouldDu9_3_1_, applicatio3_.UpdateDate as UpdateDate3_1_, applicatio3_.RedirectApplicationId as Redirec11_3_1_ FROM dbo.tblCore_NetworkDiverts this_ left outer join dbo.tblCore_Applications applicatio2_ on this_.ApplicationId=applicatio2_.ApplicationId left outer join dbo.tblCore_Applications applicatio3_ on applicatio2_.RedirectApplicationId=applicatio3_.ApplicationId WHERE this_.PhoneNetwork = @p0 and this_.IsEnabled = @p1
2010-09-09 18:53:54,031 DEBUG NHibernate.SQL - SELECT this_.PhoneNetwork as PhoneNet1_13_2_, this_.IsEnabled as IsEnabled13_2_, this_.UpdateDate as UpdateDate13_2_, this_.ApplicationId as Applicat4_13_2_, applicatio2_.ApplicationId as Applicat1_3_0_, applicatio2_.ApplicationName as Applicat2_3_0_, applicatio2_.ValidationKey as Validati3_3_0_, applicatio2_.ApplicationWebInterfaceUrl as Applicat4_3_0_, applicatio2_.IpAddress as IpAddress3_0_, applicatio2_.ApplicationWebInterfaceVersion as Applicat6_3_0_, applicatio2_.ShouldSend as ShouldSend3_0_, applicatio2_.ShouldRedirect as ShouldRe8_3_0_, applicatio2_.ShouldDumpMessage as ShouldDu9_3_0_, applicatio2_.UpdateDate as UpdateDate3_0_, applicatio2_.RedirectApplicationId as Redirec11_3_0_, applicatio3_.ApplicationId as Applicat1_3_1_, applicatio3_.ApplicationName as Applicat2_3_1_, applicatio3_.ValidationKey as Validati3_3_1_, applicatio3_.ApplicationWebInterfaceUrl as Applicat4_3_1_, applicatio3_.IpAddress as IpAddress3_1_, applicatio3_.ApplicationWebInterfaceVersion as Applicat6_3_1_, applicatio3_.ShouldSend as ShouldSend3_1_, applicatio3_.ShouldRedirect as ShouldRe8_3_1_, applicatio3_.ShouldDumpMessage as ShouldDu9_3_1_, applicatio3_.UpdateDate as UpdateDate3_1_, applicatio3_.RedirectApplicationId as Redirec11_3_1_ FROM dbo.tblCore_NetworkDiverts this_ left outer join dbo.tblCore_Applications applicatio2_ on this_.ApplicationId=applicatio2_.ApplicationId left outer join dbo.tblCore_Applications applicatio3_ on applicatio2_.RedirectApplicationId=applicatio3_.ApplicationId WHERE this_.PhoneNetwork = @p0 and this_.IsEnabled = @p1;@p0 = 0, @p1 = True
2010-09-09 18:53:54,031 DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - ExecuteReader took 0 ms
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - Opened IDataReader, open IDataReaders: 1
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Loader - processing result set
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Loader - done processing result set (0 rows)
2010-09-09 18:53:54,031 DEBUG NHibernate.Driver.NHybridDataReader - running NHybridDataReader.Dispose()
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - Closed IDataReader, open IDataReaders :0
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - DataReader was closed after 1 ms
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - Closed IDbCommand, open IDbCommands: 0
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.ConnectionManager - aggressively releasing database connection
2010-09-09 18:53:54,031 DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
2010-09-09 18:53:54,031 DEBUG NHibernate.Loader.Loader - total objects hydrated: 0
2010-09-09 18:53:54,031 DEBUG NHibernate.Engine.StatefulPersistenceContext - initializing non-lazy collections
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.ConnectionManager - after autocommit
2010-09-09 18:53:54,031 DEBUG NHibernate.Impl.SessionImpl - transaction completion
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.ConnectionManager - aggressively releasing database connection
2010-09-09 18:53:54,031 DEBUG NHibernate.Impl.SessionImpl - [session-id=fce26533-bf6c-4f93-b75e-61a8c88c1e87] running ISession.Dispose()
2010-09-09 18:53:54,031 DEBUG NHibernate.Impl.SessionImpl - [session-id=fce26533-bf6c-4f93-b75e-61a8c88c1e87] executing real Dispose(True)
2010-09-09 18:53:54,031 DEBUG NHibernate.Impl.SessionImpl - closing session
2010-09-09 18:53:54,031 DEBUG NHibernate.AdoNet.AbstractBatcher - running BatcherImpl.Dispose(true)
2010-09-09 18:53:54,046 DEBUG xxx.Persist.NHibernateConnection - CreateSession(Commit)
2010-09-09 18:53:54,046 DEBUG NHibernate.Impl.SessionImpl - [session-id=d70b7e2f-062a-4495-83d0-380345acf920] opened session at timestamp: 634196552340, for session factory: [/0754517161044239b072f9d048fcb17f]
2010-09-09 18:53:54,046 DEBUG NHibernate.Transaction.AdoTransaction - Begin (Unspecified)
2010-09-09 18:53:54,046 DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
2010-09-09 18:53:54,062 DEBUG NHibernate.Event.Default.DefaultSaveOrUpdateEventListener - updating detached instance
2010-09-09 18:53:54,078 DEBUG NHibernate.Event.Default.DefaultSaveOrUpdateEventListener - updating [xxx.Message.MoMessage#0]
2010-09-09 18:53:54,093 DEBUG NHibernate.Event.Default.AbstractFlushingEventListener - collection dereferenced while transient [xxx.Message.MoMessage.Segments#0]
2010-09-09 18:53:54,093 DEBUG NHibernate.Event.Default.DefaultSaveOrUpdateEventListener - updating [xxx.Message.MoMessage#0]
2010-09-09 18:53:54,109 DEBUG NHibernate.Transaction.AdoTransaction - Start Commit
2010-09-09 18:53:54,109 DEBUG NHibernate.Event.Default.AbstractFlushingEventListener - flushing session
2010-09-09 18:53:54,140 DEBUG NHibernate.Event.Default.AbstractFlushingEventListener - processing flush-time cascades
2010-09-09 18:53:54,140 DEBUG NHibernate.Event.Default.AbstractFlushingEventListener - dirty checking collections
2010-09-09 18:53:54,140 DEBUG NHibernate.Event.Default.AbstractFlushingEventListener - Flushing entities and processing referenced collections
2010-09-09 18:53:54,171 DEBUG NHibernate.Event.Default.WrapVisitor - Wrapped collection in role: xxx.Message.MoMessage.Segments
2010-09-09 18:53:54,171 DEBUG NHibernate.Event.Default.DefaultFlushEntityEventListener - Updating entity: [xxx.Message.MoMessage#0]
2010-09-09 18:53:54,187 DEBUG NHibernate.Engine.Collections - Collection found: [xxx.Message.MoMessage.Segments#0], was: [<unreferenced>] (initialized)
2010-09-09 18:53:54,187 DEBUG NHibernate.Event.Default.AbstractFlushingEventListener - Processing unreferenced collections
2010-09-09 18:53:54,187 DEBUG NHibernate.Event.Default.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
2010-09-09 18:53:54,187 DEBUG NHibernate.Event.Default.AbstractFlushingEventListener - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
2010-09-09 18:53:54,187 DEBUG NHibernate.Event.Default.AbstractFlushingEventListener - Flushed: 1 (re)creations, 0 updates, 1 removals to 1 collections
2010-09-09 18:53:54,203 DEBUG NHibernate.Impl.Printer - listing entities:
2010-09-09 18:53:54,203 DEBUG NHibernate.Impl.Printer - xxx.Message.MoMessage{'MoMessageId'='0', 'MoMessageStatus'='52', 'PhoneNetwork'='0', 'MessageText'='Hi mum', 'ToNumber'='89000', 'FromNumber'='447000000000', 'IsCompleted'='True', 'UpdateDate'='09/09/2010 17:53:54', 'Aggregator'='xxx.AbstractAggregator#2', 'Application'='null', 'Segments'='['xxx.Message.MoSegment']'}
2010-09-09 18:53:54,203 DEBUG NHibernate.Event.Default.AbstractFlushingEventListener - executing flush
2010-09-09 18:53:54,203 DEBUG NHibernate.AdoNet.ConnectionManager - registering flush begin
2010-09-09 18:53:54,218 DEBUG NHibernate.Persister.Entity.AbstractEntityPersister - Updating entity: [xxx.Message.MoMessage#0]
2010-09-09 18:53:54,218 DEBUG NHibernate.AdoNet.AbstractBatcher - Opened new IDbCommand, open IDbCommands: 1
2010-09-09 18:53:54,218 DEBUG NHibernate.AdoNet.AbstractBatcher - Building an IDbCommand object for the SqlString: UPDATE dbo.tblCore_MoMessage SET MoMessageStatus = ?, PhoneNetwork = ?, MessageText = ?, ToNumber = ?, FromNumber = ?, IsCompleted = ?, UpdateDate = ?, AggregatorId = ?, ApplicationId = ? WHERE MoMessageId = ?

A: The problem appears to be opening another session inside my current one.  The second/inner session just loads some Aggregator and Application objects.  No idea why that is causing my problem all I can say is not opening another session and loading the other objects has solved the initial problem.
Looks like I will have to use the outer session to load the other objects but I have other stuff to do for now.


text:
Q: Removing number from for loop I have a question about Matlab.
My chunk of code looks like this:
piece = 1:25;
piece([12]) = [];

for sub = 1:(valid_subject)
    group_data = [];
    for j = 1:length(piece)
        group_data = [group_data; subject_data{sub}.trial{j}'];
    end
    group_mat(:,:,1,sub) = group_data
end

What I want to do is to loop through all trials, from 1 to 25, but omitting trial 12. By using length(piece) I just go through 24 numbers, from 1 to 24. Do you know another way to have numbers from 1 to 25 without 12 as j?
Thank you!

A: You have modified piece removing 1 item therefore piece now only has 24 elements and you are telling the for loop to follow [1:1:length(piece)]
Instead of for j=1:length(piece) use for j=1:piece

redpajama_set_name: RedPajamaStackExchange


text:
Q: Round NaN in Haskell To my great surprise, I found that rounding a NaN value in Haskell returns a gigantic negative number:
round (0/0)
-269653970229347386159395778618353710042696546841345985910145121736599013708251444699062715983611304031680170819807090036488184653221624933739271145959211186566651840137298227914453329401869141179179624428127508653257226023513694322210869665811240855745025766026879447359920868907719574457253034494436336205824

The same thing happens with floor and ceiling.
What is happening here? Is this behavior intended? Of course, I understand that anyone who doesn't want this behavior can always write another function that checks isNaN - but are there existing alternative standard library functions that handle NaN more sanely (for some definition of "more sanely")?

A: TL;DR: NaN have an arbitrary representation between 2 ^ 1024 and 2 ^ 1025 (bounds not included), and - 1.5 * 2 ^ 1024 (which is one possible) NaN happens to be the one you hit.

Why any reasoning is off

What is happening here?

You're entering the region of undefined behaviour. Or at least that is what you would call it in some other languages. The report defines round as follows:

 6.4.6 Coercions and Component Extraction
The ceiling, floor, truncate, and round functions each take a real fractional argument and return an integral result. … round x returns the nearest integer to x, the even integer if x is equidistant between two integers.

In our case x does not represent a number to begin with. According to 6.4.6, y = round x should fulfil that any other z from round's codomain has an equal or greater distance:
y = round x ⇒ ∀z : dist(z,x) >= dist(y,x)

However, the distance (aka the subtraction) of numbers is defined only for, well, numbers. If we used
dist n d = fromIntegral n - d

we get in trouble soon: any operation that includes NaN will return NaN again, and comparisons on NaN fail, so our property above does not hold for any z if x was a NaN to begin with. If we check for NaN, we can return any value, but then our property holds for all pairs:
dist n d = if isNaN d then constant else fromIntegral n - d

So we're completely arbitrary in what round x shall return if x was not a number.
Why do we get that large number regardless?
"OK", I hear you say, "that's all fine and dandy, but why do I get that number?" That's a good question.

Is this behavior intended?

Somewhat. It isn't really intended, but to be expected. First of all, we have to know how Double works.
IEE 754 double precision floating point numbers
A Double in Haskell is usually a IEEE 754 compliant double precision floating point number, that is a number that has 64 bits and is represented with
x = s * m * (b ^ e)

where s is a single bit, m is the mantissa (52 bits) and e is the exponent (11 bits, floatRange). b is the base, and its usually 2 (you can check with floadRadix). Since the value of m is normalized, every well-formed Double has a unique representation.
IEEE 754 NaN
Except NaN. NaN is represented as the emax+1, as well as a non-zero mantissa. So if the bitfield
SEEEEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM

represents a Double, what's a valid way to represent NaN?
?111111111111000000000000000000000000000000000000000000000000000
            ^

That is, a single M is set to 1, the other are not necessary to set this notion. The sign is arbitrary. Why only a single bit? Because its sufficient.
Interpret NaN as Double
Now, when we ignore the fact that this is a malformed Double—a NaN– and really, really, really want to interpret it as number, what number would we get?
m = 1.5
e = 1024

x = 1.5 * 2 ^ 1024
  = 3 * 2 ^ 1024 / 2
  = 3 * 2 ^ 1023

And lo and behold, that's exactly the number you get for round (0/0):
ghci> round $ 0 / 0
-269653970229347386159395778618353710042696546841345985910145121736599013708251444699062715983611304031680170819807090036488184653221624933739271145959211186566651840137298227914453329401869141179179624428127508653257226023513694322210869665811240855745025766026879447359920868907719574457253034494436336205824
ghci> negate $ 3 * 2 ^ 1023
-269653970229347386159395778618353710042696546841345985910145121736599013708251444699062715983611304031680170819807090036488184653221624933739271145959211186566651840137298227914453329401869141179179624428127508653257226023513694322210869665811240855745025766026879447359920868907719574457253034494436336205824

Which brings our small adventure to a halt. We have a NaN, which yields a 2 ^ 1024, and we have some non-zero mantissa, which yields a result with absolute value between 2 ^ 1024 < x < 2 ^ 1025.
Note that this isn't the only way NaN can get represented:

In IEEE 754, NaNs are often represented as floating-point numbers with the exponent emax + 1 and nonzero significands. Implementations are free to put system-dependent information into the significand. Thus there is not a unique NaN, but rather a whole family of NaNs.

For more information, see the classic paper on floating point numbers by Goldberg.

A: This has long been observed as a problem. Here're a few tickets filed against GHC on this very topic:

*

*https://ghc.haskell.org/trac/ghc/ticket/3070

*https://ghc.haskell.org/trac/ghc/ticket/11553

*https://ghc.haskell.org/trac/ghc/ticket/3676
Unfortunately, this is a thorny issue with lots of ramifications. My personal belief is that this is a genuine bug and it should be fixed properly by throwing an error. But you can read the comments on these tickets to get an understanding of the tricky issues preventing GHC from implementing a proper solution. Essentially, it comes down to speed vs. correctness, and this is one point where (i) the Haskell report is woefully underspecified, and (ii) GHC compromises the latter for the former.


text:
Q: How to assign a shortcut to the mouse navigation button in Visual Studio? I'm using VS2010, VS2012 & VS2013.
I want to assign a keyboard shortcut to the back/next navigation buttons to be set to View.NavigateBackward and View.NavigateForward.
In the toold->options->keyboard I can't bind a command shortcut to a mouse-previous nor mouse-next button. Maybe because they are not keyboard-shortcuts...
Is there any way to assign a shortcut to those? (or to any mouse+keyboard shortcuts)
I know they are set by default to do almost the same thing but still I find the Ctrl+- and Ctrl++ (NavigateBackward and View.NavigateForward respectively) to be much more predictive and so much more usefull.
I saw this post (which also writes how the mouse-previous and mouse-next button work in VS by default):
How do Visual Studio 2012's navigation buttons behave?
and also the link there on the answer is broken.

A: This is not possible without a VS extension, which can be found here: Link. Sometimes though, the navigation backwards does not work with the mouse, but works when pressing the button in the interface.


text:
Q: vim and python scripts debugging Are there any ways to debug python scripts not leaving vim in *nix systems (executing the script, setting up breakpoints, showing variables in watch-list, etc)?

A: As of Python 3.7, you can use breakpoint() builtin without importing anything.
Built-in breakpoint() calls sys.breakpointhook(). By default, the latter imports pdb and then calls pdb.set_trace()
Inheriting code from Pierre-Antoine's answer, the code would look like this:
def main():
  list = [1,2,3]
  breakpoint()
  list = [2,3,4]

if __name__ == '__main__':
    main()

Source: https://docs.python.org/3/whatsnew/3.7.html#pep-553-built-in-breakpoint

A: Try pyclewn. It allows to use vim as front end for pdb. You can create/delete break points, control flow of debugging process, look at values of your variables. All from vim!

A: Also try https://pypi.python.org/pypi/pudb - its like pdb but more advanced. Contains code highlighting, stack, showing avaliable values, etc. Not only-vim solution but for me works perfectly.
Three Steps:
Install:

pip install pudb

Paste set_trace in code

from pudb import set_trace; set_trace()

Run your code

A: Use pdb:
import pdb
def main():
  list = [1,2,3]
  pdb.set_trace()
  list = [2,3,4]

if __name__ == '__main__':
    main()

Now run using :!python % and you'll hit your breakpoint and be able to debug interactively like in gdb.

A: As 2020 the Debugger Adapter Protocol is taken care by vimspector.
Supporting Cpp, Python, Java, Js, Go ...
See my other answer

A: The vimpdb plugin integrates the Python debugger pdb into the VIM editor.
I do recommend it.
Hope it helps.

A: Vim and pdb-clone is the combination I use. I use Home - pyclewn which provides a replacement for pdb called pdb-clone that is quite faster than vanilla pdb. It integrates well with vim via a plugin, and the thing I appreciate most is that it takes care of breakpoints outside the code, not setting traces within, thus not messing up my line numbers. It does not have a watch window for python yet. You might have a look at vim-debug too, which I could not get to work with my existing highlighting setup.

A: See the "Debugging" section in this blog post. It shows how to setup F7 to set breakpoints and Shift+F7 to remove breakpoints. It also uses pdb, as mentioned before. With a little modification, you can replace the use of pdb with ipdb (pdb using ipython), which is a lot nicer to use.

A: From what I know, there is one more option: You could use Eclipse + PyDev for project managing and Vim as an editor for Eclipse. That way You could use the best of both worlds.
Also, I haven't tried it, but You could try this script.

A: It sounds like you want to use VIM as a Python IDE.
A quick Google search found this and this example, with many more.
EDIT: Well, Ok, it seems likely you've searched more than I have.
I hope someone else has some ideas.


text:
Q: Pivot across multiple columns with repeating values in each column I am trying to pivot a pandas dataframe, but the data is following a strange format that I cannot seem to pivot. The data is structured as below:
Date, Location, Action1, Quantity1, Action2, Quantity2, ... ActionN, QuantityN
<date>   1      Lights    10         CFloor     1        ...  Null     Null
<date2>  2      CFloor    2          CWalls     4        ...  CBasement 15
<date3>  2      CWalls    7          CBasement  4        ...  NUll     Null

Essentially, each action will always have a quantity attached to it (which may be 0), but null actions will never have a quantity (the quantity will just be null). The format I am trying to achieve is the following:
       Lights    CFloor    CBasement   CWalls
1        10         1         0           0
2        0          2         19          11

The index of the rows becomes the location while the columns become any unique action found across the multiple activity columns. When pulling the data together, the value of each row/column is the sum of each quantity associated with the action (i.e Action1 corresponds to Quantity1). Is there a way to do this with the native pandas pivot funciton?
My current code performs a ravel across all the activity columns to get a list of all unique activities. It will also grab all the unique locations from the Location column. Once I have the unique columns, I create an empty dataframe and fill it with zeros:
       Lights    CFloor    CBasement   CWalls
1        0         0         0            0
2        0         0         0            0

I then iterate back over the old data frame with the itertuples() method (I was told it was significantly faster than iterrows()) and populate the new dataframe. This empty dataframe acts as a template that is stored in memory and filled later.
#Creates a template from the dataframe
def create_template(df):
    act_cols = ['Activity01', 'Activity02', 'Activity03', 'Activity04']
    activities = df[act_cols]
    flat_acts = activities.values.ravel('K')
    unique_locations = pd.unique(df['Location'])
    unique_acts = pd.unique(flat_acts)
    pivot_template = pd.DataFrame(index=unique_locations, columns=unique_acts).fillna(0)
    return pivot_template

#Fills the template from the dataframe
def create_pivot(df, pivot_frmt):
    act_cols = ['Activity01', 'Activity02', 'Activity03', 'Activity04']
    quant_cols = ['Quantity01', 'Quantity02', 'Quantity03', 'Quantity04']

    for row in df.itertuples():
        for act, quantity in zip(act_cols, quant_cols):
            act_val = getattr(row, act)
            if pd.notna(act_val):
                quantity_val = getattr(row, quantity)
                location = getattr(row, 'Location')
                pivot_frmt.loc[location, act_val] += quantity_val
    return pivot_frmt

While my solution works, it is incredibly slow when dealing with a large dataset and has taken 10 seconds or more to complete this type of operation. Any help would be greatly appreciated!

A: After experimenting with various pandas functions, such as melt and pivot on multiple columns simulatenously, I found a solution that worked for me:
For every quantity-activity pair, I build a partial frame of the final dataset and store it in a list. Once every pair has been addressed I will end up with multiple dataframes that all have the same row counts, but potentially different column counts. I solved this issue by simply concatenating the columns and if any columns are repeated, I then sum them to get the final result.
def test_pivot(df):
    act_cols = ['Activity01', 'Activity02', 'Activity03', 'Activity04']
    quant_cols = ['Quantity01', 'Quantity02', 'Quantity03', 'Quantity04']
    dfs = []
    for act, quant in zip(act_cols, quant_cols):
        partial = pd.crosstab(index=df['Location'], columns=df[act], values=df[quant], aggfunc=np.sum).fillna(0)
        dfs.append(partial)

    finalDf = pd.concat(dfs, axis=1)
    finalDf = test.groupby(finalDf.columns, axis=1).sum()
    return finalDf

There are two assumptions that I make during this approach:

*

*The indexes maintain their order across all partial dataframes

*There are an equivalent number of indexes across all partial dataframes

While this is probably not the most elegant solution, it achieves the desired result and reduced the time it took to process the data by a very significant margin (from 10s ~4k rows to 0.2s ~4k rows). If anybody has a better way to deal with this type of scenario and do the process outlined above in one shot, then I would love to see your response!


text:
Q: Signing out of GoogleFit I have tried to use this however the recommended does not do anything:
Fitness.getConfigClient(this, GoogleSignIn.getLastSignedInAccount(this)).disableFit()

How I authenticate with Google:
if (!GoogleSignIn.hasPermissions(GoogleSignIn.getLastSignedInAccount(this), fitnessOptions)) {
        GoogleSignIn.requestPermissions(this, REQUEST_OAUTH_REQUEST_CODE,
                GoogleSignIn.getLastSignedInAccount(this),
                fitnessOptions);
    } else {
        subscribe();
    }

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == Activity.RESULT_OK) {
            if (requestCode == REQUEST_OAUTH_REQUEST_CODE) {
                subscribe();
            }
        }
    }

public void subscribe() {

        Fitness.getRecordingClient(this, GoogleSignIn.getLastSignedInAccount(this))
                .subscribe(DataType.TYPE_STEP_COUNT_CUMULATIVE)
                .addOnCompleteListener(
                        new OnCompleteListener<Void>() {
                            @Override
                            public void onComplete(@NonNull Task<Void> task) {
                                if (task.isSuccessful()) {
                                    Log.i(TAG, "Successfully subscribed!");
                                } else {
                                    Log.w(TAG, "There was a problem subscribing.", task.getException());
                                }
                            }
                        });
    }

I need to be able to get the google account which was last signed in and provide an option to the user to sign out of their google account.

A: For disconnecting Google account from your app you should use signOut method from GoogleSignIn which will preserve granted permissions or you can use revokeAccess method to do both signing out and revoke granted permissions:
val options = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
    .addExtension(getFitnessOptions())
    .requestProfile()
    .build()

GoogleSignIn.getClient(this, options).signOut() // or GoogleSignIn.getClient(this, options).revokeAccess()


text:
Q: Cordova app no longer sends cookies in its httprequests I have an Ionic (Cordova/Angular) app that I have running on an Android phone (Galaxy S6 Edge, Android 5.1.1).
This app communicates with a server for which the user must login first.
After login, authentication cookies received from the server are automatically send back to the server on each request by including withCredentials=true inside $http calls.
For instance:
$http({
                method: 'POST',
                url: LoginStatusUrlMobile,
                responseType: 'document',
                withCredentials: true
            })

This used to work, but this weekend the cookies were no longer sent and the app no longer works.
I tried several things to figure out what is going on:

*

*Is it the new release of Chrome 46?
=> I uninstalled the updates of Chrome and the Chrome webview on my Phone but this didn't make any difference

*In my development environment the app still works (Chrome version 46.0.2490.71 on Mac with --disable-web-security to turn of same origin policy)

*I tried to run the app inside Genymotion and this worked on a virtual device running Android 4.4.4 but it didn't send the cookies on a virtual device running Android 5.1.0

*The app also runs on iOS, and I haven't tested that thoroughly yet but it works OK on my iPad with iOS 8.1
This is my situation right now and my question is:
does anyone know how to send cookies back to the server with angular $http requests, when withCredentials=true no longer seems to work.

A: I found a solution by removing the Android platform and then recreating it.
After that I added the cordova-whitelist-plugin as stated here.
Now everything is working properly again.


text:
Q: Why is the log-Sobolev constant of a finite Markov chain attained? I am reading through Saloff-Coste's "Lecture notes on finite Markov Chains". He defines the log-Sobolev constant $\alpha$ of a finite Markov Chain $(K, \pi)$ [transition kernel $K$, stationary measure $\pi$] by
$$ \alpha(K) = \min \left\{ \frac{\mathcal E(f, f)}{\mathcal L(f)} : \mathcal L(f) \ne 0\right\}$$
where $\mathcal E(\bullet, \bullet)$ is the Dirichlet-form of $(K, \pi)$, and $\mathcal L(f) = \textrm{E}_\pi |f|^2 \log \frac{|f|^2}{\|f\|_2^2}$.
Under the assumption of the existence of a function $u$ which attains this minimum, he proves that $\alpha > 0$, but I don't see why such a function should exist (since the set we are optimising on isn't even closed).
[[I am asking, why is this a min, and not an inf in the definition.]]
Thanks!

A: A scaling argument shows that
$$
\alpha(K)=\inf\{\mathcal E(f,f):\mathcal L(f)=1\}.
$$
Now you are minimizing a continuous function over a compact set -- because the setting is finite dimensional.


text:
Q: docker hub: interpreting layers to understand what is already installed I have started using docker frequently recently. I usually pull an image from dockerhub or write a Dockerfile based on a dockerhub image.
Is there a way to know what is already in the image (obviously without pulling the image) like what OS it is built on, if python, pip is installed, if some python library like NumPy is installed or not?
For example: this image https://hub.docker.com/layers/tensorflow/tensorflow/2.6.0rc0-gpu
From the tag, I can know that it has tensorflow with cuda (gpu) support. But no other info is provided.
I recently figured out, I can click each layer, to see the actual code. But it actually takes some digging around to find more details.
For example: I saw some apt commands to figure out it is based on debian/ubuntu OS. Or, after reading the python3-pip keyword from the image, I realized pip is installed.
The code is not very readable (to me at least). Is there a better way to figure what is already in the image to avoid redundant installation in the Dockerfile?

A: You can always find the dockerfile of the image that you're interested in. For example, you can find all layers of, for example, image python:3.9 here
Or you can use docker history to view all layers of one image.
Docker (brilliantly) use previous layers for a new build, and this is also primary difference from virtual machine. For example, you can pull a python image:
docker pull python:3.6

Take a quick look at images available with docker image ls you can find an image id like this
python       3.6       5fad76530472   7 days ago           875MB
Then create a new dockerfile:
FROM python:3.6
ENTRYPOINT ["echo", "something"]

The image python is already downloaded at /var/lib/docker/overlay2 so when you run it with docker build -f dockerfile ., you can see:
Sending build context to Docker daemon     47MB
Step 1/2 : FROM python:3.6
 ---> 5fad76530472
Step 2/2 : ENTRYPOINT ["echo", "test"]
 ---> Running in b7034642a88d
Removing intermediate container b7034642a88d
 ---> 0a6f3dc9d10a
Successfully built 0a6f3dc9d10a

The image id of Python is exactly the same, which means Docker doesn't restart everything from scratch, but instead, reuse the image already available.
If you go to the directory /var/lib/docker/overlay2, and run
$ du -sh -m overlay2
1087 overlay2

This means the total size of data for is about 1087 MBs, but if you run docker image ls and sum up the total size of all images, it is much bigger! We can say that there is some sort of intelligent mechanics for storing Docker images and that we cannot simply imply that all the sizes of the Docker images equal retrieve the real storage size.
Hopefully, this addresses partly your concerns about redundant images in Dockerfile.


text:
Q: How can a parameter in a Generic method be assigned to an Integer and a Character class at the same time? Why this code isn't showing any compilation error?
public class Generic
{
    public static void main(String[] args)
    {
        Character[] arr3={'a','b','c','d','e','f','g'};
        Integer a=97;
        System.out.println(Non_genre.genMethod(a,arr3));
    }
}

class Non_genre
{
    static<T> boolean genMethod(T x,T[] y)
    {
        int flag=0;
        for(T r:y)
        {
            if(r==x)
                flag++;
        }
        if(flag==0)
            return false;
        return true;
    }
}

If we write a normal code like this(shown below)
public class Hello
{
    public static void main(String[] args)
    {
        Character arr=65;
        Integer a='A';
        if(arr==a)  //Compilation Error,shows Incompatible types Integer and Character
            System.out.println("True");
    }
}

Then why the above above is running fine,how can T be of Integer class and array of T be of Character class at the same time,and if its running then why its not printing true,ASCII vaue of 'a' is 97,so it should print true.

A: Because the compiler infers Object as a type argument for your invocation of
Non_genre.genMethod(a, arr3)

Within the body of that method
static <T> boolean genMethod(T x, T[] y) {

your type parameter T is unbounded, and so can only be seen as an Object.
Since x and the elements of y are of the same type (T), they can be compared just fine.
if (r == x)


text:
Q: A fatal error occurred while creating a TLS client credential. The internal error state is 10013 Recently deployed a Windows 2016 Standard Server, with Active Directory and Exchange 2016.
We have disabled SSL 1.0, 2.0 and 3.0 for both Server and Client, and have disabled TLS 1.0 and TLS 1.1.
We are repeatedly getting the following entry in our system log.  What is causing this, and how can I fix it.

A: Basically we had to enable TLS 1.2 for .NET 4.x.  Making this registry changed worked for me, and stopped the event log filling up with the Schannel error.
More information on the answer can be found here
Linked Info Summary
Enable TLS 1.2 at the system (SCHANNEL) level:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2]
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server]
"DisabledByDefault"=dword:00000000
"Enabled"=dword:00000001

(equivalent keys are probably also available for other TLS versions)
Tell .NET Framework to use the system TLS versions:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SystemDefaultTlsVersions"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SystemDefaultTlsVersions"=dword:00000001

This may not be desirable for edge cases where .NET Framework 4.x applications need to have different protocols enabled and disabled than the OS does.

A: After none of the methods I could find anywhere helped me:
I opened the Event Viewer and searched when this error started to show so often. I used filter set to Error from Schannel source. In my case, this error was happening every now and then but then, on certain date, it started to show every few seconds! I went to Settings -> Apps & features and searched if anything new was installed on this date – and bingo! It was PrivadoVPN. After uninstalling PrivadoVPN, the error stopped to show!
P.S. I'm not saying that specifically PrivadoVPN is problematic. Mybe it is something with my configuration… Just suggesting the method I used to find the root cause of the error in my case.

A: After making no changes to a production server we began receiving this error.  After trying several different things and thinking that perhaps there were DNS issues, restarting IIS fixed the issue (restarting only the site did not fix the issue).  It likely won't work for everyone but if we tried that first it would have saved a lot of time.

A: In my case, the Windows 2016 server where this was happening was hardened for security compliance. As a result, only specific cipher suites were allowed. This was causing an incompatibility when making HTTPS connections to highly secure endpoints (like Apple Push Notifications API aka APNS)
To fix the issue, I downloaded IIS Crypto and clicked on the Cipher Suites button on the left, to display the list of enabled/disabled cipher suites, and then clicked the "Best Practices" button and rebooted the server. Problem fixed.

A: I encountered this while rebuilding a server that was moving from Server 2012R2 to DataCenter 2019.  It was making me crazy because I could debug it from Visual Studio just fine but IIS immediately returned a 500 error.
In my case, we have several .NET 3.5 and .NET 4.5 applications commingled on the same server and when I created the application for one of the 4.5 applications I had pointed it to the 2.0 App Pool.
Repointing it to the 4.0 App Pool resolved the issue.

A: I found this here: https://port135.com/schannel-the-internal-error-state-is-10013-solved/
"Correct file permissions
Correct the permissions on the c:\ProgramData\Microsoft\Crypto\RSA\MachineKeys folder:
Everyone Access: Special Applies to 'This folder only'
Network Service Access: Read & Execute Applies to 'This folder, subfolders and files'
Administrators Access: Full Control Applies to 'This folder, subfolder and files'
System Access: Full control Applies to 'This folder, subfolder and Files'
IUSR Access: Full Control Applies to 'This folder, subfolder and files'
The internal error state is 10013
After these changes, restart the server. The 10013 errors should disappear."


text:
Q: .htaccess rewrite subdirectory to parent directory I have a page template that exists at a directory:
/users/

I would like to use the page template at this level, call it index.php for any other sub directories within this directory
/users/firstname-lastname/

Essentially using the next directory as a clean query string to dictate what is on the index.php page.
Thanks in advance for the help!

A: Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your  DOCUMENT_ROOT/.htaccess file:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{DOCUMENT_ROOT}/$1/$2 -d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(users)/(.+)$ /$1/index.php [NC,L]


text:
Q: RabbitMQ upgrade from 3.6.6 to 3.6.11 I have a question related to RabbitMQ upgrade from 3.6.6 to 3.6.11.
Is it possible to upgrade directly from 3.6.6 to 11 or we should go step by step.
In the release notes, it is stated that 3.6.11 doesn't have incompatibility issues with 3.6.7 walking through 3.6.10, what about 3.6.6?
https://github.com/rabbitmq/rabbitmq-server/releases/tag/rabbitmq_v3_6_11
Does anyone have prior experience with upgrading RabbitMQ?

A: To upgrade a non-clustered RabbitMQ from one major or minor release to another simply install the new version and restart it. All configuration and persistent message data is retained.
In case of clustered RabbitMQ setup there are some caveats. Please refer to the following link for upgrading RabbitMQ cluster:
http://www.rabbitmq.com/clustering.html#upgrading
As a side note, please refer the release notes before upgrading for any key announcements.
FYI: We did a non-clustered RabbitMQ upgrade on our production setup by simply installing the latest version and restarting it. Everything worked fine.


text:
Q: How to determine current branch in post-rewrite hook Background: I want to have post-rewrite hook that will push changes automatically to the upstream repo (I'm the only user of it, and I use it to share my own work between different machines). The post-rewrite is the only time when I have to use force push, so I'd like it to be something like:
currentBranch=...
git push [origin] $currentBranch -f

In other questions it's been suggested to use git rev-parse --abbrev-ref HEAD or git symbolic-ref --short HEAD. These both correctly determine current branch when used outside of post-rewrite script, but not inside of it. If I set my post-rewrite script to be:
#!/bin/bash
git rev-parse --abbrev-ref HEAD
git symbolic-ref --short HEAD

Console output will be:
$ git rebase [...]
First, rewinding head to replay your work on top of it...
Applying: [...]
HEAD
fatal: ref HEAD is not a symbolic ref
$ git rev-parse --abbrev-ref HEAD
myBranch
$ git symbolic-ref --short HEAD
myBranch

EDIT:
Short script to replicate my issue:
# setup the repo
git init test
cd test
echo "git rev-parse --abbrev-ref HEAD" >> .git/hooks/post-rewrite
echo "git symbolic-ref --short HEAD" >> .git/hooks/post-rewrite
chmod a+x .git/hooks/post-rewrite

# create the root branch
git checkout -b root
touch test
git add test
git commit -m "test commit for root" test

# branch out
git checkout -b test1
touch test1
git add test1
git commit -m "test commit 1" test1

# branch out again
git checkout -b test2 root
touch test2
git add test2
git commit -m "test commit 2" test2

# rebase
git rebase test1
git rev-parse --abbrev-ref HEAD
git symbolic-ref --short HEAD

Expected output would be (after cutting out previous messages):
First, rewinding head to replay your work on top of it...
Applying: test commit 2
test2
test2
test2
test2

Instead, I get
First, rewinding head to replay your work on top of it...
Applying: test commit 2
HEAD
fatal: ref HEAD is not a symbolic ref
test2
test2

A: Between Filip Wolski's additional information (edit and comments) and manual investigation, I now believe this is a bug in git.
When you invoke a non-interactive rebase, git runs its git-rebase--am script (out of the git --exec-path directory), which detaches from the current branch and uses git am ... --rebasing ... to apply patches (as produced by git format-patch with various flags).
There is an exception here: if you use the keep-empty-commits flag, the script uses git cherry-pick to copy commits, including empty commits.
In any case, at the end of git-rebase--am, the script gets back on the branch and adjusts the branch label.  However, this is after the git am script has finished and returned.  It's the git am script that invokes the post-rewrite hook, and that happens too soon, before the "current branch" notion has been restored.
This seems to make for two bugs:

*

*If you use the -k or --keep-empty flag, the post-rewrite script won't run at all.

*Otherwise you hit this case, where the post-rewrite hook runs, but while in detached-HEAD state.

It seems to me that $(git --exec-path)/git-am needs to leave the notes adjusting and post-rewrite hook to the git-rebase--am script.
Until the bug is fixed, one workaround is to use interactive rebase (you can set the environment variable GIT_SEQUENCE_EDITOR to : or true to make it run without an edit session).


text:
Q: radiobuttonlist selectedindexchanged event not firing every time Here's the data bind code:
    protected void Page_Init(object sender, EventArgs e)
    {
        List<ListItem> source = new List<ListItem>();
        source.Add(new ListItem("Remark A", "0"));
        source.Add(new ListItem("Remark B", "1"));
        source.Add(new ListItem("Remark C", "2"));

        rbnRemarks.DataSource = source;
        rbnRemarks.DataBind();
    }
    protected void rbnRemarks_SelectedIndexChanged(object sender, EventArgs e)
    {
        refreshGrid();
    }

Here's the Markup page:
    <asp:RadioButtonList OnSelectedIndexChanged="rbnRemarks_SelectedIndexChanged" AutoPostBack="true" runat="server" ID="rbnRemarks" RepeatDirection="Horizontal">
    </asp:RadioButtonList>

The problem is:
If I change the selected item to Remark B or Remark C the event is fired, but if I change the selected item back to Remark A, the event isn't fired and the Page_Init only triggers when I select Remark B or Remark C, why this happen??


text:
Q: Improve hovering over points to display tooltip I am developing a datetime series line chart of efficiencies (in percentage) over time.
I need a tooltip to display information about each point on the chart, but I am finding that it is difficult to hover over points which coincide with the line or marker of another series.
The chart will be static in nature in that users will not be able to remove series from the chart - so they wouldn't be able to remove a series in order to be able to get more easily hover over the desired point.
In this demo - https://jsfiddle.net/slaws/37y4cteq/10/ - it takes many attempts moving the cursor in that area to get the tooltip for the last point in the series with the black markers to show.
Here

I moved my cursor around the area marked in red, but couldn't get the tooltip for any points other than one shown to display.
I had to follow a specific procedure and get my cursor to a specific point to be able to hover over the black marker and get the tooltip to display. Here

I had to hover over the second to last black marker and then move the cursor to the point indicated to get the tooltip for the last marker to display.
I have tried using the findNearestPointBy (x, y and xy) in combination with stickyTracking (true and false), with no improvement.
        "stickyTracking": false,
        "findNearestPointBy": 'y'

I read something about a direct hover mode rather than nearest neighbor but found no details about how to implement that.
Any guidance on how I can make it easier for my users to display the tooltips in my use case would be greatly appreciated!

A: Setting tooltip.snap as 0 and setting back stickyTracking to default options fixes your issue.
Demo: https://jsfiddle.net/BlackLabel/54q2eubd/
API: https://api.highcharts.com/highcharts/tooltip.snap


text:
Q: Access openfire Java API through .net? I am looking to access the openfire Java API through .net/asp.net so I can basically interface openfire and it's plugins in an asp.net web application.
I am wondering what the best way to go about accessing a Java API through .net or if someone knows of another way of using openfire with asp.net. I know that doing a conversion with sharpen would take a very long time and probably wouldn't be worth it.
Any information on this topic is good information IMO. Thank you.

A: There are several solutions available:

*

*IKVM.NET

IKVM.NET is an implementation of Java for Mono and the Microsoft .NET
  Framework. It includes the following components:

*

*A Java Virtual Machine implemented in .NET

*A .NET implementation of
  the Java class libraries

*Tools that enable Java and .NET interoperability

*

*jni4net

Bridge between Java and .NET (intraprocess, fast, object oriented,
  open-source)


text:
Q: How to make a dialog box in android returning a value (boolean) I am making an application in which i need to display dialog box many times,I do not want to write code of dialog box again and again,so how should I make a common dialog box so that i can perform different functions on selection of yes or no at different places. please help,I tried a lot but not got the solution.

A: You can create a method like:
public Dialog showDialog(String title, String msg, final Activity activity) {

        final AlertDialog alertDialog = new AlertDialog.Builder(activity)
                .create();
        alertDialog.setTitle(title);
        alertDialog.setMessage(msg);
        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                alertDialog.dismiss();

                    activity.finish();

            }
        });
        alertDialog.show();

        return alertDialog;

    }

And wherever you want to make dialog just call showDialog("Title","your message",Acitivity);

A: Declare dialog box as public
        public Dialog dialog_box;

Initialize it.... in oncreate...
    dialog_box = new Dialog(HSMPDFViewer.this,android.R.style.Theme_Translucent);
    dialog_box.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog_box.setCancelable(true);

Make a function for it...
and use it...
     /**
 * Alert Dialog
 */
public void AlertDialogMessage() {
    dialog_text.setText("Problem in loading ..");
    dialog_btnOk.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            dialog_box.dismiss();
        }
    });
    dialog_box.show();

}

A: You could try making a class extended from Dialog/AlertDialog or whatever you want. Then you can implement some functionality of your custom Dialog box. You can make yesPerformed() and noPerformed() methods which ones you can simply override when you need to use your custom DialogBox.

A: I am just pasting my ready made code here as i did with my projects. Please modify different tags accordingly or ask me for further help!

*

*The Following dialog can be made backward compatible to 1.6 using android v4 support library

*Dialog will not dismiss itself on device rotation.

This is how your dialog will looks like:

Step 1: Create a new class with the name ConfirmationDialog and past the following code in it.
public class ConfirmationDialog extends DialogFragment {

    private Handler mHandler;
private Bundle mBundle;
private String messageToShow;
private String dialogTitle;

public ConfirmationDialog(Handler mHandler, String dialogTitle,
        String messageToShow) {
    this.mHandler = mHandler;
    mBundle = new Bundle();
    this.messageToShow = messageToShow;
    this.dialogTitle = dialogTitle;
    Log.i(MyConstants.LOG_TAG,
            "------------CONSTRUCTOR EXECUTED------------");
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRetainInstance(true);
    Log.i(MyConstants.LOG_TAG, "------------ONCREATE EXECUTED------------");
}

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(dialogTitle);
    builder.setIcon(R.drawable.ic_alerts_and_states_warning);
    builder.setMessage(messageToShow);
    builder.setPositiveButton(getString(R.string.ok),
            new OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mBundle.clear();
                    mBundle.putInt(MyConstants.CONFIRM_NOTE_DELETE_TAG,
                            MyConstants.DIALOG_OK);
                    Message m = new Message();
                    m.setData(mBundle);
                    mHandler.sendMessage(m);
                }
            });

    builder.setNegativeButton("Cancel", new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            mBundle.clear();
            mBundle.putInt(MyConstants.CONFIRM_NOTE_DELETE_TAG,
                    MyConstants.DIALOG_CANCEL);
            Message m = new Message();
            m.setData(mBundle);
            mHandler.sendMessage(m);
        }
    });
    Dialog theDialog = builder.create();
    theDialog.setCanceledOnTouchOutside(true);
    return theDialog;
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    return super.onCreateView(inflater, container, savedInstanceState);
}

@Override
public void onDestroyView() {
    if (getDialog() != null && getRetainInstance()) {
        getDialog().setDismissMessage(null);
    }
    super.onDestroyView();
    }
}

Then past the following code in the fragment where you want to show the dialog:
Handler mHandler = new Handler() {
    public void handleMessage(Message m) {
        Bundle mBundle = new Bundle();
        mBundle = m.getData();
        Log.i(MyConstants.LOG_TAG, "Got the data returned by the Dialog!");

        int dialogOkCancel = MyConstants.DIALOG_CANCEL;
        if (!mBundle.isEmpty())
            dialogOkCancel = mBundle.getInt(
                    MyConstants.CONFIRM_NOTE_DELETE_TAG,
                    MyConstants.DIALOG_CANCEL);
        if (dialogOkCancel == MyConstants.DIALOG_OK) {
            Log.i(MyConstants.LOG_TAG, "Ok selected");
        } else if (dialogOkCancel == MyConstants.DIALOG_CANCEL) {
            Log.i(MyConstants.LOG_TAG, "Cancel selected");
        }
    } // end handleMessage
};

Step 3: Then execute this code when you want to show the dialog:
ConfirmationDialog mConfirmationDialog = new ConfirmationDialog(
                        mHandler, "Delete Routine Task",
                        "Are you sure to delete Routine Task?");
                FragmentManager fragmentManager = getFragmentManager();
                FragmentTransaction fragmentTransaction = fragmentManager
                        .beginTransaction();
                fragmentTransaction.add(mConfirmationDialog,
                        MyConstants.CONFIRM_NOTE_DELETE_TAG);
                fragmentTransaction.commit();

A: In order to avoid  code  rewriting for  Dialogues,I created a custom class  which  can be used  from any UI activity.
Create a customDialog class  as below and call from any activity by   CustomDialog.ShowErrorDialog(errormsg,myActivity.this);
or by
CustomDialog.ShowErrorDialogNRedirect(errormsg,myActivity.this,redirectActivityClass);
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;

/*****
 *
 *    This is CustomDialog class which is used commonly  in all the UI Activity .
 *  1)ShowErrorDialog function  is called from any activity by:
 *  --> CustomDialog.ShowErrorDialog(errormsg,myActivity.this);
 *
 *  This Dialogue shows  error msg only.
 *
 *
 *  2)ShowErrorDialogNRedirect function  is called from any activity by:
 *  --> CustomDialog.ShowErrorDialogNRedirect(errormsg,myActivity.this,redirectActivityClass);
 *   This Dialogue shows  error msg and redirects from one UI Activity to another Activity.
 *
 * @author Jerry Abraham Varghese
 * @license  WTFPL (do whatever you want with this, nobody cares)
 */

public class CustomDialog  {

    // (1) Show  Error  Dialog
 @SuppressWarnings("deprecation")
public static void ShowErrorDialog(String errormsg ,final Activity activity)
 {
     AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
        // Setting Dialog Title
alertDialog.setTitle("Alert ");
// Setting Dialog Message
alertDialog.setMessage(errormsg);
// Setting Icon to Dialog
//alertDialog.setIcon(R.drawable.tick);
// Setting OK Button
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int which) {
 // Write your code here to execute after dialog closed
// Toast.makeText(getApplicationContext(), "You clicked on OK", Toast.LENGTH_SHORT).show();
     }
});
// Showing Alert Message
        alertDialog.show();
 }

 // (2) Show  Error  Dialog &  Redirect After Showing the Dialogue
 @SuppressWarnings({ "deprecation", "rawtypes" })
 public static void ShowErrorDialogNRedirect(String errormsg,final Activity activity,final Class nextRedirectActivityClass) {
     AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
     // Setting Dialog Title
 alertDialog.setTitle(" ");
 // Setting Dialog Message
 alertDialog.setMessage(errormsg);
 // Setting Icon to Dialog
 alertDialog.setIcon(R.drawable.companylogo);
 //On touch outside does not allow anything by setting "setCanceledOnTouchOutside" to false
 alertDialog.setCanceledOnTouchOutside(false);
 //In order to avoid the back pressed button not  to work when Dialog is open below code:
 alertDialog.setCancelable(false);
 // Setting OK Button
 alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
 public void onClick(DialogInterface dialog, int which) {
 // Write your code here to execute after dialog closed
     Intent nextActivity= new Intent(activity,nextRedirectActivityClass);
     activity.startActivity(nextActivity);
     }
});
// Showing Alert Message
alertDialog.show();
 }//End function of ShowErrorDialog()

}


text:
Q: Sync iPhone 4 to a new computer
Possible Duplicate:
How do I transfer my iPhone and iTunes application to another computer?
Transfer music from iPhone to the computer

i have a emergent problem for my iphone 4.
My old computer crashed. I now need to sync my iphone to a new computer. How can I do this when the iphone is only made to sync to one computer? help please!

A: Ehm... Install iTunes and connect your phone?


text:
Q: BigQuery connection for Power BI through ODBC drivers I am facing an issue while trying to connect BigQuery to Power BI using Simba ODBC driver. Does anybody faced an issue like this and can help me with it? Any help or suggestion is appreciated! Thank you very much in advance!
On BigQuery, I have a table which is connected directly from Google Sheets using its URL. First I tried to connect BigQuery or Google Sheets to Power BI but it gave me authentication errors. Then I learned that I can use ODBC drivers to prevent this issue. I downloaded and configured the driver and tested, it worked successfully. Then I created the connection through ODBC on Power BI, right now I can see and connect all the table I have in my project but the table I need is not there still. Could this issue be because of the Google Sheets access settings, because it is not publicly accessible?

A: As James mentioned, Power Bl has a direct connector to BigQuery Connect to BigQuery in Power BI Desktop. You should give it a try.
I read that Google BigQuery can query Google Sheets just like any other table. Look here:  BigQuery and Google Sheets. The MS documentation does not mention any limitation or restriction related to Google Sheets so I think there won't be any other issue.
Also, did you follow any tutorial or doc? Can you share it?

A: Some "Google resources" (projects, files, etc) tend to be hidden so external tools can't see or access to them, even when there is a connection between tools.
This user had a similar situation BigQuery Sheets and Power BI connector, take a look at it. They suggested to enable the Google Drive API so they can manipulate file's data.
Another similar situation was seen here Connecting Google Sheets to Power BI, where they connected the Spreadsheet directly to Power BI. This is more related, as you prior mentioned, to the file's privacy settings.

A: I have created connection power bi to big query engine using ODBC and Simba driver, here
I'm explaining the procedure
1) Download Simba driver for BigQuery from Download and install

2) Search ODBC Driver (64bit) in the windows search bar

3) From that you click and move to system DNS, there you can find the Google Big Query Driver installed

4) Select Driver and Click configuration option then select OAuth Mechanism is User Authentication and click the sign-in button

5) It redirects to login and permission allow the window

6) Once you allowed then you will get a refresh token. Copy that one and past on ODBC driver refresh token text box and select your project to query and get the data

7) Go to Power bi and select get data option select ODBC driver, click connect option

8) Data source name as google big query and next text box leave blank and last text box write your query

9) finally you will get the result as given below.


text:
Q: How can I convert an XML processing instruction to a tag using Perl? How do I convert the processing instruction elements into normal XML element using Perl?
for example:
<?legalnoticestart?>
<?sourcenotestart?>
<para>Content para</para>
<?sourcenoteend?>
<?literallayoutstart?>
<?literallayoutend?>
<?literallayoutend?>
<?legalnoticeend?>

Required format:
<legalnotice>
<sourcenote>

Content para

</sourcenote>
<literallayout>

body content

</literallayout>
</legalnotice>

Please give me any solutions using Perl scripts?
Code will be appreciated.
Best Regards,
Antony

A: Oddly enough I would use XML::Twig for that:
#!/usr/bin/perl

use strict;
use warnings;

use XML::Twig;

XML::Twig->new( twig_roots => { '#PI' => \&out_pi, },
                twig_print_outside_roots => 1,
              )
         ->parsefile( 'pi2elt.xml')
         ;

sub out_pi
  { my( $t, $pi)= @_;
    my $target= $pi->target;
    $target=~ s{^(.*)start$}{$1};
    $target=~ s{^(.*)end$}{/$1};
    print "<$target>";
  }

This will go through the file, only processing PIs ( the twig_roots option)and outputting the rest unchanged (the twig_print_outside_roots option).
A few caveats: your input file needs to be valid XML, so it must be in UTF-8 or UTF-16, or have an XML declaration that specifies its encoding. There is also no check at all that the output is valid XML, you can check the output with any proper XML parser.

A: Here's my solution (regex based):
my $string = <<TEXT;
<?legalnoticestart?>
<?sourcenotestart?>
<para>Content para</para>
<?sourcenoteend?>
<?literallayoutstart?>
<?literallayoutend?>
<?literallayoutend?>
<?legalnoticeend?>';
TEXT

$string =~ s!<\?([^\?]+)start\?>!<\1>!g;
$string =~ s!<\?([^\?]+)end\?>!</\1>!g;
print $string;


text:
Q: Redistributable Python 2.7 package for bundling? Our application embeds a Python interpreter to let users run one-off scripts and extend the application through plugins.
We are embedding Python 2.7 (and not Python 3.x) because our field (visual effects and animation) has not made the transition yet. Python 2.7 is also the version mandated by the VFX Reference Platform.
To make our users' life easier, we would like to bundle a Python 2.7 distribution with our application, at least on Windows.
We are looking for a redistributable Python 2.7 package that we could bundle with our application, similar to what exists for Python 3.x.
Does such a thing exist?


text:
Q: Is there diffrence to get MAC address PC and Cellphone? I would like to get MAC address in Laravel project.
my Laravel Framework is 6.18.8
I use below code and I could get MY PC's MAC address sucessfully
However When I access this page by my cellphone I can't get MAC address.
I looked Mysql database's table, the MAC column was empty.
Could someone teach me right code please?
THis is my current code
 function getMAcAddressExec()
    {
            return substr(exec('getmac'), 0, 17);
    }


text:
Q: Adjustbox do not scale up smaller image does not work I am trying to set the max width of an image by using the adjustbox package. What I want is that an image only scales DOWN to \linewidth if needed. But if it smaller than \linewidth then it should NOT be scaled at all. However when using the following code, the image gets still scaled to \linewidth
\documentclass[a4paper]{scrreprt}

\usepackage[pdftex]{graphicx}

\usepackage[export]{adjustbox}

\begin{document}
xxxxx
\begin{figure}[H]
    \centering
    \adjincludegraphics[max width=\linewidth]{images/dialog.png}
    \caption[asdf]{asdf}
    \label{fig:dialog}
\end{figure}
yyyyyyyyyy
\end{document}

What did I miss?

A: Some information is missing from your question. Since, I do not have that specific image to test with, I must raise a few queries.

*

*Did you crop out the required dialogue box from your screenshot and then used the cropped image in LaTeX?

*If so, post-cropping did you resize the image? If not, as @LaRiFaRi mentions, what is its original resolution? For example, width=221 pixels at 96 dpi & height=334 pixels at 96 dpi
This way, looking at the original resolution of just the required part within your screenshot (e.g. the dialogue box) should give you an idea.

*Also, do you intend to use \linewidth or \textwidth? Both are quite different! In your current situation, the difference may not matter. However, from the conventional point of view:

A \linewidth is defined as -- The width of a line in the local
  environment.
  A \textwidth is defined as -- The width of the text on
  the page. (fixed design-oriented length) ; for reference, see: LaTeX default lengths

Also see this scintillating discussion on Difference between \textwidth, \linewidth and \hsize, which includes a nicely illustrated example that shows the difference between these lengths in different situations.

*To print the exact size of either of these lengths, use the following after \begin{document} :
textwidth = \the\textwidth ; linewidth = \the\linewidth ; hsize = \the\hsize
In onecolumn mode, all three lengths should be equal.

*Now, you can compare your original image resolution and the size of your selected width parameter to determine if the image is smaller or larger than the width. For unit conversions, see: Units used in LaTeX
That should provide you with enough tools to troubleshoot your own problem! Happy hunting!!


text:
Q: Proving $\lim_{x\to 1}\frac{2+4x}{3}=2$ using the $\epsilon$ -$\delta$ definition of a limit I'm looking for a verification of my $\epsilon-\delta$ proof of a limit example, if my proof is not completely mathematically rigorous, please tear it apart.

Required to Prove:
$$\lim_{x \to 1} \ \  \frac{2+4x}{3} = 2$$

Epsilon-Delta Definition
$$  \lim_{x \to a} f(x) = L \Leftrightarrow \forall \epsilon >0 (\exists  \delta>0 \ni (\forall x \in D(0 < |x-a| < \delta \implies |f(x)-L| < \epsilon)))$$

Proof:

I start out with $0 < |x-a| < \delta$ and use it to prove that it implies $|f(x)-L| <\epsilon$
$$0 < |x-a| < \delta$$
$$Let \ \ a = 1$$
$$0 < |x-1| < \delta$$
Multiplying by 4 throughout the inequality we get
$$4(0) < 4|x-1| < 4\delta$$
$$0 < |4x-4| < 4\delta$$
Diving by 3 throughout the inequality we get
$$\frac{0}{3} < \frac{1}{3}|4x-4| < \frac{4}{3}\delta$$
$$0 < |\frac{4x-4}{3}| < \frac{4}{3}\delta$$
$$0 < |\frac{4x+2}{3}-2| < \frac{4}{3}\delta$$
Letting $f(x) = \frac{4x+2}{3}$ and $L=2$, we can see that we have something similar to what we want to arrive at
$$0 <|f(x)-L| < \frac{4}{3}\delta$$
This suggests that we choose $\frac{4}{3}\delta = \epsilon \implies \delta = \frac{3}{4}\epsilon$
$$\implies |f(x)-L|<\epsilon \ , \ \ \ \forall \ \delta =\frac{3}{4}\epsilon$$
$$\implies \delta(\epsilon) = \frac{3}{4}\epsilon $$
Therefore we have proven that given any $\epsilon > 0$, we can always find a $\delta>0$, that satisfies the inequality $0 <|x-a|<\delta \implies |f(x)-L|<\epsilon$
$$ Q.E.D.$$

Some notes on my proof.
(and on writing delta as a function of epsilon)
Since $\delta$ is dependent on $\epsilon$ I've written $\delta$ as a function of $\epsilon$ , i.e. $\delta(\epsilon)$. Sometimes this is seen as a "no-no" when writing $\epsilon - \delta$ proofs, because as a previous user put it :

"I guess one could also write something like $\delta(\epsilon)$ although implying that delta is a function of epsilon is in general incorrect because we can usually find multiple delta satisfying the condition for a given epsilon, not just one." - User A
"If for a given $\epsilon$ a $\delta$ is "good", then any $0<\delta'<\delta$ is also "good". So I'm not sure it'd be a well-defined function, but you can certainly think of it as one - keeping in mind that there are a lot of other $\delta$'s for that $\epsilon$." - User B

This implies that $\delta(\epsilon)$ is not a function as for any input ($\epsilon$) we have multiple output ($\delta$'s)
But since we are only trying to prove the existence of a single $\delta$ (to satisfy the $\epsilon-\delta$ definition of a limit), shouldn't writing $\delta(\epsilon)$ still be considered mathematically rigorous given the fact that we are only finding a function $\delta(\epsilon)$ that has a co-domain of a subset of all possible $\delta$'s? If not what are possible ways to workaround this, and introduce further mathematical rigor to this last step?
So is my proof mathematically rigorous? Are there any errors I've made? If this proof is not completely mathematically rigorous, please tear it apart, I'm looking to improve my proof-writing skills as an undergraduate student majoring in Pure Mathematics, so please feel-free to offer any criticism and/or suggestions if you feel necessary.

A: It appears that your proof is correct, albeit in a very verbose way. I would recommend thoroughly polishing it; of course, the ability to do that effectively comes with time: I hardly think I have mastered proof-writing, but I thought I would contribute what I think is a much more succinct proof of your claim.

Claim: $\displaystyle\lim_{x\to 1}\frac{2+4x}{3}=2$
Proof. Given $\epsilon>0$, choose $\delta=\frac{3}{4}\epsilon$. If $|x-1|<\delta$, then
$$
\left|\frac{2+4x}{3}-2\right|=\frac{4}{3}|x-1|<\frac{4}{3}\delta=\frac{4}{3}\left(\frac{3}{4}\epsilon\right)=\epsilon.
$$
Thus, if $|x-1|<\delta$, then $\left|\frac{2+4x}{3}-2\right|<\epsilon$. Therefore, by the definition of a limit, $\lim_{x\to 1}\frac{2+4x}{3}=2$, as desired. $\blacksquare$

Truthfully, the "Thus, if ..." part directly above is not even necessary. You could have concluded at the "... $=\epsilon$." part. Sometimes it simply comes down to a matter of style, but the rule of thumb is to not write more than is necessary. Your proof details more of all of your thought that went into it (and that is great in some contexts), but the final proof should be something much more clean and crisp. Hopefully you find that helpful in some manner.


text:
Q: Validate multiple checked Checkbox is there a way to validate multiple checked checkboxes properly?
How are the data been sent?
Something like eyeColor[0] = blue?
<form action="send" method="POST" id="send-form">
 <input type="checkbox" id="eyeColor" name="eyeColor[]" value="blue">
 <input type="checkbox" id="eyeColor" name="eyeColor[]" value="brown">
 <input type="checkbox" id="eyeColor" name="eyeColor[]" value="green">
</form>

"eyeColor" -> seq(text.verifying(enum(eyeColor().keySet.map(_.toString), "error.searchProfile.eyeColor")))

A: In your controller you get eyeColor as a List[String], as if it was a multiple select. You can not see the ones that are not selected (they're not passed in the http request).


text:
Q: Как обновить главное окно основного потока из дополнительного потока Есть GUI собранный в PyQt5 в отдельном файле. В главном файле его импортирую и инициализирую в основном классе class mywindow(QtWidgets.QMainWindow).
В основном классе много функций, во все них взаимодействовать с интерфейсом могу.
Но одна функция слишком тормознутая и при ее запуске прога подвисает на 10 сек. Вот ее я кинул в другой класс class Class_2(QThread) для запуска в отдельном потоке.
Проблему с подвисанием это решило, но появилась другая проблема - я не могу вывести результаты в виджет textEdit основного интерфейса программы.
Как это реализовать?
from PyQt5 import QtCore, QtGui, QtWidgets, Qt
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QLabel, QApplication)
from PyQt5.QtCore import QThread
from ad_gui import Ui_MainWindow
import sys
class mywindow(QtWidgets.QMainWindow):

   def __init__(self):
       super(mywindow, self).__init__()
       self.ui = Ui_MainWindow()
       self.ui.setupUi(self)
       self.ui.pushButton_1.clicked.connect(self.open_class_2)
   def open_class_2(self):
       self.a=Class_2(self)
       self.a.start()
   def write_text_3_class_2(self, result):
       self.ui.textEdit_3.append(result)
class Class_2(QThread):
   def __init__(self, parent=None):
       super(Class_2, self).__init__()
   def run(self):
       ...
       resultat='какой-то текст'
       mywindow().write_text_3_class_2(result=resultat)
app = QtWidgets.QApplication([])
app.setStyle('fusion')
application = mywindow()
application.show()

sys.exit(app.exec())

A: Нельзя обращаться из дополнительного потока к объектам основного потока !
Надо использовать сигналы и слоты.
from PyQt5 import QtCore, QtGui, QtWidgets, Qt
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QLabel, QApplication)
from PyQt5.QtCore import QThread
from PyQt5.Qt import *

#from ad_gui import Ui_MainWindow

class Class_2(QThread):
    my_singal = pyqtSignal(str)                            # +++

    def __init__(self, parent=None):
        QThread.__init__(self, parent)
        self.i = 1

    def run(self):
        #...
        while self.i < 10:
            resultat = f'какой-то текст -> {self.i}'
            self.my_singal.emit(resultat)                 # +++
            self.msleep(1000)
            self.i += 1

#       mywindow().write_text_3_class_2(result=resultat)

class MyWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super(MyWindow, self).__init__()
#       self.ui = Ui_MainWindow()
#       self.ui.setupUi(self)

        self.textEdit_3 = QTextEdit()

        self.pushButton_1 = QPushButton('Button')
        self.pushButton_1.clicked.connect(self.open_class_2)

        self.centralwidget = QWidget()
        self.setCentralWidget(self.centralwidget)

        layout = QVBoxLayout(self.centralwidget)
        layout.addWidget(self.textEdit_3)
        layout.addWidget(self.pushButton_1)

    def open_class_2(self):
        self.a = Class_2(self)
        self.a.my_singal.connect(self.write_text_3_class_2)             # +++
        self.a.start()

    def write_text_3_class_2(self, result):
        self.textEdit_3.append(result)

if __name__=="__main__":
    import sys
    app = QApplication(sys.argv)
    w = MyWindow()
    w.show()
    sys.exit(app.exec_())


text:
Q: Convert special characters to normal characters ? and = will be used as parts in my url. In generating the url, I use
<?php echo l('node/'. $someID .'/delete?destination=chapter/'. $anotherID);?>. When I check on Firebug, the href attribute of the link is not the usual url, instead of having ?, it is being replaced with %3F and = is being replaced with %3D. How do I fix this?

A: I had the same problem but I used the following code and worked for me:
rawurldecode(rawurldecode(l('node/'. $someID .'/delete?destination=chapter/'. $anotherID,array('absolute' => TRUE))));

Hope this helps anyone.

A: Read the documentation of the l() function in Drupal (I assume you are using Drupal)
http://api.drupal.org/api/drupal/includes%21common.inc/function/l/6
The 'html' option defaults to FALSE in the attributes array, however this needs to be TRUE if you are using HTML content...


text:
Q: Python: Cannot print tuple of 5 lists to file I am trying to print a tuple of 5 lists to a file in Python, however, I get the error:
TypeError: Can't convert 'tuple' object to str implicitly

the following is my code:
def listjoin():
illegallist = zip(carreglist, illegalspeed, illegaltime, illegalname, illegaladdress)
for item in illegallist:
    illegaldatafile.write("Registration: "+item)
    illegaldatafile.write("\n")
    illegaldatafile.write("Speed "+item)
    illegaldatafile.write("\n")
    illegaldatafile.write("Time: "+item)
    illegaldatafile.write("\n")
    illegaldatafile.write("Name: "+item)
    illegaldatafile.write("\n")
    illegaldatafile.write("Address: "+item)
    illegaldatafile.write("\n")
    illegaldatafile.write("\n")
    illegaldatafile.close()

I'm trying to get something like this:
Registration: BH34JKX
Speed: 80
Time: 6:45:21
Name: John Adams
Address: SW34 7MN

Registration: DX34JKS

etc..
 (Accidentally posted too early)
I printed a list toa file earlier in my code, and it did not need to be converted to a string. I can't do this:
illegallist = zip(str(carreglist, illegalspeed, illegaltime, illegalname, illegaladdress))

Because str() only takes 3 arguments.
I tried putting it here:
illegallist = str(zip(carreglist, illegalspeed, illegaltime, illegalname, illegaladdress))

But then It just says that my file is closed.

A: You are appending the same tuple item over and over to a string. You have to take individual elements from this tuple. This is my (more compact) proposal:
colnames = ['Registration', 'Speed', 'Time', 'Name', 'Address']
for tup in zip(carreglist, illegalspeed, illegaltime, illegalname, illegaladdress):
    for colname, value in zip(colnames, tup):
        illegaldatafile.write('{}: {}\n'.format(colname, value))
    illegaldatafile.write('\n')

A: Instead of calling each loop iteration's item simply item, you should unpack it so you can more easily reference each object. String formatting will also be helpful:
def listjoin():
    illegallist = zip(carreglist, illegalspeed, illegaltime, illegalname, illegaladdress)
    for reg,speed,timing,name,address in illegallist:
        illegaldatafile.write("Registration: {}\n".format(reg))
        illegaldatafile.write("Speed: {}\n".format(speed))
        illegaldatafile.write("Time: {}\n".format(timing))
        illegaldatafile.write("Name: {}\n".format(name))
        illegaldatafile.write("Address: {}\n\n".format(address))
    illegaldatafile.close()

A: You could use print statement with file parameter and if you have only 5 tuples you could use %:
def listjoin():
    illegallist = zip(carreglist, illegalspeed, illegaltime, illegalname, illegaladdress)
    for item in illegallist:
        print("Registration: %s" % item[0], file=illegaldatafile)
        print("Speed: %s" % item[1], file=illegaldatafile)
        print("Time: %s" % item[2], file=illegaldatafile)
        print("Name: %s" % item[3], file=illegaldatafile)
        print("Address: %s" % item[4], file=illegaldatafile)
        print(file=illegaldatafile)
    illegaldatafile.close()


text:
Q: How to copy text to clipboard without using flash? I am using the below button to read data from a web service and display it in a prompt window. The problem I am having is newer versions of Chrome and FireFox and now IE 11 do not allow data to be copied to clipboard.
I have used Postman to test the end point /Areas/Journal/Handlers/CSVString.ashx it is returning data. but the below code is showing an empty box
Is there a way to copy data to clipboard without using flash ?
Any ideas why I am getting an empty window in IE when I run the below code ?
<input id="htmlCopyCSV" type="button" value="Copy" onclick="$.get('/Areas/Journal/Handlers/CSVString.ashx', function (data) { alert(data);window.prompt('Copy to clipboard: Ctrl+C, Enter', data); });" />

A: Bind this function to the copy button
function myFunction() {
  var copyText = document.getElementById("myInput");
  copyText.select();
  document.execCommand("Copy");
  alert("Copied the text: " + copyText.value);
}


text: Q: How to determine a fresh login and a subsequent login in Community portal? I have a login Flow setup for a Community. When Customer logs in I should show them two distinct screens based on the scenario first time login User and subsequent login User. I used Auth Session obj record to determine this. But the auth session record gets created as soon as Customer clicks on the activation link. So I would not know if he has really set his password and logged into the SF. Is there any way to determine this? Kindly help.


text:
Q: asp timespan validation with regular expression In one of my models I'm using the following property :
[Required(ErrorMessage = "Please enter the duration of the service")]
[RegularExpression(@"^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$", ErrorMessage = "Use format HH:MM only")]
public TimeSpan Duration { get; set; }

I used this regular expression to make sure that the duration`s format will be in HH:mm.
Every time that I tried to insert a value in that format I got the error message "Usage format HH:MM only". Once I removed the regular expression annotation I successfully saved an HH:MM (format string but I realized that it was saved in another format (HH:MM:SS). I tried to change the regular expression to the following annotation :
[RegularExpression(@"^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$", ErrorMessage = "Use format HH:MM:SS only")]

and now I can save duration in this format. It seems that when I try to save an HH:MM format it is automatically converted to HH:MM:SS and that's why it is failing in the annotation check.
How can I handle this issue? I don't want to enter the seconds of some flow, just the hours and the minutes.

A: The RegularExpressionAttribute calls the ToString() method of the TimeSpan, which results in the format you describe (i.e. including seconds). You could just create a customized ValidationAttribute based on the RegularExpressionAttribute, where you include the format @"hh\:mm" when calling ToString on the TimeSpan.

A: I used the following annotation to solve the problem :
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:hh\\:mm}")]
    [RegularExpression(@"((([0-1][0-9])|(2[0-3]))(:[0-5][0-9])(:[0-5][0-9])?)", ErrorMessage = "Time must be between 00:00 to 23:59")]


text:
Q: Input type hidden passes the same value from foreach in javascript I have a code with foreach which prints the image and then it will stores the image id in hidden form field. I want to get the particular image id when user clicks the particular image . But it returns the first value of foreach image id . Sorry for bad english . Somebody please help me with this.

    <?php foreach ($hair['hair_color_media'] as $key => $row){?>
   <input type = "hidden" name = "hair_color_slug" value = "<?=$row->hair_color_slug?>">
   <a href="#" class="elevatezoom-gallery" data-toggle="tooltip" title="<?=$row->hair_color?>" data-update="" data-image="<?=base_url('assets/img/products/large/'.$row->media_images);?>" data-zoom-image="<?=base_url('assets/img/products/large/'.$row->media_images);?>" onclick = "getPrice();">
      <img data-toggle="tooltip" title="<?=$row->hair_color?>" src="<?=base_url('assets/img/products/pin/'.$row->media_images);?>" width="50" style = "border-radius: 50%;">

<?php }?>

<input type = "text" readonly="" id ="color" name = "color"/>

A: pass the handler 'this' keyword within getPrice function to obtain the current element which fired the event.
onclick = "getPrice(this);

On click will get the previous hidden value of clicks element and put in the color field.
function getPrice(getprice)
{
    var color = $(getprice).prev().val();

    document.getElementById('color').value = color;
}