Skip to content

Instantly share code, notes, and snippets.

@munckymagik
munckymagik / TrelloListPointsTotaller.es6
Last active October 1, 2015 09:29
An ES6 snippet to total up estimates embedded in Trello cards
// Paste this into the Chrome Dev Console when on a Trello board
// Estimates are expected to be integers wrapped in square brackets at the start of the card name e.g.
// "[2] as a developer I want a way to total estimates on Trello cards so I can keep stats"
(() => {
'use strict'
class Card {
static all($scopeElem) {
return Array.from($scopeElem.querySelectorAll('.list-card')).map(($elem) => {
return new Card($elem)
@munckymagik
munckymagik / svg_viewbox_from_use.js
Created January 28, 2016 10:24
Work out SVG viewBox attribute values
/*
* 1. Load your SVGs into a page using a <use> element.
* 2. Paste this into you developer console and run it.
* 3. It will print out the viewBox values you need for each SVG.
*/
(() => {
'use strict';
let f = (e) => {
let id = e.attributes['xlink:href'].value;
@munckymagik
munckymagik / binary_adder.rb
Last active October 7, 2017 14:40
Using Ruby to emulate how hardware adds binary numbers
# Sums two bits
def half_adder(a, b)
sum = a ^ b
carry = a & b
[carry, sum]
end
# Sums three bits
def full_adder(a, b, c)
carry1, sum1 = half_adder(a, b)
@munckymagik
munckymagik / c_cpp_properties.json
Created June 21, 2018 10:25
vscode-cpptools properties for Arduino Due and Uno
{
"env": {
"HOME": "/Users/danm"
},
"configurations": [
{
"name": "Arduino AVR 4.9.2 UNO",
"includePath": [
"${HOME}/Library/Arduino15/packages/arduino/hardware/avr/1.6.21/cores/arduino",
"${HOME}/Library/Arduino15/packages/arduino/hardware/avr/1.6.21/variants/standard",
@munckymagik
munckymagik / JupyterTOC.js
Last active February 16, 2019 09:52
Jupyter notebook & lab TOC generator bookmarklet
javascript:(() => {
const anchors = Array.from(document.querySelectorAll('a.anchor-link,a.jp-InternalAnchorLink'));
const linkData = anchors.map(
a => [
Number(a.parentElement.tagName[1]),
a.parentElement.firstChild.textContent,
new URL(a.href).hash
]
);
@munckymagik
munckymagik / compare_presenters.jl
Created August 30, 2019 21:32
A Julia script that analyses interface differences between a bunch of Ruby presenter files
using CSV, DataFrames, Query
struct Record
class_name::String
public::Bool
item_type::String
item_name::String
end
function parse_file(file_name::String)::Array{Record}
@munckymagik
munckymagik / module_functions.rb
Created August 31, 2019 06:59
Ruby module_functions demo
module A
module_function
def a
'I am a'
end
def b
'I am b'
end
@munckymagik
munckymagik / Cpp11TryOut.cpp
Created August 31, 2019 07:11
Trying out the features of C++11
//
// main.cpp
// Cpp11Tryout
//
// Created by Dan Munckton on 01/05/2014.
// Copyright (c) 2014 Dan Munckton. All rights reserved.
//
#include <iostream>
#include <functional>
@munckymagik
munckymagik / CMakeLists.txt
Created August 31, 2019 07:13
Trying out "moves" in C++
# Basic CMake project
cmake_minimum_required(VERSION 2.8.11)
# Name the project after the exercise
project(moving CXX)
set(CMAKE_CXX_FLAGS "-std=c++17 -Wall -Werror")
add_executable(moving moving.cpp)
@munckymagik
munckymagik / range.cpp
Created August 31, 2019 07:14
Trying out building a Range class in C++
// clang++ -std=c++11 -o range range.cpp && ./range
// Based on http://stackoverflow.com/questions/7185437/is-there-a-range-class-in-c11-for-use-with-range-based-for-loops
// However https://en.wikipedia.org/wiki/Generator_%28computer_programming%29#C.2B.2B is a way simpler example
#include <iostream>
template <class T>
class RangeClass {
public: