Skip to content

Instantly share code, notes, and snippets.

View stevecastaneda's full-sized avatar

Steve Castaneda stevecastaneda

View GitHub Profile
@stevecastaneda
stevecastaneda / Reschedule Tasks (new)
Created April 4, 2011 23:23
After the refactor...
// Remove the task from the UI
$("#task_<%= @task.id %>").slideUp("slow", function() {
// Reload the tasks
$("#tasks").html("<%= escape_javascript(render(:partial => 'tasks/tasks'))%>");
// Highlight the task that was rescheduled
$("#task_<%= @task.id %>").effect("highlight", {}, 1250);
});
@stevecastaneda
stevecastaneda / Reschedule Tasks (old)
Created April 4, 2011 23:22
Before the refactor...
// Detach the task from it's current location and save to var task
var task = null;
task = $("#task_<%= @task.id %>").detach();
// Was this the last task for one of the sections?
// If so, remove the header and spacer (remove), add no-tasks span if today
if($("#tasks_today > div.task").length == 0) {
if($("#tasks_today").children("div").children("span").length == 0) {
$("#tasks_today > hr").before('<div class="span-7 last"><span>Nothing to do. <%= link_to "Bored?", "#", :id => "bored_link" %></span></div>');
}
@stevecastaneda
stevecastaneda / rails_3_1_beta_1_changes.md
Created May 6, 2011 18:33 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 Beta 1

  • The -j option of the application generator accepts an arbitrary string. If passed "foo", the gem "foo-rails" is added to the Gemfile, and the application JavaScript manifest requires "foo" and "foo_ujs". As of this writing "prototype-rails" and "jquery-rails" exist and provide those files via the asset pipeline. Default is "jquery". [fxn]

  • jQuery is no longer vendored, it is provided from now on by the jquery-rails gem. [fxn]

  • Prototype and Scriptaculous are no longer vendored, they are provided from now on by the prototype-rails gem. [fxn]

  • The scaffold controller will now produce SCSS file if Sass is available [Prem Sichanugrist]

@stevecastaneda
stevecastaneda / CSSTransition.tsx
Created June 10, 2020 02:44
A CSS Transition component to use as a child of TransitionGroup.
// http://reactcommunity.org/react-transition-group/transition
// http://reactcommunity.org/react-transition-group/transition-group
import React, { ReactNode } from "react";
import { Transition as ReactTransition } from "react-transition-group";
interface TransitionProps {
in?: boolean;
timeout: number | { appear?: number; enter?: number; exit?: number };
enter?: string;
@stevecastaneda
stevecastaneda / callable.tsx
Last active June 29, 2020 16:54
This simple callable function throws a deadline-exceed error, even when it successfully returns a response.
import React, { useEffect } from "react";
// Run the callable function on mount only once by adding an empty array.
export function Callable() {
useEffect(() => {
async function helloWorld() {
try {
const helloWorldCallableFunction = functions.httpsCallable("helloWorld", { timeout: 10000 });
const response = await helloWorldCallableFunction();
@stevecastaneda
stevecastaneda / ModalExample.tsx
Last active July 26, 2020 20:17
[Typescript] Modified Transition React Component to Support Nested Transitions w/ Tailwind
// Modal Source: https://tailwindui.com/components/application-ui/overlays/modals
import React, { ReactNode } from "react";
import { Transition } from "components/transition";
interface Props {
/** The modal open/close state */
open: boolean;
}
@stevecastaneda
stevecastaneda / Example.tsx
Created July 16, 2020 00:49
A Tailwind-ready Modal using React Aria from Adobe
import React, { useState, useContext, useRef } from "react";
import { useOverlayTriggerState } from "@react-stately/overlays";
import { useButton } from "@react-aria/button";
import { Modal } from "components/overlays/Modal";
export function Example() {
let state = useOverlayTriggerState({});
function onOpen() {
state.open();
@stevecastaneda
stevecastaneda / CSSTransition.tsx
Last active August 9, 2022 21:54
CSSTransition component (Typescript). This one allows you use TransitionGroup with Tailwind, animating in a list of items.
import React, { ReactNode } from "react";
import { CSSTransition as ReactTransition } from "react-transition-group";
interface TransitionProps {
in?: boolean;
timeout: number;
enter?: string;
enterFrom?: string;
enterTo?: string;
leave?: string;
@stevecastaneda
stevecastaneda / onNodeDelete.ts
Last active November 18, 2023 07:02
Tiptap: Check if a node has been deleted
// From Github issue
// https://github.com/ueberdosis/tiptap/issues/3700
// Requires that the node have an ID
// See: https://tiptap.dev/api/extensions/unique-id
import { Node } from "@tiptap/pm/model";
import { Editor as CoreEditor } from "@tiptap/core";