This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"PATOS DE MINAS/MG": 3148004, "JO\u00c3O PESSOA/PB": 2507507, "CALDAZINHA/GO": 5204557, "EUG\u00caNIO DE CASTRO/RS": 4307831, "S\u00c3O LUIZ GONZAGA/RS": 4318903, "ITACAMBIRA/MG": 3132008, "S\u00c3O JO\u00c3O EVANGELISTA/MG": 3162807, "RIO DOS \u00cdNDIOS/RS": 4315552, "ACARI/RN": 2400109, "NORMANDIA/RR": 1400407, "CENTRAL DO MARANH\u00c3O/MA": 2103125, "S\u00c3O LU\u00cdS/MA": 2111300, "LAGOA/PB": 2508109, "HELIODORA/MG": 3129202, "SOBRAL/CE": 2312908, "S\u00c3O JO\u00c3O DO ORIENTE/MG": 3162609, "AURORA/SC": 4201901, "S\u00c3O JOS\u00c9 DO HORT\u00caNCIO/RS": 4318481, "BARRA DO BUGRES/MT": 5101704, "S\u00c3O JO\u00c3O DA PONTA/PA": 1507466, "MESSIAS TARGINO/RN": 2407609, "ARA\u00c7U/GO": 5201603, "SALTINHO/SP": 3545159, "PIRAQUARA/PR": 4119509, "MATOS COSTA/SC": 4210704, "SALTINHO/SC": 4215356, "SEBERI/RS": 4320206, "CL\u00c1UDIA/MT": 5103056, "CURU\u00c7\u00c1/PA": 1502905, "S\u00c3O BERNARDO/MA": 2110609, "PALMEIRA DAS MISS\u00d5ES/RS": 4313706, "SANTA CRUZ DA VIT\u00d3RIA/BA": 2927804, "MORROS/MA": 2107 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a test-proved, one-liner function that returns: | |
// "red" if the input number is below or equal 300, | |
// "yellow" if it is below or equal 700, or | |
// "green" if it is above 700. | |
// from 0 to 1000. | |
const getScoreColor = s => (s === undefined || s === null || s.toString() !== '0' && !parseInt(s) || +s < 0 || +s > 1000) && new Error('invalid input') || +s <= 300 && 'red' || +s <= 700 && 'yellow' || 'green' | |
// make sure you have jest installed globally. | |
test('it should throw an invalid input error', () => { | |
expect(getScoreColor(true)).toEqual(Error('invalid input')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PureComponent } from 'react' | |
import { Platform, WebView as WebViewAndroid } from 'react-native' | |
import WebViewIOS from 'react-native-wkwebview-reborn' | |
const webviewRef = 'webview' | |
... | |
class App extends PureComponent { | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
handleNavigationStateChange({ url }) { | |
... | |
if(Platform.OS === 'ios') { | |
this.refs[webviewRef].evaluateJavaScript('var isNative = "ios"') | |
} else { | |
this.refs[webviewRef].injectJavaScript('var isNative = "android"') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
window.onMessage = function(event) { | |
// now you'll follow with your callback | |
} | |
facebookLoginClicked() { | |
// how to post a message | |
switch(window.isNative) { | |
case 'android': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
is(type, { nativeEvent, body }) { | |
return body === type || (nativeEvent && nativeEvent.data === type) | |
} | |
handleMessage(args) { | |
if(this.is('facebookLogin', args)) { | |
console.log('calling native facebook login') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PureComponent } from 'react' | |
import { StyleSheet, Platform, WebView } from 'react-native' | |
import WebViewIOS from 'react-native-wkwebview-reborn' | |
import { LoginManager, GraphRequest, GraphRequestManager } from 'react-native-fbsdk' | |
const | |
webviewRef = 'WEBVIEW', | |
styles = StyleSheet.create({ | |
webview: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(d, s, id){ | |
var js, fjs = d.getElementsByTagName(s)[0] | |
if (d.getElementById(id)) {return} | |
js = d.createElement(s); js.id = id | |
js.src = "//connect.facebook.net/en_US/sdk.js" | |
fjs.parentNode.insertBefore(js, fjs) | |
}(document, 'script', 'facebook-jssdk')) | |
window.fbAsyncInit = function() { | |
FB.init({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jwt | |
from time import time # para geracao da timestamp | |
secret = 'minha_super_chave_imprevisivel' | |
user_id = 123 | |
payload = { | |
'uid': user_id, | |
'exp': int(time()) + 3600 # queremos que o token seja valido por uma hora |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jwt | |
secret = 'minha_super_chave_imprevisivel' | |
meu_jwt = request['headers']['authorization'] | |
try: | |
informacoes = jwt.decode(meu_jwt, secret, algorithm='HS256') | |
except ExpiredSignatureError: | |
print('Seu token esta expirado!') |
OlderNewer