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
module.exports = (file, api, options) => { | |
const j = api.jscodeshift; | |
const root = j(file.source); | |
// We have to add "use strict" for node to play nice | |
// Taken from https://github.com/cpojer/js-codemod/blob/master/transforms/use-strict.js | |
const hasStrictMode = body => | |
body.some( | |
statement => j.match(statement, { | |
type: 'ExpressionStatement', |
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
require 'sinatra' | |
require 'open-uri' | |
require 'json' | |
# This application is the bare minimum to authorize with OAuth 2.0 | |
# using the authorization grant scheme. No error handling included. | |
# The application is both a client and a resource server. | |
# Start it by using 'ruby <file>' and navigate to http://localhost:4567 | |
# | |
# The application also needs the oauth-server written in Java. |
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
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
const name = "subscribeToPlan"; | |
const newName = name; | |
const root = j(file.source); | |
root | |
.find(j.MethodDefinition) | |
.filter(path => !!path.value.key.name) |
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
module.exports = (file, api, options) => { | |
const j = api.jscodeshift; | |
const root = j(file.source); | |
const createArrowFunctionExpression = fn => { | |
return j.arrowFunctionExpression( | |
fn.params, | |
fn.body, | |
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
const stripe = require("stripe")("api_key"); | |
const CUSTOMER = ""; | |
const PLAN = ""; | |
const quantity = 1; | |
const startTimeInSecondsSinceEpoch = 0; | |
const billingCycleAnchorInSecondsSinceEpoch = 0; | |
async function foo() { | |
const subscription = await stripe.subscriptions.create({ |
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
// run in console on a https page | |
stream = await navigator.mediaDevices.getUserMedia({ video: true, audio:true }) | |
video = document.createElement("video"); | |
video.muted = true; | |
video.srcObject = stream; | |
await video.play(); | |
canvas = document.createElement("canvas") | |
ctx = canvas.getContext("2d") | |
ctx.drawImage(video, 0, 0, video.videoWidth, video.videoHeight); | |
imageData = ctx.getImageData(0,0,video.videoWidth, video.videoHeight) |
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
src = "url_to_imgur" | |
img = new Image(); | |
img.crossOrigin = "Anonymous"; | |
img.addEventListener("load", analyze, false); | |
img.src = src; | |
function analyze() { | |
canvas = document.createElement("canvas") | |
ctx = canvas.getContext("2d") |
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 dgram = require('dgram'); | |
// STUN binding request | |
const bind = Buffer.from('000300002112a4425f73a4b270529f877091d580', 'hex'); | |
const socket = dgram.createSocket('udp4'); | |
socket.on('message', (data) => { | |
console.log('STUN BINDING RESPONSE', data.toString()); | |
}); |
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
if ('mediaCapabilities' in navigator && 'encodingInfo' in navigator.mediaCapabilities) { | |
const videoFileConfiguration = { | |
type : 'record', | |
video : { | |
contentType: "video/webm;codecs=vp8", | |
width: 1920, | |
height: 1080, | |
bitrate: 2500000, | |
framerate: 30, | |
} |
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 WebRtcSupportGate({ | |
children, | |
forceUnsupported, | |
forceUnsupportedIos, | |
forceUnsupportedFacebook, | |
forceUnsupportedInApp, | |
}) { | |
const isWebRtcSupported = | |
!!global.RTCPeerConnection && | |
!!global.navigator.mediaDevices && |
NewerOlder