Skip to content

Instantly share code, notes, and snippets.

View Raincode's full-sized avatar
🖨️
Fixing a printer

Raincode

🖨️
Fixing a printer
View GitHub Profile
@Raincode
Raincode / huffman.m
Created April 12, 2019 19:15
MATLAB huffman encoding function
% creates an optimal code for probability vector P using huffman coding
% The codes are ordered according to the input probabilities.
% Alternatively, you could sort them descending, or add another column to the cell
% array containing the symbols (like the huffmandict function). This would require an
% additional input parameter.
% My measurements show this running faster than the huffmandict function.
function [c,h,w]=huffman(P)
% function [c,h,w]=huffman(P)
@Raincode
Raincode / main.cpp
Last active April 10, 2019 13:25
Windows WASAPI Managing active audio sessions example
// WASAPI Example to set application volumes
// 10.04.2019
#include <iostream>
#include <limits>
#include <string>
#include <vector>
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
@Raincode
Raincode / Calculator.cpp
Last active June 5, 2017 21:55
Desk Calculator in C++
#include "Calculator.hpp"
#include <fstream>
#include <iostream>
#include <sstream>
#include "mps/str_util.hpp"
#include "mps/clipboard.hpp"
#include "mps/console_util.hpp"
function unite(arr1, arr2, arr3) {
var unique = arr1.concat(arr2, arr3);
console.log("arr:");
console.log(unique);
for (var i = 0; i != unique.length; ++i) {
unique.reduce(function(isDuplicate, item, index, arr) {
if (index != i && unique[i] === item) {
delete unique[index];
}