Skip to content

Instantly share code, notes, and snippets.

View thomashagstrom's full-sized avatar

Thomas Hagström thomashagstrom

  • Chas Consulting AB
  • Stockholm, Sweden
View GitHub Profile
@thomashagstrom
thomashagstrom / ReadMe.md
Created January 11, 2019 22:50
Codecov Markdown badge

[codecov]

@thomashagstrom
thomashagstrom / jest.config.js
Created January 11, 2019 22:42
Jest code coverage
module.exports = {
collectCoverage: true,
collectCoverageFrom: [
"**/*.{ts,tsx}",
"!**/node_modules/**",
"!**/vendor/**",
"!**/__mocks__/**",
"!**/__snapshots__/**",
"!**/android/**",
"!**/ios/**",
@thomashagstrom
thomashagstrom / DropboxService.cs
Created January 11, 2019 13:13
DropboxClient
using (var client = new DropboxClient(this.AccessToken))
{
// List files
var list = await client.Files.ListFolderAsync(string.Empty);
IList<Metadata> entries = list?.Entries;
// Get file as bytes
var response = await client.Files.DownloadAsync(file);
var bytes = response?.GetContentAsByteArrayAsync();
@thomashagstrom
thomashagstrom / DropboxService.cs
Created January 11, 2019 13:11
WebViewOnNavigating method
private async void WebViewOnNavigating(object sender, WebNavigatingEventArgs e)
{
if (!e.Url.StartsWith(RedirectUri, StringComparison.OrdinalIgnoreCase))
{
// we need to ignore all navigation that isn't to the redirect uri.
return;
}
try
{
@thomashagstrom
thomashagstrom / DropboxService.cs
Last active January 11, 2019 13:09
DropboxService.Authorize
/// <summary>
/// <para>Runs the Dropbox OAuth authorization process if not yet authenticated.</para>
/// <para>Upon completion <seealso cref="OnAuthenticated"/> is called</para>
/// </summary>
/// <returns>An asynchronous task.</returns>
public async Task Authorize()
{
if (string.IsNullOrWhiteSpace(this.AccessToken) == false)
{
// Already authorized
@thomashagstrom
thomashagstrom / cloudSettings
Last active January 15, 2018 13:48
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-01-15T13:48:50.107Z","extensionVersion":"v2.8.7"}
@thomashagstrom
thomashagstrom / DropBoxService.cs
Last active April 7, 2024 15:51
Xamarin.Forms DropboxService API v2
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Dropbox.Api;
using Dropbox.Api.Files;
using HLI.Forms.Services;