Skip to content

Instantly share code, notes, and snippets.

@bradrice
bradrice / new_gist_file.sql
Last active November 2, 2018 12:43
reset increment on sql table #sql
ALTER TABLE tablename AUTO_INCREMENT = 1
@bradrice
bradrice / gist:465e1d82abd5619b70b8
Created September 23, 2014 20:27
Markdown vim-template for Pelican
Date: %FDATE%
Author: Brad Rice
Email: [email protected]
Title: %HERE%
Slug:
Tags:
Category:
@bradrice
bradrice / home_scroller
Created March 28, 2014 13:17
Home scroller velocity code
#set($query = "+structureName:homeScroller +(conhost:5ce88b4e-45bc-4870-bd1e-3cb8399a11a1 conhost:SYSTEM_HOST) +homeScroller.active:1")
#set($list = $dotcontent.pull($query, '0', 'homeScroller.weightedOrder desc'))
<script type="text/javascript">
// execute your scripts when DOM is ready. this is a good habit
jQuery(function() {
// initialize scrollable
jQuery("div.scrollable").scrollable(
{
@bradrice
bradrice / dotcms_categories
Created March 19, 2014 13:32
Pull list of categories from widget code
#foreach($inode in $carouselCategory)
#if($velocityCount == 1)
#set($catlist = "categories:$categories.getCategoryByInode($inode).getCategoryVelocityVarName()")
#else
#set($catlist = "$catlist categories:$categories.getCategoryByInode($inode).getCategoryVelocityVarName()")
#end
#end
@bradrice
bradrice / gist:9625254
Created March 18, 2014 17:43
jquery validator overides for bootstrap 3`
// override jquery validate plugin defaults
$.validator.setDefaults({
highlight: function(element) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function(element) {
$(element).closest('.form-group').removeClass('has-error');
},
errorElement: 'span',
errorClass: 'help-block',
@bradrice
bradrice / filter colon
Created July 8, 2013 18:26
replace the colon with unicode
if(searchVal.match(/:/g)){
n = searchVal.replace(':', '\\x3A');
$scope.searchObj['filterText'] = n;
} else {
$scope.searchObj['filterText'] = searchVal;
}
@bradrice
bradrice / curriculum_course_other.php
Created October 1, 2012 18:06
curriculum_course_other
public function get_curriculum_course_other_details($curriculumID)
{
return $this->db
->select('a.*,c.name as "className",b.name as "title"')
->from('curr_courses a')
->join('other_courses b', 'a.class = b.id', 'left')
->join('other_depts c','b.other_dept_id = c.id', 'left')
->where('a.curriculum_id', $curriculumID)
->where('a.flag_other', 1)
->order_by('a.year asc, a.term asc')
{
"curriculum": [
{
"id": "351",
"usr_created": "curr_bcas",
"dttm_created": "2012-09-26 13:05:04",
"usr_last_modified": "curr_bcas",
"dttm_last_modified": "2012-09-27 13:58:43",
"usr_submitted": null,
"dttm_submitted": null,
@bradrice
bradrice / select2_curriculumGuide
Created September 25, 2012 14:37
Select 2 dropdown
function build_course_dept_dds(thisCourseCell)
{
selector = (!thisCourseCell)?$('.thisCourseDept'):$('.thisCourseDept',thisCourseCell);
//console.log('build_course_dept_dds');
selector.select2(
{
data:thisCourseDeptData,
placeholder: 'Select Department/Track'
}).bind('change',function(){
@bradrice
bradrice / vel-js.html
Created July 6, 2012 16:30
Velocity to make json
<script type="text/javascript">
#set($left_b = "{")
#set($right_b = "}")
#set($colon = ":")
#set($comma = ",")
#set($ar_size = $my_id_array.size())
#foreach($item in $my_id_array)
#set($a_i = "${quote}$item.cnt${quote}${colon}${left_b}${quote}id${quote}${colon}${quote}${item.id}${quote}${comma}${quote}urlmap${quote}${colon}${quote}${item.urlmap}${quote}${right_b}#if($velocityCount<$ar_size)${comma}#end")
#if($velocityCount == 1)
#set($my_json = "$a_i")