Posts

Showing posts from March, 2013

create filter in controller symfony2

Sometimes you need to make changes to the Response object, after it is returned by your controller, but before it is rendered as output to the client (e.g. the browser). You may want to set some extra response headers, or " completely mess up the content " of the response. You can accomplish this by creating an event listener that listens to the kernel.response event. I give you a sample event listener which changes the Content-Type header in case the requested format is json and the browser’s accepted response format contains "text/html" in that case, at least in my experience, the browser doesn’t render the JSON string as plain text when the status code is 4xx or 5xx. So in these situations, the event listener changes the “ Content-Type ” to “ text/plain ”, to be sure you always get decent output in the browser. Put the event listener in, for example /src/Acme/DemoBundle/EventListener/ResponseListener.php : namespace Acme\DemoBundle\EventListener;...

remove non ASCII characters from a String

Hi guys I had a problem with removing non-utf8 characters from string, which are not displaying properly. Characters are like this 0x97 0x61 0x6C 0x6F (hex representation). I am getting some encoded value from url. Let assume it's encoded email and value is ankitchauhan22@gmail.com When I tried to find out the length of this string as $email = somefunction($encodedStringFromUrl); $length = strlen($email); print $length; I was shocked. It's printing 37 instead of 24. Than I printed each index of this string on the string but after 24 character, nothing printed. I used trim() to remove whitespace but didn't work. Then I tried something which worked for me. This is a little snippet that will remove any non-ASCII characters from a string. $string = "ankitchauhan22@gmail.com äó"; $string = preg_replace('/[^(\x20-\x7F)]*/','', $string); Now It's printing 24.

jQuery & JavaScript PDF Viewer plugin

Image
Hi guys In this Post I'm providing best jQuery PDF viewer plugin & tutorial with examples. Due to popularity of online document viewer like Google Docs some javascript developers develop a good and useful plugins to view pdf file on online pdf viewer.Here is some good list of online pdf viewers. JavaScript PDF Reader : pdf.js It's an HTML5 experiment that explores building a faithful and efficient PDF renderer without native code assistance. Read More Demo jQuery Media Plugin The jQuery Media Plugin supports unobtrusive conversion of standard markup into rich media content. It can be used to embed virtually any media type, including Flash, Quicktime, Windows Media Player, Real Player, MP3, Silverlight, PDF and more, into a web page and is compatible with all web hosting services The plugin converts an element which holds the object, embed iframe tags neccessary to render the media content. Demo PDFObject : Embeds PDF files into HTML documents A JavaScript ...

css3 tips and tricks collection

You can never have too much of a good thing–and two good things we rely on in our work are tips and tricks. Nuggets of information, presented clearly and succinctly, help us build solutions and learn best practices. CSS level 3 has been under development since December 15, 2005. CSS3 is modularized and consists of several separate recommendations. CSS3 is one of the more exciting and versatile developments for the web in some time. In this article I am going to create a huge list of CSS3 Tips, Tricks and Tutorials for Web Developers. Useful Link : Be updated with these Featured Table Design With CSS3 Basic CSS3 Techniques That You Should Know CSS3 Animated Bubble Buttons How To Create CSS3 Christmas Tree Ornaments Quick Tip : New HTML5 Form Features The State Of CSS3 In Email Templates CSS3 Transition Tutorial – Menü mit Slide-Effekt im Apple-Style Semantic CSS3 Lightboxes Creating A Realistic Looking Button With CSS3 CSS3 Gradient Buttons Pure CSS3 Speech Bubbles Sha...

speed up symfony2 application with varnish

Hi everyone, Just a quick note about Varnish integration for symfony. I’m sure you have heard of Varnish reverse proxy server. Varnish is a web accelerator written with performance and flexibility in mind. It’s modern architecture gives it a significantly better performance than many of it’s competing products. Varnish store web pages in memory so the web servers don’t have to create the same web page over and over again. The web server only recreate a page when it is changed. Additionally Varnish can serve web pages much faster then any application server is capable of – giving the website a significant speed up. So in first order you may be interested to integrate Varnish to handle pages which don’t require authentication (for myself I’m still not sure if there is any advantage for integrating pages for logged in users): sub vcl_recv { set req.http.Surrogate-Capability = "abc=ESI/1.0"; } sub vcl_fetch { if (beresp.http.Surrogate-Control ~ "ESI/1.0...

Creating a PrestaShop module

Image
A PrestaShop module consists of: A root folder, named after the module, which will hold all of the module's files, and will reside in PrestaShop's /modules folder. A main PHP file, named after the module, located in that root folder. This PHP file should have the same name as its root folder. An icon file, named logo.gif, representing this module. Optional: some .tpl files, containing the module's theme. Optional: language files, if the module or its theme have text to display (and therefore, that should be translatable). Optional: in a /themes/modules folder, a folder with the same name as the module, containing .tpl and language files if necessary. This last folder is essential during modifications of existing module, so that you can adapt it without having to touch its original files. Notably, it enables you to handle the module's display in various ways, according to the current theme. Now I am going to create a module named Testmodule. Your module can b...

Styling Progress Bar With HTML5

Image
0% Reload HTML5 introduced the progress bar element, which allows us to show the progress of certain tasks, like uploads or downloads, basically anything that is in progress Basic Usage The progress bar can be added with <progress> ; the progress value is determined with the value, min and max attributes, as follows. <progress value="40" max="100"></progress> Since this is a native progress bar, the presentation is vary dependent on the platform. Below is how a native progress bar looks in Windows and OSX. Now, let's try styling this progress bar, so it has a consistent or similar look across all platform. Styling Progress Bar In the stylesheet, we actually can use the element selector to target and add style rules to <progress> element. In this example, we change the background color, remove the border line, and make it rounded by adding a border radius at half of its height. progr...