Skip to content

Instantly share code, notes, and snippets.

View coryetzkorn's full-sized avatar
😴
probably writing code

Cory Etzkorn coryetzkorn

😴
probably writing code
View GitHub Profile
@coryetzkorn
coryetzkorn / delete-supabase-objects-and-account.ts
Last active August 4, 2023 04:45
Delete a user's Supabase storage objects and their account
import { SupabaseBucket, SUPBABASE_BUCKETS } from "@helpers/fileHelpers"
import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs"
import { createClient } from "@supabase/supabase-js"
import { cookies } from "next/headers"
import { NextRequest, NextResponse } from "next/server"
import { Database } from "../../../../types/supabase"
/**
* DELETE to:
* http://localhost:3000/api/actions/delete-account
@coryetzkorn
coryetzkorn / prev-next.php
Last active August 5, 2022 19:16
Craft CMS Prev / Next Entries
{% set prevSibling = craft.entries().prevSiblingOf(entry).one() %}
{% set nextSibling = craft.entries().nextSiblingOf(entry).one() %}
{% set prevEntry = prevSibling ? prevSibling : craft.entries().section('work').inReverse().one() %}
{% set nextEntry = nextSibling ? nextSibling : craft.entries().section('work').one() %}
@coryetzkorn
coryetzkorn / contentful-nested-response-preview-api.js
Created April 24, 2020 22:52
contentful-nested-response-preview-api
// API Call
// https://preview.contentful.com/spaces/spoqsaf9291f/environments/master/entries?sys.id=5R8jRmZhFypDxCs0oVjV3D&include=4
// Response
{
"sys": {
"type": "Array"
},
"total": 1,
"skip": 0,
@coryetzkorn
coryetzkorn / contentful-response.js
Last active April 24, 2020 22:50
contentful-nested-response-delivery-api
// API call
// https://cdn.contentful.com/spaces/spoqsaf9291f/environments/master/entries?sys.id=5R8jRmZhFypDxCs0oVjV3D&include=4
// Response
{
"sys": {
"type": "Array"
},
"total": 1,
"skip": 0,
@coryetzkorn
coryetzkorn / contentful-response.js
Created April 23, 2020 23:38
contentful-nested-response
{
"sys": {
"type": "Array"
},
"total": 1,
"skip": 0,
"limit": 100,
"items": [
{
"sys": {
<template>
<p>Hello, {%= @user.name %}!</p>
<div id="replace-me"></div>
</template>
<script>
document.getElementById("replace-me").innerHTML = "Welcome to the future.";
</script>
<style scoped>
<template>
<p>{{ greeting }} World!</p>
</template>
<script>
module.exports = {
data: function () {
return {
greeting: 'Hello'
}
@coryetzkorn
coryetzkorn / hendrix-profile-query.rb
Created July 24, 2018 15:12
Hendrix Profile Query
@profiles = Profile
.where(visible: true)
.includes(:profile_type)
.joins(:user)
.where(:users => {:state => User.states[:active]})
sort_by = params[:sort] ? params[:sort] : "recently-active"
case sort_by
when "recently-active"
@profiles = @profiles.order('users.last_sign_in_at DESC')
dropdb db-name
createdb db-name
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d db-name ~/desktop/db-backup
@coryetzkorn
coryetzkorn / gist:0223245750fa12149d10
Created May 1, 2015 19:02
JSON to Wordpress Import
$json = file_get_contents(get_bloginfo('template_directory') . '/posts.json');
$json = json_decode($json);
foreach($json as $post) {
$my_post = array(
'post_title' => $post->title,
'post_date' => date("Y-m-d", strtotime($post->date)),
'post_status' => 'publish',
'post_type' => 'press',
'post_author' => 1
);