Skip to content

Instantly share code, notes, and snippets.

@serslon
serslon / is-ellipsis-active.ts
Created March 4, 2024 14:18
Checking if the element has the Ellipsis
/**
* using this function to check if the text is overflowed and the ellipsis is active
*
* Example: (showing toltipe only if the title has a long text
* const elmRef = useRef(null);
*
* conat onHover = useCallback(() => {
* const isShowToltipe = isEllipsisActive(elmRef.current);
* setShowToltipe(isShowToltipe)
* }, []);
@serslon
serslon / Readme.md
Created February 22, 2022 14:34
How to check variable is one of the types?

This function resolves the problem with different values in a function or class.

Example: We have a function with different parameters and descriptions like:

interface MyExample1 {
 count: number;
 cost: number;
}
@serslon
serslon / webpack.config.js
Created September 25, 2018 07:59
the configuration for proxy webpack dev server from http to https
{
devServer: {
port: 9000,
publicPath: '/',
proxy: {
'/oauth2': {
target: {
host: 'securehost.com',
protocol: 'https:',
port: 443,
@serslon
serslon / generator.js
Last active November 8, 2016 15:50
usage generator function with promise or async function
/**
function decorator
**/
function runGenerator(g) {
const it = g();
let ret;
// asynchronously iterate over generator
(function iterate(val) {
ret = it.next(val);
@serslon
serslon / Note.txt
Last active January 14, 2019 14:07
systemd example configuration for run nodejs application like service
1. INSTALL as service *mvp-admin*: Run command `systemctl enable /srv/mvp-admin/server/systemd/<application>.service`
2. Enable control service from user:
- Create file in `/etc/sudoers.d` with name user. Command: `touch /etc/sudoers.d/<user>`
- Add to file some command:
- %<user> ALL= NOPASSWD: /bin/systemctl stop <application>
- %<user> ALL= NOPASSWD: /bin/systemctl start <application>
- %<user> ALL= NOPASSWD: /bin/systemctl restart <application>
3. After any change in files <application>.service need restart systemd next command `systemctl daemon-reload`
Now you can constrol service from user:
@serslon
serslon / example.js
Created June 15, 2016 13:39
Convert string from downdash or dash to camelCase string
string.toLowerCase().replace(/[-_]+(.)?/g, (match, group) => group ? group.toUpperCase() : '')
/*
Incoming string like Data_Example-string out string dataExampleString
*/
@serslon
serslon / index.html
Created May 24, 2016 07:32 — forked from lig/index.html
IT talk - DataArt - Voronezh - Trip Planner
<!doctype html>
<html lang="en" ng-app="plannerApp">
<head>
<title>IT talk - DataArt - Voronezh - Trip Planner</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet"
href="https://rawgit.com/kuhnza/angular-google-places-autocomplete/master/dist/autocomplete.min.css">
@serslon
serslon / .babelrc
Last active February 7, 2017 06:35
webpack - hot reloader integrate to hapijs usage hapi-webpack-plugin
{
"presets": ["es2015", "stage-0", "react"],
"env": {
"development": {
"plugins": [
["react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]