Skip to content

Instantly share code, notes, and snippets.

View k9ordon's full-sized avatar
🐙

Klemens Gordon k9ordon

🐙
View GitHub Profile
@TheRealFlyingCoder
TheRealFlyingCoder / .Keystone.js with Docker and Fly.io
Last active January 10, 2023 13:24
Keystone.js with Docker and Fly.io
So once you figure out all the caveats, running Keystone on Docker and in Fly.io is relatively simple.
package.json:
You need --fix on your setup script for Docker to auto update the schemas
"setup": "keystone postinstall --fix"
NOTES FOR DOCKER:
1. I use Yarn V3 in a monorepo hence the corepack lines and project structure
page.includeJs("http://www.google.com/jsapi?key=AIzaSyA5m1Nc8ws2BbmPRwKu5gFradvD_hgq6G0", function() {
page.evaluate(function() {
google.load("feeds", "1");
var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
feed.includeHistoricalEntries(); // tell the API we want to have old entries too
feed.setNumEntries(250); // we want a maximum of 250 entries, if they exist
feed.load();
@codingwithchris
codingwithchris / KEYSTONE-JS-ACCESS-CONTROL.MD
Last active March 16, 2022 09:25
Unpacking Keystone JS Access Control (a security-focused perspective)

Access Control (Creating a Secure and Trusted Application)

Access control is critical to the security of our application. Beyond proper credential encryption, hashing, SALTing etc, access control is the next line of defense in protecting our users data.

Role Based Access Control Methodology (RBAC)

When giving elevated access to a User for a particular part of the system, we use a methodology called RBAC. This means that we create Roles where we assign permissions and apply filter policies. These Roles then get assigned to Users who have their CRUD access to Lists, Records, and Fields determined accordingly.

Our Access Control Philosophy

@mcevskb
mcevskb / trakt-remove-history.js
Last active July 8, 2021 21:07 — forked from hugoboos/trakt-remove-history.js
Remove duplicate episodes from Trakt
// Run in console on the history page (http://trakt.tv/users/<username>/history)
// Will remove all the duplicate episodes, on that page, from the watched history.
var episodesRemoved = []
// episodeItems = $("[data-type=episode]")
episodeItems.each(function(){
var $this = $(this);
var episodeId = $this.data('episode-id')
var showId = $this.data('show-id')
@datchley
datchley / es6-eventemitter.js
Last active June 7, 2021 03:40
A straight forward EventEmitter implemented in Javascript using ES6
let isFunction = function(obj) {
return typeof obj == 'function' || false;
};
class EventEmitter {
constructor() {
this.listeners = new Map();
}
addListener(label, callback) {
this.listeners.has(label) || this.listeners.set(label, []);
@Couto
Couto / webpack.js
Last active November 11, 2020 17:53
Fetch polyfill with webpack
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var folders = {
APP: path.resolve(__dirname, '../app'),
BUILD: path.resolve(__dirname, '../build'),
BOWER: path.resolve(__dirname, '../bower_components'),
NPM: path.resolve(__dirname, '../node_modules')
};
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@Daniel-Hug
Daniel-Hug / delegate-event.js
Last active September 14, 2020 05:05
Vanilla JS equivalent of jQuery's .live(): use event delegation to handle events whose target matches a selector, closest(): get nearest parent element matching selector
// get nearest parent element matching selector
var closest = (function() {
var el = HTMLElement.prototype;
var matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
return function closest(el, selector) {
return matches.call(el, selector) ? el : closest(el.parentElement, selector);
};
})();
@nathansmith
nathansmith / screwed.js
Last active June 10, 2020 17:01
Force yourself to learn JavaScript.
// If you're a glutton for punishment, and/or claim
// that JavaScript libraries have too much "bloat",
// use this to force yourself to write JS longhand.
(function(window) {
function screwed() {
window._ = null;
window.$ = null;
window.$A = null;
window.$F = null;
@njbotkin
njbotkin / README.md
Last active December 19, 2019 13:25
Trigger SPA reloads without server polling with Cloudflare Workers

How it works:

  1. On app deploy, autoincrement Cloudflare KV value
  2. Cloudflare Worker adds a "version" cookie to every Response with the content from the KV
  3. Client checks cookies periodically to see if the "version" cookie has changed. If so, reload page