Skip to content

Instantly share code, notes, and snippets.

View petervmeijgaard's full-sized avatar
🎸
Rocking!

Peter van Meijgaard petervmeijgaard

🎸
Rocking!
View GitHub Profile
@petervmeijgaard
petervmeijgaard / run.ts
Last active May 11, 2023 14:56
Object entries performance test
import * as R from "remeda";
const generateInput = (amountOfEntries: number) => {
const entries = Array.from<never[], [string, string]>(
{ length: amountOfEntries },
(_, index) => [`KEY_${index}`, `VALUE_${index}`]
);
return Object.fromEntries(entries);
};
@petervmeijgaard
petervmeijgaard / AsCompositionApi.vue
Last active July 15, 2021 19:08
Writing Reusable Vue Composables - Introduction - Composition API
<template>
<div>
<p>My Number - {{ myNumber }}</p>
<p>Parent Number - {{ parentNumber}} - {{ parentNumberPlusOne }}</p>
<button @click="addNumber()">
Add
</button>
</div>
</template>
@petervmeijgaard
petervmeijgaard / AsOptionsApi.vue
Last active July 15, 2021 18:57
Writing Reusable Vue Composables - Introduction - Options API
<template>
<div>
<p>My Number - {{ myNumber }}</p>
<p>Parent Number - {{ parentNumber}} - {{ parentNumberPlusOne }}</p>
<button @click="addNumber()">
Add
</button>
</div>
</template>
@petervmeijgaard
petervmeijgaard / objectToDotNotation.js
Last active June 14, 2021 08:03
Recursive Object to Dot Notation Helper
const isObject = value => typeof value === 'object' && value !== null && !Array.isArray(value);
const getDottedKey = (current, parent = null) => (parent ? `${parent}.${current}` : current);
const objectToDotNotation = (value, key = null, carry = {}) => {
if (!isObject(value) && !key) {
return value;
}
if (!isObject(value)) {
@petervmeijgaard
petervmeijgaard / PostController_v1.php
Created September 11, 2018 17:39
My take on the Repository Pattern
<?php
namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use App\Repositories\Contracts\PostRepository;
class PostController extends Controller
{
/**
@petervmeijgaard
petervmeijgaard / Todo.spec.js
Created September 18, 2017 15:21
Testing Vue components
import { shallow } from 'vue-test-utils'
import sinon from 'sinon'
import Todo from '@/components/Todo'
describe('Todo.vue', () => {
/**
* Test will check if the name of the component is todo.
*/
it('Is called todo', () => {
// Initialize the test.
@petervmeijgaard
petervmeijgaard / keybase.md
Created September 15, 2016 11:37
keybase.md

Keybase proof

I hereby claim:

  • I am petervmeijgaard on github.
  • I am petervmeijgaard (https://keybase.io/petervmeijgaard) on keybase.
  • I have a public key ASAe841CdWHVGt4RkG3Hjd5uxy2dcaIxAN6wZvtM75Nvngo

To claim this, I am signing this object:

@petervmeijgaard
petervmeijgaard / loader.js
Created July 30, 2016 09:59
Webpack Vue File Loader
export default {
file(file, async = false) {
console.log(file);
if (async) {
return (resolve) => {
require([`${file}`], resolve);
};
}
@petervmeijgaard
petervmeijgaard / elixir.json
Created July 20, 2016 21:11
Laravel elixir problem
{
"stylus": {
"input": "./resources/area/frontend/stylus/app.styl",
"output": "public/frontend/css/app.css"
},
"version": {
"input": [
"public/frontend/css/app.css"
],
"output": "./public/frontend/build"
@petervmeijgaard
petervmeijgaard / webpack.config.js
Last active August 9, 2016 15:30
webpack.config.js
var webpack = require('webpack')
var path = require('path')
module.exports = {
entry: './src/index.js',
output: {
path: './dist/',
filename: 'index.js',
library: 'VueComponents',
libraryTarget: 'umd'