Skip to content

Instantly share code, notes, and snippets.

@mrtcmn
mrtcmn / compress.compare.js
Created August 1, 2023 14:08
Brotli compression params compare
const zlib = require('zlib');
const fs = require('fs');
const { performance } = require('perf_hooks');
const filePath = './output.fixture.json'; // Change this to your file
const outputPath = './compressed.br';
// Weight for time and size in the calculation. Must be between 0 and 1.
const timeWeight = 0.5; // weight for time
const sizeWeight = 1 - timeWeight; // weight for size
@mrtcmn
mrtcmn / gist:5236c947226e2daae71a53fb87214e54
Created January 19, 2022 11:19
Browser height detection
let vh = window.innerHeight * 0.01;
let vw = window.innerWidth * 0.01;
const setDimensions = (_vh, _vw) => {
const rs = _vh / _vw < 0.8 ? vh : vw;
document.documentElement.style.setProperty('--vh', `${_vh}px`);
document.documentElement.style.setProperty('--vw', `${_vw}px`);
document.documentElement.style.setProperty('--rs', `${rs}px`);
};
@mrtcmn
mrtcmn / .sh
Created November 26, 2021 12:41
What the hell is this file sizes?
du -hs * | sort -hr
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const outputPath = path.join(__dirname, "dist")
const port = process.env.PORT || 3000;
module.exports = {
context: __dirname,
entry: './src/App.jsx',
output: {
@mrtcmn
mrtcmn / workaround.css
Created November 27, 2020 15:04
firefox backdrop-filter workaround
@supports (-webkit-backdrop-filter: none) or (backdrop-filter: none) {
.blurred-container {
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
}
}
/* slightly transparent fallback for Firefox (not supporting backdrop-filter) */
@supports not ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) {
.blurred-container {
$ git init
@mrtcmn
mrtcmn / yarn init
Last active March 23, 2020 18:04
initialization project
$ yarn init
yarn init v1.22.4
question name (react-project): enter-your-project-names
question version (1.0.0): //give semantic versioning number.
question description: // brief project description is very usefull for future manitaners
question entry point (index.js): // You can enter and pass here
question repository url (https://github.com/user/repo-name): // you can pass here
question author (Murat Çimen <mrtcmen@gmail.com>): // enter your mail name and mail adress
question license (MIT): // if your project will be opensource, i recomend to read software licensing
question private: // open source or private money maker thing?
<form [formGroup]="_FormGroup" (ngSubmit)="onSubmit()" novalidate>
<div [ngClass]="stylesConfig.field">
<label [ngClass]="stylesConfig.label">Form Name</label>
<div class="control">
<input [ngClass]="stylesConfig.formNameInput" type="text" placeholder="Form Name" formControlName="formName">
</div>
</div>
<div [ngClass]="stylesConfig.field">
this._FormGroup = this.fb.group({
formName: '',
decs: '',
questions: this.fb.array([this.fb.group({ // First level array here. After bracet again using FormGroup function for creating AbstractControl.
question: '',
questionType: '',
answers: this.fb.array([ // Second level array here. After bracet again using FormGroup function for creating AbstractControl.
this.fb.group({ value: ''})
])
})])
@mrtcmn
mrtcmn / main.ts
Last active October 27, 2017 19:21
import { Component} from '@angular/core';
import { FormBuilder, FormGroup, FormsModule, FormArray } from '@angular/forms'; // Import required forms modules
@Component({
selector: 'form-creator-form'
templateUrl: './formCreatorForm.component.html'
})
export class formCreatorComponent implements {