Skip to content

Instantly share code, notes, and snippets.

@nicgene
nicgene / vue.md
Created July 19, 2021 22:05 — forked from DawidMyslak/vue.md
Vue.js and Vuex - best practices for managing your state

Vue.js and Vuex - best practices for managing your state

Modifying state object

Example

If you have to extend an existing object with additional property, always prefer Vue.set() over Object.assign() (or spread operator).

Example below explains implications for different implementations.

@nicgene
nicgene / cloudflareworker-verifyjwt.js
Created April 11, 2021 00:15 — forked from bcnzer/cloudflareworker-verifyjwt.js
Sample Cloudflare worker that gets the JWT, ensures it hasn't expired, decrypts it and returns a result
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
// Following code is a modified version of that found at https://blog.cloudflare.com/dronedeploy-and-cloudflare-workers/
/**
* Fetch and log a request
* @param {Request} request
*/
import { createConnection, createPool, createPoolCluster } from './interfaces';
interface promise {
createConnection: createConnection;
createPool: createPool;
createPoolCluster: createPoolCluster;
}
declare const mariadb: createConnection & createPool & createPoolCluster;
/// <reference types="node" />
export interface ConnectionOptions {
bigNumberStrings?: boolean;
bulk?: number;
charset?: string;
compress?: boolean;
logPackets?: boolean;
connectAttributes?: boolean | object; // ???
connectTimeout?: number;
@nicgene
nicgene / serverless.yml
Last active June 2, 2018 00:55
AWS Lambda and DynamoDB
service: serverless-aws-node-rest-api
provider:
name: aws
runtime: nodejs8.10
stage: dev
region: us-east-1
iamRoleStatements:
- Effect: Allow
Action:
@nicgene
nicgene / JwtRequestMethodPathRule.php
Created December 20, 2016 21:57
Rules to decide by HTTP verb (optional) and request path whether or not the request should be authenticated. This is a rule interface for tuupola/slim-jwt-auth - https://github.com/tuupola/slim-jwt-auth
<?php
/**
* This file is part of PSR-7 JSON Web Token Authentication middleware
*
* Copyright (c) 2015-2016 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
@nicgene
nicgene / app.js
Last active August 29, 2015 14:24
AngularJs Google Analytics Tracking
app.run(['$rootScope', '$window', '$location', function($rootScope, $window, $location) {
$rootScope.$on('$viewContentLoaded', function() {
$window.ga('send', 'pageview', { page: $location.path() } )
});
}]);