Skip to content

Instantly share code, notes, and snippets.

View schmidt1024's full-sized avatar

Schmidt schmidt1024

View GitHub Profile
@schmidt1024
schmidt1024 / sanitizehtml.pipe.ts
Last active December 13, 2019 01:42
angular 4 pipe for bypass security trust html
// <div [innerHTML]="your.value | sanitizeHtml" ></div>
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@Pipe({name: 'sanitizeHtml'})
export class SanitizeHtmlPipe implements PipeTransform {
constructor(private _sanitizer:DomSanitizer) {
}
transform(v:string):SafeHtml {
@schmidt1024
schmidt1024 / lab2hub.txt
Last active August 21, 2017 09:14
git move from gitlab to github
# first create an empty repo on GitHub
git remote add github https://yourLogin@github.com/yourLogin/yourRepoName.git
git push --mirror github
git remote rename origin gitlab
git remote rename github origin
@schmidt1024
schmidt1024 / round.ts
Last active June 8, 2021 14:52
math round in typescript
// round(1234.5678, 2); // 1234.57
round(number, precision) {
var factor = Math.pow(10, precision);
var tempNumber = number * factor;
var roundedTempNumber = Math.round(tempNumber);
return roundedTempNumber / factor;
};
@schmidt1024
schmidt1024 / paste-and-indent.js
Created May 29, 2017 09:53
sublime text - paste and indent
// swap the keybindings for paste and paste_and_indent
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" }
// linux and windows
//{ "keys": ["ctrl+v"], "command": "paste_and_indent" },
//{ "keys": ["ctrl+shift+v"], "command": "paste" }
@schmidt1024
schmidt1024 / app.const.ts
Created May 3, 2017 07:24
using constants in angular 2
'use strict';
export const dist = '../path/to/dist/';
export const version: string = '0.0.1';
@schmidt1024
schmidt1024 / tsconfig.json
Created April 26, 2017 07:58
tsconfig.json for angular2 with lib:dom to find localStorage
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "../dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
@schmidt1024
schmidt1024 / keys.pipe.ts
Created April 24, 2017 10:01
angular2 pipe to call the keys of json properties
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'keys'})
export class KeysPipe implements PipeTransform {
transform(value) : any {
let keys = [];
for (let key in value) {
keys.push({key: key, value: value[key]});
}
return keys;
@schmidt1024
schmidt1024 / validIBAN.ts
Last active July 17, 2019 09:23
iban validation for angular2 / typescript
//this.validIBAN('DE89 3704 0044 0532 0130 00');
validIBAN(iban) {
// valid == 1
// invalid != 1
console.log(this.isValidIBANNumber(iban));
}
isValidIBANNumber(input) {
let CODE_LENGTHS = {
@schmidt1024
schmidt1024 / sort2level.js
Created March 28, 2017 14:21
typescript/javascript sort array of objects by attribute second level
sortArray(property, array) {
property = property.split('.');
var l = property.length;
return array.sort( function(a, b) {
var i = 0;
while( i < l) {
a = a[property[i]];
b = b[property[i]];
i++;