1. Си / Говнокод #17352

    +139

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #ifndef STDC
    #  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
    #    define const       /* note: need a more gentle solution here */
    #  endif
    #endif

    Совместимость

    Ccik, 22 Декабря 2014

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

    +157

    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
    $('.file_work .left .content a.create').bind('click', function(){
            show.in_question(strings.question[2], {
                0:strings.question[2].buttons[0], 
                1:strings.question[2].buttons[1]
            }, function(action, string){
                if(action !='ok'){
                    return;
                }
                if(string.length<4){
                    show.error(strings.error[7], '');
                    return;
                }
                CreateTag(cache.current, string);
            });
        });

    хуита, 22 Декабря 2014

    Комментарии (11)
  3. C++ / Говнокод #17350

    +58

    1. 1
    int (o)(0);

    http://ideone.com/9JL6K4

    bormand, 22 Декабря 2014

    Комментарии (11)
  4. C++ / Говнокод #17349

    +50

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    #include <iostream>
     
    void koko() { return throw "kook"; }
     
    int main() try {
    	koko();
    } catch(const char * e) {
    	std::cout << e;
    }

    когда никто не видит, throw возвращает void
    http://ideone.com/VDMPwE

    Xom94ok, 22 Декабря 2014

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

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    express_static = express.static(static_files.file_path)
        app.use('/files', (req, res, next) ->
            if Math.random() > app.failureProbability
                express_static.handle(req, res, next)
            else
                # server failure or timeout
                if Math.random() < 0.5
                    console.log('\x1B[31mRandom failure\x1B[0m')
                    res.send(500, 'Fuck you')
                else
                    console.log('\x1B[31mRandom timeout\x1B[0m')
        )

    а вот так мы тестируем сетевую нагрузку (нода, кофе)

    makc3d, 21 Декабря 2014

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    anim.object.strokeWidthEnd = _.distance((end.replace(/(#[0-9a-f]{6})|(#[0-9a-f]{3})|(rgba?\((\d{1,3})\,\s*(\d{1,3})\,\s*(\d{1,3})(\,\s*([0-9\.]{1,4}))?\))|(rgba?\((\d{1,3})\%?\,\s*(\d{1,3})\%?\,\s*(\d{1,3})\%?(\,\s*([0-9\.]{1,4}))?\))/, '').match(/(\d+|(\d+)?\.\d+)(em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|px|pt|pc)?/) || [])[0]);
    if(end.indexOf('transparent') > -1)
        anim.object.strokeColorEnd = [anim.object.strokeColor[0], anim.object.strokeColor[1], anim.object.strokeColor[2], 0];
    else
        anim.object.strokeColorEnd = _.color((end.match(/(#[0-9a-f]{6})|(#[0-9a-f]{3})|(rgba?\((\d{1,3})\,\s*(\d{1,3})\,\s*(\d{1,3})(\,\s*([0-9\.]{1,4}))?\))|(rgba?\((\d{1,3})\%?\,\s*(\d{1,3})\%?\,\s*(\d{1,3})\%?(\,\s*([0-9\.]{1,4}))?\))/) || end.match(new RegExp(Object.keys(_.colors).join('|'))) || [])[0]);

    одна-проблема-и-регулярка.jpg

    gost, 20 Декабря 2014

    Комментарии (0)
  7. Java / Говнокод #17346

    +78

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public static void create(String title, int width, int height) {
            if (isWindowCreated())
                throw new RuntimeException("Window created.");
            if (title == null)
                throw new NullPointerException("Window title == null.");
            if (width <= 0 || height <= 0)
                throw new IllegalArgumentException("Window size <= 0.");
            if ((window = GLFW.glfwCreateWindow(width, height, title, MemoryUtil.NULL, MemoryUtil.NULL)) == MemoryUtil.NULL)
                throw new RuntimeException("Failed to create the GLFW window.");
        }

    jangolare, 20 Декабря 2014

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

    +132

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    var resultList = new List<CentralBankRateData>();
    using (var resultSet = m_Service.GetCursOnDate(request.Date))
    using (var reader = new DataTableReader(resultSet.Tables["ValuteCursOnDate"]))
    	while (reader.Read())
    		resultList.Add(new CentralBankRateData
    		{
    			Name = (string) reader["Vname"],
    			Nominal = (decimal) reader["Vnom"],
    			Rate = (decimal) reader["Vcurs"],
    			NumberCode = (int) reader["Vcode"],
    			StringCode = (string) reader["VchCode"]
    		});

    Какой Центробанк, такая и валюта. m_Service типа DailyInfoSoap, это сервис отдачи курсов валют. А еще у них получение актуального списка БИКов возможно только в древнейшем формате dBASE.

    yamamoto, 19 Декабря 2014

    Комментарии (4)
  9. Python / Говнокод #17343

    −107

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    ****@****:~$ python
    >>> import this
    The Zen of Python, by Tim Peters
    <....>There should be one-- and preferably only one --obvious way to do it.<...>
    >>> exit
    Use exit() or Ctrl-D (i.e. EOF) to exit

    preferably only one

    heyzea1, 19 Декабря 2014

    Комментарии (11)
  10. Куча / Говнокод #17342

    +129

    1. 1
    CN-1489: Commit tests to isolate the bug (sadly, they pass)

    someone, 19 Декабря 2014

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