Skip to content

Instantly share code, notes, and snippets.

View sibelius's full-sized avatar
🦈
give me a feedback https://entria.feedback.house/sibelius

Sibelius Seraphini sibelius

🦈
give me a feedback https://entria.feedback.house/sibelius
View GitHub Profile
@sibelius
sibelius / Codemod RN24 to RN25.md
Last active November 9, 2016 13:09
Codemod React Native 24 imports to RN25 imports

README

Why this transform is necessary?

Until React Native 24, you import React from 'react-native' package, but this will change on RN 25, you will need to import React from 'react'. You probably have many files that does this, so I've created a codemod to save you a bunch of time

How to use this

  • Install jscodeshif
@sibelius
sibelius / .babelrc
Created May 9, 2016 19:37
PubNub-cli - simulate a message from a friend
{
"presets": ["es2015", "stage-0"]
}
@sibelius
sibelius / find_hostname.bash
Created May 20, 2016 11:49
hostname command on an OSX
hostname
shopt -s histappend
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
export HISTFILE=~/.bash_eternal_history
export HISTCONTROL=ignoreboth
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
@sibelius
sibelius / prepareMongooseObject.js
Created September 7, 2016 21:31
prepareMongooseObject to use with jest snapshot
export function prepareMongooseObject(obj) {
const placeholder = {};
let counter = 0;
const objectIdToNumber = {};
// TODO - find a better way to extract objects id
Object.keys(obj.toJSON()).map((key) => {
const value = obj[key];
@sibelius
sibelius / prepareObjectSnapshot.js
Created September 15, 2016 21:39
Prepare an object to be snapshoted by jest
/**
* Prepare an object to be snapshoted by jest
* replace objectID
* replace datetime
* frozen same specific keys
* @param obj
* @returns {{}}
*/
export function prepareObject(obj, frozenKeys = []) {
const placeholder = {};
@sibelius
sibelius / promise.all.limit.js
Created October 6, 2016 17:31
Promise.all limit
let start = 0;
const limit = 10;
items.slice(start, limit).forEach(subset =>
await Promise.all(subset.map(async (item) => {
// do async work with a single item
}))
.then(() => (start += limit)
);
@sibelius
sibelius / NetInfo.js
Last active August 20, 2017 20:13
Tiny component that shows an alert bar when there is no internet connection
import React, { Component } from 'react';
import {
View,
Text,
TouchableHighlight,
NetInfo,
} from 'react-native';
export default class ConnectionInfo extends Component {
state = {
// @flow
import Relay, { Environment } from 'react-relay';
import { Platform } from "react-native";
import RelayNetworkDebug from 'react-relay/lib/RelayNetworkDebug';
class RelayStore {
constructor() {
this._env = new Environment();
this._networkLayer = null;
@sibelius
sibelius / ex-navigation.md
Created November 10, 2016 13:44 — forked from knowbody/ex-navigation.md
My exponent's ex-navigation docs/thoughts

Exponent - ex-navigation

This is for now, for my personal use only, things might not be correctly explained here. For the official docs please check: https://github.com/exponentjs/ex-navigation/blob/master/README.md

Navigation bar configuration

On every screen you can use the built-in navigation bar, you can add a title, left button, right button or change navigation bar’s style. All you need to do is pass appropriate params to navigationBar in the route configuration:

import React, { Component } from 'react';