Skip to content

Instantly share code, notes, and snippets.

View js2me's full-sized avatar
🚙
I may be slow to respond.

Sergey S. Volkov js2me

🚙
I may be slow to respond.
View GitHub Profile
@js2me
js2me / media-query.css
Created December 27, 2019 10:56 — forked from AyoAlfonso/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@js2me
js2me / react.d.ts
Created November 27, 2019 11:09
Get props type from React component
type Propsable = {
FC: React.FC;
C: React.Component;
CC: React.ComponentClass<any>;
F: (...args: any) => any;
}
type PropsOfFC<C extends Propsable["FC"]> = {
[K in keyof C["propTypes"]]: C["propTypes"][K] extends React.Validator<infer P>
? P
: K
@js2me
js2me / dotline.ts
Created November 14, 2019 13:02
DotLine
export const DotLine = styled.div<{ size: number, count: number, distance: number }>`
background: black;
width: ${({ size }) => `${size}px`};
height: ${({ size }) => `${size}px`};
opacity: 0.65;
border-radius: ${({ size }) => `${size / 2}px`};
box-shadow: ${({ count, distance }) => count === 1 ? 'none' : Array(count-1).fill(1).map((_, i) => `0 ${(i+1) * distance}px`).join(', ')};
margin-top: ${({ distance, size }) => `${distance * -(size + size/2)}px`};
@js2me
js2me / style.css
Created November 11, 2019 11:53
Point background
.background {
background-image: radial-gradient(#D7D7D7 1px, transparent 1px), radial-gradient(#ffc6c6 1px, transparent 1px);
background-position: 0 0, 25px 25px;
background-size: 50px 50px;
}
@js2me
js2me / index.d.ts
Created October 31, 2019 13:02
Sexy common TypeScript types
type Mutate<T, PropertyName extends keyof T, NewValue> = Omit<T, PropertyName> & {
[K in keyof T]: K extends PropertyName ? NewValue : T[K];
}
type PickAndOmit<TPick, TOmit, PropertyName extends (keyof TPick & keyof TOmit)> = Pick<TPick, PropertyName> & Omit<TOmit, PropertyName>
@js2me
js2me / mock-console.ts
Created July 31, 2019 10:18
Mock console.warn console.log console.error
const mockedMethods = ['log', 'warn', 'error']
export const { originalConsoleFuncs, consoleMessages } = mockedMethods.reduce(
(acc: any, method: any) => {
acc.originalConsoleFuncs[method] = console[method].bind(console)
acc.consoleMessages[method] = []
return acc
},
{
@js2me
js2me / fixed-header-sticky-table.css
Created July 26, 2019 09:09
FIxed header in table using pure css (position: sticky)
.fixed-header-table { overflow-y: auto; height: 100px; }
.fixed-header-table thead th {
position: sticky;
top: 0;
/* don't use border, just use box-shadow */
box-shadow: 0 1px 0 #c6c7c9;
}
table { border-collapse: collapse; width: 100%; }
@js2me
js2me / base_helpers.js
Created July 22, 2019 07:55
Basic helpers which reduce your code (most of them are polyfills)
/**
* Check value on type which contains in arrayOfTypeNames
*
*
* Examples:
* valueIs('example', ['String']) -> true
* valueIs({}, ['String', 'Number']) -> false
*
* @param {any} value
@js2me
js2me / build_output.js
Created July 5, 2019 05:52
Rollup, terser - mangle options true with reserved keywords
var n,e;n=this,e=function(n){var e;!function(n){n.t="@ONLY_STRINGS",n.o="@ONLY_STRINGS",n.i="@ONLY_STRINGS",n.u="@STRING_AND_CLASS",n.s="@SERIALIZERS"}(e||(e={}));var t,o=function(n){return"object"==typeof n&&null!==n&&!(n instanceof Array)},r=function(n){return!("object"==typeof n||n instanceof Array||"function"==typeof n)},i=function(){for(var n=[],e=0;arguments.length>e;e++)n[e]=arguments[e];throw console.error.apply(console,["❗️ : "].concat(n)),Error("❗️ : Exception based on message above")},u=function(){for(var n=[],e=0;arguments.length>e;e++)n[e]=arguments[e];console.warn.apply(console,["⚠️ : "].concat(n))},f=function(){return(f=Object.assign||function(n){for(var e,t=1,o=arguments.length;o>t;t++)for(var r in e=arguments[t])({}).hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}).apply(this,arguments)},a=function(n,e){return null!==n&&u('Not possible to cast value "',n,'" to type '+e+".")},c=function(n,e){var t=Object.keys(p);return-1===t.indexOf(n)&&i("Type ",n," of value of property ",e," is not possble f
@js2me
js2me / README.md
Last active July 1, 2019 08:58 — forked from roachhd/README.md
EMOJI cheatsheet 😛😳😗😓🙉😸🙈🙊😽💀💢💥✨💏👫👄👃👀👛👛🗼🔮🔮🎄🎅👻

EMOJI CHEAT SHEET

Emoji emoticons listed on this page are supported on Campfire, GitHub, Basecamp, Redbooth, Trac, Flowdock, Sprint.ly, Kandan, Textbox.io, Kippt, Redmine, JabbR, Trello, Hall, plug.dj, Qiita, Zendesk, Ruby China, Grove, Idobata, NodeBB Forums, Slack, Streamup, OrganisedMinds, Hackpad, Cryptbin, Kato, Reportedly, Cheerful Ghost, IRCCloud, Dashcube, MyVideoGameList, Subrosa, Sococo, Quip, And Bang, Bonusly, Discourse, Ello, and Twemoji Awesome. However some of the emoji codes are not super easy to remember, so here is a little cheat sheet. ✈ Got flash enabled? Click the emoji code and it will be copied to your clipboard.

People

:bowtie: 😄