Skip to content

Instantly share code, notes, and snippets.

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

Rumen Rusanov hpstuff

🏠
Working from home
View GitHub Profile
//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;
class Test {
tokens$: Observable;
message$: Observable;
constructor() {
this.tokens = Observable.create((observer) => {
this.getToken(observer);
this.messaging.onTokenRefresh(() => this.getToken(observer));
});
@hpstuff
hpstuff / Animated.js
Created January 31, 2018 09:07
GSAP vs Animated
/* (...) */
show(toValue, cb) {
return Animated.timing(this.animation, {
toValue,
duration,
easing: Ease.ease(Ease.out)
}).start(({finished}) => finished && cb);
}
/* (...) */
show(0);
...
renderHeader() {
return (
<View>
<Text>{`Header`}</Text>
</View>
)
}
...
render() {
@hpstuff
hpstuff / AppDelegate.swift
Created August 12, 2017 10:49
ReactNative - Airbnb Navigation
import UIKit
import NativeNavigation
import React
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, RCTBridgeDelegate, ReactNavigationCoordinatorDelegate {
/*...*/
func flowCoordinatorForId(_ name: String) -> ReactFlowCoordinator? {
@hpstuff
hpstuff / Animation.js
Last active June 9, 2017 08:33
Javascript Animation
static class Easing {
// no easing, no acceleration
static linear(t) { return t; }
// accelerating from zero velocity
static easeInQuad(t) { return t*t; }
// decelerating to zero velocity
static easeOutQuad(t) { return t*(2-t); }
// acceleration until halfway, then deceleration
static easeInOutQuad(t) { return t<0.5 ? 2*t*t : -1+(4-2*t)*t; }
// accelerating from zero velocity
@hpstuff
hpstuff / NotificationCenter.java
Created March 29, 2017 09:16
NotificationCenter
import java.util.ArrayList;
import java.util.HashMap;
public class NotificationCenter {
//static reference for singleton
private static NotificationCenter _instance;
private HashMap<String, ArrayList<Runnable>> registredObjects;
@hpstuff
hpstuff / TransformUtil.js
Created March 14, 2017 16:32
ReactNativeTransformHelper
import MatrixMath from 'react-native/Libraries/Utilities/MatrixMath';
class TransformUtil {
constructor(matrix) {
this.matrix = matrix || MatrixMath.createIdentityMatrix();
}
perpective(x) {
MatrixMath.reusePerspectiveCommand(this.matrix, x)
@hpstuff
hpstuff / Game.jsx
Last active February 28, 2017 13:22
ReactGame
class Dispatcher {
id = 0;
_callbacks = [];
register(callback){
const id = this.id + 1;
this._callbacks[id] = callback;
return id;
}
@hpstuff
hpstuff / Score.js
Created February 23, 2017 08:47
React Native
'use strict';
import React from 'react';
import {
StyleSheet,
Text,
View,
Animated,
Easing
} from 'react-native';