This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html><head></head><body> | |
<script> | |
var YOUR_CLIENT_ID = 'REPLACE_THIS_VALUE'; | |
var YOUR_REDIRECT_URI = 'REPLACE_THIS_VALUE'; | |
var fragmentString = location.hash.substring(1); | |
// Parse query string to see if page request is coming from OAuth 2.0 server. | |
var params = {}; | |
var regex = /([^&=]+)=([^&]*)/g, m; | |
while (m = regex.exec(fragmentString)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crypto = require('crypto'); | |
export class CryptoAES { | |
private algorithm = 'aes-256-cbc'; | |
private key: string; | |
private IV_LENGTH: number = 16; | |
private iv: Buffer; // random bytes | |
/** | |
* @example crytpo = new CryptoAES(<string 16,32 bits>) {Class object} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { IsString, IsNumber, IsArray, ValidateNested, ArrayMinSize, ArrayMaxSize } from 'class-validator'; | |
import { Type } from 'class-transformer'; | |
export class SMa1 { | |
@IsNumber() | |
id: number; | |
@IsString() | |
type: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"context" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"os" | |
"path" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function refreshSession() { | |
if (!gapi.auth2.getAuthInstance().currentUser.get().isSignedIn()) { | |
return; | |
} | |
var authResponse = gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse(); | |
if (authResponse.expires_at - Date.now() < 60000) { | |
gapi.auth2.getAuthInstance().currentUser.get().reloadAuthResponse() | |
.then(() => { | |
setTimeout(refreshSession, 5000); // 5s | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Copyright 2018 Google LLC | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
https://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This class is for generating a string in microformat (vCard or hCard) with supplied data. | |
* It currently only supports vCard format version 3.0. | |
* | |
* Available parameters (description in parentheses) and suggested format (default value in parentheses): | |
* - 'strict' (true = enforce strict vCard format, false = try your best) => false | |
* - 'acceptedPhoneNumberTypes' => 'work', 'home', 'mobile' | |
* - 'acceptedAddressTypes' => 'work', 'home' | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/tls" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"log" | |
"github.com/emersion/go-imap" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "bytes" | |
func StreamToByte(stream io.Reader) []byte { | |
buf := new(bytes.Buffer) | |
buf.ReadFrom(stream) | |
return buf.Bytes() | |
} | |
func StreamToString(stream io.Reader) string { | |
buf := new(bytes.Buffer) |