{ Snipperize }
Snipperize snippets
Rsync Algorithm In Python
An implementation of the rsync algorithm in Python. As my rolling checksum, I just summed all of the ascii byte values in a given window. Even with this simple weak rolling checksum, computing and comparing the produced rolling checksums is still terribly slow. I'm fairly certain the speed could be reduced a fair amount but I haven't decided what the most efficient manner of doing this in Python alone would be.
Python / algorithm, delta, diff, rsync / by ThePeppersStudio (2 days, 1.54 hours ago)
Efficient Algorithm for computing a Running Median
Maintains sorted data as new elements are added and old one removed as a sliding window advances over a stream of data. Running time per median calculation is proportional to the square-root of the window size.
Python / algorithm, indexable, median, running, skiplist, statistics / by ThePeppersStudio (2 days, 1.65 hours ago)
NSDateFormater
How to use NSDateFormater
Objective-C / NSDateFormater, NSDate / by ThePeppersStudio (10 days, 5.13 hours ago)
Autodetect NSString Encoding from NSData
Use UniversalDetector to detect NSString encoding.
Objective-C / NSString, encoding, universaldetector / by ThePeppersStudio (12 days, 4.77 hours ago)
Rounded Corner UIImage
Just call the static method makeRoundCornerImage and pass your image to have the image rounded off the way you want. Note that you do need the CoreGraphics framework for this to compile.
Objective-C / UIImage, round, corner / by ThePeppersStudio (15 days, 10.30 hours ago)
Rounded Corner UIImageView
you'll have to import <QuartzCore/QuartzCore.h>
Objective-C / UIImageView, round, corner / by ThePeppersStudio (15 days, 10.38 hours ago)
Code Snippets To Implement 301 Redirect
Sometimes, if you use a CMS like WordPress or Movable Type, you could need to change the URL structure in use on your blog with a more SEO friendly structure. This is a big problem especially if your site is already indexed and some posts are popular on search engines: if you change the URL structure, all your posts will be unavailable at the old URLs and, in this way, you risk to lose visitors and ranking. A safe way to change the URL structure of your blog, without losing visitors and ranking, is to apply a permanent redirect to your pages (301 redirect). This redirect says to the search engine bot “the current page has permanently moved to a new URL” so that the bot can follow the new link and properly index it. In this post I’m going to illustrate how to apply a permanent redirect to your pages using some techniques and scripting languages. Redirect 301 with htaccess In my opinion htaccess is the best and quickly way to redirect your pages. Only an advice: you need to have a base knowledge of htaccess for use it or you risk to have some serious problems on your site! So, before start using htaccess, I suggest you some good reading: Complete guide to htaccess for Beginners and Htaccess tutorials on apache.org. Here is an example of htaccess usage: Redirect permanent http://mysite.com http://www.mysite.com Now supposed you have the following two URLs: http://www.mysite.com and http://mysite.com. For Google, for example, these URLs are two different pages and their page rank will be divided among two pages. So, why not using htaccess to redirect all traffic to only one page? The only thing you have to do is to create a new file called .htaccess with the following code: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^mysite\.com [NC] RewriteRule ^(.*)$ http://mysite.com/$1 [L,R=301] </IfModule> …and put this file in the root directory (for mac users: remember that files that start with “.” are hidden, so you need to modify visualization options on your Mac or FTP clients to see them). In this way you are creating a redirect from all HTTP requests from the URL http//mysite.com to http://www.mysite.com. As I said before, htacces is the best SEO technique to redirect pages but it’s not the only one. You can also use a scripting server language to implement a permanent redirect. Here is a small list with short code snippets to implement quickly a permanent redirect using PHP, ASP, ASP.net and Coldfusion.
Plain / redirect, 301 / by ThePeppersStudio (16 days, 3.99 hours ago)
How to read ID3 tag of mp3 files with PHP
Inside mp3 files there are often some usefull informations stored. Those data are called “id3 tags” and deal with Author name, Title and Album name. There are also some other informations sometimes: such as the length of the track, or the track number of the album, and more, this code will help read those files!
PHP / mp3, id3, meta / by ThePeppersStudio (17 days, 4.03 hours ago)
Redirect Domain Including Subdomains and Arguments
I used this as an include on every page to redirect every page incl arguments from .com to .de
PHP / redirect, subdomain, domain / by ThePeppersStudio (20 days, 0.18 hours ago)
Javascript OOP Form Validator
Just thought id put up a version of my form validation class. It will be expanded in the future but I thought Id let everyone have a look.
Javascript / form, oop, validator / by ThePeppersStudio (20 days, 0.28 hours ago)
- Home
- New Snippet
- Languages
-

