Disclaimer: These are my notes on learning about StableSwap and may contain errors. Please do your own research and cite the official whitepaper. Intro StableSwap is an autonomous market-maker (AMM) for stablecoins. The StableSwap AMM aims to provide low slippage and low fees when trading stablecoins (such as USDC, DAI, USDT, etc). A starting point for understanding the StableSwap protocol is to…
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…
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…
This was originally posted on “Explain Kubernetes to me like I’m Five” on dev.to ELI5: Kubernetes Docker images: think of them as blueprints, for example a blueprint for creating a cow. Docker daemon: think of it as corral for letting the cows run wild. Docker swarm (and Kubernetes): think of it as a rancher that manages the cows. Let’s say you create many cows (docker…
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…
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.…
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…
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…
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…
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…
Note: These are some “tricks” I’ve read about and thought it be interesting to share. 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.…
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.
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…
An example of example of how to download a blob object in JavaScript. var a = document .createElement( 'a' ); document .body.appendChild(a); a.style.display = 'none' ; var blob = new Blob([audio], {type : 'audio/mpeg' }); var url = window .URL.createObjectURL(blob); a.href = url; a.download = 'file.mp3' ; a.click(); window .URL.revokeObjectURL(url);
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…
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…
Here are example of how to encrypt, decrypt, and manage PGP keys using GPG . Generate a new key pair $ gpg --gen-key gpg ( GnuPG ) 1.4.19; Copyright ( C ) 2015 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Please select what kind of key you want: ( 1 ) RSA and RSA ( default ) ( 2 ) DSA and…
Create a dictionary file containing all the words that will be used. You can use the CMU Sphinx Pronouncing Dictionary to get the phonemes for English dictionary words. keyphrase.dic : CAT K AE T DOG D AO G FISH F IH SH Create a keyphrase list file with a threshold for each phrase. Defaults to 1 . Lower thresholds increase the number of matches but might also increase the number of false alarms.
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…
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…
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…
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…
Convert a Buffer to ArrayBuffer . var isArrayBufferSupported = ( new Buffer( 0 )).buffer instanceof ArrayBuffer; var bufferToArrayBuffer = isArrayBufferSupported ? bufferToArrayBufferSlice : bufferToArrayBufferCycle; function bufferToArrayBufferSlice(buffer) { return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength); } function bufferToArrayBufferCycle(buffer) { var ab…
Convert an ArrayBuffer to Buffer . var isArrayBufferSupported = ( new Buffer( new Uint8Array([ 1 ]).buffer)[ 0 ] === 1 ); var arrayBufferToBuffer = isArrayBufferSupported ? arrayBufferToBufferAsArgument : arrayBufferToBufferCycle; function arrayBufferToBufferAsArgument(ab) { return new Buffer(ab); } function arrayBufferToBufferCycle(ab) { var buffer = new Buffer(ab.byteLength); var view = new…
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…
Slice out a portion of an AudioBuffer. var audioContext = new ( window .AudioContext || window .webkitAudioContext); function AudioBufferSlice(buffer, begin, end, callback) { if ( ! ( this instanceof AudioBufferSlice)) { return new AudioBufferSlice(buffer, begin, end, callback); } var error = null ; var duration = buffer.duration; var channels = buffer.numberOfChannels; var rate =…
A balance point is where the left side of the index is equal to the right side of the index. This function returns an array of indices of balance points. function balancePoints(array) { if ( ! Array .isArray(array)) { return []; } var totalSum = array.reduce(sum, 0 ); var leftSum = 0 ; return array.reduce( function (points, current, i) { if (i > 0 ) { leftSum += array[i - 1 ]; } var rightSum =…
Returns an array of unique values that is the symmetric difference of the provided arrays. function arrayDifference( /* arrays */ ) { var arrays = [].slice.call(arguments); var complement = []; for ( var i = 0 ; i < arrays.length; i ++ ) { var array = arrays[i]; if ( Array .isArray(array)) { for ( var j = 0 ; j < array.length; j ++ ) { var value = array[j]; var atIndex = complement.indexOf(value);…
Find the maximum value in an array. function max(col, fn) { var top = - Infinity ; var index; if ( Array .isArray(col)) { for ( var i = 0 ; i < col.length; i ++ ) { var result = col[i]; if ( typeof fn === 'function' ) { result = fn(col[i]); } else if ( typeof fn === 'string' ) { result = col[i][fn]; } if (result >= top) { top = result; index = i; } } } return typeof index !== 'undefined' ?…
Find the minimum value in an array. function min(col, fn) { var bottom = Infinity ; var index; if ( Array .isArray(col)) { for ( var i = 0 ; i < col.length; i ++ ) { var result = col[i]; if ( typeof fn === 'function' ) { result = fn(col[i]); } else if ( typeof fn === 'string' ) { result = col[i][fn]; } if (result <= bottom) { bottom = result; index = i; } } } return typeof index !== 'undefined' ?…
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…
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…
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…
Battery Status API wrapper: function Battery() { observable( this ); if ( typeof navigator.getBattery !== 'function' ) { navigator.getBattery = function () { return new Promise ( function (resolve, reject) { if (navigator.battery) { resolve(navigator.battery); } else { reject( new Error ( 'Battery Status API not implemented.' )); } }); }; } navigator.getBattery().then( function (batteryManager) {…
Using a regular expression to check if it is a valid domain. function isValidDomain(v) { if ( ! v) return false ; var re = /^(?!:\/\/)([a-zA-Z0-9-]+\.){0,5}[a-zA-Z0-9-][a-zA-Z0-9-]+\.[a-zA-Z]{2,64}?$/gi ; return re.test(v); } Usage isValidDomain( 'example.com' ) // true isValidDomain( 'foo.example.com' ) // true isValidDomain( 'bar.foo.example.com' ) // true isValidDomain( 'exa-mple.co.uk' ) //…
Extract the MIME type from a base64 string using a regular expression. function base64MimeType(encoded) { var result = null ; if ( typeof encoded !== 'string' ) { return result; } var mime = encoded.match( /data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/ ); if (mime && mime.length) { result = mime[ 1 ]; } return result; } Usage: var encoded = 'data:image/png;base64,iVBORw0KGgoAA...5CYII=' ;…
Open a Terminal tab programatically in Node.js. index.js : var exec = require( 'child_process' ).exec; var through = require( 'through' ); var os = require( 'os' ); var child; var args = process.argv; function openTab(cmd, cb) { if (os.platform() !== 'darwin' ) { throw new Error ( 'No support for this operating system but feel free to fork the repo and add it :)' ); } var open = [ 'osascript -e…
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…