Skip to content

Instantly share code, notes, and snippets.

View triskweline's full-sized avatar

Henning Koch triskweline

View GitHub Profile
@triskweline
triskweline / jquery_shuffle_children.js
Created November 15, 2018 08:44 — forked from joseluisq/jquery_shuffle_children.js
Shuffle child elements with jQuery
jQuery.fn.shuffleChildren = function(){
var p = this[0];
for (var i = p.children.length; i >= 0; i--) {
p.appendChild(p.children[Math.random() * i | 0]);
}
};
@triskweline
triskweline / test.html
Created June 24, 2018 07:59
Custom Elements v0 vs. DOMParser
<!doctype html>
<html>
<head>
<title>Custom elements test</title>
</head>
<body>
<h3>Custom elements from HTML</h3>
<ol class="from-html" start="0">
Foo
- foo
- bar
code
code
- baz
Test
- foo
- bar
baz
- bam
- ofo
- bar
bam
- zzz
ul.tree
cursor: pointer
$self_color: desaturate($COLOR_MIDNIGHT_BLUE - 10, 20)
$darkening_per_level: 10
$indent: 28px
.self
background-color: $self_color
@triskweline
triskweline / patterns.rb
Last active September 1, 2015 14:20
Regular expression to sanity check URLs
URL = %r{
\A # Beginning of string
(http|https) # $1: Scheme
:\/\/ # ://
([\w\-_]+(?:\.[\w\-_]+)*) # $2: Hostname. Does not begin or end with a dot. No two dots in a row.
(?::(\d+)) # $3: Port (without leading colon)
(/[^/\?\#]*) # $4: Path (with leading slash)
(?:\?([^\#]*)) # $4: Query (without leading question mark)
(?:\#(.*)) # $5: Hash (without leading hash)
\z # End of string
### Keybase proof
I hereby claim:
* I am henning-koch on github.
* I am triskweline (https://keybase.io/triskweline) on keybase.
* I have a public key whose fingerprint is 17CF 7D9F 8992 66DA CB28 7332 9169 5476 8F13 232D
To claim this, I am signing this object: