Skip to content

Instantly share code, notes, and snippets.

View jerryharrison's full-sized avatar
🐢
Marathon not a sprint.

Jerry Harrison jerryharrison

🐢
Marathon not a sprint.
View GitHub Profile
@jerryharrison
jerryharrison / Call the modal...
Created August 13, 2012 15:26
This is the sample of the modal framework that I use.
<!-- // Here I'm using an anchor tag to call the modal, however this can virtually be done anywhere using the same attribute or jquery // -->
<a href="#" onClick="showModal('/assignments/create/<?php echo $course['Course']['id'];?>');return false;">Add an Assignment</a>
<!-- // JQuery - inside your jquery handler simply call the function, as display in a click // -->
$('div#Photo').click(function(){
showModal('/view/to/render/here','specificClassNameForModalCSSTargeting');
return false; // not needed I just like to return something...
@jerryharrison
jerryharrison / css
Created August 17, 2012 22:58
Wrapping Long URLs and Text Content with CSS
span {
white-space: pre; /* CSS 2.0 */
white-space: pre-wrap; /* CSS 2.1 */
white-space: pre-line; /* CSS 3.0 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
white-space: -moz-pre-wrap; /* Mozilla */
word-wrap: break-word; /* IE 5+ */
}
@jerryharrison
jerryharrison / gist:3666843
Created September 7, 2012 14:53
Fullscreen code
function goFullscreen(id) {
// Get the element that we want to take into fullscreen mode
var element = document.getElementById(id);
// These function will not exist in the browsers that don't support fullscreen mode yet,
// so we'll have to check to see if they're available before calling them.
if (element.mozRequestFullScreen) {
// This is how to go into fullscren mode in Firefox
@jerryharrison
jerryharrison / remove.php
Created September 8, 2012 14:05
Removing text after a certain character - PHP
$user['User']['name'] = 'Jerry Harrison';
echo $user['User']['name'];
// prints 'Jerry Harrison'
// process with strpos and substr;
// We use strpos to find the position of the character we wish to remove characters after, it returns the first one
// Next we put that number into substr - substr('string', [number of chars to take off the front], [number of chars to count from the start])
// So with that said using zero as the first param and the position of the character we wish to replace as the second we've successfully removed
@jerryharrison
jerryharrison / gist:3723565
Created September 14, 2012 17:59
Quick-N-Dirty: Simple javascript confirmation alert.
<a href="/users/delete/12" onclick="return confirm('Are you sure you want to delete this user?');">Delete</a>
@jerryharrison
jerryharrison / hash_location.js
Created December 12, 2012 16:53
Javascript: Grabbing the hash from the location.href and targeting a specific state on a page.
// auto open the album
var hash = window.location.hash.toString().replace('#','').split('-');
if(hash != ''){
// console.log(hash);
if (hash[2] != undefined) {
@jerryharrison
jerryharrison / Something in the default view
Created February 17, 2013 18:26
Quick gist of how to use Sassafrass
$this->Sassafras->storeVariables($sass_theme_options);
echo $this->Sassafras->build(array(
'reset.sass' => 'reset.css',
'app.sass' => 'app.css',
$this->params['controller'] . DS . $this->params['controller'] . '.sass' => $this->params['controller'] . '.css',
$this->params['controller'] . DS . $this->params['action'] . '.sass' => $this->params['controller'] . '_' . $this->params['action'] . '.css'
), 'compressed');
@jerryharrison
jerryharrison / AppModel.php
Created June 8, 2013 18:19
Sample AppModel. Notice the function lastQuery(); This returns the last sql query used, mainly for logging and ajax testing. FYI.
<?php
class AppModel extends Model
{
public $actsAs = array('Containable');
function lastQuery(){
return $this->getDataSource()->getLog(false, false);
}
@jerryharrison
jerryharrison / sql.sql
Created June 8, 2013 18:34
blog post example
SELECT `ExampleShift`.`id`, `ExampleShift`.`date`, `ExampleShift`.`description`
FROM `lunadesk*******`.`example_shifts` AS `ExampleShift`
WHERE
((30600 BETWEEN `ExampleShift`.`start_time` AND `ExampleShift`.`end_time`)
OR
(63000 BETWEEN `ExampleShift`.`start_time` AND `ExampleShift`.`end_time`))
AND
`ExampleShift`.`date` = '2013-06-06'
AND
`ExampleShift`.`user_id` = 27 LIMIT 1