Skip to content

Instantly share code, notes, and snippets.

View kutyel's full-sized avatar
🌊
数学者に俺は成る!

Flavio Corpa kutyel

🌊
数学者に俺は成る!
View GitHub Profile
import { Painter } from './painter';
export var PAINTERS: Painter[] = [
{
id: 1,
name: 'Michelangelo',
style: 'Renaissance',
examples: ['David', 'Sistine Chapel', 'The Last Judgement']
},
{
export interface Painter {
id: number;
name: string;
style: string;
examples: string[];
}
import { Component } from '@angular/core';
import { Painter } from './painter';
@Component({
inputs: ['painter'],
selector: 'my-painter-detail',
template: `
<div *ngIf="painter">
<h2>{{painter.name}}</h2>
import { Injectable } from '@angular/core';
import { Painter } from './painter';
import { PAINTERS } from './painters.mock';
@Injectable()
export class PainterService {
getPainters(): Promise<Painter[]> {
return Promise.resolve(PAINTERS);
@kutyel
kutyel / index.html
Last active June 21, 2016 06:19
Angular 2 Template
<!DOCTYPE html>
<html lang="en">
<head>
<title>Angular 2 Famous Painters</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles/app.css">
@kutyel
kutyel / package.json
Last active June 21, 2016 06:10
Angular 2 Template
{
"name": "angular2-famous-painters",
"author": "noob",
"version": "1.0.0",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
@kutyel
kutyel / iban.filter.js
Last active May 1, 2018 12:40
AngularJS filter to format IBAN accounts
(function() {
'use strict';
/**
* Formats a string and returns a valid IBAN account string
* @param {string} input example: 'ES0123456789012345678901'
* @return {string} output example: 'ES01 2345 6789 0123 4567 8901'
* @example <caption>{{'ES0123456789012345678901' | IBAN}}</caption>
*/
angular.module('app').filter('IBAN', () => iban => iban ? iban.replace(/[^\dA-Z]/g, '').replace(/(.{4})/g, '$1 ').trim() : '');
@kutyel
kutyel / xquery.sql
Created January 26, 2016 11:41
Basic XMLQuery Example
select replace(xmlquery('$array/array/id[last()]/text()' passing xmltype('<array><id>$1</id><id>$2</id><id>$3</id></array>') as "array" returning content), '$', '') from dual;
@kutyel
kutyel / reduce.js
Last active August 15, 2017 21:47
reduce() vs Universe
// reduce() awesomeness
const a = [1, 2, 3, 4, 5, 5, 3]
const b = [{ key: 1, value: 'a' }, { key: 2, value: 'b' }]
const c = [Promise.resolve(), Promise.resolve(), Promise.resolve()]
const d = ['a', 'a', 'a', 'a', 'a']
// Max
a.reduce((x, y) => x > y ? x : y) // > 5
// Min