Import custom HTML element with shadow DOM
1 2 3 4 |
<!-- importing document --> <link rel="import" href="my-element.html"> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<!-- my-element.html --> <template> <!-- HTML, JavaScript, CSS here will not be accessible from importing document --> </template> <script> (function() { var component = document.currentScript.ownerDocument; var tpl = component.querySelector('template'); var MyProto = Object.create(HTMLElement.prototype); MyProto.createdCallback = function() { this.root = this.createShadowRoot(); this.root.appendChild(document.importNode(tpl.content, true)); }; document.registerElement('my-element', { prototype: MyProto }); })(); </script> |
Most used Git commands
Working tree status git status
Stage only tracked files git add -u
Unstage git reset
Review changes between HEAD and working tree before each commit git diff
.
git commit
git push origin master
Deploy git pull origin master
Bower vs NPM confusion
“Bower is created solely for the front-end and is optimized with that in mind (…) requires a flat dependency tree.”
How to add new client javascript library to a project?
- Edit bower.json
bower update
grunt wiredep
*
* See Gruntfile.js.
Edit or create package.json and use npm to install grunt and wiredep.
Shades of gray
1 2 3 4 5 6 7 |
# p - percentage of black def gray(p): h = hex(int(255 - int(255/100*p))) return '#' + h[2:] + h[2:] + h[2:] |
WordPress download and extract script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<?php /** * @author Ruslanas Balčiūnas */ /* DELETE AFTER USAGE */ $url = 'http://wordpress.org/latest.tar.gz'; $fname = 'latest.tar.gz'; file_put_contents($fname, fopen($url, 'r')); // remove old version if(file_exists('latest.tar')) { unlink('latest.tar'); } $p = new PharData($fname); try { $p->decompress(); } catch (Exception $e) { die($e->getMessage()); } try { $phar = new PharData('latest.tar'); $phar->extractTo('./', null, true); } catch (Exception $e) { $e->getMessage(); } unlink('latest.tar'); unlink($fname); echo 'Done!'; ?> |
Recent Comments
Nice poetry
— Darius, About
Galėtų būti daugiau komentarų.
— Alter ego, WordPress download and extract script
Jėga!
— Darius, WordPress download and extract script
Search
Recent Posts
Tags
Recent RFCs
- RFC 8361: Transparent Interconnection of Lots of Links (TRILL): Centralized Replication for Active-Active Broadcast, Unknown Unicast, and Multicast (BUM) Traffic
- RFC 8360: Resource Public Key Infrastructure (RPKI) Validation Reconsidered
- RFC 8362: OSPFv3 Link State Advertisement (LSA) Extensibility
- RFC 8352: Energy-Efficient Features of Internet of Things Protocols
- RFC 8367: Wrongful Termination of Internet Protocol (IP) Packets
Chris Lowis
- Web Audio Weekly has moved
- Notes for my talk 'A brief history of synthesis with the Web Audio API'
- Notes for my talk 'The Origins Of Computer Music'
- Creating dub delay effects with the Web Audio API
- Interview with Adrian Holovaty of Soundslice
- Writing tests for the Web Audio API
- Synthesis with the Web Audio API - Envelopes
- Playing notes with the Web Audio API Part 2 - Polyphonic Synthesis
- Playing notes with the Web Audio API Part 1 - Monophonic Synthesis
- Using YouTube videos in HTML5 presentations