Skip to content

Instantly share code, notes, and snippets.

@robozavri
robozavri / getUrlParams.js
Created August 23, 2021 11:05
[js get url params] #javascript #url #params
var urlParams = new URLSearchParams(window.location.search);
console.log(urlParams.has('post')); // true
console.log(urlParams.get('action')); // "edit"
console.log(urlParams.getAll('action')); // ["edit"]
console.log(urlParams.toString()); // "?post=1234&action=edit"
console.log(urlParams.append('active', '1')); // "?
@robozavri
robozavri / patterns.js
Created March 11, 2021 20:59
#js #date #decimal #pattern
/^(\d{1,2}\/\d{1,2}\/\d{4})$/.test(date.toLocaleDateString())
/^\d+(\.\d{2})$/
@robozavri
robozavri / detect_bottom_on_scroll.js
Created March 2, 2021 13:17
#angular #scroll detect bottom on scroll
<div (scroll)="onScroll($event)">
...
...
</div>
import { Component, HostListener } from '@angular/core';
...
...
@robozavri
robozavri / fontdetect.js
Created March 1, 2021 12:22
#javascript #font-face-detect #fontdetect #detect
document.fonts.ready.then(function () {
// alert('All fonts in use by visible text have loaded.');
alert('like-note-font loaded ?: ' + document.fonts.check('1em like-note-font')); // true
});
@robozavri
robozavri / phone_regex.js
Created February 25, 2021 07:43
#regex #phone #javascript
^\(?([0-9]{3})\)?[-. ]?([0-9]{2})[-. ]?([0-9]{2})[-. ]?([0-9]{2})$
https://stackoverflow.com/questions/33924655/position-last-flex-item-at-the-end-of-container
.container {
display: flex;
width: 100%;
border: 1px solid #000;
}
p {
height: 50px;
@robozavri
robozavri / youtube
Last active October 20, 2020 09:04
#youtube #embed
<iframe type="text/html"
width="640"
height="360"
src="https://www.youtube.com/embed/h4mc7ibxdTQ?enablejsapi=1&autoplay=1&loop=1&playlist=h4mc7ibxdTQ"
frameborder="0"
allowfullscreen></iframe>
<iframe class="embed-responsive-item"id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/M7lc1UVf-VE?&autoplay=1&loop=1&rel=0&showinfo=0&color=white&iv_load_policy=3&playlist=M7lc1UVf-VE"
frameborder="0" allowfullscreen></iframe>
@robozavri
robozavri / php pdf geo font
Created September 20, 2020 13:48
php pdf converter with georgian font
1. download tcpdf https://github.com/tecnickcom/tcpdf
2. add georgian specific font
3. run script below
Add specific font from cmd
need run php this [TCPDF/tools/tcpdf_addfont.php] file drom cmd
example:
php tcpdf_addfont.php -i C:\OSPanel\domains\localhost\pdf-generators\dm-niko-nikoladze.ttf
or
@robozavri
robozavri / node.js auth.ts
Last active September 10, 2020 13:11
#node.js
import { Request, Response, NextFunction } from 'express';
import { verify, sign } from 'jsonwebtoken';
import * as User from '../api/users/user.dao';
import config from '../config/environment';
import { roles } from '../constants/user';
import { UnauthorizedError, ResourceNotFoundError, ValidationError } from '../errors';
import * as cookie from 'cookie';
export async function setUser(req: Request, res: Response, next: NextFunction) {
@robozavri
robozavri / express init.ts
Last active September 10, 2020 13:14
#express #node.js
import { Express } from 'express';
import compression from 'compression';
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
import cors from '../config/cors';
import ejs from 'ejs';
import passport from 'passport';
export function initExpress(app: Express) {
app.disable('x-powered-by');