Jump to content

Koobi

Staff Alumni
  • Posts

    419
  • Joined

  • Last visited

    Never

Everything posted by Koobi

  1. welcome to phpfreaks. i have to warn you though, the new guy has to buy everyone a round of drinks the first week :) is friday good?
  2. great :D now that everyone's back to normal, back to the topic. i decided to throw in a solution of my own: [code=php:0] <?php     $words_band=array("red","green","blue","pink","purple");     $word="my pink dog keeps barking";     function filter($data, $banned)     {         $banned = (array) $banned;         foreach($banned as $eachBanned)         {             if(strpos($data, $eachBanned) === FALSE)             {                 return FALSE;             }         }         return TRUE;     }     if(filter($word, $words_band) === FALSE)     {         echo "sorry word not allowed";     }     else     {         echo"words are ok";     } ?> [/code]
  3. [quote author=hostfreak link=topic=102325.msg406439#msg406439 date=1154352089] Sorry, but seems your slacking... lets up our game a bit and get to these problems sooner, can we? I mean, good thing this thread kept getting replies and you finally came to moderate it otherwise I would of been under the impression that using "vulgar" language was ok, or un-moderated. [/quote] i would have thought that knowing the appropriate place and time to use vulgar language would be common sense :) SA is not slacking. In case you haven't noticed, a whole lot of threads are created everyday. Concerned users generally report a post that they believe seems inappropriate. Feel free to do so yourself in the future :) now let's just get on with this thread.
  4. [quote author=Barand link=topic=102083.msg406127#msg406127 date=1154287205] Really shaving off the microseconds there, Koobi [/quote] hehe yeah :) i think it really depends on the situation though. like for example, in this process i'm creating, i would have to loop through something almost 3 million times and 3 million micro seconds can add up but that's an extreme case. don't think you'd really have to do the things i mentioned in my post, w4seem, just thought i'd cover all bases. you should be fine following the rest of the posts before mine :)
  5. most of the things mentioned in this thread are the main things you want to consider for optimization. but there are other tiny things that can add up and eat up a lot of time. if you follow general good coding practice, you should be ok. but there are also other things...things like, using double quotes and single quotes appropriately. not using regular expresions when you can use string functions. running PHP as an Apache module or as a CGI.
  6. Koobi

    Music

    hehe you've got some nice artistes there, SA. i like a whole bunch of stuff...here's a trimmed output of my music folder: [list] [+]Aerosmith [+]Air Supply [+]Akinyele [+]al green [+]Annie Lennox [+]Aswad [+]A Tribe Called Quest [+]Barry White [+]Big L [+]Billie Holiday [+]Björk [+]Blackalicious [+]Black Eyed Peas [+]Black Star [+]Bob Marley & The Wailers [+]Bonnie Tyler [+]Brand Nubian [+]Camp Lo [+]Canibus [+]Chaka Demus & Pliers [+]Chicago [+]C.J. Lewis [+]Clannad [+]Common [+]Counting Crows [+]Cuban Link [+]CunninLynguists [+]Daddy Freddy [+]Dean Martin [+]De La Soul [+]Digable Planets [+]Dilated Peoples [+]Eazy-E [+]Elvis Costello [+]Enya [+]Erick Sermon [+]Erykah Badu [+]Filter [+]Foreign Exchange [+]Frank Sinatra [+]Funkdoobiest [+]FU-Schnickens [+]Geto Boys [+]India.Arie [+]Jay-Z [+]Jedi Mind Tricks [+]Jefferson Starship [+]Jon B [+]Jurassic 5 [+]Kaliphz [+]Kanye West [+]KRS-One [+]Lamb [+]Leo Sayer [+]LL Cool J [+]Lords of the Underground [+]Louis Armstrong [+]Lucy Pearl [+]Marvin Gaye [+]Mary J. Blige [+]MC Lyte [+]Metabolics [+]Missy Elliott [+]Mos Def [+]Musical Youth [+]Nas [+]New Edition [+]Norah Jones [+]Notorious B.I.G [+]Peter Gabriel [+]Pete Rock [+]Phife Dawg [+]Plumb [+]Poor Righteous Teachers [+]Ras Kass [+]Ray Charles (only some tracks) [+]REO Speedwagon [+]Rick Price [+]Sadat X [+]Sade [+]Scarface [+]Shyheim [+]Slick Rick [+]Spooks [+]Starship [+]Super Cat [+]Talib Kweli [+]Tha Alkaholiks [+]The Roots [+]The Wonders [+]DJ Tony Touch [+]Trigger The Gambler [+]u2 [+]ub40 [+]Urban Thermo Dynamics [+]Vertical Horizon [+]the entire Wu-Tang Clan crew [+]Zapp & Roger [/list]
  7. well i messed about with the basics of perl a bit. didn't really get much done because there are other aspects of the project that need to be completed as well. i was wondering, since i'm in a hurry and this needs to be done properly and securely, do you think i'd be able to outsource this module to you? i could give you the pseudo code as well as the PHP code. if you are interested, let me know, effigy. my contact details can be found in the [b]Staff Contact Info.[/b] sticky thread in the Admin Cafe.
  8. but if you're totally new to Linux, i'd recommend Ubuntu. but once you get familiar with Ubuntu, Gentoo is probably the best move you could make unless you become a BSD freak hehe but yeah linux generally has package managers (some basic lite distros like slackware, don't). a package manager does the installing and configuration (and some package managers even handle dependency problems) all for you. there are software repositories that the package manager would go grab the software you want from and install it. so instead of hunting for what you need, you can search for the software via your package manager (if that particular linux distro offers that feature) and then install it. all within two lines. for example, on Ubuntu, if you wanted to search for an mp3 player software, you could type this in a terminal: [code] apt-cache search mp3 [/code] of course now you'll also get a list of libraries with the name "mp3" in them as well as software with the words "mp3". but suppose you do find the mp3 player you want to install and it's name was "xmms" ;), you would type this in a terminal: [code] sudo apt-get install xmms [/code] and it will install the program and configure it for you. that's it. easier than windows :) apt-* are commands that interact with Ubuntu's package manager. Gentoo's package manager is more advanced that Ubuntu's but i think Gentoo might be a little overwhelming, in general, to the average windows user. if anything we said doesn't make sense, please do ask. i'm sure most of us (if not, myself) here would be more than glad to see you use a linux box :) Distros == Distributions
  9. [quote author=bobleny link=topic=101871.msg404790#msg404790 date=1154036366] Do you know if Linux can support basic MS programs such as, MS Office 2005? [/quote] Linux has an emulator named Wine that will let you run Photoshop. But the PC has to be powerful to deal with the emulator. I use OpenOffice. It's almost exactly like MS Office. In fact, I exchange documents with clients who use MS Office while i'm on OpenOffice and I don't seem to have many issues apart from the occasional minor formatting difference. see: [url=http://en.wikipedia.org/wiki/Wine_%28software%29]Wine[/url]
  10. i want to be a hobo. they seem to lead much simpler lives
  11. i don't see a real use for karma but it doesn't bother me that it was there either. but then again if something isn't really necessary for the forum to function well and that something can cause problems, then i don't really see the point in keeping it. i'd say it was a good decision to remove it.
  12. yeah i don't think there's any point going beyond 72dpi because most monitors display at 72dpi (and very few display at 96dpi, right?) you would use 150/300dpi if you were to print banners...but you would have to ask your printer what resolution they want. also find out what colourspace they want...there are many colourspaces, on the web, it's usually RGB (Red Green Blue) but for print, depending on the printer, you can use either RGB or CMYK (Cyan Magenta Yellow blacK/Key) i haven't touched Photoshop in almost 2 years...but when i did use Photoshop, i used to work on a lot of manips. for manips, first make sure you have a very high resolution image, use the clone tool, texture tool and layer blending modes appropriately. you will also find the layer masks and the quick masks very useful. the Filter > Extract Tool is useful too (i assume it's still in the Filter menu). if you want to extract an image with the Extract Tool, duplicate the layer in question, use curves (ctrl+M i believe) to create an S shaped curve to increase contrast, then extract from that layer and once you've commited the extraction, ctrl+click on that layer to create a selection of the unextracted pixels and make a copy off the original layer. image manipulation takes a lot of practice. but for things like layouts, buttons, logos and banners, you should be able to pick it up quite fast. also, keep in mind that it's better to use vectors where possible for print because print demands better quality and vectors are very sharp so it's useful for logos. and don't believe anyone that tells you Photoshop does vectors, it does't. it's all raster images even though it seems like a vector. I recommend something like Illustrator or CorelDraw or even Inkscape for vector graphics.
  13. maybe the problem lies in us expecting something in return instead of genuinely wanting to give to or help someone? :)
  14. ok great. i understand it so far. i have another questions with regards to argv. suppose i want to pass 3 csv files, they would be in argv[1], argv[2] and argv[3] right, assuming i used it like i have posted below? [code] $ perlExecutable -file=1.csv 2.csv 3.csv myScript.pl [/code] do you know of any issues Apache has with perl? I'd have to use mod_perl, right?
  15. thanks for taking the time to explain :) are warnings in Perl similar to the ones in PHP? i.e., do they have similar error levels? so i could pass the csv file name to perl via terminal as an option and argv would grab it? or would i have to use ">" or "|" to direct the csv contents via cat? also, how is Perl with db connectivity? Postgres specifically.
  16. [quote author=effigy link=topic=101767.msg403385#msg403385 date=1153856324] Here's a basic example to start with. Simply run it with the csv file as the argument, e.g. [tt]./csv.pl in.csv[/tt]. [code] #!/usr/local2/bin/perl use warnings; use strict; while (<>) { chomp; my @fields = split ',' => $_; } [/code] If the commas are surrounded by whitespace, replace ',' with /\s*,\s*/. [/quote] thanks for that. so on the first line you have the shebang line, followed by the inclusion of libraries? and what's the condition in that while loop? and what is chomp? i dont understand the next line either. what does $_ do? can you direct me to the official perl manual? is this it: http://www.cs.cmu.edu/cgi-bin/perl-man ? wouldn't mind some beginner toutorials too, if you have any handy links
  17. [quote author=effigy link=topic=101767.msg403374#msg403374 date=1153855496] I know Perl has a reputation for being the champ at text processing. I asked some of the guys on www.perlmonks.net how they would accomplish this. One recommendation was to use [url=http://search.cpan.org/~jzucker/DBD-CSV-0.22/lib/DBD/CSV.pm]DBD::CSV[/url], while another mentioned that going line-by-line shouldn't be an issue due to input buffering by either readline or the OS itself; I know nothing about either. I think the shell would be nasty for this, but this could depend on the content and how much processing is needed. awk seems like a viable option; I know very little myself. Is the data using quotes as delimiters also, or just commas? You can always use Unix's [b]time[/b] command to see who gets the job done quicker. [/quote] thanks for asking at perlmonks.net :) i will have a look at that option if i go for that idea, thanks. it's a comma delimited CSV. yeah, actually i should have used time to do my research instead of posting here but unfortunately, time is a big problem. we are almost at the deadline and there's still some work to be done and i didn't want to have to try a bunch of options so i thought i would ask here first. thanks so far guys.
  18. [quote author=effigy link=topic=101767.msg403174#msg403174 date=1153836381] Do you have the option to use Perl? [/quote] Not at the moment...but it's running on a dedicated server which i have full access to so i could install what i want i suppose.I don't think it would be a problem...any ideas, effigy? unfortunately, i don't know Perl but i'm willing to learn what i need to (for now) to get this running efficiently. I'm also considering using the shell because I'm guaranteed that this application will only be run on a Linux/UNIX, Apache, Postgres, PHP environment. i could bypass PHP entirely and use awk and parse the CSV and write them to a text file as SQL inserts and use CLI for Postgres to refer to the text file for the queries. from thereon, i could access a few hundred records at a time from the database and process them. that would be more efficient, i imagine, since it's the OS's shell that will be handling everything. i just thought about this...sounds like a good idea right? except that i know very little awk but it's syntax seems relatively simple but i have no idea how to work Postgres via CLI.
  19. the problem with method A is that it immediately takes up memory like effigy mentioned. i would have to change PHP's default memory allocation. Currenty it's 8 and 2MB. would 20 and 12MB be sufficient? the problem with method B is that i will be accessing the disk over 3 million times. thats a lot :/
  20. This isn't really PHP specific so i thought i'd post here. I'm reading a CSV file into my script (and this CSV may well contain upto 3 million records with upto 53 fields per record) and I do a number of things to the data like mathematical calculations and insertions into a database. The database i'm using is Postgres. I'm wondering if it would be better for me to: A. read the entire CSV into an array (via fgetcsv) and INSERT it into a temporary table in the database and then select based on a LIMIT clause and process around 500 records at a time B. read each CSV record, line by line (via fgets or fscanf) and process each line as i come accross it. there are other options such as running a system command. what i'm looking for is the fastest method for process these records. thanks for your time.
  21. plus assembly is really low level and nowadays, most languages are high level. you wouldn't gain much by learning assembly unless your applications had to interact at a low level. also, i don't really think you can call PHP a programming language as yet. it's more like a scripting language but on the server side.
  22. [quote author=ryanlwh link=topic=101405.msg401436#msg401436 date=1153520271] by using LINK, main.php is treated as a separated script and would not see the variable scope of the current page as Koobi mentioned. you could use Koobi's methed, or include define.php within main.php [/quote] i don't know why i didn't think to include define.php in main.php i think that would be a better solution than passing the values via the URL.
  23. well the thing is, your HTML would access the CSS via HTTP as far as i know and PHP would have parsed the main.php file via Apache by then. What you could do is pass the variables to CSS via the URL: main.php [code=php:0] <?php header('Content-type: text/css'); ?> body {background: #<?php echo $_GET['bg']; ?>;} [/code] HTML file [code=php:0] <link href="main.php?bg=0f0" rel="stylesheet" type="text/css" /> [/code]
  24. I'm a systems analyst/project manager for a web dev company and we work for one dedicated client that serves a computer reseller in the US. i don't enjoy it so much since i mostly just analyze systems and manage it. i'd rather code but i figure i should learn as many aspects of the industry as i can so here i am :) i still freelance program at home one weeks when i have time. time is a bi*ch :/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.