Top

Code Snippets by Hawkee

  (30)  
Sort by 
This code will search the library. Add RegexKitLite.h and RegexKitLite.m to your Classes folder and follow these steps to add a linker flag to make the library work properly: Project > Edit Active..
+ 0 likes
20 comment(s)    Score: 0.0    Platform: iPhone    Posted by Hawkee on Mar 07, 2009
This is a very short and simple snippet that will take a given string, $string, and if it is plural the 's' will be removed from the $string.
Tags: plural  remove  string 
+ 0 likes
7 comment(s)    Score: 0.0    Platform: PHP    Posted by Hawkee on Jan 21, 2009
This will extract the search query from a Google search. It doesn't specifically look for Google in the referer so it may capture more than just Google searches. You can use this information to re-perform..
Tags: google  http  query  referer  search 
+ 3 likes
4 comment(s)    Score: 8.0    Platform: PHP    Posted by Hawkee on Nov 19, 2008
This is a simple Javascript snippet that lets you toggle a group of checkboxes on or off at the same time. This is the format for your HTML form: You can use this in multiple groups on the same..
+ 0 likes
1 comment(s)    Score: 0.0    Platform: Javascript    Posted by Hawkee on Oct 18, 2008
This is a very simple Javascript toggle that'll show or hide a div depending on its current state. Here is the HTML code:
+ 1 likes
11 comment(s)    Score: 0.0    Platform: Javascript    Posted by Hawkee on Sep 10, 2008
This snippet will display each of your Hawkee friends sorted by the number of comments they've posted. It uses the viewer and person objects to build an array of friends, then sorts by a custom person..
+ 0 likes
1 comment(s)    Score: 6.0    Platform: OpenSocial    Posted by Hawkee on Aug 02, 2008
This is a sample javascript gadget. It only displays text, but it uses the gadget syntax referenced on Google: http://code.google.com/apis/gadgets/docs/gs.html So far we support gadgets and are..
Tags: gadget 
+ 0 likes
1 comment(s)    Score: 0.0    Platform: OpenSocial    Posted by Hawkee on Apr 01, 2008
This is a little snippet that will remove any non-ASCII characters from a string.
Tags: ascii  pregreplace  strip 
+ 0 likes
0 comment(s)    Score: 0.0    Platform: PHP    Posted by Hawkee on Mar 31, 2008
This code produces a sort box for any number of arbitrary criteria on any type of data you have in your database. For this particular example we've got a product sort where users can sort by price or..
Tags: database  mysql  search  sort 
+ 1 likes
2 comment(s)    Score: 9.0    Platform: PHP    Posted by Hawkee on Mar 24, 2008
This is a very simple PHP snippet that will set $title, $meta_keywords and $meta_description for use in your page header. You'll need to create meta_tags.txt which will use this format: page_name.html|page..
Tags: dynamic  keywords  meta  php  tags  title 
+ 2 likes
52 comment(s)    Score: 4.0    Platform: PHP    Posted by Hawkee on Dec 10, 2007
This will extract a zip file via PHP. Just be sure to set the $file and $path variables. $file represents the zip file name which may or may not contain a path. $path represents the directory to extract..
Tags: file  gunzip  unzip 
+ 0 likes
6 comment(s)    Score: 9.0    Platform: PHP    Posted by Hawkee on Jun 21, 2007
This is a very handy command line use of perl. You basically execute the s// function of perl on a handful of files to do a global search and replace. Just run this from the command line and indicate..
Tags: perl  replace  search 
+ 0 likes
1 comment(s)    Score: 0.0    Platform: Perl    Posted by Hawkee on Apr 13, 2007
This is more of a note to myself, but I use it to dump databases where there are additional fields in the new table. When you're upgrading a database you can either add the new fields to the old table..
Tags: complete  insert 
+ 0 likes
4 comment(s)    Score: 0.0    Platform: mySQL    Posted by Hawkee on Mar 28, 2007
This was used in our The display is either "none" if we don't need to show the "Full Review" link or "inline" which will make the dots appear after the cut-off text.
Tags: css  cut  end  long  php  string 
+ 0 likes
2 comment(s)    Score: 8.5    Platform: Javascript    Posted by Hawkee on Mar 24, 2007
This will copy the text in a given field to the clipboard. Unfortunately it only works in IE, so Firefox users will still need to do the actual copy. But it'll at least select the text for Firefox users. Here..
Tags: clipboard  copy 
+ 0 likes
5 comment(s)    Score: 7.0    Platform: Javascript    Posted by Hawkee on Mar 24, 2007
I always need these for my CSS development. They're great for making your CSS more visible for debugging. You can include one or all in your main stylesheet and just apply the style to any div you're..
Tags: border  css  styles 
+ 0 likes
7 comment(s)    Score: 0.0    Platform: CSS    Posted by Hawkee on Mar 23, 2007
This can be used in conjunction with my snippet. The colors are what we use here at Hawkee, so please feel free to change them. If you find a scheme that works well post it as a snippet.
Tags: cloud  stylesheet  tagcloud  tags 
+ 0 likes
1 comment(s)    Score: 0.0    Platform: CSS    Posted by Hawkee on Mar 21, 2007
This will assign font sizes to tags based on their counts. It tries to evenly distribute the font sizes among the tags while keeping all tags with the same counts under the same font size. The data needs..
+ 0 likes
15 comment(s)    Score: 8.0    Platform: PHP    Posted by Hawkee on Nov 18, 2005
I thought this was pretty neat and useful. You can combine strtotime with the date function to create your own date verbally. This is just an alternative to using mktime that's a little more intuiti..
Tags: date  time  timestamp 
+ 0 likes
3 comment(s)    Score: 7.0    Platform: PHP    Posted by Hawkee on Nov 02, 2005
This is a stand alone example of a review system. This is the administration page for entering and editing reviews. It'll create your table for you automatically, so all you need to do is change the..
Tags: editor  mysql  php  review  score 
+ 0 likes
7 comment(s)    Score: 10.0    Platform: PHP    Posted by Hawkee on Aug 24, 2005
This is a very simple Ruby snippet that creates an unnecessary function.
Tags: def  function  puts 
+ 0 likes
4 comment(s)    Score: 7.7    Platform: Ruby / Rails    Posted by Hawkee on Aug 18, 2005
I've found this to be quite useful in handing uploaded files through HTTP. You can use this to move the file from your /tmp folder to a folder on your site that isn't mode 777. The concept is simple...
Tags: copy  file  ftp  http  secure 
+ 1 likes
3 comment(s)    Score: 7.3    Platform: PHP    Posted by Hawkee on Mar 13, 2005
This will download a datafeed to your server from the given FTP account. This only supports CSV datafeeds and requires a minor tweak to accomodate any other type of datafeed. It also requires that you..
Tags: csv  datafeed  ftp  import  mysql  wget 
+ 0 likes
3 comment(s)    Score: 7.3    Platform: PHP    Posted by Hawkee on Mar 10, 2005
This is a ready to go PHP script that can be pasted into a blank .php document. Run it through your webserver after changing $myemail to the value of your E-Mail address. It also sends the referring..
+ 0 likes
32 comment(s)    Score: 6.0    Platform: PHP    Posted by Hawkee on Sep 04, 2004
This is very handy for making a yyyymmddhhmmss date look pretty.
Tags: convert  mktime  mysql  pubdate  rss  timestamp 
+ 0 likes
2 comment(s)    Score: 5.0    Platform: PHP    Posted by Hawkee on Aug 29, 2004
1 2 Next
Bottom