<canvas id="canvas"></canvas>
<script>
var ctx = canvas.getContext("2d");
ctx.fillStyle = "red";
ctx.fillRect(0, 0, 8, 8);
var webp = canvas.toDataURL("image/webp"); // Chrome only?
var png = canvas.toDataURL("image/png");
var jpg = canvas.toDataURL("image/jpeg");
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
/* | |
* This work is free. You can redistribute it and/or modify it under the | |
* terms of the Do What The Fuck You Want To Public License, Version 2, | |
* as published by Sam Hocevar. See the COPYING file for more details. | |
*/ | |
/* | |
* Easing Functions - inspired from http://gizma.com/easing/ | |
* only considering the t value for the range [0, 1] => [0, 1] | |
*/ | |
EasingFunctions = { |
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
// requires raf.js (polyfil) | |
(function(){ | |
var ids = {}; | |
function requestId(){ | |
var id; | |
do { | |
id = Math.floor(Math.random() * 1E9); | |
} while (id in ids); |
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
#! /usr/bin/env bash | |
### | |
# | |
# install_mysql.sh | |
# | |
# This script assumes your Vagrantfile has been configured to map the root of | |
# your application to /vagrant and that your web root is the "public" folder | |
# (Laravel standard). Standard and error output is sent to | |
# /vagrant/vm_build.log during provisioning. |
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 | |
class GeoSpatialThingController extends \BaseController { | |
/** | |
* Display a listing of the resource. | |
* | |
* @return Response | |
*/ | |
public function index() |
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 whitelist = ['chrome', 'crios', 'firefox', 'fxios', 'googlebot']; | |
const isSupportedBrowser = uas => { | |
if (uas && Array.isArray(uas) && uas.length > 0) { | |
return uas.some(ua => | |
whitelist.some(w => ua.value.toLowerCase().includes(w)) | |
); | |
} | |
return false; | |
}; |
Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex
command line tool.
To learn more about migrations, check out this article on the different types of database migrations!
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
# Usage: | |
# aws cloudformation --region <region> create-stack --stack-name <stack name> --template-body file://vpc-fargate.yaml | |
# This template will: | |
# Create a VPC with: | |
# 2 Public Subnets | |
# 2 Private Subnets | |
# An Internet Gateway (with routes to it for Public Subnets) | |
# A NAT Gateway for outbound access (with routes from Private Subnets set to use it) | |
# |
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 path = require('path'); | |
const https = require('https'); | |
const zlib = require('zlib'); | |
const downloadContent = (url, callback) => { | |
https.get(url, (res) => { | |
let response; | |
let body = ''; | |
if (res.headers['content-encoding'] === 'gzip') { |
OlderNewer