Skip to content

Instantly share code, notes, and snippets.

David Pennington Xeoncross

Block or report user

Report or block Xeoncross

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View AuthPortal.tsx
import axios from 'axios'
import AsyncStorage from '@react-native-community/async-storage'
import React, { useEffect, useState } from 'react'
import { Linking } from 'react-native'
import InAppBrowser from 'react-native-inappbrowser-reborn'
import { LoadingIndicator } from '../LoadingIndicator'
interface AuthPortalProps {
client_id: string
scopes: string[]
View ApiProvider.tsx
import * as React from 'react';
import Axios, { AxiosInstance } from 'axios';
import { createContext, consume } from '../lib/context-utils';
import { AuthContext } from './AuthProvider';
export const ApiContext = createContext('apiContext', {
api: undefined as AxiosInstance | undefined,
auth: undefined as React.ContextType<typeof AuthContext> | undefined,
})
View user.js
import React from 'react';
import { Auth } from 'aws-amplify';
// Create a context that will hold the values that we are going to expose to our components.
// Don't worry about the `null` value. It's gonna be *instantly* overriden by the component below
export const UserContext = React.createContext(null);
// Create a "controller" component that will calculate all the data that we need to give to our
// components bellow via the `UserContext.Provider` component. This is where the Amplify will be
// mapped to a different interface, the one that we are going to expose to the rest of the app.
@EduVencovsky
EduVencovsky / Auth.jsx
Last active Oct 17, 2019
Private Routes with Auth using react-router and Context API
View Auth.jsx
import React, { useState, useEffect } from 'react'
import PropTypes from 'prop-types'
import { checkIsAuthenticated, authSignUp, authLogin, authLogout } from '../../services/auth'
export const AuthContext = React.createContext({})
export default function Auth({ children }) {
const [isAuthenticated, setIsAuthenticated] = useState(false)
const [isLoading, setIsLoading] = useState(true)
View goeventbus-final.go
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
type DataEvent struct {
@kvnxiao
kvnxiao / awesome-go-sorted-by-stars-2019-04-30.md
Last active Nov 1, 2019
awesome-go-sorted-by-stars-2019-04-30.md
View awesome-go-sorted-by-stars-2019-04-30.md

Awesome Go

Build Status Awesome Slack Widget Netlify Status

patreon avelino financial support to Awesome Go

A curated list of awesome Go frameworks, libraries and software. Inspired by awesome-python.

Contributing

@EnchanterIO
EnchanterIO / bitcoin_pow_nonce_hashing.go
Last active Feb 11, 2019
Implementing Bitcoin's Proof of Work hashing mechanics based on a concept of Nonce using GoLang. This exercise is part of BlocksByLukas twitter-chain series on blockchain: https://twitter.com/BlocksByLukas/status/1094981148428640256
View bitcoin_pow_nonce_hashing.go
package main
// Author: twitter.com/BlocksByLukas
// PoW Theory: https://twitter.com/BlocksByLukas/status/1094275846783815683
// Description: Implementing Bitcoin's Proof of Work hashing mechanics based on a concept of Nonce using GoLang.
// The demonstration is not super efficient but easily readable for demonstration purposes.
import (
"bytes"
"crypto/sha256"
@yoya3312
yoya3312 / youtube.py
Created Jan 10, 2019
streamlink with youtube
View youtube.py
import re
from streamlink.compat import urlparse, parse_qsl
from streamlink.plugin import Plugin, PluginError
from streamlink.plugin.api import http, validate
from streamlink.plugin.api.utils import parse_query
from streamlink.stream import HTTPStream, HLSStream
from streamlink.stream.ffmpegmux import MuxedStream
import json
View use-local-storage-example.js
import { useState } from 'react';
// Usage
function App() {
// Similar to useState but first arg is key to the value in local storage.
const [name, setName] = useLocalStorage('name', 'Bob');
return (
<div>
<input
@kwilczynski
kwilczynski / dynamodb-setup.sh
Last active Nov 20, 2019
Something put together quickly to automatically associate Elastic IP address with the current EC2 instance.
View dynamodb-setup.sh
aws dynamodb create-table --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --attribute-definitions "AttributeName=key,AttributeType=S" --key-schema "AttributeName=key,KeyType=HASH" --billing-mode "PAY_PER_REQUEST"
aws dynamodb create-table --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --attribute-definitions "AttributeName=key,AttributeType=S" --key-schema "AttributeName=key,KeyType=HASH" --billing-mode "PROVISIONED" --provisioned-throughput "ReadCapacityUnits=1,WriteCapacityUnits=1"
aws dynamodb update-time-to-live --region <REGION> --profile <PROFILE> --table-name "<TABLE>" --time-to-live-specification "Enabled=true,AttributeName=ttl"
aws dynamodb scan --region <REGION> --profile <PROFILE> --table-name "<TABLE>"
You can’t perform that action at this time.