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 / Candlestick.sql
Created August 11, 2023 21:44
Candlestick
WITH initial_price as (
SELECT transaction_hash,
index,
blocks.number as block_number,
blocks.timestamp as block_timestamp,
sqrt_ratio as sqrt_ratio_after
FROM initializations
JOIN blocks ON initializations.block_number = blocks.number
WHERE pool_key_hash = 3444297103257838275074422089987936420839083129914207634282919550416207684544
),
@LFSCamargo
LFSCamargo / offer.js
Last active August 2, 2019 20:42
creating the offer
// Peer 1
pc.createOffer(
offer => {
pc.setLocalDescription(
offer,
() => {
// send the offer sdp to the other peer
},
e => console.log(e),
)
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' },
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(
@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' },
@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 / 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 / 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 / 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 / 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,