Skip to content

Instantly share code, notes, and snippets.

View gr2m's full-sized avatar
🧚
automatin'

Gregor Martynus gr2m

🧚
automatin'
View GitHub Profile
@gr2m
gr2m / payments_dreamcode.js
Last active April 29, 2024 19:17
Imagine you could purchase items from your store, with pure JavaScript in the browser. How would it look like? Here's what I came up with. Forks & comments much appreciated! #nobackend #dreamcode
// purchase a product with a credit card
purchase('productId')
.using( {
cc: "4556934156210213",
valid: "2016-10",
csc: "123"
} )
// purchase a product with paypal
purchase('productId')
@gr2m
gr2m / account_dreamcode.js
Last active May 7, 2022 08:22
Imagine the typical backend tasks for user authentication would exist right in the browser. How would the code look like? This is what I came up with. Forks & comments much appreciated! #nobackend #dreamcode
// sign up
account.signUp('joe@example.com', 'secret');
// sign in
account.signIn('joe@example.com', 'secret');
// sign in via oauth
account.signInWith('twitter');
// sign out
// Menu: Create gist from clipboard
// Description: Creates a new GitHub Gist with the contents of your current clipboard
// Author: Gregor Martynus
// Twitter: @gr2m
// https://github.com/gr2m/scriptkit-octokit/
const { Octokit } = await npm("scriptkit-octokit");
const octokit = new Octokit({
auth: {
scopes: ["gist"],
// Menu: Set GitHub Status with Octokit
// Description: Sets the status text on your GitHub Profile
const { Octokit } = await npm("scriptkit-octokit");
const octokit = new Octokit({
auth: {
scopes: ["user"],
env: "GITHUB_TOKEN_SET_USER_PROFILE",
},
});
//Shortcut: command shift -
// Menu: Set GitHub Status
// Description: Sets the status text on your GitHub Profile
const message = await arg("What would you like to say?");
const token = await env("GITHUB_STATUS_TOKEN", {
secret: true,
ignoreBlur: true,
hint: md(
`Create a token [on GitHub](https://github.com/settings/tokens/new?scopes=user&description=kit%20script)`
@gr2m
gr2m / copy-github-name.js
Last active April 30, 2021 21:12
A Kit script (https://www.scriptkit.com/) to copy the first name of a GitHub user
// Menu: Copy GitHub user name
// Description: Copies a GitHub user's first name, fallback to @login
// Author: Gregor Martynus
// Twitter: @gr2m
const { Octokit } = await npm("octokit");
const { createOAuthDeviceAuth } = await npm("@octokit/auth-oauth-device");
// set GitHub Token unless it's already set
@gr2m
gr2m / demo.gif
Last active February 24, 2021 23:55
Deno script which uses Octokit with the OAuth Device authentication strategy
demo.gif
@gr2m
gr2m / email_dreamcode.js
Last active January 28, 2021 15:10
Imagine you could send emails with JavaScript, multipart, and with attachments?! How would the code look like? This is what I came up with. Forks & comments much appreciated! #nobackend #dreamcode
// send text email
sendEmail({
subject: "Hello, World!",
text: "This mail has been sent from the frontend",
to: "joe@exam.pl"
})
// send multipart text / html email
sendEmail({
subject: "Hello, World!",