Thursday, April 19, 2012

Check database for similar value , MySQL

I have a table server like this;



Model | Brand
-------------------
M4000 | Dell
S4000 | Hp
S3500 | Hp
S6500 | Sun


I want to display different data from the 'Brand' field which means I don't want the second 'Hp' data to display again. How do I do that?





Access textboxes dynamically created at runtime

I add textboxes dynamically at runtime. How do I access them later in the program?





Css rounded images with border and some padding

enter image description here



Hope this image speaks everything...!!! Need to do this in html + css .. Note: I want the border inside the image.





Convert general regex to bash proof regex

I have the following regex that checks for a password policy. it is validated to work:



(^([zZ]\d{3})*$)|((?=.{9,})(?=.*?[^\w\s])(?=.*?[0-9])(?=.*?[A-Z]).*?[a-z].*)



I want to use the regex in a bash script to validate a psssword the following way :



echo $password | grep "(^([zZ]\d{3})*$)|((?=.{9,})(?=.*?[^\w\s])(?=.*?[0-9])(?=.*?[A-Z]).*?[a-z].*)"
if [[ $? -eq 0 ]] ; then


This does not work in bash.
My question is :



How do i convert this "pure" regex to a one that work in bash ? which characters do i need to escape, what is the correct way to pass the regex to grep ? are there any other things i need to look out for ?



Thanks





Wpf MVVM UI do not update implementing modularity,eventaggregator

i'm currently experimenting wpf communication between two views of different modules using prism IEventAggregator. publishing module and subscribing module is working fine, for some reason i can't understand why the subscriber UI is not updating.i place a button to display a msgbox at the subscriber module just to be sure that it receives it and it does. and i think i properly implement the INotifyPropertyChanged.



if i place subscribe in subscriber view's code-behind it works as i want it to be....do i do it the wrong way? please correct me. thanks.



Public Class SendServices
Public Shared Property SendMessage As EventAggregator

Shared Sub New()
SendMessage = New EventAggregator
End Sub
End Class


Publisher :



Public Class Module1ViewModel

Private _msgsend As String
Public WriteOnly Property MessageSend As String
Set(value As String)
_msgsend = value
End Set
End Property

Public Sub Send()
SendServices.SendMessage.GetEvent(Of SendStringEvent).Publish(New SendString With {.Name = _msgsend})
End Sub
End Class


Subscriber :



Public Class Module2ViewModel
Implements INotifyPropertyChanged

Private _receivedMSG As String
Public Property ReceivedMSG As String
Get
Return _receivedMSG
End Get
Set(value As String)
_receivedMSG = value

OnPropertyChanged("ReceivedMSG")
End Set
End Property
'Binded to subscriber View button using interactions
Public Sub Received()
MsgBox(ReceivedMSG)
End Sub

Private Sub ReceivedMessage(msg As SendString)
_receivedMSG = msg.Name
End Sub

Public Sub New()
SendServices.SendMessage.GetEvent(Of SendStringEvent)().Subscribe(AddressOf ReceivedMessage, ThreadOption.UIThread, False)
End Sub

Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Protected Sub OnPropertyChanged(ByVal name As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name))
End Sub
End Class


Subscriber View code-behind



Public Class Module2View
Sub New()
InitializeComponent()
Me.DataContext = New Module2ViewModel
End Sub
End Class


and the binding part to display the message



<TextBox Height="23" HorizontalAlignment="Left" Margin="111,39,0,0" Name="TextBox1" VerticalAlignment="Top" Width="158" Text="{Binding Path=ReceviedMSG}"/>




Get date of last successful job run?

I have a single step job that executes a stored procedure. I would like get the date of the last successful job execution time so that I can just update a delta instead of the whole set of data.



Right now I have the job setup to run once every day, so I have a default parameter that if it's null I set it to GETDATE() - 1 so I'm still updating a delta but what I'd like to do is set the date to the last successful execution of the job.



exec dbo.usp_UpdateFrom @LastSuccessfulExecutionTime


Current procedure is something like



CREATE PROCEDURE dbo.usp_UpdateFrom
@FromDate datetime = NULL --would like to pass last successful execution time of the job
AS
IF @FromDate IS NULL
SET @FromDate = GETDATE() - 1

-- do stuff
END




UPDATE : Most Samsung Androids have "Settings" button too in soft keyboard. How to intercept or disable that?

I have a full screen activity with a ExitText. When edit text is clicked(gets focus) a softkeyboard shows up.



Now, on some samsung android phones(atleast two that I have used), the keypad also has a small "Settings" button which will close your activity and take you to phone's system settings button.



I want to intercept when a user click's this "Settings" soft button and then take some decision before my activity gets pushed back to the stack.



Is it possible? If yes, how?



EDIT



I know that in normal circumstance its a bad user experience and should be avoided. However, I am more interested in the solution (technology side). I am not going to launch an app in the market with such a thing for regular user, so please dont comment saying I should not do this.



I know that developers put such comments in the benefit of the users who are still learning but in some cases, "Its more about HOW to do it?". This scenario is just one of them. Hope nobody takes what I said in a wrong sense. Thnx!