Skip to content

Instantly share code, notes, and snippets.

View sebmarkbage's full-sized avatar

Sebastian Markbåge sebmarkbage

View GitHub Profile
el.set('contentEditable', true)
.addEvents({
keydown: function(e){ if (e.key == 'enter') e.preventDefault(); },
keypress: function(e){ if (e.event.which == 0 && e.code == 13) e.preventDefault(); },
blur: function(){ var text = this.get('text'); this.set('text', text); }
});
@sebmarkbage
sebmarkbage / Lightbox.css
Created August 8, 2010 00:10
Old Lightbox implementation by Leon Radley and Sebastian Markbåge at Calyptus Life AB
.Lightbox
{
position: absolute;
background: #fff;
border: 10px solid #fff;
width: 200px;
height: 200px;
top: 50%;
left: 50%;
margin: -100px;
// A nicer comparison of CoffeeScript syntax compared to manual ECMAScript Harmony style syntax
// Assignment:
let number = 42,
opposite = true
// Conditions:
if (opposite) number = -42
// Functions:
var playhead, art, keyframe1, keyframe2;
addEvent('load', function(){
art = new ART(400, 400).inject(document.body);
playhead = new ART.Rectangle(200, 200)
.inject(art)
.fill('#00F');
public static Messages.Decimal BuildDecimal(decimal d)
{
int[] bits = decimal.GetBits(d.Value);
if (bits[2] != 0 || bits[1] < 0) throw new Exception("Unrepresentable decimal number. Out of range.");
long value = (((long)bits[1]) << 32) | ((long)bits[0] & 0xFFFFFFFFL);
if ((bits[3] & 0x80000000) != 0) value = -value;
uint scale = ((uint)bits[3] >> 16) & 0xF;
<html>
<head>
<script src="mootools.js"></script>
<script src="mootools-1.2.4.4-more.js"></script>
<script src="rx.js"></script>
<script src="rx.mootools.js"></script>
<script>
window.addEvent('domready', function() {
/*
---
name: ART.Wedge
description: Wedge shape for ART
authors: [Sebastian Markbåge](http://calyptus.eu)
provides: [ART.Wedge]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Reflection;
using System.Reflection.Emit;
using System.Linq.Expressions;
using System.Text;
public static class DbConnection
Autocompleter.implement({
choiceOver: function(choice, selection){
if (!selection && this.options.forceSelect) this.selectedValue = this.opted = choice.inputValue;
return this.parent.apply(this, arguments);
},
hideChoices: function(clear){
if (clear && this.options.forceSelect && (!this.visible || !this.selected) && this.element.value != this.opted) {
this.opted = "";
if (window.XDomainRequest) (function(){
var onLoad = function(){
cleanup(this.xhr);
this.response = {text: this.xhr.responseText, xml: this.xhr.responseXML};
this.success(this.response.text, this.response.xml);
};
var onError = function(){
cleanup(this.xhr);