Skip to content

Instantly share code, notes, and snippets.

ajmas / CircularProgress.vue
Created Feb 8, 2018
Vue Component for drawing a circular progress bar
View CircularProgress.vue
Vue Component for drawing a circular progress bar
<div class="circular-progress" ref="circularProgress">
<svg :height="height" :width="width">
<path class="channel" :d="channel"/>
<path class="progress" :d="progress" />
<text x="55%" y="55%" :font-size="fontSize">
ajmas / vt100-to-html.js
Last active Jan 5, 2018
Quick attempt to convert ansi/vt100 escape sequence to HTML
View vt100-to-html.js
let text = "\u001b[H\u001b(B\u001b[mtop - 02:11:23 up 36 days, 18:31, 0 users, load average: 4.25, 5.34, 5.98\u001b(B\u001b[m\u001b[39;49m\u001b(B\u001b[m\u001b[39;49m\u001b[K\r\n\r\n%Cpu(s):\u001b(B\u001b[m\u001b[39;49m\u001b[1m 21.7 \u001b(B\u001b[m\u001b[39;49;35;43mus,\u001b(B\u001b[m\u001b[39;49m\u001b[1m 8.7 \u001b(B\u001b[m\u001b[39;49msy,\u001b(B\u001b[m\u001b[39;49m\u001b[1m 0.0 \u001b(B\u001b[m\u001b[39;49mni,\u001b(B\u001b[m\u001b[39;49m\u001b[1m 68.3 \u001b(B\u001b[m\u001b[39;49mid,\u001b(B\u001b[m\u001b[39;49m\u001b[1m 0.0 \u001b(B\u001b[m\u001b[39;49mwa,\u001b(B\u001b[m\u001b[39;49m\u001b[1m 0.0 \u001b(B\u001b[m\u001b[39;49mhi,\u001b(B\u001b[m\u001b[39;49m\u001b[1m 1.1 \u001b(B\u001b[m\u001b[39;49msi,\u001b(B\u001b[m\u001b[39;49m\u001b[1m 0.3 \u001b(B\u001b[m\u001b[39;49mst\u001b(B\u001b[m\u001b[39;49m\u001b(B\u001b[m\u001b[39;49m\u001b[K\r\nKiB Mem :\u001b(B\u001b[m\u001b[39;49m\u001b[1m 62916344 \u001b(B\u001b[m\u001b[39;49mtotal,\u001b(B\u001b[m\u001b[39;49m\u001b[1m 3671244 \u001b(B
ajmas / Demo.vue
Last active Dec 26, 2017
dabeng/OrgChart adapted to work with Vue Single File Component
View Demo.vue
<div id="orgchart" class="orgchart">
<node :model="nodeData" v-on:node-click="nodeClick"></node>
<p><button id="add">Add</button><button id="remove">Remove</button></p>
<p>(You can double click on an item to turn it into a folder.)</p>
<ul id="demo">
ajmas / asciiFriendlyText.js
Last active Nov 1, 2017
Remove accents and symbols not compatible with Latin base alphabet
View asciiFriendlyText.js
This works by converting text to decomposed unicode form, such that the
accents are treated as separate characters. We then select the characters
we want, by means of a regex and then join the matched groups.
There are certain characters that won't work with this, such as 'ø', since
it is not an 'o' with a slash accent.
ajmas /
Created Oct 18, 2017
Shell script to control the start, stop and restart of a node application.
## Script to control the applicaion start and stop
## Note, if the application was started separate to this script,
## then there is a risk that it will be started twice.
## Also note if you plan to use this with systemd, then you need to ensure
## the 'Service' section looks as follows:
## [Service]
ajmas / screenctl
Last active Oct 4, 2017
Script for turning on and off a connected screen, on a Raspberry Pi
View screenctl
## script for turning and off the connected screen
## taken from
if [ $1 = 'on' ]; then
tvservice -p
fbset -depth 8
fbset -depth 16
fbset -depth 32
ajmas / addAll.js
Last active Sep 4, 2017
Javascript function, for adding all numbers from 1 to n, inclusive
View addAll.js
* Adds all numbers from 1 to maxInteger, inclusive
function addAll (maxInteger) {
let n = maxInteger;
let m = 0;
if (n%2 === 1) {
m = n;
n = n - 1;
ajmas / array-functions.js
Created Feb 27, 2017
Collection of array function
View array-functions.js
// ref:
function anyOfInArray (array1, array2, findIndexComparator) {
var i=0;
var containsAny= false;
findIndexComparator = function (currentValue, index, arr) {
return JSON.stringify(currentValue) === JSON.stringify(this)
//return currentValue === this;
ajmas / confgurable-password-checker.js
Last active Feb 2, 2017
Configurable Password Checker
View confgurable-password-checker.js
// This version work on simply checking something that fails a rule, though
// it may be useful to check based on estimated password strength. For this
// each function would return a value indicating strength. This value could
// be positive or negative. For example, a string longer than 16 characters
// could get a rating of +5, but being digit only get a -5. Other methods
// could simply return 0/+1.
var ruleFunctions = {
duplicateChars: function(password, min) {
var prevChar, i;
View web-sensor-proxy.js
* Creates an HTTP server to allow to read the sensor data via
* HTTP. Improvements could include caching the data, to avoid
* the sensor being hit too frequently.
* Not tested in-situ.
const express = require('express');
const app = express();
const net = require('net');
You can’t perform that action at this time.