Skip to content

Instantly share code, notes, and snippets.

View NarHakobyan's full-sized avatar
🎯
Focusing

Narek Hakobyan NarHakobyan

🎯
Focusing
View GitHub Profile
@NarHakobyan
NarHakobyan / package.json
Created November 27, 2020 14:14
Yarn monorepo example
{
"name": "@monorepo/root",
"private": true,
"workspaces": {
"packages": [
"packages/*"
],
"main": "index.ts",
"nohoist": [
"**/tslint-eslint-rules",
@NarHakobyan
NarHakobyan / take-if.validator.ts
Last active November 11, 2019 21:10
take-if.validator.ts
export function TakeIf<T>(func: (data: T) => boolean, validationOptions?: ValidationOptions) {
return (object: T, propertyName: string) => {
const args: ValidationMetadataArgs = {
validationOptions,
propertyName,
type: ValidationTypes.CONDITIONAL_VALIDATION,
target: object.constructor,
constraints: [(obj: any, _: any) => {
const isOptional = func(obj);
@NarHakobyan
NarHakobyan / lodash_get.ts
Last active September 13, 2019 07:08
Type safe lodash get function
function get<B, C = undefined>(func: () => B, defaultValue?: C): B | C | undefined {
try {
const value = func();
if (typeof value === 'undefined') {
return defaultValue;
}
return value;
} catch {
return defaultValue;
@NarHakobyan
NarHakobyan / vee-validate-child-component.txt
Created January 15, 2019 11:44
vee-validate in child components
Parent Component:
...
provide () {
return { parentValidator: this.$validator }
},
...
Child Component:
@NarHakobyan
NarHakobyan / dynamic-script.js
Created November 18, 2018 12:55
javascript dynamic script load
// Create script tag
const stripeScript = document.createElement('script');
//add necessary html attributes
stripeScript.setAttribute('type', 'text/javascript');
stripeScript.setAttribute('src', 'https://js.stripe.com/v3/');
// add listener for which will trigger when script will fully loaded
stripeScript.addEventListener('load', () => {
console.log(window['Stripe']);
@NarHakobyan
NarHakobyan / tslint.json
Created May 2, 2018 09:09
Angular 5 tslint prettier best practice
{
"extends": [
"tslint:latest",
"tslint-eslint-rules",
"tslint-config-prettier"
],
"rulesDirectory": [
"node_modules/codelyzer",
"node_modules/tslint-origin-ordered-imports-rule/dist",
"node_modules/tslint-consistent-codestyle/rules",
@NarHakobyan
NarHakobyan / android-react-native-log.sh
Created December 14, 2017 14:52
see android logs in react-native application
adb logcat *:S ReactNative:V ReactNativeJS:V
@NarHakobyan
NarHakobyan / gist:5120e097b8f1012c0758fb7b4be45e9e
Created October 26, 2017 18:40 — forked from jnhuynh/gist:86693d8b485f4d335300
React Native Directory Structure
.
├── index.ios.js
├── js
│   ├── actions
│   │   ├── ChatServerActionCreators.js
│   │   └── ChatThreadActionCreators.js
│   ├── components
│   │   ├── ChatScreen
│   │   │   ├── index.js
@NarHakobyan
NarHakobyan / killport
Last active October 12, 2017 10:50
kill port of ubuntu
#!/bin/sh
PNUMPER=$1;
kill -9 `lsof -w -n -i tcp:$PNUMPER| awk '{print $2}'|awk 'END{print}'`;
#killport {{PORT}}
import { Injectable } from '@angular/core';
import { BaseRequestOptions, RequestOptions } from '@angular/http';
import { AuthService } from './auth.service';
@Injectable()
export class DefaultRequestOptions extends BaseRequestOptions {
constructor(private authService: AuthService) {
super();