- 1
IT Оффтоп #42
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
IT Оффтоп #42
#8: (vanished) https://govnokod.xyz/_24815
#9: https://govnokod.ru/24867 https://govnokod.xyz/_24867
#10: https://govnokod.ru/25328 https://govnokod.xyz/_25328
#11: (vanished) https://govnokod.xyz/_25436
#12: (vanished) https://govnokod.xyz/_25471
#13: (vanished) https://govnokod.xyz/_25590
#14: https://govnokod.ru/25684 https://govnokod.xyz/_25684
#15: https://govnokod.ru/25694 https://govnokod.xyz/_25694
#16: https://govnokod.ru/25725 https://govnokod.xyz/_25725
#17: https://govnokod.ru/25731 https://govnokod.xyz/_25731
#18: https://govnokod.ru/25762 https://govnokod.xyz/_25762
#19: https://govnokod.ru/25767 https://govnokod.xyz/_25767
#20: https://govnokod.ru/25776 https://govnokod.xyz/_25776
#21: https://govnokod.ru/25798 https://govnokod.xyz/_25798
#22: https://govnokod.ru/25811 https://govnokod.xyz/_25811
#23: https://govnokod.ru/25863 https://govnokod.xyz/_25863
#24: https://govnokod.ru/25941 https://govnokod.xyz/_25941
#25: https://govnokod.ru/26026 https://govnokod.xyz/_26026
#26: https://govnokod.ru/26050 https://govnokod.xyz/_26050
#27: https://govnokod.ru/26340 https://govnokod.xyz/_26340
#28: https://govnokod.ru/26372 https://govnokod.xyz/_26372
#29: https://govnokod.ru/26385 https://govnokod.xyz/_26385
#30: https://govnokod.ru/26413 https://govnokod.xyz/_26413
#31: https://govnokod.ru/26423 https://govnokod.xyz/_26423
#32: https://govnokod.ru/26440 https://govnokod.xyz/_26440
#33: https://govnokod.ru/26449 https://govnokod.xyz/_26449
#34: https://govnokod.ru/26456 https://govnokod.xyz/_26456
#35: https://govnokod.ru/26463 https://govnokod.xyz/_26463
#36: https://govnokod.ru/26508 https://govnokod.xyz/_26508
#37: https://govnokod.ru/26524 https://govnokod.xyz/_26524
#38: https://govnokod.ru/26539 https://govnokod.xyz/_26539
#39: https://govnokod.ru/26556 https://govnokod.xyz/_26556
#40: https://govnokod.ru/26568 https://govnokod.xyz/_26568
#41: https://govnokod.ru/26589 https://govnokod.xyz/_26589
−1
Currently, we're ignoring failures to mlock signal stacks in the
workaround for #35777. This means if your mlock limit is low, you'll
instead get random memory corruption, which seems like the wrong
trade-off.
самый лучший язык на свете продолжает шпарить, отказались от free after use - получили «забыл сделать if (err != nil)»
https://github.com/golang/go/commit/69614c0d0e05787c8203bdc364c3293e1cf5094a
+1
char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size )
{
char *dst = dst_buffer;
for ( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- )
{
if ( *src == '#' )
{
// cut msg name out of string
static char word_buf[255];
char *wdst = word_buf, *word_start = src;
for ( ++src ; *src >= 'A' && *src <= 'z'; wdst++, src++ )
{
*wdst = *src;
}
*wdst = 0;
Тут недавно слили исходники «Team Fortress 2» и «Counter Strike: Global Offense» — и в соответствующих местах начался вой игроков: кошмар, мы все умрём, нас всех взломают!
0
public class FloatDynamicArray implements DynamicArray {
private int arrayLength;
private int countOfValues;
private float[] dataArray;
public FloatDynamicArray(int arrayLength) {
this.arrayLength = arrayLength;
dataArray = new float[arrayLength];
}
public long getLongValue(int index) {
throw new IllegalAccessError("Cannot get long value from FloatDynamicArray !");
}
public float getFloatValue(int index) {
return dataArray[index];
}
...
...
...
зачем делать отдельный метод getLongValue, который возбуждает исключение IllegalAccessError, когда мы заведомо знаем что это FloatDynamicArray, содержащий float[] значения ?
+1
function connect( $db_user, $db_pass, $db_name, $db_location )
{
$db_location = explode( ":", $db_location );
if ( isset( $db_location[1] ) ) {
$this->db_object = @mysqli_connect( $db_location[0], $db_user, $db_pass, $db_name, $db_location[1] );
}
else {
$this->db_object = @mysqli_connect( $db_location[0], $db_user, $db_pass, $db_name );
}
if ( ! $this->db_object ) {
$this->display_error( mysqli_connect_error( ), '1' );
}
$this->mysql_version = mysqli_get_server_info( $this->db_object );
mysqli_query( $this->db_object, "SET NAMES '" . COLLATE . "'" );
mysqli_set_charset( $this->db_object, "utf8" );
return true;
}
https://profiphp.ru/useful/class_mysqli.html
немного ООП ПХП
+1
<?php
class Db_object
{
protected static $db_table="users";
public static function find_all(){
global $database;
return static::find_by_query("SELECT * FROM ".static::$db_table." ");
}
public static function find_by_id($id){
global $database;
$raise=static::find_by_query("SELECT * FROM ".static::$db_table." WHERE id= $id LIMIT 1");
return !empty($raise) ? array_shift($raise): false;
}
public static function find_by_query($sql){
global $database;
$raise=$database->query($sql);
$object_array=array();
while ($row=mysqli_fetch_array($raise)) {
$object_array[]=static::instantation($row);
}
return $object_array;
}
// тут еще всякое говно
https://stackoverflow.com/questions/61362010/fatal-error-class-db-object-not-found-in-c-xampp-htdocs-cms-pro-admin-includ - ООП ЦМС ПРО АДМИН говнокодер
−2
procedure TForm1.WMDropFiles(var Msg: TMessage);
var
I, Amount, Size: Integer;
Filename: String;
Ctrl:TControl;
P:TPoint;
begin
if MessageBox(Handle, 'Внимание! Выбранные файлы будут БЕЗВОЗВРАТНО удалены. Продолжить?','Треш-угар', MB_ICONEXCLAMATION or MB_YESNO) <> ID_YES then Exit;
GetCursorPos(P);
Amount := DragQueryFile(Msg.WParam, $FFFFFFFF, @Filename[1], 255);
for i := 0 to (Amount - 1) do
begin
Size := DragQueryFile(Msg.WParam, i, nil, 0) + 1;
SetLength(FileName, Size+1);
DragQueryFile(Msg.WParam, I, @Filename[1], Size);
SetLength(FileName, StrLen(PChar(FileName)));
Ctrl:=FindDragTarget(P, False);
CleanFile(FileName);
end;
DragFinish(Msg.WParam);
end;
procedure TForm1.CleanFile(FileName:string);
var
hFile:THandle;
Size:DWORD;
BW:DWORD;
I:Integer;
P:Pointer;
NewName, Fname :string;
begin
trEmpty.SendToBack;
trFull.BringToFront;
hFile:=CreateFile(PChar(FileName), GENERIC_WRITE, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0);
if hFile=INVALID_HANDLE_VALUE then
exit;
try
Size:=GetFileSize(hFile,nil);
P:=AllocMem(Size);
SetFilePointer(hFile, 0, nil, FILE_BEGIN);
//for I:=0 to Size=1 do
//begin
//end;
WriteFile(hFile, P^, Size, BW, nil);
CloseHandle(hFile);
finally
CloseHandle(hFile);
end;
FName:=ExtractFileName(FileName);
NewName:=StrUtilsEx.RandomStr([rtLowerCase, rtUpperCase], Length(FName));
NewName:=ExtractFilePath(FileName)+FName;
MoveFile(PChar(FileName), PChar(NewName));
DeleteFile(PChar(NewName));
trFull.SendToBack;
trEmpty.BringToFront;
end;
end.
Кхе-кхе-кхе, апчхичхоу!
0
auto srv = http::Server::create(
JsClosure::create([] (JsArray::Ptr args) {
auto res = args->getPtr<http::ServerResponse>(1);
res->setHeader(http::HEADER_CONTENT_TYPE, str("text/plain"));
res->end(str("Hello World\n"));
return UNDEFINED;
}));
srv->listen(1337, str("127.0.0.1"));
node::run();
https://github.com/plenluno/libnode
Что если взять два говна (плюсы и js) и сделать свою ноду? Получится этот высер с потугами на embedded.
Неосилятор? Или переосилятор?
0
enum class Measures {
B, KB, MB, GB;
private val size = BigDecimal.valueOf(1024L).pow(ordinal)
companion object {
fun toHumanSize(value: Long): String {
val decValue = value.toBigDecimal()
val measure = values().reversed().find { it.size < decValue } ?: B
return "${decValue.divide(measure.size, 3, RoundingMode.UP)} $measure"
}
}
}
0
import ballerina/auth;
import ballerina/config;
import ballerina/http;
import ballerina/log;
auth:InboundBasicAuthProvider basicAuthProvider = new;
http:BasicAuthHandler basicAuthHandler = new (basicAuthProvider);
listener http:Listener ep = new (9090, config = {
auth: {
authHandlers: [basicAuthHandler]
},
secureSocket: {
keyStore: {
path: config:getAsString("b7a.home") +
"/bre/security/ballerinaKeystore.p12",
password: "ballerina"
}
}
});
@http:ServiceConfig {
basePath: "/hello",
auth: {
scopes: ["scope1"]
}
}
service echo on ep {
@http:ResourceConfig {
methods: ["GET"],
path: "/sayHello",
auth: {
scopes: ["scope2"]
}
}
resource function hello(http:Caller caller, http:Request req) {
error? result = caller->respond("Hello, World!!!");
if (result is error) {
log:printError("Error in responding to caller", result);
}
}
}
Кто что думает про https://ballerina.io?