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
/** | |
* General-purpose NodeJS CLI/API wrapping the Stable-Diffusion python scripts. | |
* | |
* Note that this uses an older fork of stable-diffusion | |
* with the 'txt2img.py' script, and that script was modified to | |
* support the --outfile command. | |
*/ | |
var { spawn, exec } = require("child_process"); | |
var path = require("path"); |
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
class Page | |
DEFAULT_PAGE_SIZE = 20 | |
def initialize(all_nodes, page:, per_page:) | |
@all_nodes = all_nodes | |
# Normalize pagination arguments | |
@page = if page.nil? || page < 1 | |
1 | |
else | |
page |
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
# official docs: https://graphql-ruby.org/dataloader/sources.html | |
# app/graphql/sources/association.rb | |
class Sources::Association < ::GraphQL::Dataloader::Source | |
def initialize(association_name, scope = nil) | |
@association_name = association_name | |
@scope = scope | |
end | |
def fetch(records) |
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
// Simplistic (probably most common) approach. | |
// | |
// This approach assumes either that: | |
// 1) passive effects are always run asynchronously, after paint, or | |
// 2) passive effects never attach handlers for bubbling events | |
// | |
// If both of the above are wrong (as can be the case) then problems might occur! | |
useEffect(() => { | |
const handleDocumentClick = (event: MouseEvent) => { | |
// It's possible that a "click" event rendered the component with this effect, |
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
# .github/workflows/update_with_latest_master.yml | |
# | |
# This is a Github Action Workflow to merge master into current branch when a label is added to a PR. | |
# Label: `update with latest master` | |
# | |
# 1) Add this yml file to your github workflows directory. | |
# 2) Add the issue/pr label: `update with latest master` to your project. | |
# 3) Any time you want to merge master into a branch, just add the `update with latest master` label to it! | |
# | |
# NOTE: This will trigger a new commit on your branch, potentially triggering CI, and other workflows. |
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 CopyButton({ value }) { | |
let [copied, setCopied] = React.useState(); | |
let hydrated = usePageIsHydrated(); | |
React.useEffect(() => { | |
let id = setTimeout(() => setCopied(false), 2000); | |
return () => clearTimeout(id); | |
}, [copied]); | |
return ( | |
<button |
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
module IndentUtil | |
INDENT_SIZE = 2 | |
def indent_chars(indent_level) | |
' ' * INDENT_SIZE * indent_level | |
end | |
end | |
class PrettifyObject | |
MAX_LINE_SIZE = 120 |
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
const FakeComponent = () => { | |
return ( | |
<AnimatedRoutes exitBeforeEnter initial={false}> | |
<RouteTransition exact path="/some-route"> | |
<NewUsers /> | |
</RouteTransition> | |
<RouteTransition exact path="/yo" > | |
<Users /> | |
</RouteTransition> | |
</AnimatedRoutes> |
NewerOlder