Welcome To Snipplr
Everyone's Recent Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
This function will truncate strings only at word breaks which can be used to show a teaser for complete article without breaking words.
0
1974
posted 17 years ago by paulgrenwood
Creating thumbnails of the images is required many a times, this code will be useful to know about the logic of thumbnail generation.
0
2095
posted 17 years ago by paulgrenwood
Some times you need to accept some url as input but users seldom add http:// to it, this code will add http:// to the URL if it’s not there.
1
2268
posted 17 years ago by paulgrenwood
With most of the popular web services like Twitter providing their data through APIs, it is always helpful to know how to parse API data which is sent in various formats including JSON, XML etc.
1
1723
posted 17 years ago by paulgrenwood
This snippet uses isset() instead strlen() to verify a PHP variable (in this example $username) is set and is at least six characters long.
0
1595
posted 17 years ago by paulgrenwood
This code will create a human readable string that will look more close to dictionary words, useful for captchas.
0
6058
posted 17 years ago by paulgrenwood
This function will fetch the real IP address of the user even if he is behind a proxy server.
0
1880
posted 17 years ago by paulgrenwood
If you don’t need human readable string, then use this function instead, which will create a random string you can use for user id’s etc.
1
1902
posted 17 years ago by paulgrenwood
With this snippet, you can encode any email address into HTML entities so that spam bots do not find it.
0
1788
posted 17 years ago by paulgrenwood
This function converts URLs and e-mail addresses within a string into clickable hyperlinks.
0
1938
posted 17 years ago by paulgrenwood
IE adds a vertical scrollbar to textarea input fields regardless of the height of content in it. You can fix that with this simple CSS trick.
2
2288
posted 17 years ago by paulgrenwood
Some browsers like Firefox and IE add a dotted outline border over the link user clicked. It is a useful accessibility feature that lets user know which link he clicked or is in focus. But sometimes you need to get rid of this, here’s the CSS you n...
0
1703
posted 17 years ago by paulgrenwood
While most of the internet users prefer to read content online but some of your users might like to print your article. With CSS you can control the page breaks within content just add this CSS class to your stylesheet and add this class to any tag w...
1
1795
posted 17 years ago by paulgrenwood
This is a very tall order, and we are going to be pulling out all kinds of different stuff to make it happen. First of all, because the image needs to scale, a traditional CSS background-image is already disqualified. That leaves us with an inline im...
3
2083
posted 17 years ago by paulgrenwood
This CSS trick lets you highlight the input field currently in focus. This trick does not work in IE though.
0
1595
posted 17 years ago by paulgrenwood
This piece of CSS code will highlight links that open in a new window so that user knows before hand that link will pop open in a new tab or window.
0
2232
posted 17 years ago by paulgrenwood
I needed today to format the content differently according to the screen resolution of the user. So I thought that just by detecting the screen width using the screen.width property, I could change the stylesheet using jQuery. And so it was. Check th...
0
1755
posted 17 years ago by paulgrenwood
Though CSS3 standard includes the opacity property, but not every browser supports it, here’s the CSS trick for cross browser transparency.
2
1799
posted 17 years ago by paulgrenwood
Internet Explorer does not understand the min-height property but here’s the CSS trick to accomplish that in IE.
2
1748
posted 17 years ago by paulgrenwood
CSS Attribute selectors are very powerful giving you many options to control styles of different elements e.g. you can add an icon based on the href attribute of the a tag to let the user know whether link points to an image, pdf, doc file etc.
0
1316
posted 17 years ago by paulgrenwood
In Snow Leopard, bash treats colors differently. All the color codes that are escaped with \e won't be recognized. The new escape sequence is \033.
The list below works perfectly in Snow Leopard
0
1839
posted 17 years ago by AzizLight
One drawback: Removal of button leaves a small indent in first line of paragraph, probably an element:style DIV. Don't yet know how to get rid of that.
1
1539
posted 17 years ago by thesislab