-
PHP Dev Environment One-Liner
Here’s the fastest way to get your PHP app running. No MAMP, WAMP, apache or any of that nonsense.
Moreover, it allows you to run multiple projects independently.
I’m assuming you have docker.
tl;dr
This runs the php docker image, mounts the current directory, and spins up a server on port 8086
$ docker run -v $(pwd):/www -it -p8086:8086 php:5.6-alpine sh -c "cd www; php -S 0.0.0.0:8086"The Full Version
Create your index.php
$ cat > index.php <html><body><h1><?php print("Hello World!") ?> </h1></body></html> CTRL-DRun the Server
$ docker run -v $(pwd):/www -it -p8086:8086 php:5.6-alpine sh -c "cd www; php -S 0.0.0.0:8086"Test Your Server
$ curl localhost:8086 <html><body><h1>Hello World! </h1></body></html> -
Being Scientific with Gists : The Sharable Laboratory
Next time you create a post with code snippets–like here on dev.to or stackoverflow–consider sharing a working and buildable gist along with it. By doing so, others can clone, reproduce your results, and commit new variants much more easily.
With the process below, your gist becomes a sharable laboratory. Since the gist contains all of the code variants and test cases, any team member can create a variant and run the tests against all existing variants.
-
Getting to Yes -- As Quickly as Possible
There was a great discussion a year ago about how fast gnu’s version of “yes” is. If you’re unfamiliar,
yesoutputsyindefinitely.yes |head -5 y y y y yThe key takeaway was that
writeis expensive and writing page-aligned buffers is much faster. The is true across languages, so let’s see how to do it properly in go.If you’re shocked or impressed by the results, let’s see you do it in your language – post your results in the comments.
-
GCP: Managing IAM Access Control Across Projects -- The Simpler Version
GCP resources are organized into projects – all resource IDs and IAM principles are grouped under a project ID. This means that by default roles assigned to a principle (e.g. a user or service account) are scoped only to project resources. This can be tricky if say your images are in one project’s storage bucket and your app is running in another
If you want to provide a service principle in one project access to resources in another , the approach is not obvious, nor is it well documented.
-
Publish Free Static Websites With Firebase, Hugo and Google Cloud Builder -- Part 1
Static site frameworks like Hugo allow you to manage content with Markdown and publish content via scalable hosting platforms like Firebase hosting. Uptime, performance and operations cost per user can’t be beat – you can easily hit millions of pageviews for less than $10/ month
In this tutorial we’ll make a production-ready personal website site, that supports multiple collaborators, built using Hugo. Moreover, we’ll publish with the free-to-start Firebase Hosting CDN, and build automatically using Google Cloud Builder.
-
Writing Custom Metrics to Stackdriver in Golang
Instrumentation is a critical part of any application. Along with system counters like cpu, heap, free disk, etc– it’s important to create application-level metrics to make sure health is measured closer to your customer’s experience.
Example metrics could be user-registration, password-change, profile-change, etc. If you see a major spike or dip in these metrics, a wider problem could be indicated.
For this example a custom metric was needed, and no infrastructure was in place for harvesting it (e.g. collectd). Golang is handy for creating an easy-to-install daemon which performs the measurement and periodically harvests the data into stackdriver.
-
Using AWS IOT To Arm Blink Cameras
Blink security cameras are an affordable home security camera system. Although they lack a formal public API, inventive devs have reverse-engineered their private API to allow for better integration.
Here we’ll use AWS IOT Core, Lambda and node-blink-security to arm and disarm Blink security cameras using an AWS IOT Button.
Activating Your IOT Button
The IOT Button must be configured to your account, which includes joining it to your wifi access point, and installing the client certificates.
-
Get Started with Bitcoin Using Docker
Like me, you’re probably more comfortable on a CLI. Here’s a quick way to use docker to set up a Bitcoin Wallet and trade Bitcoin for free on Testnet with Electrum. You can use the same tools to manage your real Bitcoin wallet too.
Setup
Make sure you have Docker for your OS ( Mac, Windows, Linux)
Run the
electrum-clidocker imageElectrum is a python-based Docker wallet with a both a gui and good cli. I’ve put together electrum-cli, a lightweight Alpine-linux Docker image with Electrum signed and installed with jq.
-
Using Custom Docker Images on Bitbucket Build Pipeline
Usually setting up the build dependencies is a major part of each build job. Thankfully, Atlassian’s Bitbucket Pipelines, the new CI platform that integrates into Bitbucket, supports custom docker images.
To configure the build pipeline, you create
bitbucket-pipeline.yml. This one uses our custom image (built below) and triggers builds whenever areleases-*tag is pushed.image: tonymet/tonym.us:latest pipelines: tags: release-*: - step: script: - make sync_down_images - make s3_uploadThat first line is the magic part – you can run ANY public docker image from dockerhub (and private ones as well with further setup).
-
Creating TGZ artifacts from Docker Images to Enable Service Migrations
A common migration pattern when moving to docker includes running some systems (e.g. dev, staging or a prod canary) on your docker image while the production app is still running your traditional tgz artifacts (e.g. your node app with node_modules)
Let’s create a travis build that creates two artifacts: (1) your docker image and (2) a tgz from the docker container.
Let’s assume you have a basic dockerfile with your app.js and a package.json. The key is that the app is built into
/usr/src/app