- 1
$ 67.18
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
$ 67.18
−2
Нам нужен бойцовый петух.
Петухинхо
−2
Решил я зайти на сайт и увидел в адресе .php.
Больше я не заходил на этот сайт.
+2
luabind::object FlowerEventModel::RewardInfo(int index) const {
luabind::object result = luabind::newtable(Core::luaState);
if (index < 0 && index >= (int)_presents.size()) {
return result;
}
return result;
}
−1
Кода не осталось, только скрин:
https://i.imgur.com/cyehTUH.jpg
+1
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
typedef struct
{
uint8_t arr[10];
uint8_t pos;
uint8_t is_swap;
} arr10;
arr10 bubble_sort_recursion(arr10 a);
void bubble_sort (uint8_t arr[static 10]);
void bubble_sort (uint8_t arr[static 10])
{
arr10 a;
memcpy(a.arr, arr, sizeof(a.arr));
a.pos = 0;
a.is_swap = 0;
a = bubble_sort_recursion(a);
memcpy(arr, a.arr, sizeof(a.arr));
}
arr10 bubble_sort_recursion(arr10 a)
{
if (a.pos != 9)
{
if (a.arr[a.pos] > a.arr[a.pos + 1])
{
uint8_t tmp = a.arr[a.pos + 1];
a.arr[a.pos + 1] = a.arr[a.pos];
a.arr[a.pos] = tmp;
a.is_swap = 1;
}
a.pos++;
return bubble_sort_recursion(a);
}
else
{
if (a.is_swap == 0)
{
return a;
}
else
{
a.pos = 0;
a.is_swap = 0;
return bubble_sort_recursion(a);
}
}
}
int main(void)
{
uint8_t arr[10] = {244, 90, 254, 109, 33, 85, 69, 81, 126, 71};
bubble_sort(arr);
printf("%" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8 ", %" PRIu8,
arr[0], arr[1], arr[2], arr[3], arr[4], arr[5], arr[6], arr[7], arr[8], arr[9]);
return 0;
}
Рекурсивная сортировка пузырьком
−1
public static function findById($id)
{
$model = self::where('id', $id)->get();
$count = $model->getIterator()->count();
if($count > 0) {
return $model->getIterator()->current();
}
return false;
}
Laravel Eloquent Model
−4
func (incident Incident) DeleteResponsibleMicroservices(microservices []string) {
var teamsDelete []string
responsibleMss := incident.GetResponsibleMicroservices()
for _, microservice := range microservices {
ResponsibleMssLoop:
for _, responsibleMs := range responsibleMss {
if microservice == responsibleMs.MicroserviceId {
service.GetInstanceDB().Delete(responsibleMs)
if team, ok := GetTeamByMs(microservice); ok != false {
for _, ms := range incident.GetResponsibleMicroservices() {
if teamFind, ok := GetTeamByMs(ms.MicroserviceId); ok != false && teamFind == team {
continue ResponsibleMssLoop
}
}
teamsDelete = append(teamsDelete, team)
}
}
}
}
if len(teamsDelete) > 0 {
incident.DeleteResponsibles(teamsDelete)
}
}
Отличное читается код на Golang
0
: ?>
BEGIN
SOURCE >IN @ /STRING 2DUP
S" <?" SEARCH NIP
IF
NIP OVER -
DUP 2 + >IN +!
STATE @ IF
POSTPONE SLITERAL
['] TYPE COMPILE,
ELSE
TYPE
THEN
TRUE
ELSE
DROP
STATE @ IF
POSTPONE SLITERAL
['] TYPE COMPILE,
['] CR COMPILE,
ELSE
TYPE CR
THEN
REFILL 0=
THEN
UNTIL
; IMMEDIATE
: ROW
5 0 ?DO
?> <TD> <? I . ?> </TD> <?
LOOP
;
: T-ROWS
0 ?DO
?>
<TR>
<? DUP EXECUTE ?>
</TR>
<?
LOOP
DROP
;
?> <!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>OLOLO!</TITLE>
</HEAD>
<BODY>
<H1>THIS IS FORTH BABY ;)</H1>
<TABLE>
<? ' ROW 5 T-ROWS ?>
</TABLE>
</BODY>
</HTML>
=)
+1
/**
* Cast an object into a different class.
*
* Currently this only supports casting DOWN the inheritance chain,
* that is, an object may only be cast into a class if that class
* is a descendant of the object's current class.
*
* This is mostly to avoid potentially losing data by casting across
* incompatable classes.
*
* @param object $object The object to cast.
* @param string $class The class to cast the object into.
* @return object
*/
function cast($object, $class) {
if( !is_object($object) )
throw new InvalidArgumentException('$object must be an object.');
if( !is_string($class) )
throw new InvalidArgumentException('$class must be a string.');
if( !class_exists($class) )
throw new InvalidArgumentException(sprintf('Unknown class: %s.', $class));
if( !is_subclass_of($class, get_class($object)) )
throw new InvalidArgumentException(sprintf(
'%s is not a descendant of $object class: %s.',
$class, get_class($object)
));
/**
* This is a beautifully ugly hack.
*
* First, we serialize our object, which turns it into a string, allowing
* us to muck about with it using standard string manipulation methods.
*
* Then, we use preg_replace to change it's defined type to the class
* we're casting it to, and then serialize the string back into an
* object.
*/
return unserialize(
preg_replace(
'/^O:\d+:"[^"]++"/',
'O:'.strlen($class).':"'.$class.'"',
serialize($object)
)
);
}
Это прекрасно.