Skip to content

Instantly share code, notes, and snippets.


Pier Bover PierBover

View GitHub Profile
PierBover / index.js
Last active Sep 22, 2020
FaunaDB client aggregation example
View index.js
const faunadb = require('faunadb');
const q = faunadb.query;
const client = new faunadb.Client({
async function countDocs () {
const refs = [];
let after, page;
PierBover / rename_layer.jsx
Created Sep 17, 2020
Rename Photoshop Layers
View rename_layer.jsx
var activeLayerRef = app.activeDocument.activeLayer;
if (activeLayerRef.artLayers) {
var layers = activeLayerRef.artLayers;
for (var i = 0; i < layers.length; i++) {
layers[i].name = + '_' + (i+1);
PierBover / fql.js
Created Aug 14, 2020
All FQL commands for JS
View fql.js
// All FQL commands
const {
Abort, Abs, Acos, Add, All, And, Any, Append, Asin, At, Atan, BitAnd, BitNot, BitOr, BitXor, Call, Casefold, Ceil, Collection, Collections, Concat, Contains, ContainsStr, ContainsStrRegex, Cos, Cosh, Count, Create, CreateCollection, CreateDatabase, CreateFunction, CreateIndex, CreateKey, CreateRole, Database, Databases, Date, DayOfMonth, DayOfWeek, DayOfYear, Degrees, Delete, Difference, Distinct, Divide, Do, Documents, Drop, EndsWith, Epoch, Equals, Events, Exists, Exp, Filter, FindStr, FindStrRegex, Floor, Foreach, Format, Function, Functions, GT, GTE, Get, HasIdentity, Hour, Hypot, Identify, Identity, If, Index, Indexes, Insert, Intersection, IsArray, IsBoolean, IsBytes, IsCollection, IsCredentials, IsDatabase, IsDate, IsDoc, IsDouble, IsEmpty, IsFunction, IsIndex, IsInteger, IsKey, IsLambda, IsNonEmpty, IsNull, IsNumber, IsObject, IsRef, IsRole, IsSet, IsString, IsTimestamp, IsToken, Join, KeyFromSecret, Keys, LT, LTE, LTrim, Lambda, Length, Let, Ln, Log, Login, Logout, Lower
PierBover / cloudflare-countries.json
Created Jun 1, 2020
Cloudflare countries with regions
View cloudflare-countries.json
{"code":"A1", "name":"Anonymous Proxy", "region":"NO_REGION"},
{"code":"A2", "name":"Satellite Provider", "region":"NO_REGION"},
{"code":"O1", "name":"Other Country", "region":"NO_REGION"},
{"code":"AD", "name":"Andorra", "region":"EUROPE"},
{"code":"AE", "name":"United Arab Emirates", "region":"MIDDLE_EAST"},
{"code":"AF", "name":"Afghanistan", "region":"MIDDLE_EAST"},
{"code":"AG", "name":"Antigua and Barbuda", "region":"CARIBBEAN"},
{"code":"AI", "name":"Anguilla", "region":"CARIBBEAN"},
{"code":"AL", "name":"Albania", "region":"EUROPE"},
View fastify.js
// init
const fastify = require('fastify')({
ignoreTrailingSlash: true,
logger: true
method: 'GET',
url: '/',
handler: (request, reply) => {
PierBover /
Last active Jun 24, 2020
Tools to test the performance of your website worldwide
View rollup-plugin.js
const routesFilesPlugin = {
name: 'route-files',
buildStart: async (options) => {
console.log('Generating routeModules.js');
const routesDir = path.resolve(__dirname, 'src/components/routes');
const routeFiles = fs.readdirSync(routesDir);
const routesString = => {
PierBover /
Created May 8, 2020
FQL recursive function to get nested documents

This is how you'd call the function:

Call(Function("GetNestedDocument"), [Ref(Collection("SomeCollection"), "264260207986606612"), 0, 3])


  • A Ref of a document.
  • Current depth. Since AFAIK we cannot have default values in Lambda we need to pass 0 for the first level.
  • Max depth. The max number of levels the recursive function will go.
PierBover / index.js
Last active Aug 22, 2020
Micro router for Cloudflare Workers
View index.js
const router = require('./router');
path: '/ping',
method: 'GET',
handler: ping
path: '/hello/:name',
PierBover / AppDelegate.swift
Last active Sep 2, 2019
Receive custom URL schema in macOS
View AppDelegate.swift
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
NSAppleEventManager.shared().setEventHandler(self, andSelector: #selector(self.handleGetURLEvent(event:replyEvent:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
@objc func handleGetURLEvent(event: NSAppleEventDescriptor, replyEvent: NSAppleEventDescriptor) {
let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue!
let url = URL(string: urlString!)!
You can’t perform that action at this time.