Skip to content

Instantly share code, notes, and snippets.

Avatar

Pier Bover PierBover

View GitHub Profile
@PierBover
PierBover / fauna_parser.js
Created Nov 20, 2020
Fauna object parser
View fauna_parser.js
export function faunaDocToObject (item) {
if (Array.isArray(item)) {
return item.map(itemArray => faunaDocToObject(itemArray));
}
if (item && typeof item === 'object') {
const object = {};
View rename_layers_groups.jsx
var groups = app.activeDocument.layerSets;
var first = parseInt(groups[0].name);
for (var i = 0; i < groups.length; i++) {
var groupName = first + i;
groups[i].name = groupName;
var layers = groups[i].artLayers;
@PierBover
PierBover / rename_groups.jsx
Created Nov 13, 2020
Rename groups photoshop script
View rename_groups.jsx
var groups = app.activeDocument.layerSets;
var first = parseInt(groups[0].name);
for (var i = 1; i < groups.length; i++) {
groups[i].name = first + i;
}
@PierBover
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({
secret: 'YOUR_FAUNA_SECRET'
});
async function countDocs () {
const refs = [];
let after, page;
@PierBover
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 = activeLayerRef.name + '_' + (i+1);
}
}
@PierBover
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
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
});
fastify.route({
method: 'GET',
url: '/',
handler: (request, reply) => {
@PierBover
PierBover / website_performance.md
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 = routeFiles.map((filename) => {