- 1
У Страйкера новый бизнес!
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−103
У Страйкера новый бизнес!
http://govnokod.com/
0
Гуглил, ничего не нашел.
Есть ли такая программа (кроме yacc), которой можно подать на вход структуру или класс, а она сгенерит (опционально):
- парсер конфигов в нужном формате.
- геттеры\сеттеры приватных полей.
- методы взаимодействия с БД (запрос\сохранение\удаление\изменение таблиц|записей) а-ля Django Models.
- ну и прочие удобные плюшки чтобы меньше вбивать код в редактор.
гуглил как "Генераторы исходного кода" ничего толкового не нашел.
−1
// http://p99.gforge.inria.fr/p99-html/group__flexible.html
//C99 allows a flexible array member to be defined as the last member of a struct,
// namely an array of undetermined length.
//P99_DECLARE_STRUCT(package_head);
struct package_head {
char name[20];
size_t len;
uint64_t data[];
};
// Such a struct can then be allocated on the heap with a suitable size such
// that the field data has as many elements as fit in the allocated space from
// the start of data onward. Usually one would allocate such struct with
package_head *a = malloc(sizeof(package_head) + 10 * sizeof(uint64_t));
package_head *b = malloc(sizeof(*b) + 12 * sizeof(b->data[0]));
// This has several disadvantages. Firstly, the syntax is clumsy. We have to
// use a relatively complicated expression that uses two elements of the specification of a or b.
// Secondly, it wastes space. Due to packing of the struct the offset of data "inside"
// the struct may be less than sizeof(package_head). In most cases the real size
// of the object that we want to construct is
offsetof(package_head, data) + N * sizeof(uint64_t)
// so we are wasting
sizeof(package_head) - offsetof(package_head, data)
// bytes.
// The above formula for the exact size is only valid for larger values of N. We must
// also ensure that we allocate at least sizeof(package_head) bytes. So the complete
// formula looks something like
#define P99_FSIZEOF(T, F, N) P99_MAXOF(sizeof(T), offsetof(T, F) + P99_SIZEOF(T, F[0]) * N)
// which is probably not something that you want to write on a daily basis.
// We provide several interfaces to allocate struct with flexible members
Херню написали какую-то. Забыли самое главное : нельзя так в лоб аллоцировать память под структуры. Потому что выравнивание может не то быть.
Надо использовать http://man7.org/linux/man-pages/man3/aligned_alloc.3.html
+1
f =: #.@i.~&'.O'@(#~ ~:&LF)
g =: $~&6 5@:{&'.O'@#:~&(30$2)
'K A O Y B G R RP' =: f each|. (0 : 0); (0 : 0); (0 : 0); (0 : 0); (0 : 0); (0 : 0); (0 : 0); (0 : 0)
O..O.
O..O.
OOO..
O..O.
O...O
O...O
)
.OOO.
O...O
O...O
OOOOO
O...O
O...O
)
.OOO.
O...O
O...O
O...O
O...O
.OOO.
)
.O.O.
..O..
O...O
O..OO
O.O.O
OO..O
)
OOOOO
O....
OOOO.
O...O
O...O
OOOO.
)
OOOOO
O....
O....
O....
O....
O....
)
OOOO.
O...O
OOOO.
O....
O....
O....
)
.O...
..O..
...O.
...O.
..O..
.O...
)
echo ,./g (,@:(,&0"0)) K,A,K,O,Y,0,B,A,G,O,R,0,3#RP
O..O.......OOO......O..O.......OOO.......O.O................OOOOO......OOO......OOOOO......OOO......OOOO.................O.........O.........O........
O..O......O...O.....O..O......O...O.......O.................O.........O...O.....O.........O...O.....O...O.................O.........O.........O.......
OOO.......O...O.....OOO.......O...O.....O...O...............OOOO......O...O.....O.........O...O.....OOOO...................O.........O.........O......
O..O......OOOOO.....O..O......O...O.....O..OO...............O...O.....OOOOO.....O.........O...O.....O......................O.........O.........O......
O...O.....O...O.....O...O.....O...O.....O.O.O...............O...O.....O...O.....O.........O...O.....O.....................O.........O.........O.......
O...O.....O...O.....O...O......OOO......OO..O...............OOOO......O...O.....O..........OOO......O....................O.........O.........O........
0
class Person {
protected name: string;
constructor(name: string) { this.name = name; }
}
class Employee extends Person {
private department: string;
constructor(name: string, department: string) {
super(name);
this.department = department;
}
public get ElevatorPitch() {
return `Hello, my name is ${this.name} and I work in ${this.department}.`;
}
}
let howard = new Employee("Howard", "Sales");
console.log(howard.ElevatorPitch);
наговнокодил компайлер TypeScript для Lua для тех кто терпеть не может такой говноязык как Lua но в экстазе от говно Vm от Lua 5.3
https://github.com/ASDAlexander77/TypeScriptLUA
Закомпили тестовый файл:
node __out/main.js test.ts
Теперь можно эту лажу запустить
lua test.lua
−1
Давайте обсудим документацию для программ на GNU/Linux, и документацию MSDN.
Я считаю, что по архитектуре и по документации GNU/Linux намного лучше.
Потому что в man обычно декларативный стиль, и описывается поведение.
Если же читать о windows программах -- то я обычно натыкаюсь на тупо гайды, где не описано конкнетно для чего такие действия нужно делать,
и как это будет обработано внутренней логикой программы.
Linux -- ОС для разработчиков и инженеров ПО. Windows -- сомневаюсь что нацелена на это.
−2
#include <stdio.h>
#include <locale.h>
main()
{
setlocale(LC_ALL, "Rus");
float lower, medium, upper;
lower = 2;
medium = 50;
upper = 100;
float step = 1;
printf( "\t\t%s\n\n\n","Температура пукана относительно изучения ЯП (10 лет) ");
printf("%s\t\t%s\t\t%s\n","изучение основ","изучение STL" , "делать сайтики на Ассемблере");
while (step <= 10)
{
++step;
printf("%.1f\t\t\t%.1f\t\t\t%.1f\n", lower*step, lower*step*5, medium * step*10);
}
getchar();
}
Немного статистики Hot пукана
−1
class MyBigClass
{
var $allocatedSize;
var $allMyOtherStuff;
}
function AllocateMyBigClass()
{
$before = memory_get_usage();
$ret = new MyBigClass;
$after = memory_get_usage();
$ret->allocatedSize = ($after - $before);
return $ret;
}
Зачем нам в языке адекватный sizeof, у нас нет времени, чтобы ебаться с ним!
Подробнее: https://stackoverflow.com/questions/1351855/getting-size-in-memory-of-an-object-in-php
−2
https://habr.com/post/423889/
Публикация отхватила неебическое количество плюсов.
+2
#include <stdio.h>
int main()
{
<?php
function genputs($s) {
echo "\tputs(\"$s\");\n";
}
function f($i) {
if ($i >= 5 && $i <= 20 || $i % 10 >= 5 || $i % 10 == 0)
return "ок";
elseif ($i % 10 == 1)
return "ка";
else
return "ки";
}
$i = 99;
while ($i >= 1) {
$s = f($i);
genputs("$i бутыл$s пива на стене");
genputs("$i бутыл$s пива!");
genputs("Возьми одну, пусти по кругу");
if ($i-- > 1) {
$s = f($i);
genputs("$i бутыл$s пива на стене!");
}
}
genputs("Нет бутылок пива на стене!");
?>
return 0;
}
Когда хочется в Си такой же няшный препроцессор как в FASM'е...