Skip to content

Instantly share code, notes, and snippets.

View ryaninvents's full-sized avatar

Ryan Kennedy ryaninvents

View GitHub Profile
@dogoku
dogoku / stencil-helper.js
Last active August 6, 2022 23:20
Helper functions that simplify compiling and running stencil source code in the browser
function loadStencilCompiler(doc = document) {
const s = doc.createElement('script');
// loading from jsdelivr because skypack is not converting this file correctly
s.src = 'https://cdn.jsdelivr.net/npm/@stencil/core@latest/compiler/stencil.min.js';
return new Promise((resolve, reject) => {
s.onload = () => resolve(window.stencil.transpile);
s.onerror = reject;
doc.body.appendChild(s);
});
}
import { buildSchema, graphql } from "graphql";
// Construct a schema, using GraphQL schema language
let graphqlSchema = buildSchema(`
type Query {
recipes: [Recipe]
recipes_by_pk(id: Int!): Recipe
}
type Recipe {
id: ID!
@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
// faking the firebase API to get as much as we need
import localforage from "localforage"
import { format } from "date-fns"
// localforage.clear()
// fakeStreamedData()
export const mode = "fake"
const FAKE_LATENCY = true
@herr-vogel
herr-vogel / material-ui-next-js-button.js
Last active November 16, 2021 10:14
Using Material-UI Button with Next.js Link
import React from 'react'
import Link from 'next/link'
import Button from '@material-ui/core/Button'
const ButtonLink = ({ className, href, hrefAs, children, prefetch }) => (
<Link href={href} as={hrefAs} prefetch>
<a className={className}>
{children}
</a>
</Link>
@TooTallNate
TooTallNate / jsfunc.sh
Created June 20, 2018 05:37
Write JavaScript functions - use as bash functions
#!/bin/bash
jsfunc() {
local code="$(cat)"
local fn="$(cat <<EOFF
$1() {
node <(cat <<EOF
require('stream').Readable.prototype.then = function (...args) { return new Promise((res, rej) => { const bufs = []; this.on('error', rej).on('data', buf => bufs.push(buf)).on('end', () => res(Buffer.concat(bufs))); }).then(...args) };
(async () => {
${code}
})().then(val => typeof val !== 'undefined' && console.log(typeof val === 'string' ? val : JSON.stringify(val, null, 2))).catch(err => console.error(err.stack) || process.exit(1));
@mrienstra
mrienstra / unregisterServiceWorkers.js
Created February 4, 2018 22:10
Unregister service workers, verbose
navigator.serviceWorker.getRegistrations().then(function (registrations) {
if (!registrations.length) {
console.log('No serviceWorker registrations found.')
return
}
for(let registration of registrations) {
registration.unregister().then(function (boolean) {
console.log(
(boolean ? 'Successfully unregistered' : 'Failed to unregister'), 'ServiceWorkerRegistration\n' +
(registration.installing ? ' .installing.scriptURL = ' + registration.installing.scriptURL + '\n' : '') +
@kentcdodds
kentcdodds / README.md
Created October 25, 2017 22:01
Rendering a function with React

Rendering a function with React

No, this isn't about render props

I'm going to clean this up and publish it in my newsletter next week!

Context

So react-i18n (not the npm one... one we made at PayPal internally) has this

@sombriks
sombriks / bar.js
Last active March 30, 2017 16:07
mocha+chai+budo+nightmare
"use strict"
const Nightmare = require("nightmare");
const expect = require("chai").expect;
const budo = require("budo");
describe("\u263C basic tests \u263E", () => {
const b = budo("../src/main.js");
@dersam
dersam / gitkraken.zsh
Last active May 28, 2024 22:14
Open GitKraken using the current repo directory in the cli.
## Open GitKraken using the current repo directory.
## For when you want a prettier view of your current repo,
## but prefer staying in the cli for most things.
## This will break if GitKraken ever removes the -p flag.
## If you're not using OSX, the path is definitely different.
kraken () {
~/Applications/GitKraken.app/Contents/MacOS/GitKraken -p $(pwd)
}