Skip to content

Instantly share code, notes, and snippets.

View zkwentz's full-sized avatar
😅
Working

Zach Wentz zkwentz

😅
Working
View GitHub Profile
==README==
This is a gist of Advanced Rails Recipe #13, but with Paperclip and
Paperclip_polymorph plugins. You need the following plugins for this to work:
http://github.com/thoughtbot/paperclip/tree
http://github.com/heavysixer/paperclippolymorph/tree/master
It allows you to attach multiple files in one form, pretty sweet. Big ups to
http://gist.github.com/patrickberkeley for his excellent port of this recipe
@zkwentz
zkwentz / likes_controller.rb
Created October 13, 2012 13:39
Model agnostic likes controller for SoPub
class LikesController < ApplicationController
before_filter :authenticate_user!
def like
@model = get_model(params[:model_name])
@item = @model.find(params[:id])
#only post to Facebook if this is their first time
unless current_user.voted_on?(@item)
if session[:social_mode]
@zkwentz
zkwentz / config.php
Created June 19, 2013 22:42
Sample config for AWS-SDK-PHP
<?php
global $aws_key, $aws_secret, $aws_region;
return array(
'services' => array(
'default_settings' => array(
'params' => array(
'key' => $aws_key,
'secret' => $aws_secret,
@zkwentz
zkwentz / gist:5854534
Last active December 18, 2015 22:28 — forked from badsyntax/gist:4330899
Update to use TagsManager
/**
* Threw together by Richard Willis - badsyntax.co
*/
var service = new google.maps.places.AutocompleteService();
var geocoder = new google.maps.Geocoder();
var $location = $('#locationField');
$location.typeahead({
source: function(query, process) {
@zkwentz
zkwentz / ingest.js
Created July 19, 2013 01:07
Ingest a Google Group with attached files and upload them to a specific endpoint
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
function dataURItoBlob(dataURI) {
var binary = atob(dataURI.split(',')[1]);
var array = [];
for(var i = 0; i < binary.length; i++) {
array.push(binary.charCodeAt(i));
@zkwentz
zkwentz / UILabel+DDSize.h
Created April 8, 2014 04:54
UILabel+DDSize
//
// UILabel+DDSize.h
//
// Created by Zachary Wentz on 4/7/14.
// @wentz__
#import <UIKit/UIKit.h>
@interface UILabel (DDSize)
@zkwentz
zkwentz / UIViewController.m
Created April 10, 2014 03:22
DTAttributed Label with DTTextAttachment outside UIEdgeInsets
@interface UIViewController ()
{
DTAttributedLabel* storyLabel;
}
- (void)viewDidLoad
{
storyLabel.edgeInsets = UIEdgeInsetsMake(20, 20, 20, 20);
}
@zkwentz
zkwentz / gist:c1ce87077d58d5f3569a
Created June 9, 2014 18:49
Find replace in Coda for html elements
//match class
(\<section.*)(class=")([\s\w\-]*)(")(.*\>)
//match without class
(<section\s+)(?![^>]*\bclass\s*=)([^>]*>)
//match just the element
<section>
Verifying I am +zkwentz on my passcard. https://onename.com/zkwentz
@zkwentz
zkwentz / posts_controller.rb
Last active March 10, 2016 17:08
Rails, JSONAPI, and strong_params, making them work
# app/controllers/posts_controller.rb
class PostsController < ApplicationController
include RestifyParam
...
def post_params
restify_param(:post).require(:post).permit(