Skip to content

Instantly share code, notes, and snippets.

View eugenehp's full-sized avatar
🔬
DeepTech, FinTech, BioTech, Robotics, AI.

Eugene Hauptmann eugenehp

🔬
DeepTech, FinTech, BioTech, Robotics, AI.
View GitHub Profile
@eugenehp
eugenehp / GraphQL-Relay-Redux.md
Created March 2, 2016 19:28 — forked from idibidiart/GraphQL-Architecture.md
GraphQL/Relay: The End of Redux? ... Perhaps.

GraphQL allows us to define a generic, UI-agnostic data model on the server using a graph schema that encodes the natural relationships within the data. To wire our model to data, we define resolvers in the schema that leverage our db's own query language (SQL, NoSQL, or Graph query language, etc) or in-memory objects to resolve client-defined, graph-oriented queries against our generic data model.

With each components in the UI component tree declaring its own data dependencies, GraphQL/Relay creates a projection of the graph data model that maps to the UI component tree, thus allowing us to have a UI-agnostic data model on the server, while at once giving us and UI-specific projection of the data. The queries from GraphQL server to the database are composed in an efficient manner based on the aggregate data dependencies that are declared by each component in the UI component

@eugenehp
eugenehp / registry.js
Created April 19, 2016 20:52 — forked from taion/registry.js
Relay type registry
import decamelize from 'decamelize';
import { fromGlobalId } from 'graphql-relay';
import pluralize from 'pluralize';
import getItem from '../api/getItem';
const types = {};
const endpoints = {};
const getItemOverrides = {};

NavigationExperimental notes

Containers

RootNavigationContainer

  • You pass the reducer to this, it actually ultimately receives all navigation calls via onNavigate, which is mostly equivalent to Redux dispatch. It setState and persisting state. it is like the redux "store"
@eugenehp
eugenehp / Enhance.js
Created May 3, 2016 07:47 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@eugenehp
eugenehp / whatsapp-image-compression
Created May 27, 2016 02:56 — forked from akshay1188/whatsapp-image-compression
Whatsapp like image compression
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@eugenehp
eugenehp / bootstrap.js
Created July 31, 2016 01:04 — forked from Unitech/bootstrap
PM2 / Keymetrics for Heroku/Rackspace/Joyent/Amazon Elasticbeanstalk/Azure...
// Make sure you added pm2 as a dependency in your package.json
// Then in your Procfile, do a simple `node bootstrap.js`
var pm2 = require('pm2');
var MACHINE_NAME = 'hk1';
var PRIVATE_KEY = 'z1ormi9vomgq66';
var PUBLIC_KEY = 'oa0m7nuhdfibi16';
var instances = process.env.WEB_CONCURRENCY || -1; // Set by Heroku or -1 to scale to max cpu core -1
@eugenehp
eugenehp / gist:3d981e714c5de9c9a01f15581f52765a
Created November 4, 2016 21:29
git clone all remote branches locally
#!/bin/bash
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
@eugenehp
eugenehp / HLS_dvr.sh
Created November 13, 2016 22:37 — forked from John07/HLS_dvr.sh
A small script to make recording http live streams (HLS, those streams that work on iOS devices) nicer on a Mac. Script records the stream for a defined period of time and sends the user notifications if anything goes wrong and once it's done.
# required: ffmpeg (e.g. from homebrew), terminal-notifier from https://github.com/alloy/terminal-notifier
# you can schedule this with launchd to run e.g. weekly
# Specify in seconds how long the script should record (default here is 1 hour).
seconds=3600
# Date format for the recording file name
DATE=`date "+%d-%m-%y_%H-%M"`
# start ffmpeg recording
@eugenehp
eugenehp / enable-websockets.config
Created November 16, 2016 01:48 — forked from wearhere/enable-websockets.config
Patches AWS Elastic Beanstalk's default nginx configuration to support websockets, for use with an Application Load Balancer.
container_commands:
enable_websockets:
command: |
sed -i '/\s*proxy_set_header\s*Connection/c \
proxy_set_header Upgrade $http_upgrade;\
proxy_set_header Connection "upgrade";\
' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
#!/bin/bash
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
# Bundle React Native app's code and image assets.
# This script is supposed to be invoked as part of Xcode build process