Skip to content

Instantly share code, notes, and snippets.

@zvineyard
zvineyard / html_form
Created August 30, 2012 15:29
PHP: Upload and Rename File
<form action="" enctype="multipart/form-data" method="post">
<input id="file" name="file" type="file" />
<input id="Submit" name="submit" type="submit" value="Submit" />
</form>
@zvineyard
zvineyard / gist:3361675
Created August 15, 2012 17:12
WordPress: Exclude posts if they are only tagged in a single category (Plugin)
<?php
/*
Plugin Name: Exclude Posts if in Single Category
Description: Exclude posts if they are only tagged in a single category, as defined by the category number. This will show posts in the loop if they are tagged in more than one category.
Version: 1.0
Author: Zac Vineyard
Author URI: http://www.zacvineyard.com
*/
@zvineyard
zvineyard / gist:2625997
Created May 7, 2012 04:56
WordPress: Comments Template
<?php
$default_avatar = 'http://zacvineyard.com/blog/wp-content/themes/zac/images/default-avatar.png';
?>
<a id="comments"></a>
<h2>Comments</h2>
<?php if($comments) : ?>
<ol class="comments">
<?php foreach($comments as $comment) : ?>
<li id="comment-<?php comment_ID(); ?>" class="<?php if ($comment->user_id == 1) echo "authcomment";?>">
<?php if ($comment->comment_approved == '0') : ?>
@zvineyard
zvineyard / Pipe Delimited US States
Last active March 18, 2021 16:14
Pipe delimited list of US state abbreviations.
AL|AK|AZ|AR|CA|CO|CT|DE|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VT|VA|WA|WV|WI|WY
layout: degree.njk
title: "Business"
id: 1
type: "Bachelor of Science"
categories:
- business
- finance
- accounting
contact:
name: "Chair, Department of Business"
@zvineyard
zvineyard / gist:3145677
Created July 19, 2012 17:59
Bash: Send an Email Attachment from Command line with mailx
#!/bin/bash
uuencode /file.csv /file.csv | mail x -r "from@example.com" -s "Subject" to@example.com
@zvineyard
zvineyard / example_vhost_file.txt
Created June 17, 2015 05:12
Example vhost file with SSL
<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
ServerName yourdomain.com
ServerAlias www.yourdomain.com
DocumentRoot /home/yourdomain/public_html
<Directory />
Options None
AllowOverride None
Order Deny,Allow
Deny from all
@zvineyard
zvineyard / controller.php
Created July 9, 2012 20:03
CodeIgniter: Add blank value to form_dropdown() and validate
$this->form_validation->set_rules('test', 'Test Field', 'required');
@zvineyard
zvineyard / json_class.java
Created March 10, 2012 19:56
Java: Get JSON from URL (Android)
public class Json {
public static JSONObject getJson(String url){
InputStream is = null;
String result = "";
JSONObject jsonObject = null;
// HTTP
try {
@zvineyard
zvineyard / pyrocms-cheat-sheet.md
Last active February 13, 2018 17:24
PyroCMS 3 Cheat Sheet

Crop a photo from the top:

{{ field.image().fit(400, 400, null, 'top')|raw }}