Skip to content

Instantly share code, notes, and snippets.

View chrisvogt's full-sized avatar
🌸
✿◕‿◕

Chris Vogt chrisvogt

🌸
✿◕‿◕
View GitHub Profile
@chrisvogt
chrisvogt / jquery-get-chrisvogt-projects.js
Last active August 29, 2015 14:23
Access projects.chrisvogt.me api
$(function() {
// add loading image to div
$('#loading').html('loading...');
// run ajax request
$.ajax({
type: "GET",
dataType: "json",
url: "https://projects.chrisvogt.me/api/1.0/all.json",
success: function (data) {
-- -----------------------------------------------------
-- FancySurvey Schema
-- 02/26/15 14:53:47
-- Author: @c1v0
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Table `users`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `users` (
@chrisvogt
chrisvogt / gamertag-boxes.php
Created January 19, 2015 06:46
Gamertag boxes
<?php for ($i = 0; $i < count($gamertags); $i++) : ?>
<?php if ($i == 0 || $i % 5 == 0) : ?>
<div class="row">
<?php endif; ?>
<div class="medium-3 columns">
<div class="panel">
<div class="th" href="#">
<img src="<?php echo $gamertags[$i]['Platform']['thumbnail']; ?>">
</div>
<h5>
@chrisvogt
chrisvogt / cakephp_reformat_datetime_in_results.php
Last active August 29, 2015 14:12
Prettify find() datetime results in CakePHP using CakeTime
<?php # /app/Model/AppModel.php
/**
* afterFind() override
*
* @param mixed $results
* @param boolean $primary
* @return mixed
*/
public function afterFind($results, $primary = false) {
@chrisvogt
chrisvogt / gist:51a6e0ace502850d5154
Created December 26, 2014 22:29
CakePHP add <pre> tag to select returned fields
<?php
public function afterFind($results, $primary = false) {
$html_fields = array('slider', 'social', 'body');
foreach ($html_fields as $needle) {
foreach ($results as $key => $val) {
if (isset($val['Content'][$needle])) {
$results[$key]['Content'][$needle] = $this->_addBeautifyTag(
$results[$key]['Content'][$needle] );
}
}
@chrisvogt
chrisvogt / el_grabber.php
Last active August 29, 2015 14:11
DOM element grabber using PHP Simple HTML DOM Parser.
<?php
// Include Simple HTML Dom Parser
require_once('simple_html_dom_parser.php');
/**
* @author CJ Vogt <http://chrisvogt.me>
* @uses simple_html_dom
* @see http://simplehtmldom.sourceforge.net/manual.htm
*/
<?php
/**
* API Settings Class
*
* @property string $username
* @property string $password
* @property string $endpoint
*
* @author C1V0 <mail@chrisvogt.me>
*/
@chrisvogt
chrisvogt / us-states-abbreviations.sql
Created September 23, 2013 16:25
US States table
CREATE TABLE `adsum`.`states` (
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(50) NOT NULL ,
`abbreviation` CHAR(2) NOT NULL ,
PRIMARY KEY (`id`) );
INSERT INTO `states` (`id`,`name`,`abbreviation`) VALUES ('1','Alabama','AL');
INSERT INTO `states` (`id`,`name`,`abbreviation`) VALUES ('2','Alaska','AK');
INSERT INTO `states` (`id`,`name`,`abbreviation`) VALUES ('3','Arizona','AZ');
INSERT INTO `states` (`id`,`name`,`abbreviation`) VALUES ('4','Arkansas','AR');
@chrisvogt
chrisvogt / Save-HABTM-POST-data.php
Last active December 22, 2015 23:08
HABTM POST data
<?php
/**
* Events Controller: assign() method
*/
public function assign() {
if ($this->request->is('post')) {
if ($this->Event->saveAll($this->request->data)) {
$this->Session->setFlash(__('The attendee list has been updated.'), 'flash/success');
$this->redirect(array('action' => 'index'));
} else {
@chrisvogt
chrisvogt / bootstrap-cdn-starter-template.html
Created August 16, 2013 23:07
Starter HTML template for Bootstrap 3 hosted by BootstrapCDN.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="http://placehold.it/16x16&amp;text=HI">
<title>Yet Another Bootstrap Bootstrap</title>