Search Results

Search found 28 results on 2 pages for 'zaf'.

Page 1/2 | 1 2  | Next Page >

  • User controlled html title tags

    - by zaf
    What are the best practices for allowing a user to maintain the html title tags of all the major pages of his/her site? One way could be to allow the mapping of URLs to some text. For example, we have an app with the following (most complex) url format: http://lang.example.com/searchpage.zaf?a=foo&b=bar&c=RANDOM There are several parts to this: Language sub domain Search page Static parameter 'a' (user may want this in the title) Dynamic and relevant parameter 'b' (user may want this in the title) Dynamic parameter 'c' which can be ignored Never done this before, so I'm asking how you would tackle this!

    Read the article

  • Email setup on dedicated servers

    - by zaf
    Am thinking seriously of renting a dedicated server. Now I know how to setup apache and the underlying scripting engines and databases but I'm a bit clueless with how the emails would work. Currently, I'm on a shared hosting account and I get a fancy gui which allows me to nicely add a domain, setup nameservers and then the emails for all domain names with either simple forwarding or the full account which also has a webmail app behind it. What options do I have? Are there non complicated ways to have the same email setup experience? Or are there reliable external providers I could use? My past experiences with sendmail/postfix have always been fuzzy - not exactly knowing whats happening behind the scenes.

    Read the article

  • Javascript execution order

    - by zaf
    I want to give a static javascript block of code to a html template designer, which can be: either inline or external or both used once or more in the html template and each block can determine its position in the template relative to the other javascript code blocks. An example could be image banners served using javascript. I give code to template designer who places it in two places, once for a horizontal banner in the header and once for a vertical banner. The same code runs in both blocks but knowing their positions can determine if to serve a horizontal or a vertical image banner. Make sense?

    Read the article

  • Textarea to paragraphs

    - by zaf
    When I have to render textarea content to the front end I usually pass it thru a function that converts newlines to <br/> tags and double newlines signal paragraph tags so blocks of text get surrounded by <p> and </p> tags. To save time I usually use a ready made PHP function from the wordpress codebase. You can get the link from the man himself: http://ma.tt/scripts/autop/ If you check it out you'll see it does some heavy lifting with about 20 regular expressions. I know I could use a wysiwyg editor (like TinyMCE or CKEditor) that can format the data on the client and then send it to the server (most of them add <p>..</p> tags by default) but I want to know the experience of others in handling raw textarea input and then displaying it on the front end.

    Read the article

  • smallest filesize for transparent gif

    - by zaf
    I'm looking for the smallest (in terms of filesize) transparent 1 pixel image. Currently I have a gif of 49 bytes which seems to be the most popular. But I remember many years ago having one which was less than 40 bytes. Could have been 32 bytes. Can anyone do better? Graphics format is no concern as long as modern web browsers can display it and respect the transparency.

    Read the article

  • pathinfo vs fnmatch

    - by zaf
    There was a small debate regarding the speed of fnmatch over pathinfo here : http://stackoverflow.com/questions/2692536/how-to-check-if-file-is-php I wasn't totally convinced so decided to benchmark the two functions. Using dynamic and static paths showed that pathinfo was faster. Is my benchmarking logic and conclusion valid? I include a sample of the results which are in seconds for 100,000 iterations on my machine : dynamic path pathinfo 3.79311800003 fnmatch 5.10071492195 x1.34 static path pathinfo 1.03921294212 fnmatch 2.37709188461 x2.29 Code: <pre> <?php $iterations=100000; // Benchmark with dynamic file path print("dynamic path\n"); $i=$iterations; $t1=microtime(true); while($i-->0){ $f='/'.uniqid().'/'.uniqid().'/'.uniqid().'/'.uniqid().'.php'; if(pathinfo($f,PATHINFO_EXTENSION)=='php') $d=uniqid(); } $t2=microtime(true) - $t1; print("pathinfo $t2\n"); $i=$iterations; $t1=microtime(true); while($i-->0){ $f='/'.uniqid().'/'.uniqid().'/'.uniqid().'/'.uniqid().'.php'; if(fnmatch('*.php',$f)) $d=uniqid(); } $t3 = microtime(true) - $t1; print("fnmatch $t3\n"); print('x'.round($t3/$t2,2)."\n\n"); // Benchmark with static file path print("static path\n"); $f='/'.uniqid().'/'.uniqid().'/'.uniqid().'/'.uniqid().'.php'; $i=$iterations; $t1=microtime(true); while($i-->0) if(pathinfo($f,PATHINFO_EXTENSION)=='php') $d=uniqid(); $t2=microtime(true) - $t1; print("pathinfo $t2\n"); $i=$iterations; $t1=microtime(true); while($i-->0) if(fnmatch('*.php',$f)) $d=uniqid(); $t3=microtime(true) - $t1; print("fnmatch $t3\n"); print('x'.round($t3/$t2,2)."\n\n"); ?> </pre>

    Read the article

  • Validation of user input or ?????????

    - by zaf
    We're letting users search a database from a single text input and I'm having difficulties in filtering some user supplied strings. For example, if the user submits: ????????? lcd SONY (Note the ?'s) I need to cancel the search. I include the base64 encoded version of the above string wrapped up so that its easy run: print(base64_decode("1MfLxc/RwdPHIGxjZCBTT05Z")); I've ignored such inputs before but now (am not sure why) just realised the mysql database query is taking nearly forever to execute so this is now on high priority. Another example to highlight that we are using utf-8 and mb_detect_encoding is not helping much: print(base64_decode("zqDOm8+Fzr3PhM63z4HOuc6/IM+Bzr/Phc+HzyU=")); ????t???? ?????% So: how can I detect/filter these inputs? how is this input being generated?

    Read the article

  • Auto detect internal/external development environment

    - by zaf
    We use the following function to auto detect if we are on a machine internally or on a live server and then choose the appropriate configs for various components. function devIsLocal(){ $res=false; $http_host=$_SERVER['HTTP_HOST']; if($http_host=='localhost')$res=true; if($http_host=='127.0.0.1')$res=true; if(substr($http_host,-4)=='.lan')$res=true; if(strpos($http_host, '.')===false)$res=true; return($res); } As you can see it only relies on the HTTP_HOST value. Of course, if you have use virtual host locally like example.com then the function will be tricked. Are there any other ways to fool the function? and what other variables/places could we peek at to determine where we are?

    Read the article

  • Tarballing without git metadata

    - by zaf
    My source tree contains several directories which are using git source control and I need to tarball the whole tree excluding any references to the git metadata or custom log files. I thought I'd have a go using a combo of find/egrep/xargs/tar but somehow the tar file contains the .git directories and the *.log files. This is what I have: find -type f . | egrep -v '\.git|\.log' | xargs tar rvf ~/app.tar Can someone explain my misunderstanding here? Why is tar processing the files that find and egrep are filtering? I'm open to other techniques as well.

    Read the article

  • SQL Select * from multiple tables

    - by zaf
    Using PHP/PDO is it possible to use a wildcard for the columns when a select is done on multiple tables and the returned array keys are fully qualified to avoid column name clash? example: SELECT * from table1, table2; gives: Array keys are 'table1.id', 'table2.id', 'table1.name' etc. I tried "SELECT table1.*,table2.* ..." but the returned array keys were not fully qualified so columns with the same name clashed and were overwritten.

    Read the article

  • smallest filesize for transparent single pixel image

    - by zaf
    I'm looking for the smallest (in terms of filesize) transparent 1 pixel image. Currently I have a gif of 49 bytes which seems to be the most popular. But I remember many years ago having one which was less than 40 bytes. Could have been 32 bytes. Can anyone do better? Graphics format is no concern as long as modern web browsers can display it and respect the transparency.

    Read the article

  • 3d engine with telnet access

    - by zaf
    Does anyone know of a open source 3d engine which can be operated via telnet? What I'm looking for is scripting via a socket connection. To allow for world creation and/or camera movement. Does anybody know of any that has this built in or very, very easy to add as a plugin or script? The platform is not crucial.

    Read the article

  • Perl ||= operator for PHP and Javascript

    - by zaf
    Just been re-introduced to the Perl '||=' operator from the classic Orcish Maneuver example: keys my %or_cache = @in; @out = sort { ($or_cache{$a} ||= KEY($a)) cmp ($or_cache{$b} ||= KEY($b)) } @in; Is this operator available in PHP and Javascript? And if not, do these two languages allow user defined operators?

    Read the article

  • Zoom image to pixel level

    - by zaf
    For an art project, one of the things I'll be doing is zooming in on an image to a particular pixel. I've been rubbing my chin and would love some advice on how to proceed. Here are the input parameters: Screen: sw - screen width sh - screen height Image: iw - image width ih - image height Pixel: px - x position of pixel in image py - y position of pixel in image Zoom: zf - zoom factor (0.0 to 1.0) Background colour: bc - background colour to use when screen and image aspect ratios are different Outputs: The zoomed image (no anti-aliasing) The screen position/dimensions of the pixel we are zooming to. When zf is 0 the image must fit the screen with correct aspect ratio. When zf is 1 the selected pixel fits the screen with correct aspect ratio. One idea I had was to use something like povray and move the camera towards a big image texture or some library (e.g. pygame) to do the zooming. Anyone think of something more clever with simple pseudo code? To keep it more simple you can make the image and screen have the same aspect ratio. I can live with that. I'll update with more info as its required.

    Read the article

  • High memory usage for dummies

    - by zaf
    I've just restarted my firefox web browser again because it started stuttering and slowing down. This happens every other day due to (my understanding) of excessive memory usage. I've noticed it takes 40M when it starts and then, by the time I notice slow down, it goes to 1G and my machine has nothing more to offer unless I close other applications. I'm trying to understand the technical reasons behind why its such a difficult problem to sol ve. Mozilla have a page about high memory usage: http://support.mozilla.com/en-US/kb/High+memory+usage But I'm looking for a slightly more in depth and satisfying explanation. Not super technical but enough to give the issue more respect and please the crowd here. Some questions I'm already pondering (they could be silly so take it easy): When I close all tabs, why doesn't the memory usage go all the way down? Why is there no limits on extensions/themes/plugins memory usage? Why does the memory usage increase if it's left open for long periods of time? Why are memory leaks so difficult to find and fix? App and language agnostic answers also much appreciated.

    Read the article

  • Avoiding problem of overwriting files which are in use

    - by zaf
    For example on a high traffic web server. To reduce problems when switching a file I usually rename the old file out and then rename in the new file. I was told some time ago that renaming a file does not change the 'inode data' so that processes reading the file can keep doing so without glitches. And, of course, rather than copying in the new file it is faster and safer to rename a temp copy. Is this still best practice and if not what do you do?

    Read the article

  • id vs class selection benchmark

    - by zaf
    Has anybody bench marked selecting elements with id's and class's from CSS and javascript? It would make sense that an element with an id is faster to select than if it had a class even if it was the only element with that class. Do I really need to be concerned?

    Read the article

  • Only variables can be passed by reference

    - by zaf
    I had the bright idea of using a custom error handler which led me down a rabbit hole. Following code gives (with and without custom error handler): Fatal error: Only variables can be passed by reference function foo(){ $b=array_pop(array("a","b","c")); return $b; } print_r(foo()); Following code gives (only with a custom error handler): (2048) Only variables should be passed by reference function foo(){ $a=explode( '/' , 'a/b/c'); $c=array_pop(array_slice($a,-2,1)); return $c; } print_r(foo()); The second one worries me since I have a lot of 'compact' code. So, I either ditch the bright idea of using a custom error handler (to improve my logging module) or expand all my code. Anyone with better ideas? Also, WTF?

    Read the article

  • (Pathinfo vs fnmatch part 2) Speed benchmark reversed on Windows and Mac

    - by zaf
    On a previous question the pathinfo and fnmatch functions were benchmarked and the answers all came out opposite to my benchmark results. You can read the different results with the benchmark code here: http://stackoverflow.com/questions/2693428/pathinfo-vs-fnmatch I couldn't work it out until I ran the same code on a machine running vista. The results then matched the other users. My main machine is a mac. So, my questions are: Why do we get these two different results? Could this apply to other functions?

    Read the article

  • Load image from string

    - by zaf
    Given a string containing jpeg image data, is it possible to load this directly in pygame? I've tried using StringIO but failed and I don't completely understand the 'file-like' object concept. Currently, as a workaround, I'm saving to disk and then loading an image the standard way: # imagestring contains a jpeg f=open('test.jpg','wb') f.write(imagestring) f.close() image=pygame.image.load('test.jpg') Any suggestions on improving this so that we avoid creating a temp file?

    Read the article

  • Read file as its being uploaded

    - by zaf
    By default you cannot access a file that is uploaded until it has been fully transferred to the server. What is the best way to get round this and be able to access the 'byte stream' as the file upload is in progress?

    Read the article

1 2  | Next Page >