Skip to content

Instantly share code, notes, and snippets.

View itsmepetrov's full-sized avatar
🏠
Working from home

Anton Petrov itsmepetrov

🏠
Working from home
View GitHub Profile
import React, { PropTypes, Component, Children, cloneElement } from 'react';
export default class Fullscreen extends Component {
static propTypes = {
children: PropTypes.node
};
state = {
width: 0,
height: 0
@itsmepetrov
itsmepetrov / index.js
Last active July 3, 2016 12:37
Normalize deep nested query with normalizr
import { Schema, arrayOf, normalize } from "normalizr"
const input = {
id: 100,
title: 'Playing with normalizr',
text: 'Normalize deep nested query with normalizr',
likes: {
total: 1,
page: 1,
limit: 10,
javascript:(function(){ window.open('https://hangouts.google.com/start'); })();
@itsmepetrov
itsmepetrov / FormField.js
Created September 3, 2016 16:16
redux-form Field wrapper
import React from 'react';
import { Field } from 'redux-form';
export default function FormField(props) {
const { component: Component, ...rest } = props;
const renderField = (field) => {
const { input, ...other } = field;
return (
<Component {...input} {...other} />
);
@itsmepetrov
itsmepetrov / index.js
Created March 31, 2016 07:57
redux-entities relation issue
import { combineEntitiesReducers } from 'redux-entities';
import messages from './messages';
import tickets from './tickets';
export default combineEntitiesReducers({
messages,
tickets
});
// Based on http://en.wikipedia.org/wiki/Bank_card_number#Issuer_identification_number
// Card names used from tipsi-stripe.
const brandAmericanExpress = {
name: 'American Express',
prefixes: ['34', '37'],
}
const brandDiscover = {
name: 'Discover',
prefixes: ['60', '62', '64', '65'],
}
@itsmepetrov
itsmepetrov / docker-compose.yaml
Last active May 9, 2018 12:41
Docker Compose VPN and Proxy
version: '3'
services:
vpn:
image: hwdsl2/ipsec-vpn-server
privileged: true
restart: always
volumes:
- /lib/modules:/lib/modules:ro
ports:
- 500:500/udp
@itsmepetrov
itsmepetrov / gist:54836f3cc62501a3c797ee4aa8909b0b
Last active May 12, 2018 13:57 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@itsmepetrov
itsmepetrov / classnames-loader-example.js
Last active June 4, 2018 16:39
This example shows the difference between classNames, classNames/bind and classnames-loader
// This example shows the difference
// between classNames, classNames/bind and classnames-loader
// submit-button.css
/*
:local .className {
color: green;
background: red;
}
const XIAOMI_STRUCT_ATTR = { id: 65281, type: 'charStr' }
const XIAOMI_STRUCT_OLD_ATTR = { id: 65282, type: 'charStr' }
const XIAOMI_MULTICLICK_ATTR = { id: 32768, type: 'boolean' }
const XIAOMI_PRESSURE_ATTR = { id: 16, type: 'int16' }
function parseXiaomiStruct(rawData) {
const buffer = new Buffer(rawData, 'ascii')
const data = {}
let index = 0
while (index < buffer.length) {