const chromium = require('chrome-aws-lambda'); | |
module.exports.handler = async (event) => { | |
let browser = null; | |
try { | |
browser = await chromium.puppeteer.launch({ | |
args: chromium.args, | |
defaultViewport: chromium.defaultViewport, | |
executablePath: await chromium.executablePath, | |
headless: chromium.headless |
#!/bin/sh | |
sudo yum install -y https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm | |
sudo yum install -y mysql-community-client |
This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).
This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)
- Installing Homebrew is effortless, open Terminal and enter :
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.
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!
vi /etc/environment | |
add these lines... | |
LANG=en_US.utf-8 | |
LC_ALL=en_US.utf-8 |
In this demonstration I will show you how to read data in Angular2 final release before application startup. You can use it to read configuration files like you do in other languages like Java, Python, Ruby, Php.
This is how the demonstration will load data:
a) It will read an env file named 'env.json'. This file indicates what is the current working environment. Options are: 'production' and 'development';
b) It will read a config JSON file based on what is found in env file. If env is "production", the file is 'config.production.json'. If env is "development", the file is 'config.development.json'.
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
- Follow standard conventions.
- Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
- Boy scout rule. Leave the campground cleaner than you found it.
- Always find root cause. Always look for the root cause of a problem.
private function findNearestLocation(Request $request) | |
{ | |
$location = DB::table('locations') | |
->select('name', 'latitude', 'longitude', 'region', DB::raw(sprintf( | |
'(6371 * acos(cos(radians(%1$.7f)) * cos(radians(latitude)) * cos(radians(longitude) - radians(%2$.7f)) + sin(radians(%1$.7f)) * sin(radians(latitude)))) AS distance', | |
$request->input('latitude'), | |
$request->input('longitude') | |
))) | |
->having('distance', '<', 50) | |
->orderBy('distance', 'asc') |