Skip to content

Instantly share code, notes, and snippets.

Avatar
💛
❤️💚💙

Gregor Martynus gr2m

💛
❤️💚💙
View GitHub Profile
@gr2m
gr2m / github-action-cypress-against-now-deployment.yaml
Created Mar 2, 2020
Example GitHub Action workflow which runs Cypress using now's deployment for the current commit. See https://mobile.twitter.com/gr2m/status/1234602143719419904
View github-action-cypress-against-now-deployment.yaml
name: End-to-end tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
@gr2m
gr2m / create_new_octokit_js_repository.md
Last active Oct 8, 2019
I found myself create new Octokit repositories all the time, due to its decomposable and extendable architecture. Here is how I do it for future reference. Ideally, this would all be automated using an `npm init octokit` script
View create_new_octokit_js_repository.md

Create new Octokit (JS) repository

Example

  • repository name: action.js
  • description: GitHub API client for GitHub Actions
# create new folder and change into it
mkdir action.js
@gr2m
gr2m / using_ecmascript_modules_for_octokit.md
Last active Oct 9, 2019
Living document to make the Octokit JS libraries (https://github.com/octokit?utf8=%E2%9C%93&q=.js&type=&language=) work with ECMAScript Modules, Common JS and modern browsers
View using_ecmascript_modules_for_octokit.md

My usecase: Universal JavaScript libraries for GitHub's APIs for Node.js and modern browsers.

All libraries are written in Typescript, so a build step is necessary which makes it easier to seperate the source code structure from the distribution code structure. I rely heavily on pika.dev for creating browser bundles and distributing them via their CDN. Example: https://github.com/octokit/request.js/#usage.

I use @pika/pack to create a ./pkg folder with multiple distributions right before publishing to npm. Example: https://unpkg.com/browse/@octokit/request@5.1.0/

Currently, the dist-web/ folder is the ECMAScript Module export, it's referenced using the "module" key in its package.json. The dist-node/ folder is referenced using the "main" key in its package.json.

Besides the differentiation of common

@gr2m
gr2m / worker.js
Created Aug 27, 2019
A Cloudflare worker to exchange an OAuth Web Flow code for an access token. Configure your CLIENT_ID and CLIENT_SECRET and you are all set.
View worker.js
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
const CLIENT_ID = '<your client ID>'
const CLIENT_SECRET = '<your client Secret>'
async function handleRequest(request) {
if (request.method === 'GET') {
return new Response(`$ curl -XPOST -H'Content-Type: application/json' -d'{"code": "<your oauth code>"}' ${request.url}`)
@gr2m
gr2m / octokit_pika_build_setup.md
Last active Aug 16, 2019
This is a living document on JavaScript Octokit’s build setup using pika pack and semantic-release on GitHub Actions
View octokit_pika_build_setup.md

Octokit.js build setup using @pika/pack

Install @pika/pack and build plugins

npm install --save-dev @pika/pack @pika/plugin-build-node @pika/plugin-build-web @pika/plugin-ts-standard-pkg

Configuration

View 01_README.md

Local setup

git clone git@gist.github.com:48ad793b3fb7dbb59bcd696bbf75baee.git github-lock-issue-test
cd github-lock-issue-test
npm install
node github-lock-issue-test.js

Should log

@gr2m
gr2m / list_offlinefirst_posts.graphql
Created Jul 19, 2017
With GitHub’s new GraphQL API, you can send a single request to list of files with their content. Try it out on https://developer.github.com/v4/explorer/
View list_offlinefirst_posts.graphql
{
organization(login: "offlinefirst") {
repository(name: "offlinefirst.org") {
object(expression: "gh-pages:_posts/") {
... on Tree {
entries {
object {
... on Blob {
text
}
@gr2m
gr2m / linked_in_delete_all_messages.js
Created Mar 2, 2017
This will delete all your messages on linked in. Run on https://www.linkedin.com/messaging/?trk=nav_utilities_inbox. You are welcome :)
View linked_in_delete_all_messages.js
$('[data-control-name=clear_conversation]').each(function(){this.click();$('[data-control-name=clear_conversation_confirm]').click()})
View hoodie-updates-nov-2016.md

November was a Dev Beaver-kind of month. Lots of development in preparation for the Hoodie Village release. Dale from Appback started working on Hoodie’s Task Module, the last big piece left to finish for Hoodie’s new plugin architecture. Benjamin did not only get 4 pull requests merged, he is also working on enabling app-specific plugins, very soon: https://github.com/hoodiehq/hoodie/pull/637. If you are interested how a plugin will look like, we created an example: https://github.com/hoodiehq/hoodie-plugin-example.

You can’t perform that action at this time.