yarn add react-native-config
react-native link react-native-config
- Create
.env
files for each configuration. Ex:.env.dev
,.env.prod
, etc Ex:
API_ENDPOINT=https://api.myresource.com/dev
ENV=dev
# Add field | |
echo '{"hello": "world"}' | jq --arg foo bar '. + {foo: $foo}' | |
# { | |
# "hello": "world", | |
# "foo": "bar" | |
# } | |
# Override field value | |
echo '{"hello": "world"}' | jq --arg foo bar '. + {hello: $foo}' | |
{ |
yarn add react-native-config
react-native link react-native-config
.env
files for each configuration. Ex: .env.dev
, .env.prod
, etc
Ex:API_ENDPOINT=https://api.myresource.com/dev
ENV=dev
If you ever need a mobile application, you probably have an API endpoint to talk to. And if you're doing it right, you should have different environment for your API, usually it'll be: dev, staging, production.
We dont' want to perform test againts the production API. We need a way to teach our app to talk to different API environment. But what is the switch?
The naive way:
# Assumes htpass authentication | |
registry_server='docker.mycloud.com' | |
username='bob' | |
# List all images (i.e. repositories) | |
curl -k -X GET "https://$registry_server/v2/_catalog" -u $username -H "Accept: application/json" | |
Enter host password for user 'bob': | |
{"repositories":["app-base","ubuntu","cache-base"]} | |
curl "YOUR_WEBHOOK" -d '{"text":"https://twitter.com/cdixon/status/591658510007410688"}' |
/** | |
* Fancy ID generator that creates 20-character string identifiers with the following properties: | |
* | |
* 1. They're based on timestamp so that they sort *after* any existing ids. | |
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs. | |
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly). | |
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the | |
* latter ones will sort after the former ones. We do this by using the previous random bits | |
* but "incrementing" them by 1 (only in the case of a timestamp collision). | |
*/ |
import React, { Component } from 'react' | |
import { Redirect } from 'react-router' | |
export default class Search extends Component { | |
constructor () { | |
super(); | |
this.state = { | |
fireRedirect: false | |
} | |
} |
import json | |
import numpy as np | |
import keras | |
import keras.preprocessing.text as kpt | |
from keras.preprocessing.text import Tokenizer | |
from keras.models import model_from_json | |
# we're still going to use a Tokenizer here, but we don't need to fit it | |
tokenizer = Tokenizer(num_words=3000) | |
# for human-friendly printing |
// XPath CheatSheet | |
// To test XPath in your Chrome Debugger: $x('/html/body') | |
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/ | |
// 0. XPath Examples. | |
// More: http://xpath.alephzarro.com/content/cheatsheet.html | |
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class |
//URL: https://api.linkedin.com/v1/people/~/shares | |
//Request params: | |
Array | |
( | |
[content] => Array | |
( | |
[submitted-url] => http://forestnation.com/ | |
[title] => Imagine ForestNation | |
[submitted-image-url] => http://forestnationcdn.forestnation.netdna-cdn.com/wp-content/uploads/2013/05/FN-World-150.png | |
[description] => Imagine a world where everyone grows their own tree. You plant one We plant one - Imagine ForestNation. |