This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This will be an instance member, Observable#publish. | |
* @memberof Map.prototype | |
* @param {Object} [target] - The object that the properties derived from the map's key/value pairs will be created on. | |
* @returns {Object} | |
*/ | |
Map.prototype.toObject = function(target = Object.create(null)) { | |
let props = [...this].map(kvp => { | |
let [key, value] = kvp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {Function} kvpFn - The function used to create the mapping. Return either the value to be used as key and the entire item will be set as the value, or return a key/value pair in the format [key, value] to specify both explicitely. | |
* @returns {Map} | |
*/ | |
Array.prototype.toMap = function (kvpFn){ | |
const input = this.map(kvpFn); | |
if(!input.every(p => Array.isArray(p) && p.length === 2) { | |
throw new TypeError('kvpFn must return a two element array tuple'); | |
} | |
return new Map(input); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<style> | |
[fu] { | |
position:relative; | |
} | |
[fu]::before,[fu]::after { | |
visibility: hidden; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printfn "%A" { new System.Object() with member x.ToString() = "F########" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rather than use [<DefaultValue>], define a default record. | |
type MyRecord = { | |
field1 : int | |
field2 : int | |
} | |
let defaultRecord1 = { field1 = 0; field2 = 0 } | |
let defaultRecord2 = { field1 = 1; field2 = 25 } | |
// Use the with keyword to populate only a few chosen fields |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var songInfos = [{ | |
url: "https://fuckingdj.blob.core.windows.net/test/Swedish%20House%20Mafia%20-%20Save%20The%20World%20(Zedd%20Remix).mp3", | |
}, { | |
url: "https://fuckingdj.blob.core.windows.net/test/Jewelz%20%26%20Scott%20Sparks%20feat.%20Quilla%20%E2%80%93%20Unless%20We%20Forget%20(Original%20Mix).mp3", | |
}]; | |
var song1toSong2TransitionData = { | |
startTime: 72.556, | |
skipBeginning: 45.824, | |
}; | |
var context = new AudioContext(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Specialized; | |
using System.Linq; | |
using JetBrains.Annotations; | |
// ReSharper disable CheckNamespace -- be available where Dictionary<,> is | |
namespace System.Collections.Generic | |
{ | |
/// <summary> | |
/// System.Collections.Specialized.OrderedDictionary is NOT generic. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Interop; | |
// Start Visual Studio | |
// File->New->Project->C#->WPF Application | |
// Replace MainWindow.Xaml.cs with this code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ArduinoSTL.h> | |
#include <iostream> | |
// helpers | |
template <typename T> | |
struct id { using type = T; }; | |
template <typename T> | |
using type_of = typename T::type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function drawBuffer( width, height, context, buffer ) { | |
var data = buffer.getChannelData( 0 ); | |
var step = Math.ceil( data.length / width ); | |
var amp = height / 2; | |
for(var i=0; i < width; i++){ | |
var min = 1.0; | |
var max = -1.0; | |
for (var j=0; j<step; j++) { | |
var datum = data[(i*step)+j]; | |
if (datum < min) |
OlderNewer