Skip to content

Instantly share code, notes, and snippets.

View wtho's full-sized avatar
馃寣

wtho wtho

馃寣
  • Bengaluru, India
View GitHub Profile
@wtho
wtho / !ApiKeysForTesting.md
Last active January 23, 2017 22:20
inlcude gitignored api-keys by gradle for junit testing

gitignored ApiKeys accessed through gradle in JUnit tests

This is a method to store api keys locally in an api-keys.properties file, ignored by git, but still using them in JUnit tests, as they get loaded by gradle before tests and can be accessed then by the test class through System.getProperty().

@wtho
wtho / slide-in-out-bar.component.ts
Last active August 6, 2017 16:07
Angular 4.3.3 working enter and leave Animation (with *ngIf)
import { Component, Input } from '@angular/core';
import { trigger, style, animate, transition, keyframes } from '@angular/animations';
@Component({
selector: 'my-bar', // <my-app></my-app>
template: `
<div class="containit">
<div class="lined-content" *ngIf="visible" [@shiftUpDown]="visible">line</div>
</div>
<div class="other">Some content below</div>
@wtho
wtho / emit-options-webpack-plugin.js
Last active October 20, 2017 22:06
Output Webpack Option as Single Object using custom Plugin
const fs = require('fs')
const jsonFormat = require('json-format')
class EmitOptionsWebpackPlugin {
constructor(pluginOptions) {
this.pluginOptions = { pretty: true, throwError: false, path: 'options.json', ...pluginOptions }
}
apply(compiler) {
// create JSON from js object (will loose all functions such as Plugins)
@wtho
wtho / map-get-setters.js
Last active November 9, 2017 21:52
Vuex mapGetSetters method
export function mapGetSetters(object) {
const resolved = {}
const getters = {}
const setters = []
Object.keys(object).forEach(key => {
resolved[key] = {}
const value = object[key]
if (typeof value === 'string') {
getters[key] = value
@wtho
wtho / !SetupDebuggingWithVSCodeWebpackTypeScript.md
Last active July 16, 2025 13:23
Configure launch.json in vscode for Webpack + TypeScript

How to setup Debugging with VSCode + Webpack + TypeScript

  1. Activate sourceMaps if running with TypeScript
  2. Make sure Chrome/Chromium runs with debugging on Port 9222 => Close Chrome and restart with the flag --remote-debugging-port=9222
  3. If in attach-mode, an url, or better: urlFilter is required: "urlFilter": "http://localhost:4200/*"
  4. Set the webRoot to your src folder: "webRoot": "${workspaceFolder}/src"
  5. To fix the source map matching, add sourceMapPathOverrides:

"sourceMapPathOverrides": {

@wtho
wtho / email-sld-regex.js
Last active December 27, 2018 22:16
Email-Validator that requires SLD for vue-form
const emailRegex = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@([a-z0-9][a-z0-9-]*)*[a-z0-9]\.[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
// SLD = second layer domain
const emailWithSld = function (value, attrValue, vnode) {
return emailRegex.test(value);
};
export const customValidators = {
emailWithSld
};
@wtho
wtho / join-monster-graphql14-fix.ts
Created November 14, 2018 21:40
Join Monster graphql-js v14 Fix
import { GraphQLObjectTypeConfig } from 'graphql'
import { ThunkWithArgsCtx, GraphQLObjectType } from 'graphql/type/definition'
interface OnlyJMGraphQLObjectTypeConfig<S, C> {
alwaysFetch?: string
sqlTable?: ThunkWithArgsCtx<string, any, C>
uniqueKey?: string | string[]
}
/** MonkeyPatching GraphQLObjectType Constructor to give join monster access to config */
blog:how-to-become-stronger-everyday,ts:2017-12-14
@wtho
wtho / cvimrc.js
Last active March 28, 2019 10:16
cvim config
let blacklists = ["http://localhost*","http://192.168.2.131/*","https://localhost*","https://pvmonitor.ml/*","https://stackblitz.com/*","https://*.stackblitz.io/*","https://emulatoronline.com/*"]
let defaultengine = 'duckduckgo'
@wtho
wtho / !no-class-id-serializer.md
Last active March 28, 2019 11:23
DOM element rendering without Angular's class ids

Quick Install

  • npm install --save-dev --save-exact pretty-format@24.0.0
  • copy DOMElementNoClassIdSnapshotSerializer.js to your project folder
  • add './DOMElementNoClassIdSnapshotSerializer.js' to snapshotSerializers in your jest config

Problem

Angular does create HTML for components like this:

<h1 class="ng-tns-c1-0">
 app works!