Results 21 to 30 of 42
-
30th Jun 2012, 06:26 PM #21(1only)Website's:
BarakaDesigns.com Amodity.com IMGFlare.com
-
30th Jun 2012, 07:40 PM #22Member
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);
-
1st Jul 2012, 04:51 AM #23You 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)])
My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz
-
1st Jul 2012, 06:09 PM #24(╯?□?)╯︵ ┻━┻Website's:
Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.comYEAAAAAAAAAAH 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', '')
Projects:
WCDDL - The Professional DDL Script
Top Secret Project: In Development - ZOMG
ImgTrack - Never Have Dead Images Again!
-
1st Jul 2012, 06:41 PM #25OPRespected DeveloperWebsite's:
X4B.orgThat 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
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); }
-
1st Jul 2012, 07:02 PM #26(╯?□?)╯︵ ┻━┻Website's:
Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.comlol, 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!
-
2nd Jul 2012, 02:52 AM #27Member
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")
My previous username was kaed
-
2nd Jul 2012, 08:40 AM #28(1only)Website's:
BarakaDesigns.com Amodity.com IMGFlare.comPHP 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];
}
say i wanted to get post or threads of the database i'll do
PHP Code:$forum_posts = rowcountGetter('posts');
PHP Code:$something = rowcountGetter('snippet', ' WHERE (`KWWH` & '.sql::search('post').')');
-
2nd Jul 2012, 01:10 PM #29(╯?□?)╯︵ ┻━┻Website's:
Xenu.ws WarezLinkers.com SerialSurf.com CracksDirect.comSeems 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!
-
6th Jul 2012, 07:53 AM #30Respected MemberWebsite's:
DL4Everything.com Soft2050.inWrote 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();
}
Sample Usage:
PHP Code:WebClient wc = new WebClient();
string[] proxyList = grabProxy(wc.DownloadString("http://hidemyass.com/proxy-list/"));
Array.ForEach(proxyList, s => Console.WriteLine(s));
Console.ReadKey();
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Plz Help To Add A Php Snippet Into My DLE Index !
By JoomlaZ in forum Web Development AreaReplies: 0Last Post: 7th Jul 2011, 01:18 PM -
[C#] Tiny Web Server (snippet)
By Hyperz in forum Web Development AreaReplies: 6Last Post: 24th Jun 2010, 01:19 PM -
Image Upload in php. Code snippet #2
By SplitIce in forum Tutorials and GuidesReplies: 5Last Post: 31st Oct 2009, 07:40 AM -
See real OOP (Snippet from Litewarez V2) Webmasters CP
By litewarez in forum Tutorials and GuidesReplies: 21Last Post: 19th Sep 2009, 03:59 PM -
A Snippet from my latest project
By litewarez in forum Tutorials and GuidesReplies: 19Last Post: 21st Jun 2009, 05:17 PM
themaCreator - create posts from...
Version 3.52 released. Open older version (or...