- 1
- 2
- 3
- 4
- 5
- 6
В боте @GovnokodBot обновление:
Теперь говнокоды отправляются скриншотами.
Также создан канал "Говнокода" в "Telegram": https://t.me/GovnokodChannel
Баги и пожелания можно писать сюда.Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+2
В боте @GovnokodBot обновление:
Теперь говнокоды отправляются скриншотами.
Также создан канал "Говнокода" в "Telegram": https://t.me/GovnokodChannel
Баги и пожелания можно писать сюда.
            Зеркала Говнокода и полезные ресурсы:
* https://govnokod.xyz/
* https://gcode.space/
* индекс оффтопов: https://index.gcode.space/
* https://t.me/GovnokodBot
* https://pethu.ru
        
+2
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
using Indusoft.PolypropylenPowder.Info;
//СУКИ ИНДАСОФТОВСКИЕ
namespace Indusoft.PolypropylenPowder.Converters
{
    public class BeginXxConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return null;
            var s = value as IEnumerable<object>;
            var res = 45.0;
            var flag = false;
            if (s != null)
            {
                foreach (var a in s)
                {
                    var b = a as DataTemplate5Item;
                    if (b != null)
                    {
                        if (b.IsActive5)
                        {
                            flag = true;
                            break;
                        }
                    }
                    res += 91;
                }
            }
            if (!flag)
            {
                return 0;
            }
            return res;
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}ух сука питухи, а мне это говно поддерживать
+2
if thr < 0.1 then
		one()
	elseif thr > 0.1 and thr < 0.2 then
		one()
		two()
	elseif thr > 0.2 and thr < 0.3 then
		one()
		two()
		three()
	elseif thr > 0.3 and thr < 0.4 then
		one()
		two()
		three()
		four()
	elseif thr > 0.4 and thr < 0.5 then
		one()
		two()
		three()
		four()
		five()
	elseif thr > 0.5 and thr < 0.6 then
		one()
		two()
		three()
		four()
		five()
		six()
	elseif thr > 0.6 and thr < 0.7 then
		one()
		two()
		three()
		four()
		five()
		six()
		seven()
	elseif thr > 0.7 and thr < 0.8 then
		one()
		two()
		three()
		four()
		five()
		six()
		seven()
		eight()
	elseif thr > 0.8 and thr < 0.9 then
		one()
		two()
		three()
		four()
		five()
		six()
		seven()
		eight()
		nine()
	elseif thr > 0.9 and thr < 1 then
		one()
		two()
		three()
		four()
		five()
		six()
		seven()
		eight()
		nine()
		ten()
	elseif thr == 1 then
		one()
		two()
		three()
		four()
		five()
		six()
		seven()
		eight()
		nine()
		ten()
		eleven()
	end
........
function one()
	screen.setColor(0, 255, 0)
	screen.drawRectF(12, 53, 4, 5)
end
	
function two()
	screen.setColor(0, 255, 0)
	screen.drawRectF(16, 53, 4, 5)
end
	
function three()
	screen.setColor(0, 255, 0)
	screen.drawRectF(20, 53, 4, 5)
end
	
function four()
	screen.setColor(0, 255, 0)
	screen.drawRectF(24, 53, 4, 5)
endГовнокод для рисования полоски загрузки
+2
private static final String CITY_PREFIX = "г.";
private static final Map<String, String> CITIES = new HashMap<>() {
  {
    put("В.Новгород", "Великий Новгород");
    put("Н.Новгород", "Нижний Новгород");
    put("В. Новгород", "Великий Новгород");
    put("Н. Новгород", "Нижний Новгород");
    put("Великий Новгород", "Великий Новгород");
    put("Нижний Новгород", "Нижний Новгород");
    put("Петербург", "Санкт-Петербург");
    put("Челны", "Набережные Челны");
    put("Уренгой", "Новый Уренгой");
    put("ПсковS", "Псков");
  }
};
private static final Map<String, String> CITIES_WITH_PREFIX = new HashMap<>() {
  {
    put("г.Пушкино", "Пушкино");
  }
};ну просто офигенный мапинг
+2
def __gc(self, state):
    userdata = self.lib.luaL_testudata(self.state, 1, b'python.object')
    if userdata:
        obj_ptr = (c.cast(userdata, c.POINTER(c.py_object))).contents
        if obj_ptr:
            c.pythonapi.Py_DecRef(obj_ptr)
    return 0
