Skip to content

Instantly share code, notes, and snippets.

💭
Building

David Murdoch davidmurdoch

💭
Building
Block or report user

Report or block davidmurdoch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@davidmurdoch
davidmurdoch / HackyBigDecimal.js
Created May 3, 2019
Hacked together an implementation of big decimals using `BigInt`. Doesn't do division very well. Lots of issues.
View HackyBigDecimal.js
function getDecimalSeparator(locale) {
const numberWithDecimalSeparator = 1.1;
return Intl.NumberFormat(locale)
.formatToParts(numberWithDecimalSeparator)
.find(part => part.type === 'decimal')
.value;
}
getDecimalSeparator();
const RADIX_PREFIX = {
@davidmurdoch
davidmurdoch / snippet-deflator.aspx.cs
Created Oct 9, 2013
The code behind my snippet deflator (http://www.vervestudios.co/projects/compression-tests/snippet-deflator). Original written sometime in 2009.
View snippet-deflator.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form != null && Request.Form.Count > 0 && Request.Form["text"] != null)
{
var text = Request.Form["text"];
byte[] byteArray = Encoding.ASCII.GetBytes(text);
using (var stream = new MemoryStream())
{
using (var strm = new zlib.ZOutputStream(stream, zlib.zlibConst.Z_BEST_COMPRESSION, false))
View jsmem.md

JavaScript Code

var str = "hi";

Memory allocation:

Address Value Description
...... ...
@davidmurdoch
davidmurdoch / chromeless\modules\lib\chromeless-policy.js
Created May 27, 2011
How do I register this so I can use nsIContentPolicy shouldLoad method?
View chromeless\modules\lib\chromeless-policy.js
const {Cc, Ci, Cu, Cm, Cr} = require("chrome");
const xpcom = require("xpcom");
/***********************************************************
class definition
***********************************************************/
var description = "Chromeless Policy XPCOM Component";
/* UID generated by http://www.famkruithof.net/uuid/uuidgen */
View frame-buster-buster
(function(){
var preventBust = 0;
window.onbeforeunload = function () {
preventBust++;
};
setInterval(function () {
if (preventBust > 0) {
preventBust -= 2;
window.top.location = "/statuscode/204";
}
@davidmurdoch
davidmurdoch / css30.xml
Created Mar 24, 2011 — forked from KrofDrakula/css30.xml
CSS 3 validation for Visual Studio 20(08|10)
View css30.xml
<?xml version="1.0" encoding="utf-8" ?>
<cssmd:cssmd xmlns:cssmd="http://schemas.microsoft.com/Visual-Studio-Intellisense/css" version="VS8" description="CSS3 validation data">
<cssmd:property-set>
<!-- Based on the original css21.xml from Visual Studio 2010 -->
<!-- Font Properties -->
<cssmd:property-def _locID="color" _locAttrData="description,syntax" type="color"
description="Color of an element's text"
syntax="#RRGGBB | Named Color | rgb(R, G, B) | rgba(R, G, B, A) | inherit"
enum="inherit Aqua Black Blue Fuchsia Gray Green Lime Maroon Navy Olive Orange Purple Red Silver Teal White Yellow ActiveBorder ActiveCaption AppWorkspace Background ButtonFace ButtonHighlight ButtonShadow ButtonText CaptionText GrayText Highlight HighlightText InactiveBorder InactiveCaption InactiveCaptionText InfoBackground InfoText Menu MenuText Scrollbar ThreeDDarkShadow ThreeDFace ThreeDHighlight ThreeDLighShadow ThreeDShadow Window WindowFrame WindowText"/>
You can’t perform that action at this time.