A blog on (mostly) web

Rooting an Amazon Fire TV Stick 4K

・17 min read
This tutorial will walk you through the high-level process of rooting an Amazon Fire TV Stick 4K (3rd generation of Fire TV Stick, released in 2017). Rooting the stick is possible thanks to an exploit uncovered by user xyz on the XDA forums and user k4y0z who created a nice package for executing the exploit. They called this package kamakiri. Why root Unlocking the Fire TV Stick with root access allows us to install anything we want on it and circumvent the limitations of the stock operating system. Read more...

Getting Started with WireGuard

・20 min read
WireGuard is a relatively new VPN tunnel protocol that aims to be very fast and easy to setup. It follows the Unix Philosophy closely in that it only does one thing (creating secured VPN tunnels) and does it well. If you’ve ever set up an VPN service such as OpenVPN before then you know that it can get complicated because of all the steps you have to go through such as generating certificate authorities, issuing server and client keys and certificates, setting up multiple configuration files, configuring firewall rules, setting up route traffic forwarding, etc. Read more...

Understanding Cross-Origin Resource Sharing (CORS)

・22 min read
Cross-Origin Resource Sharing (CORS) is a way of making HTTP requests from one place to another. Historically browsers have only allowed requests in JavaScript to be made from the same domain enforced by the same-origin policy which prevents cross-origin type of requests. CORS gives the server authority of who can make requests and what type of requests are allowed. Browsers are the clients that enforce CORS policies. The server can configure: Read more...

Checkpoint git commit objects to Ethereum and verify using merkle proofs

・13 min read
In this guide we’ll go through creating a smart contract on Ethereum that notarizes git commits only if the commit date is within the allocated window of time and offer the ability to verify that a commit was published by verifying with merkle proofs composed from commit hash logs. Then we’ll be using git pre-push hooks to publish the commit on-chain on every tagged release. Here’s some schematics to help visualize the processes: Read more...

Migrating from Jekyll to Hugo

・4 min read
This post will go over how I migrated my Jekyll blog over to Hugo. Top reasons for moving to Hugo are: Faster compile time (it’s the fastest static site generator) Awesome documentation and community Go based templating (biased here) Dependency free (no dealing with ruby versions and gems) Robust theming support and content model Getting started First I created my hugo site: hugo new site mysite Then installed the blank theme: Read more...

Evolution of Blockchain Components to Off-Chain Models

・10 min read
The major components of blockchain are: Consensus Networking Record keeping Computation A blockchain is a shared state database that records outputs from transactions. The inputs for these computations are new inputs and current state from previously computed results. State transition updates are broadcasted via peer-to-peer networking and each node validates the incoming state updates to reach consensus. Blockchain brings the ability to execute programs in a trustless fashion by having every participating node in the network perform the computation and reach consensus on resulting output, where the output is then recorded into an immutable ledger. Read more...

How someone can take screen captures without you ever noticing

・9 min read
Sometimes I get paranoid about people hacking into my computer, and as a way to protect myself I try to think like them. I was wondering the other day how I can detect someone taking screen captures (screenshots) of my computer. After some experimenting, I’ve determined that it’s not so easy to detect this. This post will walk you though some of the ways I was able to take screen captures of my macOS computer without being easily detected (in the shoes of a “hacker”) as I was trying to figure some of the possible ways a hacker might go about it in order for me to try to detect such behavior. Read more...

Getting Started with Secure Scuttlebutt (SSB)

・18 min read
Scuttlebutt was started in May 2014 by Dominic Tarr (dominictarr) as an alternative offline-first invite-only social network that allows users to gain total control of their data and privacy. Secure Scuttlebutt (ssb) was released shortly after which puts privacy at the forefront with more encryption features. If you’re wondering where the heck the name Scuttlebutt came from: This 19th century term for a gossip comes from the nautical Scuttlebutt: “a barrel of water kept on deck, with a hole for a cup”. Read more...

Subtle Psychological Tricks

・10 min read
For focusing Chewing gum helps your brain focus. Blood flow is increased to the brain resulting in an improved ability to focus. Chewing gum while taking a test can help you concentrate better. Look from right to left when scanning a room to slow down search and find what you’re looking for. You’re most likely to miss things when scanning from left to right because your eyes are use to always looking in that direction. Read more...

How Unix programmers at restaurants search menus for their favorite plate

