1. PHP / Говнокод #25838

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    <?
    
    function russian_date($input) {
        $date=explode("-", date("Y-m-d",strtotime($input)));
        switch ($date[1]) {
            case 1: $m='ЯНВАРЬ'; break;
            case 3: $m='МАРТ'; break;
            case 4: $m='АПРЕЛЬ'; break;
            case 5: $m='МАЙ'; break;
            case 6: $m='ИЮНЬ'; break;
            case 2: $m='ФЕВРАЛЬ'; break;
            case 7: $m='ИЮЛЬ'; break;
            case 8: $m='АВГУСТ'; break;
            case 9: $m='СЕНТЯБРЬ'; break;
            case 10: $m='ОКТЯБРЬ'; break;
            case 11: $m='НОЯБРЬ'; break;
            case 12: $m='ДЕКАБРЬ'; break;
        }
        echo ($m.' '.$date[0]);
    }
    
    ?>

    Образцовый код из одного мегапроекта от профессионалов.
    Такие монстры рождаются, когда не знаешь о локали.

    petja, 14 Сентября 2019

    Комментарии (24)
  2. Си / Говнокод #25837

    0

    1. 1
    С днём Прогромиста!

    Ко-кок
    http://torvaldsfinger.com/

    LinuxGovno, 13 Сентября 2019

    Комментарии (62)
  3. JavaScript / Говнокод #25836

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    importPackage(Packages.com.sk89q.worldedit);
    importPackage(Packages.com.sk89q.worldedit.blocks);
    importPackage(Packages.com.sk89q.worldedit.tools);
    importPackage(Packages.com.sk89q.worldedit.tools.brushes);
    importPackage(Packages.com.sk89q.worldedit.patterns);
    
    var bSize = argv.length > 1 ? parseInt(argv[1]) : 4;
    var maxFaces = argv.length > 2 ? (argv[2]) : 2;		
    var strength = argv.length > 3 ? (argv[3]) : 1;
    
    var xOff = ['1', '-1', '1', '1', '-1', '1', '-1', '-1'];
    var yOff = ['1', '1', '-1', '1', '-1', '-1', '1', '-1'];
    var zOff = ['1', '1', '1', '-1', '1', '-1', '-1', '-1'];
    
    if (bSize == 0)	{bSize = 4;}
    var blocks = new Array();
    
    var tool = context.getSession().getBrushTool(player.getItemInHand());
    var matPat = new SingleBlockPattern(new BaseBlock(maxFaces));
    
    tool.setSize(bSize);
    tool.setFill(matPat);
    
    var brush = new Brush({
        strength : strength,
        build : function(editSession,pos,mat,bSize) {
    		
    		var session = context.remember();
     
    		for (iteration = 1; iteration <= strength; iteration++)	{
    
    			var matID = mat.getBlock().getType();
    			maxFaces = ((matID >= 0) && (matID <= 6)) ? matID : 3;
    			
    			var blockTotal = 0;			
    			var blockCnt = 0;			
    			var blockFaces = new Array(6);
    
    			radius = bSize + 0.5;
    			var invRadius = 1 / radius;
    			var ceilRadius = Math.ceil(radius);
    
    			var nextXn = 0;
    			forX: for (var x = 0; x <= ceilRadius; ++x) {
    				var xn = nextXn;
    				nextXn = (x + 1) * invRadius;
    				var nextYn = 0;
    				forY: for (var y = 0; y <= ceilRadius; ++y) {
    					var yn = nextYn;
    					nextYn = (y + 1) * invRadius;
    					var nextZn = 0;
    					forZ: for (var z = 0; z <= ceilRadius; ++z) {
    						var zn = nextZn;
    						nextZn = (z + 1) * invRadius;
    
    						var distanceSq = lengthSq(xn, yn, zn);
    						if (distanceSq > 1) {
    							if (z == 0) {
    								if (y == 0) {
    									break forX;
    								}
    								break forY;
    							}
    							break forZ;
    						}
    										
    						for (var dirLoop = 0; dirLoop <= 7 ; dirLoop++)	{
    						
    							var pt = pos.add(x * xOff[dirLoop], y * yOff[dirLoop], z * zOff[dirLoop]);
    							var curBlock = editSession.getBlock(pt);
    							
    							blockCnt = 0;
    							blockFaces = [];
    							
    							blockFaces[1] = editSession.getBlockType(pt.add(1,0,0));
    							blockFaces[2] = editSession.getBlockType(pt.add(-1,0,0));
    							blockFaces[3] = editSession.getBlockType(pt.add(0,1,0));
    							blockFaces[4] = editSession.getBlockType(pt.add(0,-1,0));
    							blockFaces[5] = editSession.getBlockType(pt.add(0,0,1));
    							blockFaces[6] = editSession.getBlockType(pt.add(0,0,-1));	
    							
    							for (var lpC = 1; lpC <= 6; lpC++) {
    								if((blockFaces[lpC]) == 0) {blockCnt++;}												
    							}
    							
    							if (blockCnt >= maxFaces) {
    							
    								blocks[blockTotal] = BlockID.AIR;
    							}
    							else {
    								blocks[blockTotal] = curBlock.getType();
    							}
    							blockTotal++;
    						}
    					}
    				}

    Какой багор )))

    CkpunmoBbIu_nemyx, 12 Сентября 2019

    Комментарии (1)
  4. JavaScript / Говнокод #25835

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    export default class CheckboxFilter extends React.PureComponent {
    
      private handleChange = (field: string) => (value: unknown) => {
        const { onChange } = this.props;
        onChange({params: { [field]: value }})
      };
    
      private onChangeValue(value: string, onChange: (value: string | null) => void, checked: boolean) {
        onChange(checked ? value : null);
      }
    
      private onChange = (e: any) => {
        const {value, type} = this.props;
        if(value) {
          this.onChangeValue.bind(null, value, this.handleChange(type))(e);
        } else {
          this.handleChange(type)(e);
        }
      }
    
      public render() {
        const {checked, children} = this.props;
    
        return (
            <Checkbox
              onChange={this.onChange}
              name='check'
              checked={checked}
            >
              {children}
            </Checkbox>
        )
      }
    };

    Код на react / typescript.
    Особое внимание методу onChange

    gooseim, 12 Сентября 2019

    Комментарии (7)
  5. JavaScript / Говнокод #25833

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if(deliverySuspend == true) {
                  deliverySuspend = false;
                }
                else
                {
                  deliverySuspend = true;
                }
    
                if(deliverySuspend == false)
                {
                  lastGlucoseMarkerVal = 0.0;
                }

    Пул реквест с таким куском говна пришел от индуса.
    Стилистика и табуляции сохранены.

    venoby, 12 Сентября 2019

    Комментарии (20)
  6. Куча / Говнокод #25831

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    static F1(jtdrr){PROLOG(0055);A df,dg,hs,*x,z;B b,ex,xop;C c,id;I fl,*hv,m;V*v;
     RZ(w);
     // If the input is a name, it must be from ".@'name' which turned into ".@(name+noun)  - or in debug, but that's discarded
     if(AT(w)&NAME){RZ(w=sfn(0,w));}
     // If noun, return the value of the noun.
     if(AT(w)&NOUN)R w;  // no quotes needed
     // Non-nouns and NMDOT names carry on
     v=FAV(w); id=v->id; fl=v->flag;
     I fndx=(id==CBDOT)&&!v->fgh[0]; A fs=v->fgh[fndx]; A gs=v->fgh[fndx^1];  // In verb for m b., if f is empty look to g for the left arg.  It would be nice to be more general
     hs=v->fgh[2]; if(id==CBOX)gs=0;  // ignore gs field in BOX, there to simulate BOXATOP
     if(fl&VXOPCALL)R drr(hs);
     xop=1&&VXOP&fl; ex=id==CCOLON&&hs&&!xop;
     b=id==CHOOK||id==CADVF; c=id==CFORK;
     m=!!fs+(gs||ex);
     if(!m)R spella(w);
     if(evoke(w))R drr(sfne(w));  // turn nameref into string or verb; then take rep
     if(fs)RZ(df=fl&VGERL?every(fxeach(fs),0L,jtdrr):drr(fs));
     if(gs)RZ(dg=fl&VGERR?every(fxeach(gs),0L,jtdrr):drr(gs));
     if(ex)RZ(dg=unparsem(num[0],w));
     m+=!b&&!xop||hs&&xop;
     GATV0(z,BOX,m,1); x=AAV(z);
     RZ(x[0]=rifvs(df));
     RZ(x[1]=rifvs(b||c||xop?dg:fl&VDDOP?(hv=AV(hs),link(sc(hv[0]),link(spellout(id),sc(hv[1])))):spellout(id)));
     if(2<m)RZ(x[2]=rifvs(c||xop?drr(hs):dg));
     EPILOG(z);
    }
    
    F1(jtdrep){A z=drr(w); R z&&AT(z)&BOX?z:ravel(box(z));}
    
    
    F1(jtaro){A fs,gs,hs,s,*u,*x,y,z;B ex,xop;C id;I*hv,m;V*v;
     RZ(w);
     if(FUNC&AT(w)){
      v=FAV(w); id=v->id;
      I fndx=(id==CBDOT)&&!v->fgh[0]; fs=v->fgh[fndx]; gs=v->fgh[fndx^1];  // In verb for m b., if f is empty look to g for the left arg.  It would be nice to be more general
      hs=v->fgh[2]; if(id==CBOX)gs=0;  // ignore gs field in BOX, there to simulate BOXATOP
      if(VXOPCALL&v->flag)R aro(hs);
      xop=1&&VXOP&v->flag;
      ex=hs&&id==CCOLON&&!xop;
      m=id==CFORK?3:!!fs+(ex||xop&&hs||!xop&&gs);
      if(!m)R spella(w);
      if(evoke(w)){RZ(w=sfne(w)); if(FUNC&AT(w))w=aro(w); R w;}  // keep nameref as a string, UNLESS it is NMDOT, in which case use the (f.'d) verb value
     }
     GAT0(z,BOX,2,1); x=AAV(z);
     if(NOUN&AT(w)){RZ(x[0]=rifvs(ravel(scc(CNOUN)))); if(AT(w)&NAME)RZ(w=sfn(0,w)); x[1]=INCORPNA(w); RETF(z);}  // if name, must be ".@'name', format name as string
     GATV0(y,BOX,m,1); u=AAV(y);
     if(0<m)RZ(u[0]=rifvs(aro(fs)));
     if(1<m)RZ(u[1]=rifvs(aro(ex?unparsem(num[0],w):xop?hs:gs)));
     if(2<m)RZ(u[2]=rifvs(aro(hs)));
     s=xop?aro(gs):VDDOP&v->flag?(hv=AV(hs),aro(foreign(sc(hv[0]),sc(hv[1])))):spellout(id);
     RZ(x[0]=rifvs(s)); x[1]=INCORPNA(y);
     R z;
    }
    
    F1(jtarep){R box(aro(w));}
    
    // Create A for a string - name~, a primitive, or the boxed string
    static DF1(jtfxchar){A y;C c,d,id,*s;I m,n;
     n=AN(w);
     ASSERT(1>=AR(w),EVRANK);  // string must be an atom or list
     ASSERT(n,EVLENGTH);
     s=CAV(w); c=*(s+n-1);
     DO(n, d=s[i]; ASSERT((C)(d-32)<(C)(127-32),EVSPELL););  // must be all ASCII
     if(CA==ctype[(UC)*s]&&c!=CESC1&&c!=CESC2)R swap(w);  // If name and not control word, treat as name~, create nameref
     ASSERT(id=spellin(n,s),EVSPELL);  // not name, must be control word or primitive.  Also classify string 
     if(id!=CFCONS)y=ds(id); else{m=s[n-2]-'0'; y=FCONS(CSIGN!=*s?scib(m):2==n?ainf:scib(-m));} // define 0:, if it's that, using boolean for 0/1
     ASSERT(y&&RHS&AT(y),EVDOMAIN);   // make sure it's a noun/verb/adv/conj
     if(!self || AT(y)

    Arbatan_Pokrovan, 12 Сентября 2019

    Комментарии (31)
  7. Куча / Говнокод #25830

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    RZ(z=tail(w)); k=AN(z)<<bplg(AT(z)); // k=length of input cell in bytes
     // fill in the shape, offset, and item-count of the virtual block
     AN(a)=AN(z); AK(a)+=(n-1)*k; MCISH(AS(a),AS(z),r-1);  // make the virtual block look like the tail, except for the offset.  We start out pointing
       // to the last item; the pointer is unused in the first iteration, and we then back up to the second-last item, which is the first one we
       // process as a
    
    #define ZZPOPNEVER 1   // we mustn't TPOP after copying the result atoms, because they are reused.  This will leave the memory used for type-conversions unclaimed.
       // if we implement the annulment of tpop pointers, we should use that to hand-free results that have been converted
     // We have to dance a bit for BOXATOP verbs, because the result comes back unboxed, but it has to be put into a box
     // to be fed into the next iteration.  This is still a saving, because we can use the same box to point to each successive result.
     // Exception: if the reusable box gets incorporated, it is no longer reusable and must be reallocated.  We will use the original z box,
     // which will NEVER be virtual because it is an atom whenever BOXATOP is set, as the starting pointer to the prev boxed result
     A boxedz = z; z=(state&ZZFLAGBOXATOP)?AAV(z)[0]:z;  // init current pointer for the temp box; if BOXATOP, use >{:y as the first (to-be-boxed) result
    
    #define ZZDECL
    #define ZZSTARTATEND 1   // build result from bottom up
    #include "result.h"
    
      ZZPARMS(1,n,2)
    #define ZZINSTALLFRAME(optr) *optr++=n;
    
     AD * RESTRICT zz=0;
     for(i=0;i<n;++i){   // loop through items, noting that the first is the tail itself
      if(i){RZ(z=CALL2(f2,a,z,fs));}   // apply the verb to the arguments (except the first time)
    #define ZZBODY
    #include "result.h"
      // If BOXATOP, we need to reinstate the boxing around z for the next iteration.
      if(state&ZZFLAGBOXATOP){
       // If boxedz itself has been incorporated into the result, we have to reallocate it.  We don't need the usual check for z==boxedz, because we know we INCORPed z into
       // the boxed result, so if it was the same as boxedz, the usecount of boxedz was incremented then
       if(!ACIPISOK(boxedz))GAT0(boxedz,BOX,1,0);   // reallocate boxedz if needed
       AAV(boxedz)[0]=z; z=boxedz;  // point boxedz to the previous result, and make that the new argument for next time
      }
      // if result happens to be the same virtual block that we passed in, we have to clone it before we change the pointer
      else if(a==z){RZ(z=virtual(z,0,AR(a))); AN(z)=AN(a); MCISH(AS(z),AS(a),r-1);}
    
      AK(a)-=k;  // back up to next input
     }
    
    A jtscansp(J jt,A w,A self,AF sf){A e,ee,x,z;B*b;I f,m,j,r,t,wr;P*wp,*zp;
     wr=AR(w); r=(RANKT)jt->ranks; r=wr<r?wr:r; RESETRANK; f=wr-r;
     wp=PAV(w); e=SPA(wp,e); RZ(ee=over(e,e));
     if(!equ(ee,CALL1(sf,ee,self))){
      RZ(x=denseit(w));
      R IRS1(x,self,r,sf,z);
     }else{
      RZ(b=bfi(wr,SPA(wp,a),1));
      if(r&&b[f]){b[f]=0; RZ(w=reaxis(ifb(wr,b),w));}
      j=f; m=0; DQ(wr-f, m+=!b[j++];);
     }
     wp=PAV(w); e=SPA(wp,e); x=SPA(wp,x);
     RZ(x=IRS1(x,self,m,sf,z));
     t=maxtype(AT(e),AT(x)); RZ(e=cvt(t,e)); if(TYPESNE(t,AT(x)))RZ(x=cvt(t,x));
     GASPARSE(z,STYPE(t),1,wr+!m,AS(w)); if(!m)*(wr+AS(z))=1;
     zp=PAV(z); 
     SPB(zp,e,e); 
     SPB(zp,x,x); 
     SPB(zp,i,ca(SPA(wp,i))); 
     SPB(zp,a,ca(SPA(wp,a)));
     R z;
    }    /* f/\"r or f/\."r on sparse w */
    
    static DF1(jtsscan){A y,z;I d,f,m,n,r,t,wn,wr,*ws,wt;
     RZ(w);F1PREFIP;
     wt=AT(w);
     if(SPARSE&wt)R scansp(w,self,jtsscan);
     wn=AN(w); wr=AR(w); r=(RANKT)jt->ranks; r=wr<r?wr:r; f=wr-r; ws=AS(w); RESETRANK;
     PROD(m,f,ws); PROD1(d,r-1,f+ws+1); n=r?ws[f]:1;  // will not be used if WN==0, so PROD ok.  n is # items along the selected rank
     y=FAV(self)->fgh[0]; // y is f/
     if(((n-2)|(wn-1))<0){if(vaid(FAV(y)->fgh[0])){R r?RETARG(w):reshape(over(shape(w),num[1]),w);}else R IRS1(w,self,r,jtsuffix,z);}  // if empty arg, or just 1 cell in selected axis, convert to f/\ which handles the short arg 
    
       //

    Arbatan_Pokrovan, 12 Сентября 2019

    Комментарии (5)
  8. Lua / Говнокод #25829

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    if self.Weapon:GetNextPrimaryFire() < CurTime() then
    	if GetConVarNumber( "ma2_togglechargeui" ) == 1 then
    		if (self.Charge-self.DmgMin)/self.DmgMax*100<=10 then
    			ply:SetNWString("chargebar","██")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=20 then
    			ply:SetNWString("chargebar","████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=30 then
    			ply:SetNWString("chargebar","██████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=40 then
    			ply:SetNWString("chargebar","████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=50 then
    			ply:SetNWString("chargebar","██████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=60 then
    			ply:SetNWString("chargebar","████████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=70 then
    			ply:SetNWString("chargebar","██████████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=80 then
    			ply:SetNWString("chargebar","████████████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100<=90 then
    			ply:SetNWString("chargebar","██████████████████")
    		elseif (self.Charge-self.DmgMin)/(self.DmgMax-self.DmgMin)*100>90 then
    			ply:SetNWString("chargebar","████████████████████")
    			ply:SetNWBool("chargemaxxxed",true)
    		end
    	end
    end

    https://steamcommunity.com/sharedfiles/filedetails/?id=1825542758

    amd, 11 Сентября 2019

    Комментарии (13)
  9. PHP / Говнокод #25827

    −1

    1. 1
    https://www.theregister.co.uk/AMP/2019/09/10/intel_netcat_side_channel_attack/

    очередной мельтдаун

    MAKAKA, 11 Сентября 2019

    Комментарии (9)
  10. 1C / Говнокод #25826

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    ВЫРАЗИТЬ(ВЫРАЗИТЬ(РасчетыСКлиентамиОстатки.ЗаказКлиента КАК Документ.РеализацияТоваровУслуг).ЗаказКлиента КАК Документ.ЗаказКлиента) КАК ЗаказКлиента
    
    Типично
    Конфигурация 1С ERP Украина.

    ChoaNyan, 11 Сентября 2019

    Комментарии (6)