Skip to content

Instantly share code, notes, and snippets.

@Jonarod
Jonarod / RadioBox.vue
Created November 23, 2019 18:23
Simple custom Radio component for Vue.js, compatible with v-model.
/**
* @usage:
*
* <RadioBox label="Foo" value="foo" v-model="MySelectedValue" />
* <RadioBox label="Bar" value="bar" v-model="MySelectedValue" />
* <RadioBox label="Baz" value="baz" v-model="MySelectedValue" />
*
* data(){
* return {
* MySelectedValue: "",
@Jonarod
Jonarod / README.md
Last active April 20, 2024 19:27
Install Alpine Linux on Hetzner cloud
  1. Create an hetzner server using Ubuntu
  2. Go to the Hetzner's Server dashboard > Images
  3. Click on "Mount" over the alpine-linux-extended.iso image
  4. Shutdown the server
  5. Start the server
  6. Click the "Console" icon from the dashboard to open an interactive terminal session
  7. Login is root
  8. Configure the interface using the command setup-interfaces
  9. Pick to setup default eth0
  10. Custom config: no
@Jonarod
Jonarod / CheckBox.vue
Created November 23, 2019 18:20
Simple custom CheckBox component for Vue.js, compatible with v-model.
/**
* @usage:
*
* <CheckBox label="Foo" value="foo" v-model="MySelectedValues" />
* <CheckBox label="Bar" value="bar" v-model="MySelectedValues" />
* <CheckBox label="Baz" value="baz" v-model="MySelectedValues" />
*
* data(){
* return {
* MySelectedValues: [],
@Jonarod
Jonarod / blob_conversions_util.js
Created December 7, 2019 04:56
Javascript utility to convert Blob to Base64, ImageData or ObjectUrl back and forth. Tree shakeable and promise based.
const BlobToBase64 = function(blob){
let blobUrl = URL.createObjectURL(blob);
return new Promise((resolve, reject) => {
let img = new Image();
img.onload = () => resolve(img);
img.onerror = err => reject(err);
img.src = blobUrl;
}).then(img => {
URL.revokeObjectURL(blobUrl);
@Jonarod
Jonarod / Service_Workers_Messaging.md
Last active January 3, 2024 19:16
Describes how to send messages between a page's main thread and a service worker thread

Page to ServiceWorker

// in page.html
navigator.serviceWorker.controller.postMessage({'hello':'world'});
// in sw.js
self.addEventListener('message', event => { 
@Jonarod
Jonarod / README.md
Created August 21, 2020 13:11
Install Android Apps on Linux
@Jonarod
Jonarod / Makefile
Created March 31, 2023 17:41 — forked from francois-rozet/Makefile
Step-by-step Makefile tutorial
# Macros
ALL = program1 program2 program3
SRCDIR = src/
BINDIR = bin/
EXT = cpp
CXX = g++
CXXFLAGS = -std=c++14 -O3 -Wall -Wextra
@Jonarod
Jonarod / readlines.js
Created March 21, 2023 17:59 — forked from bwasti/readlines.js
Fast line reading in bun
async function readlines(stream, callback, buffer_len = 16) {
const reader = stream.getReader()
const td = new TextDecoder('ascii')
let overflow = null
let buffer = []
function flush_buffer() {
for (let b of buffer) {
callback(td.decode(b))
}
@Jonarod
Jonarod / ToggleSwitch.vue
Created November 23, 2019 18:31
Simple custom Toggle Switch button for Vue.js, compatible with v-model.
/**
* @usage:
*
* <ToggleSwitch :trueFalseLabels="['On','Off']" :trueFalseColors="['#1CD4A7','#ccc']" v-model="isOn" />
*
* data() {
* return {
* isOn: false
* }
* }
@Jonarod
Jonarod / CSVtoJSON.js
Last active April 3, 2020 09:39
Parse CSV and convert it to JSON with ES6
function CSVToMatrix(csv,delimiter){
let matrix = [];
csv.split('\n').map( l => { l.trim() == "" ? 0 : matrix.push(l.trim().split(delimiter).map(v=>v.trim())) })
return matrix
}
function MatrixToJSON(matrix,from,to){
let jsonResult = []; from = from||0;
matrix.map((a,i) => {
let obj = Object.assign({}, ...matrix[0].map((h, index) => ({[h]: matrix[i][index]})))