Skip to content

Instantly share code, notes, and snippets.

@ianshea
ianshea / .prettierrc
Created October 8, 2018 16:13
Prettier Configuration
{
"printWidth": 80,
"tabWidth": 2,
"singleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"parser": "babylon",
"semi": true,
"useTabs": false,
@ianshea
ianshea / policy.json
Created January 14, 2016 23:38
Amazon S3 Bucket Public Access
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"AddPerm",
"Effect":"Allow",
"Principal": "*",
"Action":["s3:GetObject"],
"Resource":["arn:aws:s3:::examplebucket/*"]
}
@ianshea
ianshea / _layout.twig
Created August 28, 2015 17:34
Uxiliary CraftCMS Layout Template
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{% if entry is defined %}
<title>{{ entry.metaTitle ? entry.metaTitle : entry.title }} | {{ siteName }}</title>
{% else %}
@ianshea
ianshea / gist:ef0b4b8a721e2ca7d75a
Created August 18, 2015 21:33
ngrok virtual host
./ngrok http -host-header=mycoolhost.dev 80
# https://ngrok.com/faq#virtual-hosts
@ianshea
ianshea / stub.js
Created August 14, 2015 04:40
React Router Test Stub
class Stub extends React.Component {
static childContextTypes = {
router: React.PropTypes.object.isRequired
};
getChildContext() {
return {
router: {
makePath(pathname, query) { },
makeHref(pathname, query) { },
@ianshea
ianshea / gist:ed561a612e3db7cff0bb
Created March 17, 2015 18:24
Remove ._ files from an unzipped tarball
find . -iname '._*' -exec rm -rf {} \;
@ianshea
ianshea / scsscomment.sublime-snippet
Last active August 29, 2015 14:16
Sublime SCSS Comment Snippets
<snippet>
<content><![CDATA[
// ${1:1.0} - ${2:Element}
//////////////////////////////////////////////
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>_//</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.scss</scope>
</snippet>
@ianshea
ianshea / BlockButtonFieldType.php
Last active August 29, 2015 14:04
CraftCMS - Custom Fieldtype w/ Model
<?php
namespace Craft;
class BlockButton_FieldType extends BaseFieldType
{
public function getName()
{
return Craft::t('Block Button');
}
@ianshea
ianshea / firsts
Created July 16, 2014 18:47
First Entry from First Sub Category from Top Category Slug in Craft
{# Get the category from the slug. This will return one CategoryModel #}
{% set topCat = craft.categories.slug('someSlug').first() %}
{# Get the first subcategory under the top level category using the getChildren() method on the category model. #}
{% set firstSubCat = topCat.getChildren().first() %}
{# Grab the first entry under that category using the relatedTo function and appending the .first() method to return only one item. #}
{% set firstEntry = craft.entries.relatedTo( firstSubCat ).first() %}
{# Set your image from your asset field #}
@ianshea
ianshea / gist:0aed51a1f4845d055ff6
Last active August 29, 2015 14:04
CraftCMS Range of Events
{#
I'm using this to build out a calendar. Not every month/day on the calendar has an event and I don't want a user to go into May 2034 and see nothing.
I needed a way to go from the current day and count out to the last event in the database and show everything in between. This is what I ended up doing.
This method assumes you have a channel of events.
Every event is assigned to an 'event' category with sub categories below it.
Every entry has an 'eventTime' date field within it.
I'm not worrying about recurring events. It's unneeded for this application.
#}