def push_object(self, obj):
    userdata = self.lib.lua_newuserdata(self.state, c.sizeof(c.py_object))
    (c.cast(userdata, c.POINTER(c.py_object)))[0] = c.py_object()
    if self.lib.luaL_newmetatable(self.state, b'python.object'):
        self.gc_thunk = c.CFUNCTYPE(c.c_int, c.c_void_p)(self.__gc)
        self.lib.lua_pushcclosure(self.state, self.gc_thunk, 0)
        self.lib.lua_setfield(self.state, -2, b'__gc')
        self.lib.lua_pushstring(self.state, b'protected')
        self.lib.lua_setfield(self.state, -2, b'__metatable')
    self.lib.lua_setmetatable(self.state, -2)
    obj_ptr = c.py_object(obj)
    c.pythonapi.Py_IncRef(obj_ptr)
    (c.cast(userdata, c.POINTER(c.py_object)))[0] = obj_ptrКак скрестить ужа с ежом.
+2
IT Оффтоп #55
            #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
#42: https://govnokod.ru/26600 https://govnokod.xyz/_26600
#43: https://govnokod.ru/26604 https://govnokod.xyz/_26604
#44: https://govnokod.ru/26627 https://govnokod.xyz/_26627
#45: https://govnokod.ru/26635 https://govnokod.xyz/_26635
#46: (vanished) https://govnokod.xyz/_26646
#46: (vanished) https://govnokod.xyz/_26654
#47: https://govnokod.ru/26671 https://govnokod.xyz/_26671
#48: https://govnokod.ru/26707 https://govnokod.xyz/_26707
#49: https://govnokod.ru/26750 https://govnokod.xyz/_26750
#49: https://govnokod.ru/26776 https://govnokod.xyz/_26776
#50: https://govnokod.ru/26804 https://govnokod.xyz/_26804
#51: https://govnokod.ru/26809 https://govnokod.xyz/_26809
#52: https://govnokod.ru/26817 https://govnokod.xyz/_26817
#53: https://govnokod.ru/26833 https://govnokod.xyz/_26833
#54: https://govnokod.ru/26840 https://govnokod.xyz/_26840
        
+2
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
+  N T M a p M e m o r y                                                      %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Mmap() emulates the Unix method of the same name.
%
%  The format of the NTMapMemory method is:
%
%    MagickPrivate void *NTMapMemory(char *address,size_t length,int protection,
%      int access,int file,MagickOffsetType offset)
%
*/
MagickPrivate void *NTMapMemory(char *address,size_t length,int protection,
  int flags,int file,MagickOffsetType offset)
{
  DWORD
    access_mode,
    high_length,
    high_offset,
    low_length,
    low_offset,
    protection_mode;
  HANDLE
    file_handle,
    map_handle;
  void
    *map;
  (void) address;
  access_mode=0;
  file_handle=INVALID_HANDLE_VALUE;
  low_length=(DWORD) (length & 0xFFFFFFFFUL);
  high_length=(DWORD) ((((MagickOffsetType) length) >> 32) & 0xFFFFFFFFUL);
  map_handle=INVALID_HANDLE_VALUE;
  map=(void *) NULL;
  low_offset=(DWORD) (offset & 0xFFFFFFFFUL);
  high_offset=(DWORD) ((offset >> 32) & 0xFFFFFFFFUL);
  protection_mode=0;
  if (protection & PROT_WRITE)
    {
      access_mode=FILE_MAP_WRITE;
      if (!(flags & MAP_PRIVATE))
        protection_mode=PAGE_READWRITE;
      else
        {
          access_mode=FILE_MAP_COPY;
          protection_mode=PAGE_WRITECOPY;
        }
    }
  else
    if (protection & PROT_READ)
      {
        access_mode=FILE_MAP_READ;
        protection_mode=PAGE_READONLY;
      }
  if ((file == -1) && (flags & MAP_ANONYMOUS))
    file_handle=INVALID_HANDLE_VALUE;
  else
    file_handle=(HANDLE) _get_osfhandle(file);
  map_handle=CreateFileMapping(file_handle,0,protection_mode,high_length,
    low_length,0);
  if (map_handle)
    {
      map=(void *) MapViewOfFile(map_handle,access_mode,high_offset,low_offset,
        length);
      CloseHandle(map_handle);
    }
  if (map == (void *) NULL)
    return((void *) ((char *) MAP_FAILED));
  return((void *) ((char *) map));
}
            Мумуляция «mmap» в «Винде». Это даже работает, если пофиксить две строчки (кто угадает, какие именно, тому ничего).
