Skip to content

Instantly share code, notes, and snippets.

View swthate's full-sized avatar

Steven Thate swthate

  • MN
View GitHub Profile
@swthate
swthate / CoolerComponent.vue
Last active March 29, 2019 19:51
Vue component with array of objects as a prop
<template>
<div>
<!-- Dynamic list of fields from template -->
<Component v-for="(field, index) in fields" :is="field.component" :key="index" v-model="fields[field.name]" />
</div>
</template>
<script>
@swthate
swthate / parse-address.php
Created March 16, 2017 19:29
Parse Address
<?php
/**
* This bit of code takes an array of address blocks---with a newline break separating
* street address from city, state, and zip code---and formats each piece of the address
* block into an HTML table.
*
* With each address block split into a table, we can easily paste it into a CSV spreadsheet.
*
* We go from:
@swthate
swthate / timber-file.twig
Created May 30, 2016 04:20
Timber ACF Relationship
{% set relations = TimberPost(post.get_field('relationship_field')) %}
{% if relations %}
{% for relation in relations %}
<h2>{{relation.title}}</h2>
{% endfor %}
{% endif %}
@swthate
swthate / Animal.php
Created October 18, 2014 19:01
Another attempt at auto-complete
<?php
# app/Model/Animal.php
class Animal extends AppModel {
}
@swthate
swthate / JqueryExamplesController.php
Created October 17, 2014 14:22
autocomplete errors
<?php
// JqueryExamplesController.php
class JqueryExamplesController extends AppController {
/**
* Example of an autocomplete field using jQuery UI
* with JSON and AJAX
*
@swthate
swthate / JobsController.php
Last active August 29, 2015 14:05
attempting autocomplete
/**
* add method
*
* @return void
*/
public function add() {
# jQuery Auto Complete
if ($this->request->is('ajax')) {
$this->loadModel('Client');
@swthate
swthate / Job.php
Created August 18, 2014 21:09
Cake AutoComplete
<!-- File: app/Model/Job.php -->
<?php
<?php
App::uses('AppModel', 'Model');
/**
* Job Model
*
* @property Client $Client
@swthate
swthate / gist:b1c1d2ccf6e86e99f7ec
Created August 15, 2014 16:38
Missing Helper Error
Missing Helper
Error: AuthHelper could not be found.
Error: Create the class AuthHelper below in file: app\View\Helper\AuthHelper.php
<?php
class AuthHelper extends AppHelper {
}
@swthate
swthate / view.ctp
Created May 19, 2014 17:16
jQuery UI Accordian
<!-- File: /app/View/Jobs/view.ctp -->
<?php echo $this->Html->css('jquery-ui-1.10.4.custom'); ?>
<?php echo $this->Html->script('jquery-1.10.2'); ?>
<?php echo $this->Html->script('jquery-ui-1.10.4.custom.min'); ?>
<script>
$(function() {
$( "#accordion" ).accordion({
collapsible: true
@swthate
swthate / JobsController.php
Last active August 29, 2015 14:01
Baked JobsController
<?php
/**
* Components
*
* @var array
*/
public $components = array('Paginator', 'Session');
public $pagiante = array(
'order' => array(
'Job.id' => 'desc'