Skip to content

Instantly share code, notes, and snippets.

View ydomenjoud's full-sized avatar

ydomenjoud ydomenjoud

View GitHub Profile
import { EMPTY, interval, Observable, of, throwError } from 'rxjs';
import { catchError, finalize, map, switchMap, take as takeOperator, tap } from 'rxjs/operators';
const noop = () => {};
type WheneverEndCallback = (err?: any) => void;
interface WheneverEndParameters<T, O> {
callback?: WheneverEndCallback;
error?: (err: any, caught?: Observable<T>) => Observable<O> | void;
@ydomenjoud
ydomenjoud / bookmark-pr.js
Last active December 10, 2020 08:22
bookmark-pr
// ==UserScript==
// @name Mark PR
// @namespace TFS
// @version 0.2
// @description bookMark
// @author yannick
// @match https://*/*
// @grant none
// ==/UserScript==
@ydomenjoud
ydomenjoud / coerce.decorator.ts
Created January 30, 2019 11:45
coerce decorator wrapper for cdk
/**
* auto coerce data
* inspired by https://stackoverflow.com/a/49554548
*/
import { coerceArray, coerceBooleanProperty, coerceCssPixelValue, coerceNumberProperty } from '@angular/cdk/coercion';
export type COERCE_TYPES = 'boolean' | 'number' | 'cssPixelValue' | 'array';
function coerceFromType(value: any, type: COERCE_TYPES) {
switch (type) {
@ydomenjoud
ydomenjoud / replaceEpicMiddlewareImportRule.ts
Created September 10, 2018 13:38
replace createEpicMiddleware from redux-observable by custom
import { Replacement, RuleFailure, Rules, RuleWalker } from 'tslint';
import { ImportDeclaration, SourceFile } from 'typescript';
const disallowedImport = 'redux-observable';
const disallowedClause = 'createEpicMiddleware';
export class Rule extends Rules.AbstractRule {
public apply(sourceFile: SourceFile): RuleFailure[] {
return this.applyWithWalker(new Walker(sourceFile, this.getOptions()));
}
@ydomenjoud
ydomenjoud / auto-unsubscribe.decorator.ts
Created September 6, 2018 08:25
angular annotation to auto unsubscribe when component is destroyed
/**
* auto unsubscribe annotation to unsubscribe subscription when component is detroyed
* how to use :
*
```
export class DumbComponent implements OnDestroy {
@autoUnsubscribe()
subscription: Subscription;
@ydomenjoud
ydomenjoud / sails-auth.sh
Last active April 6, 2017 11:52
install sails and configure for jwt auth
#!/bin/sh
#########################
# secure sails api by jwt
#########################
project_name='project'
# install sails
sudo npm -g install sails
@ydomenjoud
ydomenjoud / create-deezer-app.sh
Last active October 25, 2016 09:03
create deezer desktop app on kubuntu
#!/bin/sh
###################################
# create deezer desktop app
# work on kubuntu 16.04
###################################
application_dir=$HOME/.local/share/applications/
icon_dir=$HOME/.local/share/icons/hicolor/256x256/app/
icon_name=deezer.png
@ydomenjoud
ydomenjoud / ng2
Last active August 22, 2016 13:25
ng2 generate component ( pug + sass ), using ng2.prefix in package.json for component prefix
#!/bin/sh
##########################
# Generate basic component
##########################
############# controls
if [ "$#" -ne 1 ]; then
echo "usage: ng2 <component_name>"
fi