Skip to content

Instantly share code, notes, and snippets.

View monostere0's full-sized avatar

Daniel monostere0

  • Amsterdam, Netherlands
View GitHub Profile
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
<lots of information about the resources that Terraform is about to create>
Plan: 15 to add, 0 to change, 0 to destroy.
@monostere0
monostere0 / main.tf
Last active August 10, 2021 06:53
Terraform VPC
provider "aws" {
version = "~> 2.0"
region = "eu-central-1"
}
# VPC
resource "aws_vpc" "tf_vpc" {
cidr_block = "10.0.0.0/16"
tags = {
const assert = require('assert');
function solution(array) {
const k = array.length / 4;
let buffer = [];
return flatten(array.reduce((a, b, i) => {
buffer.push(b);
if (b !== array[i + 1]) {
a.push(buffer);
buffer = [];
@monostere0
monostere0 / enzyme_render_diffs.md
Created February 4, 2019 09:44 — forked from fokusferit/enzyme_render_diffs.md
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@monostere0
monostere0 / http-service.ts
Created August 18, 2016 11:38 — forked from tomasstankovic/http-service.ts
Angular 2 Http interceptor
import { Injectable } from '@angular/core';
import {
Http,
ConnectionBackend,
RequestOptions,
RequestOptionsArgs,
Response,
Headers
} from '@angular/http';
import { Observable } from 'rxjs/Observable';
@monostere0
monostere0 / destructuring.js
Created April 25, 2016 15:05 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => {
return [1, 2, 3];
@monostere0
monostere0 / lodash_browser_json_transformer.js
Last active August 11, 2016 15:20
Lodash in-browser JSON transformer
(function() {
/*
* LODASH in-Browser JSON transformer
* Use this in a bookmarket (save its contents in a bookmark) and whenever you open a JSON response (e.g. https://www.reddit.com/.json)
* you can use it to test lodash methods against the data.
* Lodash is exposed on window as _ and "json" global variable contains the data within the browser window.
*
* Copy the line below and save it as the url of a new bookmark (it's the same code as below but minified for bookmark use):
* javascript:!function(){function onScriptLoaded(){window.json=JSON.parse(JSON.stringify(initialJSONCode)),display(window.json),input.addEventListener("input",onInput),document.body.appendChild(input),document.body.appendChild(info)}function onInput(t){if(!t.target.value)return display(initialJSONCode),void setInputState(t.target,"success");var e=wrap(t.target.value);e&&"object"==typeof e?(setInputState(t.target,"success"),display(e)):setInputState(t.target,"error")}function display(t){pre.innerText?pre.innerText=J
@monostere0
monostere0 / format.json.bookmarklet.js
Last active December 8, 2022 04:44
Format JSON bookmarklet
javascript:!function(){var n,e,r,i;n=window,e=document.body,r=JSON.parse,i=JSON.stringify,n.isf||(e.innerHTML="<pre>"+i(r(e.innerText),null,4).replace(/\"(.*)[^\:]\:/g,'<span style="color:#9C3636">$1&colon;</span>')+"</pre>",n.isf=!0)}();
//usage:
//save as bookmark and click it whenever you open a json response in a browser tab/window
@monostere0
monostere0 / get.js
Last active October 27, 2016 14:04
Get object path
function get(obj, path) {
let spl;
return new Function(
`return arguments[0]&&${(spl = path.split('.')).reverse().map((prop, index) => {
return `arguments[0].${spl.slice(spl.length - index - 1).reverse().join('.')}`;
}).join('&&')}`)(obj);
}
//usage:
// const hello = {world:{foo:{bar:baz:1}}}
@monostere0
monostere0 / window.location.searchJSON.js
Last active February 19, 2020 08:11
Retrieve the query string params as JS object
Object.defineProperty(location, 'searchJSON', {
get: function() {
var a = window.location,
b = a.href.split('?'),
c = a.search;
return (c.slice(1) || (b.length > 1 && b[1]) || '').split("&").reduce(function(p, c) {
return (c = c.split("=")) && (p[c[0]] = unescape(c[1])) && p
}, {}) || {};
},
enumerable: false,