$ ember install ember-cli-postcss # Install ember-cli-postcss
$ npm install --save-dev tailwindcss # Install tailwindcss
$ npx tailwind init app/styles/tailwind.config.js # Optional: Generate a Tailwind config file for your project
$ npm install -save-dev postcss-import # Optional: If you want to use the @import statement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original code https://twitter.com/robinbortlik/status/1699524286568964440?s=20 | |
# app/controllers/stories.rb | |
class StoriesController < ApplicationController | |
before_action :check_authorizationa # this should check and return a 401 | |
def create | |
story = Story.new(story_params) | |
if story.save |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of using SQLite VSS with OpenAI's text embedding API | |
# from Ruby. | |
# Note: Install/bundle the sqlite3, sqlite_vss, and ruby-openai gems first | |
# OPENAI_API_KEY must also be set in the environment | |
# Other embeddings can be used, but this is the easiest for a quick demo | |
# More on the topic at | |
# https://observablehq.com/@asg017/introducing-sqlite-vss | |
# https://observablehq.com/@asg017/making-sqlite-extension-gem-installable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEG2RAD = Math::PI / 180.0 | |
def tick args | |
b = args.state.box_a ||= { x: 540, y: 360, w: 200, h: 200, angle: 45, path: 'sprites/square/blue.png' } | |
a = args.state.box_b ||= { x: 340, y: 360, w: 100, h: 100, angle: 45, path: 'sprites/square/green.png' } | |
$a = a | |
a.y += 1 if args.inputs.up | |
a.y -= 1 if args.inputs.down | |
a.x -= 1 if args.inputs.left |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function useWeakRef<T>(value: T): React.MutableRefObject<T> { | |
const ref = useRef(value); | |
useEffect(() => { | |
ref.current = value; | |
}, [value]); | |
return ref; | |
} | |
function useByrefCallback<Args extends unknown[], Result>( | |
callback: (...args: Args) => Result, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { types, IAnyModelType, Instance, cast } from "mobx-state-tree"; | |
import React, { useMemo } from "react"; | |
export const createModel = <T extends IAnyModelType>( | |
model: T, | |
value?: Record<string, any> | |
) => types.optional(model, () => model.create(value)); | |
export function castSelf<IStoreInstance, IParentModel>( | |
store: IStoreInstance, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Parallel implementation to Avatar example from | |
// https://github.com/conorhastings/use-reducer-with-side-effects/blob/19d097e95302068d8368b0a10b379b0a6bab9f93/README.md | |
import { useObserver, useLocalStore } from 'mobx-react'; | |
// WIP library inspired by `import { promisedComputed } from 'async-computed-mobx'` | |
import asyncComputed from 'utils/mobx/asyncComputed'; | |
const DEFAULT_AVATAR = '/assets/img/default-avatar.png'; | |
function Avatar(props: { userName: string }) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import produce from 'immer'; | |
import {createStore} from 'redux'; | |
const handleActions = (actionsMap, defaultState) => ( | |
state = defaultState, | |
{type, payload} | |
) => | |
produce(state, draft => { | |
const action = actionsMap[type]; | |
action && action(draft, payload); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BC.registerElement "bc-require", | |
createdCallback: -> | |
@setAttribute("pending", "") | |
attachedCallback: -> | |
BC.ready => | |
if Loader.find(@script)?.loaded | |
@activate() | |
else | |
@deactivate() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function() | |
{ | |
var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, '', { | |
preload: preload, | |
create: create, | |
update: update | |
}); | |
var dragging = false; |
NewerOlder