Skip to content

Instantly share code, notes, and snippets.

@mritzco
mritzco / Instructions.md
Last active January 4, 2020 16:03
Installing TortoiseHG on linux (2018 PPA not working)

Installing TortoiseHG

(June 2018)

PPA for tortoise is gone and Tortoise is removed when mercurial is updated.

If you're ok having an old version of Mercurial, you can reinstall following this guide:

First let's see the requirements:

sudo apt-get install tortoisehg
@mritzco
mritzco / CacheCollection.js
Created June 14, 2018 10:07
localStorage class
// src/utils/CacheCollection.js
/**
* Creates a collection of unique values in local storage
* Works with arrays only
* Singleton method to allow sharing between classes without adding extra stuff
*/
class CacheCollection {
constructor (key, expire=1200) {
this.key = key;
this.expire = expire;
@mritzco
mritzco / cachedFetch.js
Last active December 18, 2023 09:14
Javascript caching fetch data
// From https://www.sitepoint.com/cache-fetched-ajax-requests/
// All credits to: Peter Bengtsson
// Added Content-type to headers so it can go to traditional validation like fetch does
// Add some debugging messages: activate with { verbose: true }
// Add a request to be able to add headers instead of just calling URL
const CachedFetch = (url, options) => {
let expiry = options.seconds || 5 * 60 // 5 min default
let logger = (options.verbose) ? console.log : function(){};
@mritzco
mritzco / 0_Instructions.md
Last active May 11, 2018 15:09
Starting and using a private ethereum blockhain

Running your own private blockchain and connecting to it.

1. Start bootnode and private network

Go to wherever you want to run this.

  mkdir privatechain
  cd privatechain/
  
  touch genesis.json 
 mkdir data
@mritzco
mritzco / plopfile.js
Created March 8, 2018 08:09
Custom action for plop. Appends data to JSON files
const fs = require('fs-extra');
const methods = {}, priv = {};
// Private methods to do string replacement. Not optimized and cummulative trying to keep it simple.
// far better options here: https://stackoverflow.com/questions/5069464/replace-multiple-strings-at-once
priv.replaceObj = function(value, vars) {
let obj = value;
Object.keys(obj).forEach(function(item) {
obj[item] = priv.replaceStr(obj[item], vars);
});
return obj;
@mritzco
mritzco / scad
Created February 27, 2018 10:12
HDD holder
// hard disk holder
module stand(
wall=3,
height=20,
dw=20,
dd=80
) {
wall2 = wall*2;
@mritzco
mritzco / triangle.js
Last active February 23, 2018 15:55
Calculating triangles
// http://www.teacherschoice.com.au/Maths_Library/Trigonometry/triangle_given_3_points.htm
const triangle = {
corners: {},
angles:{},
sides: {},
create: function (a,b,c,d,e,f) {
this.corners.A = [ a, b ],
this.corners.B = [ c, d ],
this.corners.C = [ e, f ]
return this;
0x0a47bDaf1b1FD7E79273e286717Cb001cc05Bc48
@mritzco
mritzco / install.md
Last active September 2, 2022 00:11
Running AR.js sample locally
@mritzco
mritzco / clock.css
Created March 10, 2017 09:28
SVG Clock with duration
/* FROM LESS */
svg.clock {
background: #ffffff;
width: 120px;
height: 120px;
/* Don't define height - not overridable */
fill: none;
/* time markers */
/* Clock face and center */
}