Skip to content

Instantly share code, notes, and snippets.

View LFSCamargo's full-sized avatar
🕶️
Sunny Days Are Coming

Luiz Fernando Sousa Camargo LFSCamargo

🕶️
Sunny Days Are Coming
View GitHub Profile
@LFSCamargo
LFSCamargo / Video.js
Last active December 27, 2018 17:49
Code for the webRTC on React native
// @flow
import React, { Component } from 'react';
import {
View,
Text,
StyleSheet,
Dimensions,
TouchableOpacity,
Image,
StatusBar,
@LFSCamargo
LFSCamargo / PresenceManager.js
Created December 27, 2018 17:54
Presence manager with pubnub
// @flow
import React, { Component } from 'react';
import { View } from 'react-native';
import PubNubReact from 'pubnub-react';
import { connect } from 'react-redux';
import addContacts from '../actions/Contacts/AddContacts';
import sendRemoteMessage from '../actions/Messaging/AddRemoteMessages';
import { Contact } from '../reducers/Contacts/Contacts';
import { Messaging } from '../reducers/Messaging/Messaging';
import idx from 'idx';
@LFSCamargo
LFSCamargo / type.ts
Last active February 7, 2019 01:38
Type Composing example
// working with pipes and type
type Fruit = "orange" | "banana" | "strawberry";
// working with types and functions
type EatFruitFunction = (fruit: Fruit) => void;
// typing objects using type
type User = {
username: string,
email: string,
@LFSCamargo
LFSCamargo / interface.ts
Last active February 6, 2019 21:05
Interface composition example
interface User {
username: string;
email: string;
password: string;
}
// So here we cant user the & operator after extends to compose types
// So if you want to extend more than one interface or type you need to use type
interface Compose extends User {
@LFSCamargo
LFSCamargo / functions.ts
Created February 7, 2019 02:35
function types Typescript or flow
// Function that executes a action and dont receive any params and returns void
type ChangesSomething = () => void
// Function that receives a string and returns a string
type FormatName = (name: string) => string
// Function that checks if a string is null and returns a boolean
type CheckNull = (value: string) => boolean
// Function that sums two numbers and returns a number
@LFSCamargo
LFSCamargo / genetics.ts
Last active February 11, 2019 06:23
Generics example using flow or ts
// Generics type & interface
type HasGeneric<T> = {
genericType: T,
nonGenericType: string,
arrayGeneric: Array<T>,
}
interface GenericsInterface<T> {
genericType: T;
@LFSCamargo
LFSCamargo / AnimatedGate.tsx
Created May 30, 2019 01:48
Animated Twitter LaunchScreen
import * as React from 'react'
import { Animated, Easing, StatusBar, MaskedViewIOS, View, ViewStyle } from 'react-native'
import icons from '../../icons'
import lightTheme from '../../config/theme'
interface Props {
bootstraped: boolean
}
const AnimatedGate: React.FunctionComponent<Props> = (props) => {
@LFSCamargo
LFSCamargo / initializing.js
Last active June 21, 2019 22:26
React Native and WebRTC
export const iceServers = [
{ url: 'stun:stun.l.google.com:19302' },
{ url: 'stun:stun01.sipphone.com' },
{ url: 'stun:stun.ekiga.net' },
{ url: 'stun:stun.fwdnet.net' },
{ url: 'stun:stun.ideasip.com' },
{ url: 'stun:stun.iptel.org' },
{ url: 'stun:stun.rixtelecom.se' },
{ url: 'stun:stun.schlund.de' },
{ url: 'stun:stun.l.google.com:19302' },
MediaStreamTrack.getSources((sourceInfos)) => {
console.log('MediaStreamTrack.getSources', sourceInfos)
let videoSourceId
for (let i = 0; i < sourceInfos.length; i++) {
const sourceInfo = sourceInfos[i]
if (sourceInfo.kind === 'video' && sourceInfo.facing === 'front') {
videoSourceId = sourceInfo.id
}
}
getUserMedia(
class DisplayStream extends React.Component {
state = {
localstream: null,
}
componentDidMount() {
export const iceServers = [
{ url: 'stun:stun.l.google.com:19302' },
{ url: 'stun:stun01.sipphone.com' },
{ url: 'stun:stun.ekiga.net' },