Skip to content

Instantly share code, notes, and snippets.

View alexbassy's full-sized avatar
🌈

Alex Bass alexbassy

🌈
  • Berlin, Germany
View GitHub Profile
@alexbassy
alexbassy / stopwatch.js
Created April 15, 2015 11:53
Super simple stopwatch
// Simple stopwatch. Make a new stopwatch with any html element.
// Usage: var sw = new Stopwatch('span.elapsedTime');
// or: var sw = new Stopwatch(el);
// Output: 0.1s, 7.3s, etc
function Stopwatch(selector) {
this.element = typeof selector === 'string' ? document.querySelector(selector) : selector;
this.time = 0;
this.accuracy = 1;
this.element.innerText = '0.0s';
@alexbassy
alexbassy / Dropzone.js
Created August 13, 2015 22:55
My own attempt at a dropzone element. Requires jQuery.
"use strict";
var defaults = {
message: {
idle: {
main: 'Drop an image here',
sub: '(or click to select a file)'
},
loading: {
main: 'Loading...',
<style>
.socialIconsWrap {
display: flex;
list-style: none;
padding: 0;
}
.socialIcon {
display: block;
background: url('https://d2xy5qvxyo4wme.cloudfront.net/dist/img/common/sprites-social.svg') no-repeat;
@alexbassy
alexbassy / example.js
Created March 8, 2018 08:28
Realm + Jest / Worker error message
// SettingsController.test.js
import { SettingsController } from '../SettingsController'
const defaultOptions = [{
name: 'Enable sunshine',
value: false
}, {
name: 'Enable moonlight',
value: true
// src/api.js
require('dotenv')
const { API_CLIENT_ID, API_CLIENT_SECRET } = process.env
const API_BASE = 'https://api.typeform.com'
class Api {
}
import url from 'url'
import qs from 'querystring'
import Config from 'react-native-config'
import { AsyncStorage } from 'react-native'
const TOKEN_NAME = 'api-token'
export class Api {
constructor ({ scopes, base, secrets, fetchMock }) {
this.fetch = fetchMock || fetch
import React from 'react'
import { StyleSheet, Text, View,
TouchableOpacity, Linking, ActivityIndicator } from 'react-native'
import Api from './api'
export default class App extends React.Component {
state = {
loading: true,
loggedIn: false,
loginError: false
import React, { Component } from 'react'
import { StyleSheet, Text, View, TouchableOpacity, Linking } from 'react-native'
export default class App extends Component {
handleAuthorisationCallback = async (ev) => {
// event contains the URL to which the API will redirect the user
// in our case, it'll be typeformresponses://oauth_callback?code=XXX
}
openAuthorisationPage = async () => {
@alexbassy
alexbassy / serverless-iam.json
Last active August 20, 2018 19:35
IAM policy for serverless applications
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"lambda:CreateFunction",
"s3:Get*",
"iam:CreateRole",
service: oauth
app: helpful-oauth
tenant: alexbass
provider:
name: aws
runtime: nodejs8.10
profile: serverless