- 1
https://m.reddit.com/r/cpp/comments/4pmlpz/what_the_iso_c_committee_added_to_the_c17_working/
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
https://m.reddit.com/r/cpp/comments/4pmlpz/what_the_iso_c_committee_added_to_the_c17_working/
Мне остаётся только спросить:
+3
void MyZKbMain::keyPressEvent(QKeyEvent* k)
{
QPixmap pm; pm.load("ruleta_usr.png");
ZConfig Num(QString("numeros.cfg"), true);
ZConfig Hist(QString("historial.cfg"), true);
switch (k->key())
{
case 0x1046: //Boton Verde
break;
case 0x1030: //Boton Verde
calcular=0;
reboot = new ZMessageDlg("zRoulette",
QString("Sistema Ubeda 0.5\nBasado en el Sistema de Cuadros\n\nwww.developermoto.com/es\nwww.modmymoto.com\n\n(C)2009 RacingLocura07, CepiPerez"),
(ZMessageDlg::MessageDlgType)2, 0, this,"about", true, 0);
reboot->setTitleIcon(pm); reboot->show();
break;
case 0x1031: //Boton Rojo
calcular=0;
reboot = new ZMessageDlg("zRoulette", "Desea salir?",
(ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0);
reboot->setTitleIcon(pm); reboot->show();
if(reboot->exec()==1) { exit(); }
else { update(); break; }
case 0x1012: //Tecla de Navegacion De Izquierda
calcular=0;
if (current > 1 ) { --current; update(); break; } else { break; }
case 0x1013: //Tecla de Navegacion De Arriba
calcular=0;
if ( current > 3 ) { ------current; update(); break; } else { break; }
case 0x1014: //Tecla de Navegacion De Derecha
calcular=0;
if (current < 36 ) { ++current; update(); break; } else { break; }
case 0x1015: //Tecla de Navegacion De Abajo
calcular=0;
if (current < 34 ) { ++++++current; update(); break; } else { break; }
case 0x1038: //Softkey Izquierda
calcular=0;
reboot = new ZMessageDlg("zRoulette", "Desea reinciar la Ruleta?", (ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0);
reboot->setTitleIcon(pm); reboot->show();
if(reboot->exec()==1) { system("rm numeros.cfg"); system("rm historial.cfg"); current = 1; jugadas = 0; lista.clear(); update(); break; }
else { update(); break; }
case 0x103a: //Softkey Derecha
int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("18"), 0 );
if ( temp != 0 ) {
reboot = new ZMessageDlg("zRoulette", "Desea limpiar las jugadas dejando las ultimas 18 solamente?",
(ZMessageDlg::MessageDlgType)1, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show();
if(reboot->exec()==1) {
for ( int l=1; l<37; ++l) { Num.writeEntry ( QString("NUMEROS"), QString("%1").arg(l), QString("0") ); }
for ( int j=1; j<19; ++j) {
int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j), 0 );
if ( temp > 0 ) { Num.writeEntry ( QString("NUMEROS"), QString("%1").arg(temp), QString("1") ); }
} calcular=1; update(); break;
} else { break; }
} else {
reboot = new ZMessageDlg("zRoulette", "Deben haber mas de 18 bolas jugadas para el reinicio parcial.",
(ZMessageDlg::MessageDlgType)2, 0, this,"about", true, 0); reboot->setTitleIcon(pm); reboot->show(); break;
}
case 0x1004: //Boton Central
valortemp = Num.readNumEntry(QString("NUMEROS"), QString("%1").arg(current), 0 );
if ( valortemp < 1 ) { valortemp=0; } ++valortemp;
Num.writeEntry(QString("NUMEROS"), QString("%1").arg(current), valortemp);
int lugar=0; for ( int j=18; j>0; --j)
{ int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j), 0 ); if ( temp==0 ) { lugar=j; } }
if ( lugar > 0 ) {
Hist.writeEntry ( QString("HISTORIAL"), QString("%1").arg(lugar), QString("%1").arg(current) );
} else {
for ( int j=1; j<18; ++j) {
int temp = Hist.readNumEntry ( QString("HISTORIAL"), QString("%1").arg(j+1), 0 );
Hist.writeEntry ( QString("HISTORIAL"), QString("%1").arg(j), QString("%1").arg(temp) );
}
Hist.writeEntry ( QString("HISTORIAL"), QString("18"), QString("%1").arg(current) );
}
calcular=1;
update();
}
}
Разработчики из солнечной Аргентины. Кусочек кода из кастомного "лаунчера" для телефонов Motorola на платформе MotoMAGX (Linux 2.6.10, Qt 2.3.8, gcc 3.4.3). АДИЩЕ С ЦАРСКИМИ АНРОЛЛАМИ: https://github.com/crutchwalkfactory/motocakerteam/blob/master/Projects/MotoDesk/MyZKbMain.cpp
Что интересно, это всё как-то работало и даже довольно мило выглядело: http://exlmoto.ru/wp-content/Images/AOne/1.gif
+3
#include "stdafx.h"
#include <Windows.h>
#pragma comment(lib, "gdiplus.lib")
#include <gdiplus.h>
#include <vector>
#include <chrono>
wchar_t* path =
L"здесь был путь*";
using namespace Gdiplus;
using namespace std::chrono;
int main()
{
GdiplusStartupInput gdipInput;
ULONG_PTR gdipToken;
GdiplusStartup(&gdipToken, &gdipInput, NULL);
HWND progman = FindWindowW(L"Progman", NULL);
HWND workerw = GetWindow(progman, GW_HWNDPREV);
HDC dc = GetDC(workerw);
std::vector<Bitmap*> images;
WIN32_FIND_DATAW fdata = { 0 };
HANDLE hFind = FindFirstFileW(path, &fdata);
int
scrWidth = GetSystemMetrics(SM_CXSCREEN),
scrHeight = GetSystemMetrics(SM_CYSCREEN);
UINT width, height;
bool isInfoRetrieved = false;
std::wstring wmp(path);
wmp = wmp.substr(0, wmp.length() - 1);
do {
Bitmap* bmp = Bitmap::FromFile((wmp + fdata.cFileName).c_str());
if (bmp->GetLastStatus() != Gdiplus::Ok) continue;
int width = bmp->GetWidth();
int height = bmp->GetHeight();
double ratio = (double)width / height;
if (ratio > 1) {
width = scrWidth;
height = scrWidth / ratio;
}
else {
width = scrHeight * ratio;
height = scrHeight;
}
Bitmap* resized = new Bitmap(width, height, PixelFormat32bppRGB);
Graphics* resizedGr = Graphics::FromImage(resized);
resizedGr->DrawImage(bmp, 0, 0, width, height);
delete resizedGr;
delete bmp;
images.push_back(resized);
} while (FindNextFile(hFind, &fdata));
FindClose(hFind);
Graphics* mainGr = Graphics::FromHDC(dc);
Bitmap* bufBmp = new Bitmap(scrWidth, scrHeight, PixelFormat32bppRGB);
Graphics* bufGr = Graphics::FromImage(bufBmp);
int count = images.size();
int gap = 1000 / count;
while (true) {
for (auto it = images.begin(); it != images.end(); it++) {
milliseconds ms1 = duration_cast<milliseconds>(
system_clock::now().time_since_epoch());
Bitmap* bmp = *it;
int width = bmp->GetWidth();
int height = bmp->GetHeight();
int xOfs = (scrWidth - width) / 2, yOfs = (scrHeight - height) / 2;
bufGr->Clear(Color::Black);
bufGr->DrawImage(*it, xOfs, yOfs, width, height);
mainGr->DrawImage(bufBmp, 0, 0);
milliseconds ms2 = duration_cast<milliseconds>(
system_clock::now().time_since_epoch());
milliseconds delta = ms2 - ms1;
if (gap > delta.count())
Sleep(gap - delta.count());
}
}
return 0;
}
Код для рисования под иконками рабочего стола на винде
Да, в винде можно так делать
Нахуй никому не нужно, но выглядит заебись
+3
Оффтоп
Пишу либу для гуя в консоли. Столкнулся с проблемой медленного вывода в консоль на линуксе.
На винде есть няшный WriteConsoleOutput, который может вывести буфер разом на консоль, в линупсе ничего подобного не нашел.
Если использовать Console.WriteLine или libc-шный puts, все лагает неимоверно
Есть идеи?
0
if (strpos($route, ':') !== false) {
$route = str_replace(':any', '([^/]+)', str_replace(':num', '([0-9]+)', str_replace(':all', '(.+)', $route)));
}
Очередная обезьяна села высерать свои мысли на PHP ... Уже много говорили тут о mpak и его "cms", вот вам еще одно "чудо": https://github.com/wolfcms/wolfcms
−99
http://1c.ru/news/info.jsp?id=21537
ну не вирус конечно, но первый дропер на 1С
+2
const size_t longstring_size = 1000500; // TODO: O RLY magic constant? => Can't load edges >= 1Mbp
char longstring[longstring_size];
Орфография комментариев сохранена.
+2
using System;
using System.Collections.Generic;
using System.Net;
using System.Web.Script.Serialization;
namespace Govnokod
{
public class Program
{
private static string input;
private static string[] inputargs;
private static int inputargsh = 0;
private static int eax;
private static string hax,hbx;
public static void CommandActions()
{
if (inputargs[0] == "download")
{
if (inputargsh > 1)
{
hax = inputargs[1];
hbx = (inputargsh > 2) ? inputargs[2]:null;
if (String.IsNullOrEmpty(hbx))
hbx = Environment.CurrentDirectory+"\\"+hax;
Console.WriteLine("Downloading...");
}
else Console.WriteLine("invalid argument: 1\n");
}
else if (inputargs[0] == "apkinfo")
{
if (inputargsh > 1)
{
Console.WriteLine("Apkinfo...");
}
else Console.WriteLine("invalid argument: 1\n");
}
else if (input != "")
Console.WriteLine("invalid command: "+input+"\n");
CommandStart();
}
public static void CommandStart()
{
if (inputargsh != 0)
{
Array.Clear(inputargs,0,inputargsh);
inputargsh = 0;
}
input = Console.ReadLine();
input = input.Trim();
hax = input.ToLower();
while (true)
{
eax = hax.IndexOf(' ');
Array.Resize(ref inputargs,inputargsh+1);
if (eax != -1)
{
inputargs[inputargsh] = hax.Substring(0,eax);
hax = hax.Substring(eax);
hax = hax.TrimStart();
inputargsh++;
}
else
{
inputargs[inputargsh] = hax;
inputargsh++;
hax = null;
break;
}
}
if (inputargs[0] == "quit")
{
Console.Clear();
Console.Write("Press any key to quit...");
Console.ReadKey();
}
else CommandActions();
}
public static void Main(string[] args)
{
Console.WriteLine("; Commands:");
Console.WriteLine(";\tdownload <apk> <path>");
Console.WriteLine(";\tapkinfo <apk> or <index>");
Console.WriteLine(";\tquit <>\n");
CommandStart();
}
}
}
"Распознователь Команд 6120"
−85
может = "ИвановИИ";
текущий = ИмяПользователя();
Если Не текущий = может Тогда
ЭлементыФормы.ОсновныеДействияФормы.Кнопки.ОсновныеДействияФормыВыполнить.Доступность = РедактироватьУзел;
Предупреждение("Запустить обмен может пользователь: " + может );
КонецЕсли;
а если незнающий прог пробел добавит лишний в имя пользователя (или уволится сотрудник)... права лягут, да? ну ок.
+1
auto getMaxSize = [](const auto &vec) {
if (vec.size() == 0)
return 0;
const auto &max = *std::max_element(
vec.begin(),
vec.end(),
[](const auto &lhs, const auto &rhs){
return lhs.size() < rhs.size();
});
return max.size();
};
Раньше я не понимал актуальность шутки:
In C++14, you just write auto auto(auto auto) { auto; } The compiler infers the rest from context