Skip to content

Instantly share code, notes, and snippets.

View davidgilbertson's full-sized avatar

David Gilbertson davidgilbertson

  • Sydney, Australia
View GitHub Profile
html {
font-size: 18px;
line-height: 1.5;
@include breakpoint(mama-bear) {
font-size: 15px;
}
@include breakpoint(baby-bear) {
font-size: 13px;
}
}
import chalk from 'chalk';
const logLevelName = process.env.LOG_LEVEL;
const isProd = process.env.NODE_ENV === 'production';
const isServer = typeof window === 'undefined';
const INFO = 20;
const WARN = 30;
const ERROR = 40;
const logLevels = {
@davidgilbertson
davidgilbertson / server.js
Created September 7, 2015 10:54
Using the log util and setting the namespace
const log = require('../utils/log.js')('server:routes');
log.info('Something wonderful has happened.');
// "server:routes > Something wonderful has happened"
const log = require('./log.js')('http:request');
export default (req, nes, next) => {
const httpRequest = {
method: req.method,
url: req.url,
headers: req.headers,
remoteAddress: req.connection.remoteAddress,
remotePort: req.connection.remotePort
};

First of all, this is not my brilliant effort to get react-native working on Windows, it is the collation of work by others, particularly @mqli and @Bernd Wessels. I've just summarised what worked for me.

If you would prefer to read what I've plagerised, head over to mqli's great gist

Disclaimer

  • The below is tested with react-native-cli 0.1.5, react-native 0.12.0 on Windows 10, node 4.1.1, and Android (physical Nexus 6 and AVD with API v22)
  • I hope this will all be redundant in a few weeks. Please comment on stuff that is now fixed and I will update this to keep it relevant.
  • Sprinkle a bit of YMMV around

Keep this github issue handy, it’s the bucket for all Windows/Linux related tricks to get RN working.

var ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
random_base64 = function random_base64(length) {
var str = "";
for (var i=0; i < length; ++i) {
var rand = Math.floor(Math.random() * ALPHABET.length);
str += ALPHABET.substring(rand, rand+1);
}
return str;
}
@davidgilbertson
davidgilbertson / Screen-styles.js
Last active April 25, 2016 01:54
Styles example
import CSS from '../../utils/css.js';
export default {
main: {
position: 'absolute',
width: 1366,
height: 768,
top: 60,
left: '50%',
transform: 'translateX(-50%)',
const cloudDb = new Firebase(FIREBASE_URL);
// ref helper
function getRef(...args) {
return args.reduce((result, key) => result.child(key), cloudDb);
}
// example usage
const box = {some: 'new property'};
// where `db` is a `Firebase` ref
export function checkIfUserExists(authData) {
return db
.child('users')
.child(authData.uid)
.once('value')
.then(dataSnapshot => {
return Promise.resolve({
authData,
// Three mostly separate examples: Adding, reading/listening, and removing multiple items from firebase
// Firebase V3.0.0
// one school has many courses and many studens
// one course has many students and is in only one school
// one student is in many courses and only one school
const db = firebase.database().ref('test');
const userId = firebase.auth().currentUser.uid;
/* -- ADDING -- */