Activity Stream
48,167 MEMBERS
63993 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 42
  1.     
    #21
    (1only)
    Website's:
    BarakaDesigns.com Amodity.com IMGFlare.com
    Quote Originally Posted by SplitIce View Post
    Ask and ye shall receive.
    PHP Code: 
    function saltGenerator($limitChars=8) {
        
    $saltv '';
        for (; 
    $limitChars; --$limitChars)
            
    $saltv .= chr(rand(33,126));
        return 
    $saltv;

    Best I can think of, also includes a few more symbols in the calculation, see ascii table: http://www.asciitable.com/index/asciifull.gif
    thanks for that, makes the function more usable

    CEO Of BarakaDesigns.com, Need PSD to vB? Need a Custom skin? Hit me up -Baraka aka 1Only

  2.     
    #22
    Member
    Delete duplicate lines anywhere

    This regex matches a line if a duplicate of that line follows it, even if there are other lines between the matched line and the duplicate. Replacing all matches of this regex with nothing deletes all duplicate lines even if they are not adjacent.

    PHP Code: 
    $replaced_data preg_replace('/^(.*)(\r?\n\1)+$/m''\1'$original_data); 

  3.   Sponsored Links

  4.     
    #23
    You can call me G
    Here's something trivial: generate random IDs using list comprehensions in Python

    Code: 
    import random
    
    source_set = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    
    def random_id(length=7):
        return ''.join([random.choice(source_set) for i in range(length)])
    EDIT: just realised, it can be used for generating salt as well.. silly me - why didn't I mention it before



    My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz

  5.     
    #24
    (╯?□?)╯︵ ┻━┻
    Website's:
    Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.com
    YEAAAAAAAAAAH LIST COMPREHENSIONS!

    Gaurav goes up in my list of cool coders. lol

    Can do some really crazy stuff with list comps, dirty stuff [eviljmz]

    Code: 
    import sqlite3
    c = sqlite3.connect('test.db').cursor()
    print '%s has the following animals:\n%s' % c.execute('SELECT :name, GROUP_CONCAT(y,\'\n\') FROM (SELECT (:sone || a.name || :stwo || a.species) as y FROM animals a, keepers k WHERE a.keeper_id = k.id AND k.name = :name) a;', {'sone' : 'Name: ', 'stwo' : ', Species: ', 'name' : raw_input('Keeper Name: ').capitalize()}).fetchone(), '%s' % str(c.close()).replace('None', '')
    Prompts for a zoo keeper's name and outputs the animals they look after, in one line pretty much (apart from the initial import/connect).
    Projects:
    WCDDL - The Professional DDL Script
    Top Secret Project: In Development - ZOMG
    ImgTrack - Never Have Dead Images Again!

  6.     
    #25
    Respected Developer
    Website's:
    X4B.org
    That almost makes me spew as much as.

    Code: 
    Public Function Adler32$(data As StringReader, Optional InitL& = 1, Optional InitH& = 0)
       With data
                Dim L&, h&
                h = InitH: L = InitL
                   
                   Dim StrCharPos&, tmpBuff$
                   tmpBuff = StrConv(.mvardata, vbFromUnicode, LocaleID_ENG)
                      'The largest prime less than 2^16
                      L = (AscB(MidB$(tmpBuff, StrCharPos, 1)) + L) ' Mod 65521 '&HFFF1
                      h = (h + L) ' Mod 65521 '&HFFF1
    
                      If (0 = (StrCharPos Mod 5552)) Or _
                               (StrCharPos = Len(.mvardata)) Then
                         L = L Mod 65521  '&HFFF1
                         h = h Mod 65521  '&HFFF1
                         myDoEvents
                      End If
                      
                   Next
    
          Adler32 = H16(h) & H16(L)
       End With
    End Function
    which by the way is just
    Code: 
    static public uint adler32(byte[] data, int len){
     	        ulong a = 17;
     	        ulong b = 0;
     	        ulong MOD_ADLER = 65521;
     	        for(int i = 0; i < len; ++i){
     		        a = (a + data[i]) % MOD_ADLER;
     		        b = (b + a) % MOD_ADLER;
     	        }
     	        return (uint)((b << 16) | a);
             }

  7.     
    #26
    (╯?□?)╯︵ ┻━┻
    Website's:
    Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.com
    lol, well, that's a mess. Mine is just monstrous but if you split it up into separate statements (remove all the nesting and what not), it is well written
    Projects:
    WCDDL - The Professional DDL Script
    Top Secret Project: In Development - ZOMG
    ImgTrack - Never Have Dead Images Again!

  8.     
    #27
    Member
    VB.NET snip:
    Code: 
    Dim downloadcaptcha As New WebClient
    downloadcaptcha.DownloadFile("http://rapidgator.net" & .ParseBetween(hr.Html, "id=""yw0"" src=""", """ alt="" />", "id=""yw0"" src=""".Length), CurDir() & "\captcha.png")
    PictureBox1.Image = Image.FromFile(CurDir() & "\captcha.png")
    a little piece of what I used to grab the captcha of rapidgator and put it in a picturebox. and btw I did not use web browsers for the other parts (I hate when people use those bloated pieces of shit).
    My previous username was kaed

  9.     
    #28
    (1only)
    Website's:
    BarakaDesigns.com Amodity.com IMGFlare.com
    PHP Code: 
    function rowcountGetter($tables$puffix'') {
        if (
    $puffix)
            
    $puffix ' '.$puffix;
        (
    $rows sql::query('SELECT COUNT(*) FROM '.sql::$db->escape_string($tables).$puffix)) or sql::error(__FILE__,__LINE__);
        (
    $alter $rows->fetch_row()) or sql::error(__FILE__,__LINE__);
        
    $rows->free();
        return 
    $alter[0];

    Basically it counts the table in which rowcountGetter() is executed with
    say i wanted to get post or threads of the database i'll do
    PHP Code: 
    $forum_posts rowcountGetter('posts'); 
    how about if you need to get something off the database but need to classify where you can do
    PHP Code: 
    $something rowcountGetter('snippet'' WHERE (`KWWH` & '.sql::search('post').')'); 
    if there is room for improvement, i'd like to see

    CEO Of BarakaDesigns.com, Need PSD to vB? Need a Custom skin? Hit me up -Baraka aka 1Only

  10.     
    #29
    (╯?□?)╯︵ ┻━┻
    Website's:
    Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.com
    Seems interesting. Ideally though you should keep row counters in another table and update them on insertion of a new row. This way you simply select the appropriate counter rather than counting the rows each time (e.g. rowcounts(int key, int counter)).

    My snippet, isn't a snippet today.
    Rather a suggested logic you should implement.

    Basically pagination. You reminded me of it just now.

    Many, many people do the following:
    - Select the rows (limited to rows_per_page from the page offset)
    - Select count(*) of same query without a limit
    - Use the count to display how many pages of results there are and to know how many page links to show

    What people should do is this:
    - Select the rows (limited to rows_per_page+1 from the page offset)
    - If your result set is of size rows_per_page+1, display a 'next page' link and remove the last row from the set
    - If your result set is of a size less than rows_per_page+1, show no 'next page' link
    - If your current page is > 1, show a 'previous page' link

    This way you never select a count(), you only use one query.
    Projects:
    WCDDL - The Professional DDL Script
    Top Secret Project: In Development - ZOMG
    ImgTrack - Never Have Dead Images Again!

  11.     
    #30
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Wrote this for someone needing help:
    PHP Code: 
    public static string[] grabProxy(string source)
            {
                var 
    proxies = new List<string>();
                foreach (
    Match m in Regex.Matches(source, @"<td><span>([\s\S]*?)(\d+)</td>"))
                {
                    
    string port m.Groups[2].Value;
                    
    string ip m.Groups[1].Value;
                    
    ip Regex.Replace(ip, @"(<(div|span) style=""display:none"">\d+.*?>|<.*?>)""").Trim();
                    
    proxies.Add(string.Concat(ip":"port));
                }
                return 
    proxies.ToArray();
            } 
    Parses out proxies from http://hidemyass.com/proxy-list/, hma being a ass trying to obfuscate proxies

    Sample Usage:
    PHP Code: 
    WebClient wc = new WebClient();

                
    string[] proxyList grabProxy(wc.DownloadString("http://hidemyass.com/proxy-list/"));

                Array.ForEach(
    proxyList=> Console.WriteLine(s));

                
    Console.ReadKey(); 

Page 3 of 5 FirstFirst 12345 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Plz Help To Add A Php Snippet Into My DLE Index !
    By JoomlaZ in forum Web Development Area
    Replies: 0
    Last Post: 7th Jul 2011, 01:18 PM
  2. [C#] Tiny Web Server (snippet)
    By Hyperz in forum Web Development Area
    Replies: 6
    Last Post: 24th Jun 2010, 01:19 PM
  3. Image Upload in php. Code snippet #2
    By SplitIce in forum Tutorials and Guides
    Replies: 5
    Last Post: 31st Oct 2009, 07:40 AM
  4. See real OOP (Snippet from Litewarez V2) Webmasters CP
    By litewarez in forum Tutorials and Guides
    Replies: 21
    Last Post: 19th Sep 2009, 03:59 PM
  5. A Snippet from my latest project
    By litewarez in forum Tutorials and Guides
    Replies: 19
    Last Post: 21st Jun 2009, 05:17 PM

Tags for this Thread

BE SOCIAL