Skip to content

Instantly share code, notes, and snippets.

View limarc's full-sized avatar
🚀

Alex Lobashev limarc

🚀
  • Cyprus, Limassol
View GitHub Profile
@limarc
limarc / button.js
Last active January 11, 2018 16:34
React component + Flow
// @flow
import React, { type Node } from 'react';
import classnames from 'classnames';
import styles from './button.css';
type Design = 'primary' | 'ghost' | 'invisible' | 'danger';
type Size = 's' | 'm' | 'l';
type Element = {|
// HTMLButtonElement props
@limarc
limarc / jscodshift-transforms.txt
Last active May 13, 2017 21:44
jscodshift transforms
require-default-codeshift.js
https://gist.github.com/nsfmc/aebef4e7a4944819ff40
transform-mobx-map.js
https://gist.github.com/bjrnt/bc5e3079a59924cde995963fcf0bf741
transform-sort-imports.js
https://gist.github.com/deoxxa/4d7aff457058adb44c8f643130bd3c00
rm-merge.js
@limarc
limarc / vscode-settings.js
Last active October 2, 2018 16:02
VSCode settings
{
"editor.fontFamily": "Consolas, monospace",
"editor.fontSize": 15,
"editor.lineHeight": 20,
"workbench.colorTheme": "Material Theme",
"editor.fontLigatures": true,
"explorer.decorations.badges": false,
"window.nativeTabs": true,
"workbench.statusBar.visible": true,
"window.zoomLevel": 0,

Frontend Skills

Browser

  1. HTML
    1. Namespaces (html, svg, xhtml)
    2. Doctype
  2. Network
    1. HTTP/HTTP2
    2. Headers/Cookie
  3. Protocol Data (Restful/JSONRPC)
// Unique with use object
function uniqueObject(array) {
var hash = Object.create(null);
var result = [];
var value;
for (var i = 0; i < array.length; i++) {
value = array[i];
if (!hash[value]) {
hash[value] = true;
// Define global React
if (typeof window !== 'undefined') {
window.React = React;
}
// https://github.com/facebook/react/blob/e3131c1d55d6695c2f0966379535f88b813f912b/src/renderers/dom/ReactDOM.js
Object.defineProperty(
window, '__REACT_DEVTOOLS_GLOBAL_HOOK__', {
value: {
inject: function(runtime){ this._reactRuntime = runtime },
var sha1 = require('sha1');
function WebpackSortingFix() {}
WebpackSortingFix.prototype.apply = function(compiler) {
compiler.plugin('compilation', function(compilation) {
compilation.plugin('optimize-modules', function(modules) {
for (var index in modules) {
var module = modules[index];
@limarc
limarc / spec.js
Last active October 16, 2015 18:27
JSCS validateMagicNumber rules
var arr = [1, 2, 3, 4, 5];
const secondsInDay = 24 * 60 * 60;
var x = 1;
function getTotal(subtotal) {
var beforeTax = subtotal + 9.99;
return beforeTax + (beforeTax * 0.13);
}
setTimout(function() {}, 200);
@limarc
limarc / ws.js
Created September 24, 2015 07:54
var ws = new WebSocket('ws://echo.websocket.org');
ws.addEventListener('open', function(e) {
console.log('CONNECTED', e);
});
ws.addEventListener('message', function(e) {
console.log('RESPONSE', e);
});
// Modified prototype object
Object.prototype.x = 'test';
// Test
var http = new XMLHttpRequest();
http.open('GET', '/test.json', true);
http.onreadystatechange = function(event) {
if (http.readyState == 4) {
try {
var json = JSON.parse(http.responseText);