Skip to content

Instantly share code, notes, and snippets.

View TSMMark's full-sized avatar
🐶

Mark Allen TSMMark

🐶
View GitHub Profile
@mattdesl
mattdesl / cli.js
Created September 13, 2022 10:37
colour palette from text prompt using Stable Diffusion https://twitter.com/mattdesl/status/1569457645182152705
/**
* 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");
@itkrt2y
itkrt2y / page.rb
Last active April 12, 2023 16:23 — forked from rmosolgo/page_example.rb
Generic page number / per-page pagination with GraphQL-Ruby
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
@itkrt2y
itkrt2y / association.rb
Last active May 3, 2024 21:16
Association dataloader with graphql-ruby
# 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)
@bvaughn
bvaughn / attaching-manual-event-listeners-in-passive-effect.js
Last active July 6, 2022 23:34
Attaching manual event listeners in a passive effect
// 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,
@TSMMark
TSMMark / update_with_latest_master.yml
Last active March 31, 2021 15:40
GH Action Workflow to merge master into current branch when a label is added to a PR
# .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.
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
module IndentUtil
INDENT_SIZE = 2
def indent_chars(indent_level)
' ' * INDENT_SIZE * indent_level
end
end
class PrettifyObject
MAX_LINE_SIZE = 120
@Log1x
Log1x / README.md
Last active November 28, 2023 21:15
Uptime Robot Discord Webhook

Uptime Robot Webhook for Discord

Screenshot

Configuration

  • Alert Contact Type: Web-Hook
  • URL to Notify: https://discordapp.com/api/webhooks/CHANGEME/CHANGEME?
    • Must end with ?
@stolinski
stolinski / Example.tsx
Last active June 8, 2022 05:54
Route Transitions with Framer Motion
const FakeComponent = () => {
return (
<AnimatedRoutes exitBeforeEnter initial={false}>
<RouteTransition exact path="/some-route">
<NewUsers />
</RouteTransition>
<RouteTransition exact path="/yo" >
<Users />
</RouteTransition>
</AnimatedRoutes>