//count to 10
#include <iostream>
#include <string>
int main()
{
int i = 0;
beginning:
if (i < 10) {
std::cout << ++i << std::endl;
goto beginning;
}
else goto end;
end:
return 0;
}
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('****************************************************************************')
@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;
}
}
public void Method1(Enum foo)
{
if (GetCondition1(foo))
{
doSomething();
}
}
private bool GetCondition1(Enum foo)
{
if (foo == Enum.Value1)
return true;
return false;
}
try {
$order->addItem($item);
} catch (Exception $ex) {
throw $ex;
}
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.
<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*/
}
for(var j=0;j<10;j++){
cell=document.createElement('td');
switch(j)
{
case 0:
var date1 = events[i]['start'];
var date2 = events[i]['end'];
cell.appendChild(document.createTextNode(date1.getFullYear()+'/'+date1.getMonth()+'/'+date1.getDate()+' '+date1.getHours()+':'+date1.getMinutes()+' To '+date2.getFullYear()+'/'+date2.getMonth()+'/'+date2.getDate()+' '+date2.getHours()+':'+date2.getMinutes()));
break;
case 1: cell.appendChild(document.createTextNode(events[i]['title'])); break;
case 2: cell.appendChild(document.createTextNode(events[i]['description'])); break;
}
row.appendChild(cell);
}
The for loop that counts to 10, but the last seven
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
if( %rightBtnCmd $= "noButtons" )
{
//do nothing, as there are no buttons
}
proprietary script language.