Search Results

Search found 6 results on 1 pages for 'buggedcom'.

Page 1/1 | 1 

  • Mysql Algorithm for Determining Closest Colour Match

    - by buggedcom
    I'm attempting to create a true mosaic application. At the moment I have one mosaic image, ie the one the mosaic is based on and about 4000 images from my iPhoto library that act as the image library. I have already done my research and analysed the mosaic image. I've converted it into 64x64 slices each of 8 pixels. I've calculated the average colour for each slice and assertain the r, g, b and brightness (Luminance (perceived option 1) = (0.299*R + 0.587*G + 0.114*B)) value. I have done the same for each of the image library photos. The mosaic slices table looks like so. slice_id, slice_image_id, slice_slice_id, slice_image_column, slice_image_row, slice_colour_hex, slice_rgb_red, slice_rgb_blue, slice_rgb_green, slice_rgb_brightness The image library table looks like so. upload_id, upload_file, upload_colour_hex, upload_rgb_red, upload_rgb_green, upload_rgb_blue, upload_rgb_brightness So basically I'm reading the image slices from the slices table into PHP and then pulling out the appropriate images from the library table based on the colour hexs. My trouble is that I've been on this too long and probably had too many energy drinks so am not concentrating properly, I can't figure out the way to pick out the nearest colour neighbor if the appropriate hex code doesn't exist. Any ideas on the perfect query? NB: I know pulling out the slices one by one is not ideal however the mosaic is only rebuilt periodically so a sudden burst in the mysql load doesn't really bother me, however if there us a way to pull the images out all at once that would also be a massive bonus.

    Read the article

  • preg_match to match an optional string, but not match all of the string

    - by buggedcom
    Take for example the following regex match. preg_match('!^publisher/([A-Za-z0-9\-\_]+)/([0-9]+)/([0-9]{4})-(january|february|march|april|may|june|july|august|september|october|november|december):([0-9]{1,2})-([0-9]{1,2})/([A-Za-z0-9\-\_]+)/([0-9]+)(/page-[0-9]+)?$!', 'publisher/news/1/2010-march:03-23/test_title/1/page-1', $matches); print_r($matches); It produces the following: Array ( [0] => publisher/news/1/2010-march:03-23/test_title/1/page-1 [1] => news [2] => 1 [3] => 2010 [4] => march [5] => 03 [6] => 23 [7] => test_title [8] => 1 [9] => /page-1 ) However as the last match is optional it can also work with matching the following "publisher/news/1/2010-march:03-23/test_title/1". My problem is that I want to be able to match (/page-[0-9]+) if it exists, but match only the page number so "publisher/news/1/2010-march:03-23/test_title/1/page-1" would match like so: Array ( [0] => publisher/news/1/2010-march:03-23/test_title/1/page-1 [1] => news [2] => 1 [3] => 2010 [4] => march [5] => 03 [6] => 23 [7] => test_title [8] => 1 [9] => 1 ) I've tried the following regex '!^publisher/([A-Za-z0-9\-\_]+)/([0-9]+)/([0-9]{4})-(january|february|march|april|may|june|july|august|september|october|november|december):([0-9]{1,2})-([0-9]{1,2})/([A-Za-z0-9\-\_]+)/([0-9]+)/?p?a?g?e?-?([0-9]+)?$!' This works, however it will also match "publisher/news/1/2010-march:03-23/test_title/1/1". I have no idea to perform a match but not have it come back in the matches? Is it possible in a single regex?

    Read the article

  • Optimizing PHP require_once's for low disk i/o?

    - by buggedcom
    Q1) I'm designing a CMS (-who isn't!) but priority is being given to caching. Literally everything is cached. DB rows, DB id queries, Configuration data, processed data, compiled templates. Currently it has two layers of caching. The first is a opcode cache or memory cache such as apc, eaccelerator, xcache or memcached. If an entry is not found in there it is then searched for in the secondary slow cache, ie php includes. Are the opcode caches actually faster than doing a require_once to a php file with a var_export'd array of data in it? My tests are inconclusive as my development box (5.3 of XAMPP) keeps throwing errors installing any of the aforementioned programs. Q2) The CMS has numerous helper classes that are autoloaded on demand instead of loading all files. Mostly each has a require before it so no autoloading needs to take place, however this is not the question. Because a page script can have up to 50/60 helper files included I have a feeling that if the site was under pressure it would buckle because of all the i/o that this incurs. Ignore for the moment that there is output cache in place that would remove the need for what I am about to suggest, and also that opcode caches would render this moot. What I have tried to do is join all the helper files required for the scripts execution in one single file. This is achievable and works well, however it has a side effect of greatly increasing the memory usage dramatically even though technically the same code is being used. What are your thoughts and opinions on this?

    Read the article

  • Website url whitelists

    - by buggedcom
    I'm building a user content parser and am adding an automatic link parser. I'm adding a dialogue, that confirms that the user wants to go to the particular site being linked to. This is for two reasons. Anti phishing and spam combating. However I want to be able to disable both the dialogue and nofollow additions with commonly used websites, so I'm building a whitelist. Are there any common whitelists about or should I start building one from scratch?

    Read the article

  • Opinions Required: Custom HTML Markup from PHP with or without tag prefix.

    - by buggedcom
    I've created a class in PHP that allows you to create custom HTML markup. It basically works a bit like FB Markup or EE tags. It works off a tag prefix, so you can add tags like this. <ctag:pagination per_page="20" total="500" page="0" base="http://localhost/page?page={page}" mode="smart" adjecents="5" /> My question is: Is the markup above better than the markup below? I'm asking as I'm considering branching my code to rework the tag matching so you can just generate custom html elements. It would well for a drop in HTML5 replacement service. Match the User Agent for a none HTML5 browser and replace the HTML5 elements with your own replacements. <pagination per_page="20" total="500" page="0" base="http://localhost/page?page={page}" mode="smart" adjecents="5" /> PS, if anybody wants to look at the class I've put a download here.

    Read the article

  • Facebook Social Plugins Like button returns "Website Inaccessible"

    - by buggedcom
    We've just added Facebook like button to http://www.willyoung.co.uk/global/songs-and-lyrics/releases/the_hits?page=1, however the json returned by facebook is for (;;);{"error":0,"errorSummary":"","errorDescription":"","errorIsWarning":false,"silentError":0,"payload":{"requires_login":false,"success":false,"already_connected":false,"is_admin":false,"show_error":true,"error_info":{"brief":"Website inaccessible","full":"The page at http:\/\/www.willyoung.co.uk\/global\/songs-and-lyrics\/releases\/the_hits could not be reached."}}} It basically says that the website is not accessible. We've implemented this on other sites and it's fine. I'm not really sure where this is coming from. Any ideas?

    Read the article

1