@Override
public void afterTextChanged(Editable s) {
switch (paymentType) {
case 0:
if (s.length() == 9) etPaymentAmount.requestFocus();
break;
case 1:
if (s.length() == 9) etPaymentAmount.requestFocus();
break;
}
}
try {
$order->addItem($item);
} catch (Exception $ex) {
throw $ex;
}
Double value = item.getPrice() * loyaltyPointMultiplier;
String[] s = String.split(value.toString(), "\\.");
points = Integer.parseInt(s[0]);
if(Integer.parseInt(s[1]) > 0) {
points++;
}
return points;
Want to round up? Math.ceil() uses too little memory! Use this instead!
<Window WindowStyle="None" MouseLeftButtonDown="WindowMouseLeftButtonDown"/>
<x:Code>
<![CDATA[
private void WindowMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
]]>
</x:Code>
</Window>
http://stackoverflow.com/a/19136910 The code highlighter should be for XAML/XML, but there's no such highlighting option, so I used HTML.
@media only screen and (-webkit-min-device-pixel-ratio:2) and (max-width:768px) and (min-width:321px),not all,only screen and (max-width:768px) and (-webkit-min-device-pixel-ratio:2) and (min-width:321px),only screen and (max-width:768px) and (min-resolution:192dpi) and (min-width:321px),only screen and (max-width:768px) and (min-resolution:2dppx) and (min-width:321px){
/*some code here*/
}
if (SelectionAndTimeData[1] < 2000 or \
SelectionAndTimeData[2] < 1 or SelectionAndTimeData[2] > 12 or \
SelectionAndTimeData[3] < 1 or SelectionAndTimeData[3] > 31 or \
SelectionAndTimeData[4] < 0 or SelectionAndTimeData[4] > 24 or \
SelectionAndTimeData[5] < 0 or SelectionAndTimeData[5] > 60 or \
SelectionAndTimeData[2] < 0 or SelectionAndTimeData[2] >60):
print('***************************************************************************')
print(' Entered date is not valid')
print('****************************************************************************')
public void Method1(Enum foo)
{
if (GetCondition1(foo))
{
doSomething();
}
}
private bool GetCondition1(Enum foo)
{
if (foo == Enum.Value1)
return true;
return false;
}
public enum YesNoEnum
{
Yes = 0,
No = 1
}
I also like how they defined the enum values.
public boolean logout(String token)
{
LogedUser user = logedUsers.remove(token);
return (user != null) ? true : false;
}
UIButton * btn = [UIButton new];
[btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
//May god have mercy of me
[[btn titleLabel] setFont:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium]];
[btn setTitle:[NSString stringWithFormat:@" %@ ", btnTxt] forState:UIControlStateNormal];
[btn sizeToFit];
[btn setTitle:btnTxt forState:UIControlStateNormal];
Why keep playing with label padding or insets when you can add spaces?
var validAccountData = account.email != nil
validAccountData = account.firstName != nil
validAccountData = account.lastName != nil
if validAccountData {
return account
}
return nil
Proper validation
protected void EnableEditButtons(bool Value)
{
if (Value == false)
{
buttonAdd.Disabled = true;
buttonDelete.Disabled = true;
}
else
{
buttonAdd.Disabled = false;
buttonDelete.Disabled = false;
}
}
// ...
if (IsEditable(ID))
EnableEditButtons(true);
else
EnableEditButtons(false);
I found this old code in an app I was updating for a client a number of years back. It was so good I documented it on my own blog.
if( %rightBtnCmd $= "noButtons" )
{
//do nothing, as there are no buttons
}
proprietary script language.
public static bool HasValues<T>(this ICollection<T> collection)
{
if (collection == null)
{
return false;
}
if (collection.Count == 0)
{
return false;
}
return true;
}