Отсюда:
https://github.com/ImageMagick/ImageMagick/blob/master/MagickCore/nt-base.c
        
+2
/* meta */
typedef struct r_anal_meta_item_t {
	ut64 from;
	ut64 to;
	ut64 size;
	int type;
	int subtype;
	char *str;
	int space;
} RAnalMetaItem;
typedef struct {
	struct r_anal_t *anal;
	int type;
	int rad;
	SdbForeachCallback cb;
	void *user;
	int count;
	struct r_anal_type_function_t *fcn;
} RAnalMetaUserItem;
typedef struct r_anal_range_t {
	ut64 from;
	ut64 to;
	int bits;
} RAnalRange;
#define R_ANAL_UNMASK_TYPE(x) (x&R_ANAL_VAR_TYPE_SIZE_MASK)
#define R_ANAL_UNMASK_SIGN(x) (((x& R_ANAL_VAR_TYPE_SIGN_MASK)>> R_ANAL_VAR_TYPE_SIGN_SHIFT)==R_ANAL_VAR_TYPE_UNSIGNED)?0:1
#define R_ANAL_GET_OFFSET(x,y,z) \
	(x && x->binb.bin && x->binb.get_offset)? \
		x->binb.get_offset (x->binb.bin, y, z): -1
enum {
	R_ANAL_DATA_TYPE_NULL = 0,
	R_ANAL_DATA_TYPE_UNKNOWN = 1,
	R_ANAL_DATA_TYPE_STRING = 2,
	R_ANAL_DATA_TYPE_WIDE_STRING = 3,
	R_ANAL_DATA_TYPE_POINTER = 4,
	R_ANAL_DATA_TYPE_NUMBER = 5,
	R_ANAL_DATA_TYPE_INVALID = 6,
	R_ANAL_DATA_TYPE_HEADER = 7,
	R_ANAL_DATA_TYPE_SEQUENCE = 8,
	R_ANAL_DATA_TYPE_PATTERN = 9,
};
// used from core/anal.c
#define R_ANAL_ADDR_TYPE_EXEC      1
#define R_ANAL_ADDR_TYPE_READ      1 << 1
#define R_ANAL_ADDR_TYPE_WRITE     1 << 2
#define R_ANAL_ADDR_TYPE_FLAG      1 << 3
#define R_ANAL_ADDR_TYPE_FUNC      1 << 4
#define R_ANAL_ADDR_TYPE_HEAP      1 << 5
#define R_ANAL_ADDR_TYPE_STACK     1 << 6
#define R_ANAL_ADDR_TYPE_REG       1 << 7
#define R_ANAL_ADDR_TYPE_PROGRAM   1 << 8
#define R_ANAL_ADDR_TYPE_LIBRARY   1 << 9
#define R_ANAL_ADDR_TYPE_ASCII     1 << 10
#define R_ANAL_ADDR_TYPE_SEQUENCE  1 << 11
#define R_ANAL_ARCHINFO_MIN_OP_SIZE 0
#define R_ANAL_ARCHINFO_MAX_OP_SIZE 1
#define R_ANAL_ARCHINFO_ALIGN 2
#define R_ANAL_ARCHINFO_DATA_ALIGN 4
            Как нужно называть идентификаторы.
Источник:
https://github.com/radareorg/radare2/
        
+2
List<UserScoreDTO> userScores = users.stream()
                .map((u) -> ScoreUtils.aggregateUserAndFlagData(u, maxTestScore))
                .collect(toList());
return userScores.stream();Collect to List<UserScoreDTO> then stream the list to Stream<UserScoreDTO>
+2
The count is coded into a one-octet number using the following
formula:
   #define EXPBIAS 6
       count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
The above formula is in C, where "Int32" is a type for a 32-bit
integer, and the variable "c" is the coded count, Octet 10.
            Стандарт PHGP, набайтоёблено где не ждали. Казалось бы, в чем сложность отвести один октет на базу, а другой на сдвиг? Но сишнику проще даже не объяснить происходящее в стандарте, а просто кинуть код, типа, и так понятно же.
https://tools.ietf.org/html/rfc4880#page-12