Skip to content

Instantly share code, notes, and snippets.

@bravo-kernel
bravo-kernel / Test-ProofOfConcept.ps1
Created July 28, 2020 11:55
Simple Powershell ecrypt/decrypt
Add-Type -AssemblyName System.Security
function Encrypt-String {
param(
$String,
$Pass,
$salt = "CreateAUniqueSalt",
$init = "CreateAUniqueInit"
)
try {
@bravo-kernel
bravo-kernel / app.hooks.js
Last active September 23, 2019 10:51
Feathers: converting 0/1 to booleans (and vice versa). See comment for an explanation.
// Application hooks that run for every service
const { disallow } = require('feathers-hooks-common');
const log = require('./hooks/log');
const castResultIntegersToBoolean = require('./hooks/cast-result-integers-to-boolean');
const castQueryParamBooleansToInteger = require('./hooks/cast-query-param-booleans-to-integer');
// import uncastQueryParamBooleans from ('./hooks/uncast-query-param-booleans');
module.exports = {
before: {
all: [
@bravo-kernel
bravo-kernel / azure-pipelines.yml
Created September 2, 2019 17:12
Deploying a Feathers server/api to Azure App Service
# ---------------------------------------------------------------------------------------------------------------------
# Azure Pipeline for building and testing Feathers Server using Node.js Express Web App on Azure Linux.
#
# - uses templates found in `.azure-templates/`
# - requires installing https://marketplace.visualstudio.com/acquisition?itemName=mspremier.BuildQualityChecks
#
# More information about the Azure Pipelines YAML schema used in this file at https://aka.ms/yaml
# ---------------------------------------------------------------------------------------------------------------------
@bravo-kernel
bravo-kernel / schema.yaml
Created August 2, 2019 09:49
OpenAPI v3 document
info:
title: P2 API
description: A description
version: 0.0.1
paths:
/folders:
get:
parameters:
- description: Number of results to return
in: query
@bravo-kernel
bravo-kernel / folders.js
Last active July 31, 2019 10:47
Feathers sequelize-model-to-json-schema
module.exports = function (app) {
const sequelizeClient = app.get('sequelizeClient');
const folders = sequelizeClient.define('folders', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
allowNull: false,
primaryKey: true
@bravo-kernel
bravo-kernel / folders.json
Created July 3, 2019 16:49
Nested API response
[
{
"id": "fc109bae-368a-449a-854a-ab3021f6ca7a",
"name": "Business",
"userId": "3e78a2a7-d2f4-4c4a-9502-4b55f3591e04",
"parentId": "434d5cfe-846a-4656-8494-85b233bd9b6d",
"hierarchyLevel": 2,
"createdAt": "2019-07-02T14:13:34.000Z",
"updatedAt": "2019-07-02T14:13:34.000Z",
"children": []
<template>
<div id="FoldersPage">
<!-- new root folder -->
<div class="w-full text-center mt-10">
<!-- alert -->
<TheErrorAlert :error="error" />
<!-- new folder form -->
@bravo-kernel
bravo-kernel / Login.vue
Last active June 30, 2019 18:43
Store definition using feathers-vuex 3.x
<template>
<div class="container mx-auto h-full flex justify-center items-center sm:mt-5 md:mt-20">
<div id="login" class="w-full max-w-xs">
<h3 class="mb-5 pl-4">Sign in</h3>
<!-- alert -->
<div v-if="error" class="bg-red-100 border-t border-b border-red-500 text-red-700 px-4 py-3 mb-10" role="alert">
@bravo-kernel
bravo-kernel / lodash-recurse-deep.js
Last active June 28, 2019 06:40
Using lodash to recursively add a property to all leafs in deeply nested array with objects
var obj = [
{
"id": "1",
},
{
"id": "2",
},
{
"id": "3",
"children": [
<template>
<div id="login" class="container mx-auto h-full flex justify-center items-center sm:mt-5 md:mt-20">
<div id="login" class="w-full max-w-xs">
<h3 class="mb-5 pl-4">Sign in</h3>
<form method="post" @submit.prevent="onSubmit(email, password)" class="bg-white border rounded px-8 pt-6 pb-8 mb-4" >
<div class="mb-4">