Snipplr - brownrlhttp://snipplr.com/users/brownrl
Recent snippets posted on Snipplr.comen-usThu, 22 Feb 2018 16:28:40 GMT(PHP) Distance in SQLITEhttp://snipplr.com/view/100901/distance-in-sqlite/
This is damn crazy! sQlite does not have all the trig functions need to do distances. So here is how you load that into sQlite on the fly. ]]>Wed, 20 May 2015 01:54:01 GMThttp://snipplr.com/view/100901/distance-in-sqlite/(SQL) Migrate a Wordpresshttp://snipplr.com/view/100687/migrate-a-wordpress/
Moving a wordpress site for local dev, to staging, to production? This SQL snippet has done the job more often than not. It may not be 100% full proof but it has saved my butt hundreds of times. Please, if you know other tables or enhancements share them. ]]>Tue, 12 May 2015 23:52:20 GMThttp://snipplr.com/view/100687/migrate-a-wordpress/(SQL) Jacaard Index, Similarity based on Tag Systemhttp://snipplr.com/view/89325/jacaard-index-similarity-based-on-tag-system/
This piece of sql is used to find the similarity of one item to other items based on a 3 table tag system, cities, cities_tags, tags. It works in sQlite and MySQL. Use this code to get the idea of how you would make a "item" has "related items" based on "tags" solution. ]]>Wed, 04 Feb 2015 02:11:14 GMThttp://snipplr.com/view/89325/jacaard-index-similarity-based-on-tag-system/(PHP) CKEditor Simple Filemanagerhttp://snipplr.com/view/89238/ckeditor-simple-filemanager/
This is a plain jane very simple file manager for ckeditor, this has very limited... ^NO^ features. ]]>Tue, 03 Feb 2015 00:04:53 GMThttp://snipplr.com/view/89238/ckeditor-simple-filemanager/(PHP) GUID / UUIDhttp://snipplr.com/view/88443/guid--uuid/
A simple uuid generator for PHP. checks if there is already one. ]]>Mon, 26 Jan 2015 22:31:15 GMThttp://snipplr.com/view/88443/guid--uuid/(PHP) Sublime Snippet: dieouthttp://snipplr.com/view/72191/sublime-snippet-dieout/
This will print out a variable to a ]]>Fri, 23 Aug 2013 22:26:16 GMThttp://snipplr.com/view/72191/sublime-snippet-dieout/(PHP) Sublimee Snippet: Fichttp://snipplr.com/view/72190/sublimee-snippet-fic/
Generate a generic file comment ]]>Fri, 23 Aug 2013 20:21:07 GMThttp://snipplr.com/view/72190/sublimee-snippet-fic/(PHP) Sublime Snippet: fuchttp://snipplr.com/view/72189/sublime-snippet-fuc/
Generate a generic function comment block ]]>Fri, 23 Aug 2013 20:19:55 GMThttp://snipplr.com/view/72189/sublime-snippet-fuc/(PHP) Sublime Snippet: pageithttp://snipplr.com/view/72188/sublime-snippet-pageit/
This is a quick sublime snippet to quickly setup a DB table for pagination. Ideally from here you will be into a smarty template. ]]>Fri, 23 Aug 2013 19:59:44 GMThttp://snipplr.com/view/72188/sublime-snippet-pageit/(PHP) Sublime Snippet: dbNumRowshttp://snipplr.com/view/72180/sublime-snippet-dbnumrows/
When using PDO with sQlite ->rowCount() doesn't work. the recommendation is to do a pre query to get the number. Thus, I created this snippet to help things along. ]]>Thu, 22 Aug 2013 18:40:30 GMThttp://snipplr.com/view/72180/sublime-snippet-dbnumrows/(PHP) Custom Drupal View Fieldhttp://snipplr.com/view/71639/custom-drupal-view-field/
This is a custom field handler for a Drupal view. Sometimes you have two or more fields in a content type and you want to do a test on them to see if both are empty or both full or exclusive and return that as a field.
There are probably ways to do this in the admin/view configuration. However, this code also serves as a general skeleton for just any old custom field handler.
* Make sure that all files that you make/add to your module that you add to your .info file. If you forget this you will bash your head in later trying to figure WTF this is not working. ]]>Wed, 26 Jun 2013 20:28:56 GMThttp://snipplr.com/view/71639/custom-drupal-view-field/(PHP) Image Resize on the Flyhttp://snipplr.com/view/71224/image-resize-on-the-fly/
This is my simple image resizer on the fly thing.
-- WARNING --
Resizing and showing images on the fly could potentially kill your server or make the website slow.
Ideally, this should save the resized image in a cache. However, more often than not this method just works, no one complains, and I don't have to make some writable caching directory thing.
If anyting this could give you a good start on how you really want to handle your images. ]]>Sat, 18 May 2013 08:21:43 GMThttp://snipplr.com/view/71224/image-resize-on-the-fly/(PHP) Cleanup Downloads Directoryhttp://snipplr.com/view/71223/cleanup-downloads-directory/
This is a simple script to go into your downloads directory ( mac ). Move everything to a .YYYY-MM-DD folder. Thus you Downloads directory gets cleaned up and anything that was there has been placed into a hidden folder for finding later.
My Downloads folder is just always full of things but I don't want to blast it empty. Re-getting a file from some website is sometimes hard to remember. So I move everything to a backup and start again. ]]>Sat, 18 May 2013 07:56:52 GMThttp://snipplr.com/view/71223/cleanup-downloads-directory/(Bash) Simple Command Line Calculatorhttp://snipplr.com/view/71222/simple-command-line-calculator/
This is a simple wrapper to bc to perform basic calculator duties. with up to 4 decimal place precision. its just one of those things you might find useful. Then again all the os's out there have a gui calc easily ready too. ]]>Sat, 18 May 2013 07:50:30 GMThttp://snipplr.com/view/71222/simple-command-line-calculator/(PHP) Drupal Auto Blockshttp://snipplr.com/view/69905/drupal-auto-blocks/
This is a hook_block_info and hook_block_view template that will allow you to quickly create blocks in a Drupal module. When you use this all you have to do is create a directory "blocks" in the module and then create block.block_name.php in the directory. Inside the php you need to define a function block_block_name_content(). ]]>Tue, 12 Feb 2013 20:33:39 GMThttp://snipplr.com/view/69905/drupal-auto-blocks/(JavaScript) Get Query String Args Javascripthttp://snipplr.com/view/59019/get-query-string-args--javascript/
This will get the arguments on the query string and put them into a handy array. ]]>Fri, 23 Sep 2011 17:33:12 GMThttp://snipplr.com/view/59019/get-query-string-args--javascript/(PHP) PHP DB Table to HTML Datagridhttp://snipplr.com/view/57337/php-db-table-to-html-datagrid/
This is a skeleton mock up for showing a database table in a basic datagrid with sorting and pagination. ]]>Fri, 29 Jul 2011 19:49:16 GMThttp://snipplr.com/view/57337/php-db-table-to-html-datagrid/(PHP) PHP getTotalhttp://snipplr.com/view/55780/php-gettotal/
Simple function to return the total records in a DB. This function probably has to be modified for every project you do to adjust for your db layer and server. I have it here simply because I use ado-db lite and my other functions almost all the time. ]]>Mon, 27 Jun 2011 20:04:11 GMThttp://snipplr.com/view/55780/php-gettotal/(PHP) PHP getCheckBoxhttp://snipplr.com/view/55778/php-getcheckbox/
Simple simple simple function to make a checkbox for a form. Retains checked status. ]]>Mon, 27 Jun 2011 19:55:47 GMThttp://snipplr.com/view/55778/php-getcheckbox/(PHP) PHP dePluralhttp://snipplr.com/view/55777/php-deplural/
Small function to help de plural a word. Probably not up to the oxford english standard but close enough and extensible. ]]>Mon, 27 Jun 2011 19:46:04 GMThttp://snipplr.com/view/55777/php-deplural/