Skip to content

Instantly share code, notes, and snippets.

const likert1 = {
id: 1,
identifier: 'abc123',
type: 'Likert',
verified_at: '2023-10-01',
title: null,
question: 'Do you like these companies?',
columns: [
{ id: 1, label: 'Yes', color: '#ff0000' },
{ id: 2, label: 'No', color: '#0ff000' },
@emersonthis
emersonthis / Gemfile
Last active April 11, 2020 20:18
These are my go-to dependencies for a new Rails project
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.7'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.2'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
<?php
/**
* Expects a multi-dimensional array and returns a flattened array contianing the values.
*
* @param array $array A multi-dimensional array.
* @return array
*/
function flatten_array($array) {
$flatArray = [];
foreach ($array as $item) {
@emersonthis
emersonthis / flattenarray.php
Created January 14, 2019 02:46
Flatten array
<?php
function flatten_array($array) {
$flatArray = [];
foreach ($array as $item) {
if (is_array($item)) {
$flatArray = array_merge( $flatArray, flatten_array($item) );
} else {
$flatArray = array_merge($flatArray, $item);
}
}
@emersonthis
emersonthis / gist:08126d6c425b8b3c5fed94a8aaa2c217
Last active October 14, 2016 16:18 — forked from swalkinshaw/gist:2695510
WordPress: Mandatory Excerpt
<?php
function mandatory_excerpt($data) {
$excerpt = $data['post_excerpt'];
if (empty($excerpt)) {
if ($data['post_status'] === 'publish') {
add_filter('redirect_post_location', 'excerpt_error_message_redirect', 99);
}
$data['post_status'] = 'draft';
}
return $data;
@emersonthis
emersonthis / wordpress-plugin-svn-to-git.md
Created November 1, 2015 23:55 — forked from kasparsd/wordpress-plugin-svn-to-git.md
Using Git with Subversion Mirroring for WordPress Plugin Development
@emersonthis
emersonthis / gist:429af674f0a4e3692dcc
Last active September 16, 2015 18:07 — forked from leemark/gist:11237860
prefixed CSS for slideshow example
/* http://themarklee.com/2013/10/16/simple-crossfading-slideshow-css/ */
.css-slideshow {
position: relative;
max-width: 495px;
height: 370px;
margin: 1em auto .5em auto;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
}
.css-slideshow figure {
@emersonthis
emersonthis / sheets-api-test-part2.php
Last active September 15, 2015 22:23 — forked from karlkranich/sheets-api-test-part2.php
PHP code to use the Google Spreadsheets API with an OAuth Service Account. For more info, see http://karl.kranich.org/google-sheets-api-php
<?php
// Section 5: edit a row
// You'll need to get the etag and row ID, and send a PUT request to the edit URL
$rowid = 'cre1l'; // got this and the etag from the table data output from section 3
$etag = 'NQ8VCRBLVCt7ImA.';
$url = "https://spreadsheets.google.com/feeds/list/$fileId/od6/private/full/$rowid";
$method = 'PUT';
$headers = ["Authorization" => "Bearer $accessToken", 'Content-Type' => 'application/atom+xml', 'GData-Version' => '3.0'];
$postBody = "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:gsx=\"http://schemas.google.com/spreadsheets/2006/extended\" xmlns:gd=\"http://schemas.google.com/g/2005\" gd:etag='&quot;$etag&quot;'><id>https://spreadsheets.google.com/feeds/list/$fileid/od6/$rowid</id><gsx:gear>phones</gsx:gear><gsx:quantity>6</gsx:quantity></entry>";
$req = new Google_Http_Request($url, $method, $headers, $postBody);
@emersonthis
emersonthis / circle.yml
Created August 22, 2015 00:12
Example cicle.yml file for unit testing a Wordpress plugin with wp-cli
## Customize the test machine
machine:
timezone:
America/New_York # Set the timezone
# Version of ruby to use
php:
version:
5.6.5
@emersonthis
emersonthis / A few questions about CakePHP FileStorage plugin.md
Last active August 29, 2015 14:11
Questions about CakePHP FileStorage plugin

##1. Implementing delete I've updated ListingPhoto.php below with my code to delete files.

    public function afterDelete() {
        StorageManager::adapter($this->record['Photo']['adapter'])->delete($this->record['Photo']['path']);
    }

I copied this directly from the docs here but when I run it I get the following error: Unable to remove the "images/.../.../...jpg" key.

I checked and the path to the file is correct. And I don't think it's a permissions problem because PHP wrote the files to that location already.