class {
public State state;
//enums cant take double values...
public struct State
{
public const float IDLE = 0f;
public const float WALKING = 0.5f;
public const float RUNNING = 1f;
}
protected void Stop()
{
SetSpeed(State.IDLE);
}
protected void SetSpeed(float f)
{
agent.speed = f;
if (agent.speed > 1f && agent.speed < 5f)
{
f = State.WALKING;
agent.Resume();
}
else if (agent.speed > 5f)
{
f = State.RUNNING;
agent.Resume();
}
else
{
f = State.IDLE;
agent.Stop();
}
}
}
Who needs static float
when you can have a constant in a nested struct, as a bonus State state
has 0 references in the project
// Test read access of memory
try
{
c = ( (char*) pvMemory )[0];
c = ( (char*) pvMemory )[iNLen - 1];
}
catch( ... ) {
return -1;
}
void SummonCrowd()
{
if(!bSummoned1)
{
if (Creature* Witness1 = me->SummonCreature(NPC_LISTENER,-11009.036f, 1490.47f, 43.58f, 4.16f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness2 = me->SummonCreature(NPC_LISTENER,-11010.76f, 1488.21f, 43.57f, 4.33f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness3 = me->SummonCreature(NPC_LISTENER,-11017.39f, 1491.76f, 43.19f, 4.78f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness4 = me->SummonCreature(NPC_LISTENER,-11021.73f, 1493.054f, 43.184f, 5.09f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness5 = me->SummonCreature(NPC_LISTENER,-11025.74f, 1487.70f, 43.17f, 5.45f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness6 = me->SummonCreature(NPC_LISTENER,-11025.25f, 1482.23f, 43.03f, 6.04f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness7 = me->SummonCreature(NPC_LISTENER,-11029.68f, 1481.255f, 43.185f, 6.20f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness8 = me->SummonCreature(NPC_LISTENER,-11024.46f, 1473.88f, 43.02f, 0.43f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness9 = me->SummonCreature(NPC_LISTENER,-11019.49f, 1471.70f, 43.21f, 1.09f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness10 = me->SummonCreature(NPC_LISTENER,-11021.56f, 1497.053f, 43.20f, 5.00f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness11 = me->SummonCreature(NPC_LISTENER,-11012.29f, 1488.14f, 43.77f, 4.16f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness12 = me->SummonCreature(NPC_LISTENER,-11014.67f, 1493.14f, 43.23f, 4.60f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness13 = me->SummonCreature(NPC_LISTENER,-11019.8f, 1494.25f, 43.2f, 4.77f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness14 = me->SummonCreature(NPC_LISTENER,-11023.6f, 1489.35f, 43.17f, 4.77f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness15 = me->SummonCreature(NPC_LISTENER,-11023.1f, 1482.51f, 43.07f, 6.25f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness16 = me->SummonCreature(NPC_LISTENER,-11027.2f, 1494.37f, 43.17f, 5.15f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness17 = me->SummonCreature(NPC_LISTENER,-11029.6f, 1488.29f, 43.19f, 5.64f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness18 = me->SummonCreature(NPC_LISTENER,-11030.8f, 1485.13f, 43.31f, 5.94f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness19 = me->SummonCreature(NPC_LISTENER,-11026.2f, 1478.62f, 42.94f, 6.17f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness20 = me->SummonCreature(NPC_LISTENER,-11013.2f, 1497.81f, 43.31f, 4.44f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness21 = me->SummonCreature(NPC_LISTENER,-11011.6f, 1492.61f, 43.39f, 4.44f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness22 = me->SummonCreature(NPC_LISTENER,-11015.4f, 1489.06f, 43.28f, 4.73f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness23 = me->SummonCreature(NPC_LISTENER,-11020.2f, 1490.15f, 43.19f, 5.07f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness24 = me->SummonCreature(NPC_LISTENER,-11009.9f, 1483.52f, 44.06f, 3.88f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness25 = me->SummonCreature(NPC_LISTENER,-11020.1f, 1484.87f, 43.18f, 5.33f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness26 = me->SummonCreature(NPC_LISTENER,-11017.7f, 1487.42f, 43.24f, 4.89f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
if (Creature* Witness27 = me->SummonCreature(NPC_LISTENER,-11017.9f, 1498.24f, 43.20f, 5.04f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 90000))
{
Witness1GUID = Witness1->GetGUID();
Witness2GUID = Witness2->GetGUID();
Witness3GUID = Witness3->GetGUID();
Witness4GUID = Witness4->GetGUID();
Witness5GUID = Witness5->GetGUID();
Witness6GUID = Witness6->GetGUID();
Witness7GUID = Witness7->GetGUID();
Witness8GUID = Witness8->GetGUID();
Witness9GUID = Witness9->GetGUID();
Witness10GUID = Witness10->GetGUID();
Witness11GUID = Witness11->GetGUID();
Witness12GUID = Witness12->GetGUID();
Witness13GUID = Witness13->GetGUID();
Witness14GUID = Witness14->GetGUID();
Witness15GUID = Witness15->GetGUID();
Witness16GUID = Witness16->GetGUID();
Witness17GUID = Witness17->GetGUID();
Witness18GUID = Witness18->GetGUID();
Witness19GUID = Witness19->GetGUID();
Witness20GUID = Witness20->GetGUID();
Witness21GUID = Witness21->GetGUID();
Witness22GUID = Witness22->GetGUID();
Witness23GUID = Witness23->GetGUID();
Witness24GUID = Witness24->GetGUID();
Witness25GUID = Witness25->GetGUID();
Witness26GUID = Witness26->GetGUID();
Witness27GUID = Witness27->GetGUID();
bSummoned1 = true;
}
}
}
if ( variable )
{
}
else
{
Console.WriteLine("Wrong")
}
He doesn't know what "Not" is it :|
A,B=map(str,input().split()) # let's begin by casting strings to strings!
while(int(A)!=0 and int(B)!=0):
tamanhoa=0
tamanhob=0
for i in range(len(A)):
tamanhoa+=1 # wonderful way to determine the length of
# a string!
for i in range(len(B)):
tamanhob+=1
vA = [0]*tamanhoa
vB = [0]*tamanhob
if tamanhoa>tamanhob:
vA = [0]*tamanhoa # Just to make sure it really gets set!!!
vB = [0]*tamanhoa
for i in range(tamanhoa-1,-1,-1):
vA[i]=int(A[i]) # he even saved an operation by casting
# the char to int at the same time!
for i in range(tamanhob):
vB[i+1]=int(B[i])
elif tamanhoa<tamanhob:
vA = [0]*tamanhob # Just to make sure it really gets set!!!
vB = [0]*tamanhob
for i in range(tamanhoa):
vA[i+1]=int(A[i])
for i in range(tamanhob-1,-1,-1):
vB[i]=int(B[i])
tamanhoa=tamanhob
else:
for i in range(tamanhoa):
vA[i]=int(A[i])
for i in range(tamanhob):
vB[i]=int(B[i])
print(vA)
print(vB)
carry = 0
for i in range(tamanhoa-1,-1,-1):
soma = vA[i] + vB[i]
if soma > 9:
carry += 1
if vA[i-1]!= 9:
vA[i-1] += 1
else:
vB[i-1] +=1
if carry == 0:
print('No carry operation.')
elif carry == 1:
print(carry, 'carry operation.')
else:
print(carry, 'carry operations.')
A,B=map(str,input().split()) # why bother casting strings to int? yay
if int(A)==0 and int(B)==0:
break
This wonder was found within answers to a university programming test. Code as-is, comments added by me.
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
Never, ever define developer environment and debug as default thing! #pdk
class PythonClass {
protected boolean True = true;
protected boolean False = false;
protected Object None = null;
}
class MyClass extends PythonClass {
String do_something(Object foo) {
if (foo == False)
return "" ;
else if (foo == None)
return "!" ;
else if (foo == True)
return "Yay!" ;
}
}
Yikes
if (isset($data['phone_id']) && !empty($data['phone_id'])) {
$userPhone = $this->getDoctrine()->getRepository('STODBBundle:Phones')->find($data['phone_id']);
if ($userPhone->getPhoneNumber() != $data['phone'] || $userPhone->getMobileProviderCode()->getId() != $data['phone_code']) {
if ($data['smsCode'] ?? false) {
if ($sessionSmsCode !== $data['smsCode']) {
$aData['smsCodeShow'] = false;
$aData['isWrongCode'] = true;
} else {
$aData['isWrongCode'] = false;
$checkCode = $data['smsCode'];
}
} else {
$aData['smsCodeShow'] = true;
$aData['isWrongCode'] = true;
}
} elseif (!$userPhone->getCodeCheck()) {
if ($data['smsCode'] ?? false) {
if ($sessionSmsCode !== $data['smsCode']) {
$aData['smsCodeShow'] = false;
$aData['isWrongCode'] = true;
} else {
$aData['isWrongCode'] = false;
$checkCode = $data['smsCode'];
}
} else {
$aData['smsCodeShow'] = true;
}
} else {
$aData['isWrongCode'] = false;
}
} else {
if ($data['smsCode'] ?? false) {
if ($sessionSmsCode !== $data['smsCode']) {
$aData['smsCodeShow'] = false;
$aData['isWrongCode'] = true;
} else {
$aData['isWrongCode'] = false;
$checkCode = $data['smsCode'];
}
} else {
$aData['smsCodeShow'] = true;
}
}
shit ... this junior
"check cassandra config" in {
val config: Configuration = pureconfig.loadConfigOrThrow[Configuration]
config.cassandra.hosts shouldBe List("192.168.26.207")
config.cassandra.keyspace shouldBe "releases"
}
Why not to check works cassandra or not? What is the difference between this and hardcoding data right in source?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var token = new CancellationTokenSource().Token;
Task.Factory.StartNew (() => {
while (!token.IsCancellationRequested) {
try {
if (/*Condition*/)
this.Invoke(new Action(() => label.Text = " =)"));
else
this.Invoke(new Action(() => label.Text = " =("));
Thread.Sleep(10);
}
catch (Exception) {
throw;
}
finally {
throw new Exception();
}
}
}) ;
}
}
My collegue's way of using multithreading features (and exceptions handling) :)
function isEmpty(value) {
if (value === '') {
return false;
} else if (value === 0) {
return false;
} else if (value === null) {
return false;
} else if (value === undefined) {
return false;
} else {
return true;
}
return true;
}
javascript empty value check
Button.MouseButton1Click:Connect(function()
if TextHolder.Text == Codes.Code1 then
if Check1.Value == false then
Check1.Value = true
elseif Check1.Value == false then
TextHolder.Text = "Code Already Redeemed"
Event:FireServer("Code1")
TextHolder.Text = "Success! 500 Coins Rewarded"
elseif TextHolder.Text == Codes.Code2 then
if Check2.Value == false then
Check2.Value = true
elseif Check2.Value == false then
TextHolder.Text = "Code Already Redeemed"
Event:FireServer("Code2")
TextHolder.Text = "Success! 250 Coins Rewarded"
elseif TextHolder.Text == Codes.Code3 then
if Check3.Value == false then
Check3.Value = true
elseif Check3.Value == false then
TextHolder.Text = "Code Already Redeemed"
Event:FireServer("Code3")
TextHolder.Text = "Sucess! 100 Coins Rewarded"
else TextHolder.Text = "Invalid/Expired Code"
end
end
end
end
end)
int w = 100;
for (nil; w!=0; nil) {
w -= 1;
//so some shit
}
this code was found in chinese contract work
public static <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P> String get(A h, B u, C e, F l, G o, D v, E p, H a, I b, L c, K d, N f, J g, P i, M j, N m) {
StringBuilder yes = new StringBuilder();
yes.append((String) String.valueOf(h.toString()));
yes.append((String) String.valueOf(u.toString()));
yes.append((String) String.valueOf(e.toString()));
yes.append((String) String.valueOf(l.toString()));
yes.append((String) String.valueOf(o.toString()));
yes.append((String) String.valueOf(v.toString()));
yes.append((String) String.valueOf(p.toString()));
yes.append((String) String.valueOf(a.toString()));
yes.append((String) String.valueOf(b.toString()));
yes.append((String) String.valueOf(c.toString()));
yes.append((String) String.valueOf(d.toString()));
yes.append((String) String.valueOf(f.toString()));
yes.append((String) String.valueOf(h.toString()));
yes.append((String) String.valueOf(g.toString()));
yes.append((String) String.valueOf(i.toString()));
yes.append((String) String.valueOf(j.toString()));
return (String) String.valueOf(yes.toString());
}
why
function changePassword() {
if (isInputEmpty()) {
$.ajax({
type: 'POST',
data: '...'
url: '...',
success: function (result) {
if (result.substring(0, 3) != "!!!") {
//success
} else {
//faliure
}
},
error: function () {
}
});
}
}
And of course,in production, it always reported success and never changed the password, because of equally bad server code.