Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Rumen Rusanov hpstuff

🏠
Working from home
View GitHub Profile
@hpstuff
hpstuff / main.dart
Last active Feb 5, 2020
Flutter Painter animation Demo
View main.dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math';
import 'dart:ui';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
View .bash_profile
source ~/.local/bin/bashmarks.sh
source ~/.bashrc
source ~/.profile
alias ..="cd .."
alias ...="cd ../.."
alias pgs="phonegap serve"
alias vim="mvim --remote-tab-silent"
alias composer="php /usr/bin/composer.phar"
View Example-2.jsx
<CompareWrapper>
{this.renderPlayers}
</CompareWrapper>
renderPlayers(playerIDs, addPlayer) {
return playerIDs.map((playerID) =>
<PlayerWrapper id={playerID}>
{(player) => this.renderPlayer(player, addPlayer)}
</PlayerWrapper>
)
View 00-shema.graphqls
type Link {
url: String!
description: String!
}
type Query {
allLinks: [Link]
}
schema {
@hpstuff
hpstuff / bindNavigationActionCreators.js
Created Mar 30, 2018
bindActionCreators with wix navigator included
View bindNavigationActionCreators.js
import { bindActionCreators } from 'redux';
const bindNavigationActionCreator = (actionCreator, navigator) =>
(...args) => ({...actionCreator.apply(this, args), navigator});
export const bindNavigationActionCreators = (actionCreators, dispatch, navigator) => {
if (typeof actionCreators === 'function') {
const boundActionCreator = bindNavigationActionCreator(actionCreators, navigator);
return bindActionCreators(boundActionCreator, dispatch);
}
View Container.js
//@flow
import type { ComponentType } from 'react';
import React from 'react';
import styled from 'styled-components';
type Align = 'flex-start' | 'flex-end' | 'center';
type Props = {
align?: Align;
}
View JWTValidationMiddleware.js
import jwt_decode from 'jwt-decode';
import { setTokens } from '../actions';
import { SET_TOKEN, CLEAR_TOKEN } from '../actions/types';
import * as api from '../api';
const prefix = /^@REQUEST\//;
const refreshToken = (refresh_token, dispatch) =>
api.refresh_token(refresh_token) //call refresh token api
.then(({ authToken, refreshToken }) => {
View TextChangeAnimated.js
class TextChanges extends Component {
constructor(props) {
super(props);
this.state = {
animation: new Animated.Value(0),
currentText: '',
oldText: ''
};
}
startAnimation() {
View Test.js
//let stepOptions = options.slice(0, options.length);
let stepOptions = options.map(({title}, i) => { title, index: [i] });
stepOptions.splice(1, 0, { title: 'Best of Both', index: [0, 1] });
{stepOptions.map((({title, index}), i) => <CheckBox label={title} key={i} value={this.isSelected(index)} onChange={() => onChange(index)} />)}
isSelected(index) {
const { value } = this.props;
View Test.js
class Test {
tokens$: Observable;
message$: Observable;
constructor() {
this.tokens = Observable.create((observer) => {
this.getToken(observer);
this.messaging.onTokenRefresh(() => this.getToken(observer));
});