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
// UTILS | |
export const getPaddingFromPrecision = ( | |
floatingPointPrecision: number, | |
): number => { | |
return Math.ceil(Math.log2(360 * floatingPointPrecision)); | |
}; | |
export const convertToBinary = ( | |
num: number, |
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
const refreshToken = async () => { | |
const refreshPromise = new Promise(async (resolve) => { | |
const user = await Auth.currentAuthenticatedUser(); | |
const session = await Auth.currentSession(); | |
user.refreshSession(session.refreshToken, async (res, newSession) => { | |
if (newSession) { | |
await Auth.currentUserCredentials(); | |
} | |
resolve('ok'); |
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 () { | |
var results, currentWindow, | |
// create an iframe and append to body to load a clean window object | |
iframe = document.createElement('iframe'); | |
iframe.style.display = 'none'; | |
document.body.appendChild(iframe); | |
// get the current list of properties on window | |
currentWindow = Object.getOwnPropertyNames(window); |
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
const waitFor = (ms) => new Promise(r => setTimeout(r, ms)) | |
const asyncForEach = (array, callback) => { | |
for (let index = 0; index < array.length; index++) { | |
await callback(array[index], index, array) | |
} | |
} | |
const start = async () => { | |
await asyncForEach([1, 2, 3], async (num) => { | |
await waitFor(50) |
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
# Welcome to Serverless! | |
# | |
# Happy Coding! | |
service: cross-region-sns-subscriber | |
# Keep environment specific configurations in separate files | |
custom: ${file(config/${env:STAGE}.json)} | |
provider: |
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
// eslint-disable-next-line import/no-extraneous-dependencies | |
const { argv } = require('yargs'); | |
let { stage = 'dev' } = argv; | |
module.exports.getDomainName = () => new Promise((resolve, reject) => { | |
stage = `${stage}`.toLowerCase(); | |
if (!stage || stage == null || stage === 'dev') { | |
return resolve('dev-api.yourdomain.com'); |
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
functions: | |
TriggerFunc: | |
handler: handlers.main | |
resources: | |
Resources: | |
# Bucket 'TriggeredBucket' | |
TriggeredBucket: | |
Type: AWS::S3::Bucket |
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
/* http://meyerweb.com/eric/tools/css/reset/ | |
v2.0-modified | 20110126 | |
License: none (public domain) | |
*/ | |
html, body, div, span, applet, object, iframe, | |
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
a, abbr, acronym, address, big, cite, code, | |
del, dfn, em, img, ins, kbd, q, s, samp, | |
small, strike, strong, sub, sup, tt, var, |
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
// Cross Browser Event Utility | |
// Nicholas Zakas, Professional JavaScript for Web Developers p.441 | |
(function(window, document) { | |
'use strict'; | |
var | |
EventUtil = { | |
addHandler: function( element, type, handler ) { | |
if ( element.addEventListener ) { | |
element.addEventListener ( type, handler, false ); |
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 | |
function create_onetime_nonce( $action = -1 ) { | |
$time = time(); | |
$nonce = wp_create_nonce( $time . $action ); | |
set_transient( '_nonce_' . $time, 1, 60*60 ); // adjust the lifetime of the transient | |
return $nonce . '-' . $time; | |
} | |
function verify_onetime_nonce( $_nonce, $action = -1 ) { | |
@list( $nonce, $time ) = explode( '-', $_nonce ); |
NewerOlder