- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
#include <stdio.h>;
void check(int x, int y) {
if (2*x == y && y < 0 && 0 <= 2*x) {
puts("Impossible!");
}
}
int main() {
check(0x7F80007F, 0xFF0000FE);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
#include <stdio.h>;
void check(int x, int y) {
if (2*x == y && y < 0 && 0 <= 2*x) {
puts("Impossible!");
}
}
int main() {
check(0x7F80007F, 0xFF0000FE);
}
https://runtimeverification.com/blog/?p=257
When writing code for a specific compiler you can rely on the implementation-specified behavior, but signed overflow is still problematic. GCC promises that conversions between integer types will be reduced modulo the appropriate power of two when the value is not representable in the target type. This means that with GCC the conversion above will initialize var to -0x112234 on any architecture that GCC supports. However, only initialization and other conversions are safe. GCC still considers signed overflow in arithmetic as undefined behavior, and optimizes under the assumption that there will be no overflow. This can lead to apparently impossible results when signed values do overflow. Compiled with -O3, this program prints “Impossible!”.
By adding apparently-redundant casts to 2*x to give (int)(2*(unsigned int)x), the calculation becomes implementation-specified behavior from an out-of-range conversion instead of undefined behavior. While this code may not be portable between compilers, GCC now guarantees the “impossible” code will not be executed even with -O3.
−1
($prepayment ? 'Предо' : 'О') . 'плата счета №'
Когда DRY возведен в абсолют
−1
DBHelper dbHelper = DBConnect.getIntance().getDBHelper();
DBConnect.getIntance().addCycleReport(reportObj,dbHelper);
dbHelper.close();
Коллега попросил помочь с дебагом
−1
$(document).ready(function() {
$('.tab').click(function(){
var tabs = $(this).closest('.tabs');
// Удаляем классы active
$(this).siblings().removeClass('active');
tabs.children('.tabs-content').children('.tabs-content-item').removeClass('active');
// Добавляем классы active
$(this).addClass('active');
tabs.children('.tabs-content').children('.tabs-content-item').eq($(this).index()).addClass('active');
})
});
Вот пример:
https://codepen.io/ShvedOFF/pen/weBgrQ
Как более грамотно оформить данный код?
Все отлично работает, но выглядит коряво.
0
body{
background: gray;
text-align: center;
}
#serials{
text-align: center;
}
#search{
font-weight: bold;
border-radius: 0px 20px 20px 0px;
}
#search:hover{
color: white;
}
input{
border-radius: 20px 0px 0px 20px;
text-align: center;
}
input, #search{
border: grey;
background: #9e9e9e !important;
font-size: 20px;
padding: 10px 20px 10px 10px;
outline: none;
color: white;
}
−1
cTemp := trim(to_char(xxx.VALUE, '999999.90'));
if substr(cTemp, 1, 1) = '.' then
sText := '0'||cTemp;
else
sText := cTemp;
end if;
PL/SQL, я блять выучил маски!
−1
VTJGc2RHVmtYMTl0MlNMU1dWMUFpcjEyaHZUVTNqWVluaVVmTFFIR1ExQ1VVd3lBZUJnSkdvdE5S
MGwxdUxSZApGaDk2YjV4S0FsSzc5MmpGYk45OW9SUTk4V3JpSFhsY3E0a1lWQnVQdU82a2VYL2dQ
Wkt1TWlpeVdpL29mYmJZCmxZN2lUSVA3TmwyY3BGMlFaY0dTY0Y1cmVqQU9JSmNnNUZYNEJhc2xS
NVdJaUtBN0lIV0lxazkvUGl6UHJ6cVgKMkVHN0EwSUR3TGNpL0xiL1BPTWVycWQvcHVhQytTY1c1
T3Q2OXJzQlZjbnordWJCRDVEckN0ZWZJZGdvUCtVSgpaODI1Mk0vMlA1MW5CV0xQR3lObm5qTFkz
YUw2Y0taWWI0STI3ZFMxQzROUDYvZ3dRVU8rRDVua0xHMHQ3TXp4CmZ2S0lUeXV2anJmK0txYTRz
R1pDZGI4RExWbi84SDVMWGFFUnhjVjZPWW1EOEVEZzRUOWVKNFB2M1F3b0d3L2UKVzlMVmdwYVB1
eS9mNzRmbFh1NHAvejNRa09XRVJTVmdRUHd1cS9OODREK0ErSEEyU1ByVzFCM2RyeVBwc3MzOQo2
UFBDcmdJV1czWDVOaXdBL3JDVXVZaW03YjZIUmlNbEhCaW5VeG9KTVIxU09rVytMRGZKSTE3aS8v
U1ppM2ZSCmM1T0xVdy9ZN1ZIL2NOWURyWU9NQW5DVG96eXEyNGZOaWlVLzNhb3NsVkhy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vcnFjWE1PbUoK
RVdQRmw4N3ljcGEvMHlHZUg2Qk5EVXFvVGFiTktydUNKUVVtU0hJM3E0NVA0MlR6Uy9GeHhIZVJE
a3hEZ2lSNAp2cTNDcW9TNXY1OGIwcG1VcW5JK2w3Z21oWkFYTFNNZUhkTktSMXRqRHNxcm9oYlc2
NUhZeG0rTXpSOEpUK1ZLCll4UHB6eVRRbEdIVmRUcmFGZUFZYnhsMDQrQU1KVUNuMVRnVWcyY2ps
ZDE1cisvK3VCV0U1S3dWZWYvaVI2YmUKREFqSFdWZ2k2eDBNNUJzclNkS2JBdjA2bjVHZ3VPOUcx
dG9HTVhBZ1VvU1VKTVBCWnIzOVV4elFnSnpOUW15cgpYd3k2M2x3Tm5PMUoxSXR4TGFVTUlvSUFp
bkwwOXZVYmxOLy91SmY1YjVNTUhrdGxiamlYMlVNWjNxYmZoZzF0CkNiUWk2WjcwbUVwUmZIUjdB
RVV2N0JpdVVMMHJZci84S0xyUitURXBBL3M0cGpvN01jTnF6bWxKakxtUnpuSWcKNzlPUWVJY0wz
dE9xUDZXbVdnRE0wTWM0bWJ1UFQrZldEVnl2WlJERDJJZnhNUHcvK25DN2FXdnpUbllwaUFBdgp0
TFhWTUdoNWt3azFaaU01SG5OL1QrYjdnMHNzcUdjTlp0d1pzNnRPMEZ4empOdWtvcGRKM0p0ajhu
ZkRNUDB2CkVqdEJhTFMxUTB5SFozS1g2d3FicmlDNHk1ZTFrMGJyd3dXOFdZK1hwb3NGajJ6MUdE
dy9kUzJLVlAzV3V2S24Ka1g3WFgxM2VTejlOMXovVWVYOGNtb05tV3lkSFRObndnRmVBbWI1aFMv
−2
GUI.backgroundColor = Color.magenta;
prop = parametersObject.GetIterator();
var skip = true;
while (prop.NextVisible(true))
{
//Script object Field
if (skip)
{
skip = false;
continue;
}
if (prop.depth == 0)
{
position.height = propertyHeight;
EditorGUI.PropertyField(position, prop);
position.y += propertyWithSpaceHeight;
}
}
if (EditorGUI.EndChangeCheck())
{
if (parametersObject != null && parametersObject.targetObject != null)
{
parametersObject.ApplyModifiedProperties();
EditorUtility.SetDirty(parametersObject.targetObject);
}
}
parametersProperty.stringValue = JsonUtility.ToJson(parametersObject.targetObject);
GUI.backgroundColor = Color.white;
//Код исполняется 60 раз в секунду ((((
0
class Stream(object):
def __init__(self, generator):
object.__init__(self)
self.data = ''
self.generator = generator
self.closed = False
generator.subscribe(self)
def update(self, data):
self.data += data
def read(self):
if self.closed: return None
data = self.data
self.data = ''
return data
def close(self):
self.generator.unsubscribe(self)
self.closed = True
self.data = ''
class Server(dispatcher, dict):
writable = lambda x: False
def __init__(self, host = None, port = 0xB00B):
dispatcher.__init__(self)
self.create_socket(AF_INET, SOCK_STREAM)
dict.__init__(self, {self.fileno(): self})
self.set_reuse_addr()
self.bind((host, port))
self.listen(0xA)
self.dataSource = PiGenerator()
def removeClient(self, client):
del self[client.fileno()]
def handle_accept(self):
sock, (host, port) = self.accept()
print 'new client from %s:%d' % (host, port)
stream = Stream(self.dataSource)
self[sock.fileno()] = Client(sock, self, stream)
def handle_error(self):
print 'Server error: %s' % sys.exc_value
sys.exit(1)
class Client(dispatcher):
readable = lambda x: False
def __init__(self, sock, server, stream):
dispatcher.__init__(self, sock)
self.server = server
self.stream = stream
self.buffer = ''
def handle_error(self):
print 'Client error: %s' % sys.exc_value
import traceback
print traceback.format_exc(1000)
sys.exit(1)
def handle_write(self):
sent = self.send(self.buffer)
self.buffer = self.buffer[sent:]
def handle_expt(self):
print 'client dropped connection'
self.close()
def close(self):
self.server.removeClient(self)
self.stream.close()
self.buffer = ''
dispatcher.close(self)
def writable(self):
data = self.stream.read()
if data == None:
print 'client finished reading'
self.close()
return False
self.buffer += data
return len(self.buffer) > 0
def main():
try:
asyncore.loop(0.1, True, Server('127.0.0.1'))
except KeyboardInterrupt:
print '\nBye :-*'
sys.exit(0)
if __name__ == '__main__':
main()
start http://govnokod.ru/23059
−1
if (this.btn1.Content.ToString() == this.currentSide.ToString() && this.btn2.Content.ToString() == this.currentSide.ToString() && this.btn3.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn4.Content.ToString() == this.currentSide.ToString() && this.btn5.Content.ToString() == this.currentSide.ToString() && this.btn6.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn7.Content.ToString() == this.currentSide.ToString() && this.btn8.Content.ToString() == this.currentSide.ToString() && this.btn9.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn1.Content.ToString() == this.currentSide.ToString() && this.btn4.Content.ToString() == this.currentSide.ToString() && this.btn7.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn2.Content.ToString() == this.currentSide.ToString() && this.btn5.Content.ToString() == this.currentSide.ToString() && this.btn8.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn3.Content.ToString() == this.currentSide.ToString() && this.btn6.Content.ToString() == this.currentSide.ToString() && this.btn9.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn1.Content.ToString() == this.currentSide.ToString() && this.btn5.Content.ToString() == this.currentSide.ToString() && this.btn9.Content.ToString() == this.currentSide.ToString())
this.Victory();
else if (this.btn3.Content.ToString() == this.currentSide.ToString() && this.btn5.Content.ToString() == this.currentSide.ToString() && this.btn7.Content.ToString() == this.currentSide.ToString())
this.Victory();
Проверка на победу в крестиках-ноликах.