IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » folder The latest public folder snipts.

showing 1-9 of 9 snipts for folder
  • Remove Folders from URLs
    ## Remove a subfolder from a URL ##
    
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /sports
    RewriteCond ^sports/(.*)$ /$1 [L] 
    

    copy | embed

    0 comments - tagged in  posted by dannomatic on Mar 18, 2010 at 4:08 p.m. EDT
  • Log errors in diffent folders/files reflecting the application folder structure.
    <?php
    /**
     * Log PHP's error into separate files. Recommended for use in production site.
     * Should be used in set_error_handler() to handle certain PHP errors (i.e. E_STRICT).
     * @link http://www.php.net/manual/en/function.set-error-handler.php Reference
     */
    function errorHandler($errno, $errstr, $errfile=NULL, $errline=NULL, $errcontext=NULL) {
      // Log uncategorized errors
      if (is_null($errfile)) {
        $errfile = 'errors.log';
      }
    
      // Reconstruct the path
      // define('APP_DIR', '/my/application/')
      // define('LOG_DIR', '/log_dir/')
      // E.g. /my/application/controller/index.php -> /log_dir/controller/index.php
      $pos = strpos($errfile, APP_DIR);
      if ($pos !== FALSE) {
        // Strip off the application directory and attach log directory
        $errfile = LOG_DIR.substr($errfile, $pos + strlen(CMS_ROOT));
      }
      else {
        $errfile = LOG_DIR.$errfile; // E.g. /log_dir/errors.log
      }
      $dir = dirname($errfile);
      // Create dir if necessary
      if (! file_exists($dir)) {
        mkdir($dir, 0775, TRUE);
      }
      
      $logFile = fopen($errfile, 'a');
      fwrite($logFile, date('Y-m-d H:i:s ').$errstr);
      if ($errline) fwrite($logFile, " on line $errline");
      fwrite($logFile, "\n");
      fclose($logFile);
      
      if (PRODUCTION_SITE) // Prevent err msg from being printed out (log errors silently)
        return TRUE;
    
      return FALSE;
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by hongster on Jan 21, 2010 at 2:46 a.m. EST
  • Folder Label Remover
    #!/bin/bash
    
    # requires lsmac
    
    lsmac -L -p | tee ~/desktop/label-list | grep -v -H "None" | awk -F" " '{ print $7,$8,$9,$10}' > //~/desktop/tempfile;
    myFile="//~/desktop/tempfile";
    myLine="";
    
    
    while read
            do
                    
                    read myLine || break;
                    echo $myLine; 
                    setlabel None "`echo $myLine`";
                    
                    done < $myFile;
    

    copy | embed

    0 comments - tagged in  posted by siliconjones on Jul 08, 2009 at 4:05 p.m. EDT
  • Toucher - Changes file and folder modified date to now
    on open these_items
    	repeat with i from 1 to the count of these_items
    		set this_item to (item i of these_items)
    		set the item_info to info for this_item
    		if folder of the item_info is true then
    			process_folder(this_item)
    		else
    			process_item(this_item)
    		end if
    	end repeat
    end open
    
    -- this sub-routine processes folders 
    on process_folder(this_folder)
    	do shell script "touch \"" & POSIX path of this_folder & "\""
    	set these_items to list folder this_folder without invisibles
    	repeat with i from 1 to the count of these_items
    		set this_item to alias ((this_folder as text) & ¬
    			(item i of these_items))
    		set the item_info to info for this_item
    		if folder of the item_info is true then
    			process_folder(this_item)
    		else
    			process_item(this_item)
    		end if
    	end repeat
    end process_folder
    
    -- this sub-routine processes files 
    on process_item(this_item)
    	do shell script "touch \"" & POSIX path of this_item & "\""
    end process_item
    

    copy | embed

    0 comments - tagged in  posted by siliconjones on Jul 08, 2009 at 4:02 p.m. EDT
  • Finder Folder Labeler
    tell application "Finder"
    	set source_folder to choose folder with prompt "Choose a folder which contains files or folders you wish to modify:"
    	set item_list to list folder source_folder without invisibles
    	set source_folder to source_folder as string
    	set label_number to 0
    	display dialog ¬
    		"Enter the label value: 
    		0=None 1=Orange 2=Red 3=Yellow 4=Blue 
    		5=Purple 6=Green 7=Gray" default answer label_number buttons {"Cancel", "Label"} default button 2
    	copy the result as list to {label_number, button_pressed}
    	set label_number to label_number
    	
    	if button_pressed is "Label" then
    		repeat with i from 1 to number of items in the item_list
    			tell application "Finder"
    				set the_item to item i of the item_list
    				set the_item to (source_folder & the_item)
    				set label index of item the_item to label_number as integer
    			end tell
    		end repeat
    	end if
    	tell application "Finder"
    		open folder source_folder
    	end tell
    end tell
    

    copy | embed

    0 comments - tagged in  posted by siliconjones on Jul 08, 2009 at 4:00 p.m. EDT
  • Delete Directory PHP
    function delete_directory($dirname) {
        if (is_dir($dirname))
            $dir_handle = opendir($dirname);
        if (!$dir_handle)
            return false;
        while($file = readdir($dir_handle)) {
            if ($file != "." && $file != "..") {
                if (!is_dir($dirname."/".$file))
                    unlink($dirname."/".$file);
                else
                    delete_directory($dirname.'/'.$file);          
            }
        }
        closedir($dir_handle);
        rmdir($dirname);
        return true;
    }
    

    copy | embed

    0 comments - tagged in  posted by RiSiCO on May 23, 2009 at 6:39 a.m. EDT
  • List Folder Contents
    function folderlist($startdir, $onlinepath){
      $ignoredDirectory[] = '.';
      $ignoredDirectory[] = '..';
       if (is_dir($startdir)){
           if ($dh = opendir($startdir)){
               while (($folder = readdir($dh)) !== false){
                   if (!(array_search($folder,$ignoredDirectory) > -1)){
                     if (filetype($startdir.$folder) == "dir"){
                           $directorylist[$startdir . $folder]['name'] = $folder;
                           $directorylist[$startdir . $folder]['path'] ;
                       }
                   }
                       }
               closedir($dh);
           }
       }
    return($directorylist);
    }
    

    copy | embed

    0 comments - tagged in  posted by RiSiCO on May 23, 2009 at 6:38 a.m. EDT
  • Changing only file or folder permissions recursively in OS X
    # for files only
    $find ./ -type f -exec chmod 644 {} +
    
    # for directories only
    $find ./ -type d -exec chmod 644 {} +
    

    copy | embed

    0 comments - tagged in  posted by isagoksu on Apr 27, 2009 at 12:58 p.m. EDT
  • Delete folder & files inside
    rm -r <dir name>
    

    copy | embed

    0 comments - tagged in  posted by dorseye on Mar 22, 2009 at 6:06 p.m. EDT
Sign up to create your own snipts, or login.