This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALLOWED_TYPES = { | |
'pdf' => ['application/pdf', 'application/x-download'], | |
'image' => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif'], | |
'text' => ['application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'], | |
'spreadsheet' => ['application/excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'] | |
} | |
ALLOWED_TYPES.map{ |g,s| s }.flatten # => ["application/pdf", "application/x-download", "image/jpg", "image/jpeg", "image/pjpeg", "image/png", "image/x-png", "image/gif", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin | |
import os | |
class DetectFileTypeCommand(sublime_plugin.EventListener): | |
""" Detects current file type if the file's extension isn't conclusive """ | |
""" Modified for Ruby on Rails and Sublime Text 2 """ | |
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """ | |
def on_load(self, view): | |
filename = view.file_name() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="content"> | |
<span class="breadcrumbs"><a href="<?php bloginfo('url'); ?>">Home</a> » <a href="<?php bloginfo('url'); ?>/businesses">Businesses</a> » Add a Listing</span> | |
<h2 class="title">Add a Business Listing</h2> | |
<div class="entry clearfloat"> | |
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Hoc est non modo cor non habere, sed ne palatum quidem. Cum audissem Antiochum, Brute, ut solebam, cum M. Sed ut iis bonis erigimur, quae expectamus, sic laetamur iis, quae recordamur. Sed ne, dum huic obsequor, vobis molestus sim. An hoc usque quaque, aliter in vita? Haec para/doca illi, nos admirabilia dicamus. Quod equidem non reprehendo;</p> | |
<?php | |
$pod = new Pod('businesses'); | |
$fields = array('name','business_type','content','excerpt','www','address','city','state','zip','email','phone','facebook','twitter','slug'=>array('hidden'=>true)); | |
$pod->publicForm($fields,'Submit Business Listing',get_bloginfo('url').'/businesses/thank-you'); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkbox_list ($data, $name = 'list', $parent = 0, &$label = null) { | |
if (!empty($data)) { | |
echo '<div class="categories sub">'; | |
foreach ($data as $item) { | |
if (isset($item['children']) && !empty($item['children'])){ | |
$label .= (isset($label)) ? ' ' . $item['name'].' »' : $item['name'].' »'; | |
checkbox_list($item['children'], $name, $item['id'],$label); | |
}else{ | |
echo (isset($label)) ? '<h3>'.$label.'</h3>' : false; | |
echo '<label for="'.$name.'_'.$item['id'].'"><input type="checkbox" name="'.$name.'[]" value="'.$item['id'].'" id="'.$name.'_'.$item['id'].'" />'.$item['name'].'</label>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[0] => Array | |
( | |
[id] => 14735 | |
[name] => Biotechnology and Related Specialties | |
[displaytype] => default | |
[parent_id] => 0 | |
[children] => Array | |
( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[0] => Array | |
( | |
[id] => 14735 | |
[name] => Biotechnology and Related Specialties | |
[displaytype] => default | |
[parent_id] => 0 | |
[children] => Array | |
( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* MY_Router allows the existence of controllers and controller sub directories of the same name | |
* | |
* @author Erik Straub | |
*/ | |
class MY_Router extends CI_Router { | |
function __construct(){ | |
parent::__construct(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// get your sql results, etc | |
$results = mysql_query('SELECT * FROM table'); | |
?> | |
<form> | |
<fieldset> | |
<legend>Your Legend</legend> | |
<select name="editlist"> | |
<?php while($row = mysql_fetch_result($results, MYSQL_ASSOC) : ?> | |
<option value="<?php echo $row['companyname']; ?>"><?php echo $row['companyname']; ?></option> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$gallery_id = 1; // Use the PODS column, custom post field or however you would get this ID | |
$results = $wpdb->get_results("SELECT ng.path, np.filename FROM wp_ngg_pictures np, wp_ngg_gallery ng WHERE np.galleryid=ng.gid AND np.galleryid=".$gallery_id." AND np.pid=ng.previewpic",ARRAY_A); | |
if(!empty($results[0]['path']) && !empty($results[0]['filename'])) : | |
$imgpath = $results[0]['path'].'/'.$results[0]['filename']; | |
endif; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\b((?:(?<!:)(?:1?[0-9])(?::(?<!\d)[0-5]\d)?(?:\s?[ap][m]?)?)(?:\s?-\s?)(?<=-|\s)(?:(?:1?[0-9])(?::(?<!\d)[0-5]\d)?(?:\s?[ap][m]?)))\b |