Skip to content

Instantly share code, notes, and snippets.

@garata
garata / ie-xml5633-monkeypatch.js
Created June 15, 2014 15:25
An Internet Explorer specific snippet useful on MS IE9 and above when XML5633 error message is shown in the Dev Tool console: "XML5633: End-tag name does not match the corresponding start-tag name".
/*@cc_on
@if (@_jscript_version >= 9)
// (C) Giorgio Arata - Mit Style License.
(typeof DOMParser === "function") && !function(dp) {
var TEXT_SE = "[^<]+",
TILL_HYPHEN = "[^-]*-",
TILL_HYPHEN2 = TILL_HYPHEN + "([^-]" + TILL_HYPHEN + ")*-",
COMMENT_CE = TILL_HYPHEN2 + ">?",
TILL_RSB = "[^]]*]([^]]+])*]+",
CDATA_CE = TILL_RSB + "([^]>]" + TILL_RSB + ")*>",
@garata
garata / roundup10s.js
Created July 25, 2014 21:46
Round up a number to the nearest tens
Math.roundUp10s = (function(m) {
var ln10 = (m.LN10 || m.log(10));
// (C) Giorgio Arata - DO WHAT YOU WANT LICENSE
return function roundUp10s(value) {
var length, power, isNeg;
if (isNeg = (value < 0))
value = Math.abs(value);
length = m.floor((m.log(value) / ln10) + 1.0) - 1;
power = m.pow(10, length);
return (isNeg ? -1 : 1) * m.ceil((value) / power) * power;
@garata
garata / Anchor-Smooth-Page-Scroll.markdown
Last active August 29, 2015 14:06
A Pen by Giorgio Arata.

Anchor Smooth Page Scroll

This is a quick way to make even the simple act of scrolling up and down a page more visually appealing. Check this PEN to see Smoothy script in action, and then keep reading to learn how to add Smooth Scroll to your website.

So lets start with the basics. To add an anchor on your page add the following in the place that you would like your page scroll to.

<a id="bottom"></a>

Then to point your link at this anchor, on the same page use one of the following.

@garata
garata / tryjsil.cs
Created December 21, 2017 20:18
JSIL 1051 issue
using System;
using JSIL;
using JSIL.Meta;
class Class1
{
public Class1()
{
Delegate d = new Action<int>(
(int someVar) =>
/**
* Simple implementation of interfaces in JavaScript
*
* @description
*
* Advantages of interfaces:
* + Self-documenting
* + Encapsulation
* + Code reuse
*
@garata
garata / tryjsil.cs
Created July 23, 2014 13:05
C# Dispatch table based on "Generic Dictionary", "Collection Initializer" and "Lambda Expressions"
using System;
using System.Linq;
using System.Collections.Generic;
public class Program
{
static void Main()
{
Func<int, bool> Default = (x => true);