Skip to content

Instantly share code, notes, and snippets.

View felixmosh's full-sized avatar

Felix Mosheev felixmosh

View GitHub Profile
@felixmosh
felixmosh / CriticalAPI.ts
Last active February 9, 2022 10:08
Abort axios request on DEV mode
import { devModeInterceptor } from './devModeInterceptor';
class CriticalAPI {
private axios: AxiosInstance;
constructor() {
this.axios = Axios.create({
baseURL: process.env.BASE_URL,
});
this.axios.interceptors.request.use(devModeInterceptor);
@felixmosh
felixmosh / fakeProgress.ts
Created May 27, 2021 08:07
Fake progress update for bullMQ worker
import { Job } from 'bullmq';
import ms from 'ms';
// taken from https://github.com/tanem/react-nprogress/blob/ec007096e08af79179b8530a4915e225075d37ac/src/clamp.ts
function clamp(num: number, lower: number, upper: number): number {
num = num <= upper ? num : upper;
num = num >= lower ? num : lower;
return num;
@felixmosh
felixmosh / Formsy.input.js
Created May 2, 2019 12:10
Formsy-Semantic-ui inputAs with element support
import React, { Component, createElement, cloneElement } from 'react';
import { withFormsy } from 'formsy-react';
import { Form, Input, TextArea } from 'semantic-ui-react';
import { filterSuirElementProps } from './utils';
import PropTypes from 'prop-types';
class FormsyInput extends Component {
static propTypes = {
id: PropTypes.string,
name: PropTypes.string.isRequired,
@felixmosh
felixmosh / LazyLoader.js
Last active November 22, 2020 15:37
AngularJS (>=1.6.7) lazy load modules without ocLazyLoad
export class LazyLoader {
constructor($injector, $rootScope) {
this.$injector = $injector;
this.$rootScope = $rootScope;
}
async loadModules(bundleUrl) {
const moduleName = await import(bundleUrl);
const alreadyLoadedModules = Object.keys($injector.modules);
@felixmosh
felixmosh / SassMeister-input.scss
Created August 31, 2018 06:30
Generated by SassMeister.com.
// ----
// libsass (v3.5.4)
// ----
$themes: (
light: (
text: black
),
dark: (
@felixmosh
felixmosh / dabblet.css
Last active March 10, 2018 12:34
CssVars - currentColor
/**
* CssVars - currentColor
*/
button {
border-color: currentColor;
color: red;
}
@felixmosh
felixmosh / dabblet.css
Created March 9, 2018 12:40 — forked from anonymous/dabblet.css
Playing with background-attachment
/**
* Playing with background-attachment
*/
pre {
max-height: 150px;
border: 1px solid silver;
overflow: auto;
background: url('http://via.placeholder.com/350x150');
color: white;
@felixmosh
felixmosh / seo-urls.js
Created November 26, 2016 14:54
Use SEO friendly urls using angular 1.x and ui-router
// assuming you have constant that looks like that:
const serverSEOUrls = {
'super-seo-friendly-category-url': {type: 'category', id: 1},
'super-seo-friendly-tag-url': {type: 'tag', id: 24}
};
angular.module('app', [])
.config(($stateProvider, $urlMatcherFactoryProvider) => {
$urlMatcherFactoryProvider.type('dbType', {
encode: function (urlDef) {
@felixmosh
felixmosh / SassMeister-input-HTML.html
Created March 11, 2015 12:17
Generated by SassMeister.com.
<div class="org">
org
</div>
<div class="mine">
mine
</div>
<div class="target">
target
</div>
@felixmosh
felixmosh / SassMeister-input-HTML.html
Created December 29, 2014 16:35
Generated by SassMeister.com.
<div class="org">
org
</div>
<div class="mine">
mine
</div>
<div class="target">
target
</div>