・2 min read
A Unix programmer heads over to the local diner to get something to eat for lunch. He, or Bob as he prefers, knows better than to manually scan the entire menu with his eyeballs because it’s inefficient. Bob knows that there’s a better way to automate the process in searching for what he wants to eat. Last time he was here he had a pretty good pasta-and-shrimp plate for under 10 bucks. Read more...

Introducing cointop – An interactive terminal app for tracking cryptocurrencies

・1 min read
cointop is a fast and lightweight interactive terminal based UI application for tracking and monitoring cryptocurrency coin stats in real-time. The interface is inspired by htop and shortcut keys are inspired by vim. Cointop in action Features Quick sort shortcuts Custom key bindings configuration Vim inspired shortcut keys Fast pagination Charts for coins and global market graphs Quick chart date range change Fuzzy searching for finding coins Currency conversion Save and view favorite coins Portfolio tracking of holdings 256-color support Custom colorschemes Help menu Offline cache Supports multiple coin stat APIs Works on macOS, Linux, and Windows It’s very lightweight; can be left running indefinitely Try it out brew install cointop For other platforms, check out the releases page or read the installation instructions in the README. Read more...

Getting Started with RxJS

・25 min read
A guide in to the world of Functional Reactive Programming with RxJS.

Exploring Decorators in JavaScript

・5 min read
In Object Oriented Programming, The Decorator Pattern is a popular design pattern that allows behavior to be added, removed, or modified from an object dynamically at runtime. In the latest iteration of the ES2016/ES7 specification, there is a proposal for JavaScript Decorators which lets us annotate and modify classes and properties at design time. I will be going over examples of decorators and how we can start using decorators in our code today. Read more...

Alexa Voice Service (AVS) Authentication

・3 min read
Here I am going to walk you through on how to retrieve an access token in order to be able to interact with the Alexa Voice Service by using cURL. I have been getting a lot of requests on how to do this step from people reading the Alexa Voice Service with cURL blog post. Set up AVS Device Type If you haven’t already, go into the Alexa Developer Console and register a new Device as Product Type: Read more...

Getting started with Service Workers

・6 min read
Service Workers enables the ability to cache files for offline use, serve as a network proxy, enable the ability for push notification, and even background data sync. AppCache was an attempt to solve this problem but it made many assumptions about intended uses and in the end just caused more fustration than anything, so it became deprecated. Service Workers is AppCache’s successor, which greatly superceeds it by giving the developer a lot more granular control. Read more...

Alexa Voice Service (AVS) with cURL

・5 min read
The Alexa Voice Service (AVS) is an Amazon service which lets you interact with Alexa by sending requests in audio format. This means that we can create our own Amazon Echo by just having a microphone and a speaker available. The easiest way to get started is with a hello world example using cURL. But before we jump to it cURL we have to generate our test audio first. Generate sample audio The audio MUST be mono channel, sampled at 16k Hz, and signed 16 bit PCM encoding. Read more...

Set up Raspberry Pi as a Network Server

・13 min read
The Raspberry Pi has an infinite amount of uses and one of them is using it as a network server. This is handy because people in your home network can connect to this network server and access shared files, such as movies and music, which can be streamed to your TV. I will be going over how to set this up on a fresh RPi. Install Raspbian Raspbian is a light-weight Debian based Linux distro tailored for the RPi. Read more...

Summary of "Think and Grow Rich"

・9 min read
This past weekend I decided to read the book Think and Grow Rich by Napolean Hill. If you are not familiar with Hill, he interviewed hundreds of men with tremendous amounts of wealth, over the span of many years in the early 20th century, to figure out what it takes to bring in riches and fortunes. The findings of his research is what became the book. After reading it I must say that it is one of best books I have ever read in the sense that the value of the information presented is absolutely pricless. Read more...

Generate Self-signed SSL Certificate

・3 min read
Using HTTPS for your web application is a no-brainer, but sometimes it is not intuitively clear on how to get started on using SSL for your website. I’m going to be going over step-by-step on generating a self-signed certficate and testing it out on a Node.js web server. Generating Private Key First let’s generate a private key. The private key is used to decrypt the data encrypted by the public key. Read more...

K-Means Clustering in JavaScript

・9 min read
Clustering is grouping of data or dividing a large data set into smaller data sets of some similarity. A well known clustering algorithm in unsupervised machine learning is K-Means clustering. The K-Means algorithm takes in n observations (data points), and groups them into k clusters, where each observation belongs to a cluster based on the nearest mean (cluster centroid). The distance between a data point and cluster centroid is calculated using the Euclidean distance. Read more...

Naive Bayes Classifier in JavaScript

