Skip to content

Instantly share code, notes, and snippets.

Avatar

Trevor Davis davist11

View GitHub Profile
@davist11
davist11 / $slug.jsx
Last active Jan 22, 2022
Remix + Craft Live Preview
View $slug.jsx
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 Jan 17, 2022
Remix Blog Post
View action.jsx
import {
useActionData,
Form,
redirect,
json
} from 'remix'
export async function action({ request }) {
const formData = await request.formData()
const errors = {}
@davist11
davist11 / Standard.json
Created Sep 23, 2020
Redactor Language Plugin
View Standard.json
{
"buttons": [
"html",
"formatting",
"bold",
"italic",
"unorderedlist",
"orderedlist",
"link",
"image",
@davist11
davist11 / external-links.js
Created May 5, 2017
target external links
View external-links.js
@davist11
davist11 / gist:2b3488fe9587be959a46
Created May 9, 2014
Generate video embed URL from YouTube or Vimeo
View gist:2b3488fe9587be959a46
<?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) {
View gist:9621117
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 Aug 29, 2015
in_array plugin method
View pi.php
<?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;
}
View jquery.tabs.js
/**
* @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) {
View pi.auto_link.php
View pi.auto_link.php