Skip to content

Instantly share code, notes, and snippets.

View paveltretyakovru's full-sized avatar
🐯
Om 🔱

Pavel Tretyakov paveltretyakovru

🐯
Om 🔱
  • St.-Petersburg (Russia)
View GitHub Profile
@paveltretyakovru
paveltretyakovru / trust-innert-html.ts
Created March 13, 2019 22:46
Allow html properties when using angular [innerHtml] property on the tempate
import { BrowserModule, DomSanitizer } from '@angular/platform-browser';
@Component({
selector: 'my-app',
template: `
<div [innerHtml]="html"></div>
`,
})
export class App {
constructor(private sanitizer: DomSanitizer) {
@paveltretyakovru
paveltretyakovru / update-angular-form-array.ts
Last active March 3, 2019 19:10
Dinamic updating Angular FormArray fields on FormGroup
getService(): void {
const id = parseInt(this._route.snapshot.params['id']);
if (id && id > 0) {
this.indLoading = true;
this._restService.getById('/api/serviceapi/, id).subscribe(
resp => {
// get form array reference
const staffs = this.serviceFrm.get('Staffs') as FormArray;
// empty form array
while (staffs.length) {
@paveltretyakovru
paveltretyakovru / db_info.php
Created August 6, 2018 22:16
PHP terminal application with a i/o fuctionality
<?php
echo "Welcome to the OZ-TZ init script \n";
$f_db_host = fopen ("php://stdin","r");
$f_db_dbname = fopen ("php://stdin","r");
$f_db_username = fopen ("php://stdin","r");
$f_db_userpassword = fopen ("php://stdin","r");
echo "Type DB host: ";
$db_host = fgets($f_db_host);
@paveltretyakovru
paveltretyakovru / set-axios-authorization-header.js
Created April 13, 2018 18:33
It's the note about the seting "Authorization" property to the axios requests headers
let webApiUrl = 'example.com/getStuff'
let tokenStr = 'xxyyzz'
axios.get(webApiUrl, { headers: {"Authorization" : `Bearer ${tokenStr}`}
@paveltretyakovru
paveltretyakovru / hosts
Created April 13, 2018 00:52
Nginx host configuration to webpack application developing
127.0.0.1 localhost
127.0.0.1 mydev.app
192.168.0.2 mydev.app
// Refactored loader 3 script from https://github.com/lukehaas/css-loader
// html -> <div class="laoder"></div>
// html without "loading..." like in the source
.loader {
$loader_color: #979797;
width: 12px;
height: 12px;
position: relative;
@paveltretyakovru
paveltretyakovru / nav.component.html
Created January 16, 2017 11:21
Angular2 navbar example with routes
<ul class="nav navbar-nav">
<li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}">
<a [routerLink]="['/']">Home</a>
</li>
<li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}">
<a [routerLink]="['/about']">About</a>
</li>
<li [routerLinkActive]="['active']" [routerLinkActiveOptions]="{exact:true}">
<a [routerLink]="['/calendar']">Calendar</a>
</li>
'use strict';
/**
*
* # Запуск сборки в продакшн
* $ NODE_ENV=production webpack
*
* # Создать файл stats.json для анализа на http://webpack.github.io/analyse
* $ webpack --json --profile > stats.json
*
" Some start configs
syntax on
filetype plugin indent on
set termencoding=utf-8
set fileencodings=utf8,cp1251
set encoding=utf8
if has("autocmd")
autocmd BufRead *.sql set filetype = mysql
@paveltretyakovru
paveltretyakovru / Gruntfile.coffee
Last active November 23, 2015 11:31
Clear deafult Grunt file with description
module.exports = ( grunt ) ->
grunt.initConfig
pkg : grunt.file.readJSON 'package.json'
haml :
init :
files :[
expand : true
cwd : 'source/haml' # From folder