・8 min read
The Naive Bayes classifier is a pretty popular text classification algorithm because of it’s simplicity. You’ll often see this classifier used for spam detection, authorship attribution, gender authentication, determing whether a review is positive or negative, and even sentiment analysis. The Naive Bayes classifier takes in a corpus (body of text) known as a document, which then a stemmer runs through the document and returns a “bag or words” so to speak. Read more...

Pixelate images with Canvas

・2 min read
There may be cases in which you want to pixelate an image, such as creating 8-bit style pixel art themed games or you simply want to give a hint of what an image is about without exposing too much. Turns out that it’s not complicated at all to do pixelation with canvas. View demo » The main methods needed from the canvas context are imageSmoothingEnabled for rendering crisp pixels and drawImage for drawing those pixels on to the canvas context. Read more...

Bitwise operators in JavaScript

・8 min read
Bitwise operators act on the level of individual bits which allows for fast comparisons and calculations. I’ll be going over a couple of ways to use bitwise opeartors in JavaScript since it’s not entirely clear at first. Some of the examples shown are from various sources which I’ve accumlated over time in which I’m going to elaborate on them. Bitwise AND Return a one if the two bits are both one. Read more...

ES6 Examples

・9 min read
If you’ve been up-to-date with what’s going on in the JavaScript world then you know that ES6 is currently the new hotness in town. I’m going to be showing examples of some of the nicest features in ES6, which include: Modules Classes Arrow Functions Destructuring Generators Promises Proxies Defaults Maps Weak Maps Sets Symbols Shorthand Objects Spread Operator Rest operator Constants Block Scoping Template Strings Modules Export example (math. Read more...

Deployment with Git

・2 min read
A Git hook allows you to execute custom scripts when an action occurs, such as when a commit or push is performed. Before I discovered git hooks, my deployment process consisted of pushing changes to my remote repository, SSH’ing into the server, navigating to the site directory, pulling the changes, and restarting the webserver. It wasn’t efficient at all and a waste of time doing that several times a day. I’ll explain how to set up a simple git hook making the deployment process a bit more effortless, but first I want to give credit to this how-to article which got me started. Read more...

Intro to Redis

・8 min read
Redis is an in-memory, key-value store that is fast. Really fast. Redis can hold hundreds of millions of keys in memory and handle tens of thousands of requests per second without breaking a sweat. It’s useful for caching data, maintaining sessions, keeping counters, queues, publish/subscribe real time notifications, and so on. There are many use cases for Redis due to it’s simple dictionary model that maps keys to values, but what one should be aware of is that it’s focus is not long-term data persistance. Read more...

Getting Started with Backbone.js

・17 min read
In this tutorial I will go over Backbone.js main components: Models, Collections, Views, and Routes. We will not be building an application but instead we will be going over a number of simple examples of each Backbone compoment, that hopefully after we are done you will have a firm understanding of Backbone.js and be able to put it all together. Models Models are a key component of Backbone applications. With model objects you can easily keep track of your data and update as needed. Read more...

Memoization – Caching function results in JavaScript

・3 min read
Memoization (based on the word memorable) is technique that caches the result of a function in order to avoid recalculation the next time the same function is called. Initially when the function is executed, the result gets added to an object holding the calculated results. When the function is called again, it checks the results object to see if already contains the result and if it does then return it. If it’s not cached, then calculate and store it. Read more...

Set up SSH keys

・1 min read
Having to type in a password in order to SSH into your server every single time is tedious and not the way to go. I will show you how to set up SSH keys so that you can elimate an extra step from your workflow. Generating keys On your local maching, generate a new SSH key with the command: # Generate new key. ssh-keygen -t rsa When asked for the file to save the key in, enter: Read more...

Node.js and Nginx on Ubuntu

・5 min read
In this tutorial I will show how to install and configure Node.js and Nginx on you Ubuntu server. Installing Dependencies The only dependency we really need is the build-essential package in order to be able to compile the Node.js source code. # Make sure to download the latest repos. sudo apt-get update # Required to run `make` command. sudo apt-get install build-essential # If you need to use https. sudo apt-get install libssl-dev # My favorite text editor. Read more...

Raspberry Pi camera board video streaming

・4 min read
Raspberry Pi camera board So you got your Raspberry Pi and decided to get a Camera Board to do something awesome with it. Why not turn it a simple video streamer? That’s what I thought too. I wanted to set up a simple security camera for my home so that I can see spy on whoever is lurking around from wherever I am through a web browser. Read more...

Screenshots with getUserMedia API

・4 min read
With the getUserMedia API, it is now possible to access the user’s webcam and microphone using just JavaScript. What this means is that we can finally get rid of those nasty Flash plugins and use this native approace instead. At the writing of this post, only Firefox 17+ and Chrome 21+ have support for getUserMedia. Give credit where credit is due. The code is heavily inspired by HTML5 Rocks’ article Capturing Audio & Video in HTML5. Read more...

Basic HTML5 Audio Manipulation

・2 min read
Using JavaScript, we can create an audio object and manipulate it very easily. Below is some code (gist) to help you get started. You can play, stop, pause, and loop the audio. <!-- Audio Control Buttons --> <button id="play-button">Play</button> <button id="stop-button">Stop</button> <button id="pause-button">Pause</button> <button id="loop-button">Loop</button> // Basic HTML5 audio manipulation (function () { 'use strict'; // Set namespace. var NS = {}; // Control buttons. NS.playButton = document.getElementById('play-button'); NS. Read more...

Slide Out Navigation using CSS3 Translate

・5 min read
There are many ways to create a navigation menu for a mobile site, but the kind that seems to be most popular at the time is a slide out menu, such as the one you see on the Facebook app. The advantages of using this type of menu is that it is easily accessible and there is a lot of room for list items since the user can scroll within the menu. Read more...

Call and Apply Methods in JavaScript

・3 min read
The call and apply methods in JavaScript might look complicated at first glance, but they are actually easy to wrap your head around. Suppose we have an object called square with a few properties: var square = { color: "red", getColor: function () { return "I am the color " + this.color + "!"; }, getArea: function (width, height) { return "My area is " + (width * height) + " feet! Read more...

Sass Triangles

・1 min read
Creating CSS triangles shouldn’t be hard. Here’s a handy little mixin for creating triangles in Sass (gist): @mixin triangle($size:24px, $color:#000, $direction:up, $trim:false, $transparent:false) { content: ""; display: inline-block; width: 0; height: 0; border: solid $size; @if $direction == up { border-color: transparent transparent $color transparent; @if $transparent { border-color: $color $color transparent $color; } @if $trim { border-top-width: 0; } } @if $direction == right { border-color: transparent transparent transparent $color; @if $transparent { border-color: $color $color $color transparent ; } @if $trim { border-right-width: 0; } } @if $direction == down { border-color: $color transparent transparent transparent; @if $transparent { border-color: transparent $color $color $color; } @if $trim { border-bottom-width: 0; } } @if $direction == left { border-color: transparent $color transparent transparent; @if $transparent { border-color: $color transparent $color $color; } @if $trim { border-left-width: 0; } } }

Understanding Prototype in JavaScript

・4 min read
A prototype is an object from where other objects inherit properties from. All objects in JavaScript are descended from Object, a global object. Why this matters I’ll explain later, but for now let’s jump in to some code. Constructor and Methods Let’s define a functional object constructor called Quadrilateral and have width and height as parameters. // Define our constructor var Quadrilateral = function(width, height) { this.width = width; this.height = height; return this; } Traditionally if we wanted to have a method we would define it something like this: Read more...

Responsive Video

・1 min read
Dealing with responsive video can be quite troublesome. Here is a simple script you might find useful: (function() { // Responsive Video function responsiveVideo(selector) { // Get videos var videos = document.querySelectorAll(selector); // Loop through videos for (var i = 0; i < videos.length; i++) { var video = videos[i]; // Get aspect ratio var videoRatio = (video.height / video.width) * 100; // Stretch video video. Read more...

iPhone and iPad Web App Startup Images

・1 min read
In order to avoid having a blank white screen when launching a web app, you can use a apple-touch-startup-image. This is displayed momentarily while the web app is loading. There are a number of link tags to target all iPhone and iPad devices which you must use. But there’s also a very important thing to not do, and that is to not use width=device-width on the viewport meta tag because this will letterbox the viewport and it will not work. Read more...

Sass Media Queries

・2 min read
There are various methods of setting breakpoints in Sass. The first method, which I use, is heavility inspired by Chris Eppstein’s selector hacks. The second method is how ZURB’s Foundation 4 breakpoints are set. Here is the gist: // Sass Media Query Breakpoints // // METHOD 1 // // Inspired by http://thesassway.com/intermediate/responsive-web-design-in-sass-using-media-queries-in-sass-32 // // Usage: // // div { // color: blue; // // @include respond-to(mobile) { // color: red; // } // // } // $break-mobile: 640px; $break-desktop: 1024px; @mixin respond-to($media) { @if $media == mobile { @media only screen and (max-width: $break-mobile) { @content; } } @else if $media == tablet { @media only screen and (min-width: $break-mobile + 1) and (max-width: $break-desktop - 1) { @content; } } @else if $media == desktop { @media only screen and (min-width: $break-desktop) { @content; } } } // // METHOD 1 (extended) // // Inspired by https://gist. Read more...

CSS3 Filters

・1 min read
Webkit has implemented CSS filters, which can spice up the way your photos look without the hassle of having to deal with software like Photoshop. Currently there are 10 CSS filters available, which are: blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate and sepia. In the meantime you must use the -webkit- vendor prefix, like so (gist): img { -webkit-filter: blur(2.5px); /* values: 0px - 25px */ -webkit-filter: brightness(5%); /* values: -100% - 100% */ -webkit-filter: contrast(1. Read more...

mig.gs™ — url shortener

・1 min read
Everyone now-a-days seems to have their own url shortening service, such as goo.gl, t.co, youtu.be, fb.me, git.io, and so on. So I thought I’d have my own as well, and therefore mig.gs was born. mig.gs offers basic analytics using Google Charts API to display daily clicks and generate a QR code. It also displays a Google map of your link visitors by using their IP Address. You can make an account to save your links or use a custom word instead of a random code if you’d like, kind of like bit. Read more...

How To Survive a Zombie Outbreak

・10 min read
Illustration by Tony Moore Illustration Ever wondered what to do if a zombie outbreak actually occurred one day? I bet you have, and you should be worried. The zombie apocalypse is near as we know it, but the question is, are you ready for it? You wake up on a gloomy Monday morning, only to find your deceased yet viable emotionless little sister munching savagely on your mother’s juicy, bloody human flesh. Read more...

Ant task to compress HTML files

・2 min read
I will show you how to compress your HTML files using the Java library HtmlCompressor. So let’s say your html code looks something like this: <!doctype html> <html> <head> <title>htmlcompressor</title> </head> <body> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed gravida suscipit lectus. <!-- comment --> </body> </html> After we compress it, it’ll look like this: <!doctype html> <html> <head> <title>htmlcompressor</title> </head> <body> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Read more...

Display latest delicious bookmarks with jQuery

・2 min read
If you look below you see my three most recently saved bookmarks from (delicious)[http://delicious.com/miguelmota]: fetching bookmarks... var niceTime = (function(){ var ints = { second: 1, minute: 60, hour: 3600, day: 86400, week: 604800, month: 2592000, year: 31536000 }; return function(time){ time = +new Date(time); var gap = ((+new Date()) - time) / 1000, amount, measure; for (var i in ints){ if (gap ints[i]){ measure = i; } } amount = gap / ints[measure]; amount = gap ints. Read more...

HTML5 Reset Stylesheet

・1 min read
I couldn’t find an HTML5 reset stylesheet that suited my needs so I decided to modify HTML5 Doctors’ CSS reset a bit. Here is the gist: html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video { background: transparent; border: 0; font-size: 100%; margin: 0; outline: 0; padding: 0; vertical-align: baseline; } body { line-height: 1; } article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; } ol, ul { list-style: none; } h1, h2, h3, h4, h5, h6 { font-size: 100%; font-weight: normal; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; } :focus { outline: 0; } a { text-decoration: none; } ins { text-decoration: none; } mark { font-style: italic; font-weight: bold; } del { text-decoration: line-through; } abbr[title], dfn[title] { border-bottom: 1px dotted; cursor: help; } table { border-collapse: collapse; border-spacing: 0; } caption, th, td { font-weight: normal; text-align: left; } hr { border: 0; border-top: 1px solid #ccc; display: block; height: 1px; margin: 1em 0; padding: 0; } input, select { vertical-align: middle; } What CSS reset do you use? Read more...

Make an Awesome Tooltip with jQuery

・5 min read
I will attempt to show you how to make a simple yet awesome tooltip using jQuery and CSS3. Ok so first let’s set up the HTML: <a class="awesometooltip" href="http://www.miguelmota.com" title="Hello, I am a tootip!">hover over me</a> All we did was make a link with the class of awesometooltip (that’s what I decided to call this mini plugin) and gave it a title attribute. Now let’s move on to the fun stuff. Read more...

Hello World

・0 min read
Why hello there, and welcome to my blog. I am using jekyll, a static site generator, and it is being hosted on GitHub Pages. I will blog about all things web, usually about code and design tips, tricks and techniques. So yep, that’s pretty much it!