Snipperize snippets

Snipperize is a code clips warehouse, support nearly all the computer languages.
Here are the latest snippets. Please choose your favorite one or add a new one.

Auto-Replace Broken Images

There are 2 jQuery snippets, both replace broken images with one of your choosing, the difference is that one is "safe" and the other is "persistent". The safe one will quick working, so if your doing something that dynamically changed images on a page it'll only work for the first broken image. The persistent one will keep working, but if your missing image image is missing it'll cause a overflow error.

Javascript / jquery, auto, replace, image, img, broken, error / by ThePeppersStudio (1177 days, 0.90 hours ago)

Use NLTK Toolkit to Classify Documents

Python / nltk, toolkit, classify, document, machine learning, classification, text, features / by ThePeppersStudio (1177 days, 0.97 hours ago)

Number of Connections by IP

Returns a list of the number of connections by IP.

Bash/Shell / ip, connection, netstat / by ThePeppersStudio (1520 days, 19.37 hours ago)


Reading anything on the Internet has become a full-on nightmare. As media outlets attempt to eke out as much advertising revenue as possible, we’re left trying to put blinders on to mask away all the insanity that surrounds the content we’re trying to read. It’s almost like listening to talk radio, except the commercials play during the program in the background. It’s a pretty awful experience. Our friend to date has been the trusty “Print View” button. Click it and all the junk goes away. I click it all the time and rarely print. It’s really become the “Peace & Quiet” button for many. Recently, Mandy Brown wrote a wonderful article for A List Apart called In Defense Of Readers. It’s an attempt to awaken designers responsibility to those who read on the Web: Despite the ubiquity of reading on the web, readers remain a neglected audience. Much of our talk about web design revolves around a sense of movement: users are thought to be finding, searching, skimming, looking. We measure how frequently they click but not how long they stay on the page. We concern ourselves with their travel and participation–how they move from page to page, who they talk to when they get there–but forget the needs of those whose purpose is to be still. Readers flourish when they have space–some distance from the hubbub of the crowds–and as web designers, there is yet much we can do to help them carve out that space. Mandy is spot on – and her concerns are even more salient in today’s cram-all-the-ads-on-one-page Web.

Javascript / readability, extract / by prof.syd.xu (1551 days, 15.98 hours ago)

Full RSS Feed Maker

full rss feed maker, readability to Python

Python / extract, string, rss, readability, feed / by prof.syd.xu (1551 days, 16.18 hours ago)

Extract the main content of a webpage

Extract the main content of a webpage

Python / extract, string, tidy, htmlparser, html / by prof.syd.xu (1551 days, 16.22 hours ago)

Decision Maker

This is a sample run: Number of items: 2 Number of constraints for each item: 3 Constraint 1 name: price Lower(0) or Higher(1) is better: 0 Constraint 2 name: speed Lower(0) or Higher(1) is better: 1 Constraint 3 name: ram Lower(0) or Higher(1) is better: 1 Item 1 name: laptop1 price: 500 speed: 1.5 ram: 4 Item 2 name: laptop2 price: 600 speed: 2 ram: 8 The best item decided: laptop2

Python / decision, ai / by ThePeppersStudio (1597 days, 17.78 hours ago)

c++ singleton with std::auto_ptr

The reason for auto_ptr is insurance that the destructor (of class Test in this instance) gets called when the program exits.

C++ / singleton, template, auto_ptr / by ThePeppersStudio (1597 days, 18.22 hours ago)

creating binary tree with c++

creating binary tree with c++

C++ / btree, binarytree / by ThePeppersStudio (1597 days, 18.25 hours ago)

A deployment script for a generic Cocoa Mac application

Here then is a bash script to handle all of the above steps. It's an annoying diversion into another language for a C/Obj-C/C++ programmer but some things (especially setting folder view options) need to be done a specific way. A script of this sort is the traditional way that this type of deployment is handled. However, it is actually not how I handle my deployments (but I'm a little weird in this respect). Next week, I'll show you the code I use for deployment. Assumptions in this script There's a few assumptions here. While they are normally valid assumptions if you create your project using default Cocoa Mac Application template, there are certainly cases where they won't apply and you'll need to tweak the script a little. This script requires 1 parameter: the .xcodeproj file you want to build. The target you want to build must have the same name as the project (minus the .xcodeproj extension). The Info.plist for the application must have the same name as the project (minus the .xcodeproj extension) with the suffix "-Info.plist". The application build has the same name as the project (minus the .xcodeproj extension). The deployment build is the "Release" build and the build project directory is the build/Release directory. You use git for your repository (although this script will continue if git is not installed). The background image for your DMG folder is a 400x300px PNG named background.png in the same folder as the .xcodeproj file (although this script will skip background image steps if the background.png is missing). The deployment DMG file will be saved to the Desktop with the same name as the project (minus the .xcodeproj extension) with the suffix ".dmg" (build will fail if there's already something at this location).

Bash/Shell / deployment, mac, bash, application, script / by ThePeppersStudio (1604 days, 17.56 hours ago)