Skip to content

Instantly share code, notes, and snippets.

View davist11's full-sized avatar
👨‍💻

Trevor Davis davist11

👨‍💻
View GitHub Profile
@davist11
davist11 / $slug.jsx
Last active January 22, 2022 14:35
Remix + Craft Live Preview
import { json } from 'remix'
import { gql } from 'graphql-request'
import { gqlClient } from 'graphql.server'
export const loader = async ({ request }) => {
const { entries } = await gqlClient(request).request(gql`
{
YOUR GRAPHQL QUERY HERE
}
`)
@davist11
davist11 / action.jsx
Last active January 17, 2022 16:07
Remix Blog Post
import {
useActionData,
Form,
redirect,
json
} from 'remix'
export async function action({ request }) {
const formData = await request.formData()
const errors = {}
@davist11
davist11 / Standard.json
Created September 23, 2020 19:20
Redactor Language Plugin
{
"buttons": [
"html",
"formatting",
"bold",
"italic",
"unorderedlist",
"orderedlist",
"link",
"image",
@davist11
davist11 / external-links.js
Created May 5, 2017 19:10
target external links
@davist11
davist11 / gist:2b3488fe9587be959a46
Created May 9, 2014 18:56
Generate video embed URL from YouTube or Vimeo
<?php
public function getEmbedCode($url)
{
if (strpos($url, 'youtube') !== FALSE) {
$url_parts = parse_url($url);
parse_str($url_parts['query'], $segments);
return '//www.youtube.com/embed/' . $segments['v'];
} else if (strpos($url, 'vimeo') !== FALSE) {
var $body = $('body');
if (!$body.hasClass('whatever')) {
var header_wrap = $('#header-wrap');
var sticky_navigation_offset_top = header_wrap.offset().top;
var sticky_navigation = function() {
var scroll_top = $(window).scrollTop();
if (scroll_top > sticky_navigation_offset_top) {
@davist11
davist11 / pi.php
Last active August 29, 2015 13:57
in_array plugin method
<?php
public function in_array()
{
$haystack = $this->EE->TMPL->fetch_param('haystack', NULL);
$needle = $this->EE->TMPL->fetch_param('needle', NULL);
if ($haystack === NULL || $needle === NULL) {
return;
}
@davist11
davist11 / jquery.tabs.js
Last active August 29, 2015 13:57
jQuery tabs
/**
* @name jQuery Tabs
* @author Trevor Davis
* @copyright (cc) Trevor Davis (http://www.viget.com)
*
* Licensed under the CC-GNU GPL (http://creativecommons.org/licenses/GPL/2.0/)
*/
;(function($, window, document, undefined) {
var Tabs = function(elem, options) {