The fun part of user scripting is deciding what happens. The boring part is scavenging the DOM for bits of templated data, or elements you want to mod.
Have on.js
do it for you!
The fun part of user scripting is deciding what happens. The boring part is scavenging the DOM for bits of templated data, or elements you want to mod.
Have on.js
do it for you!
function square(x) { | |
return x*x; | |
} | |
function add3(x) { | |
return x + 3; | |
} | |
function sub10(x) { | |
return x - 10; |
⇐ back to the gist-blog at jrw.fi
Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.
I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.
This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso
(aka "Algebraic JavaScript Specification")
This project specifies the behavior of a number of methods that may optionally be added to any object. The motivation behind this is to encourage greater code reuse. You can create functions that just rely on objects having implementations of the methods below, and in doing so you can make them work with a wide variety of different, but related data structures.
For the purposes of this, spec, an "entity" is an object that has an [[equivalent]]
operation (see bellow) and may implement some or all of the other methods.
#define USE_ROBIN_HOOD_HASH 1 | |
#define USE_SEPARATE_HASH_ARRAY 1 | |
template<class Key, class Value> | |
class hash_table | |
{ | |
static const int INITIAL_SIZE = 256; | |
static const int LOAD_FACTOR_PERCENT = 90; | |
struct elem |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000
import groovy.transform.* | |
// Immutable test object | |
def tim = new Person( 'tim', new Address( 'Woo', 123 ) ) | |
// Lens for setting address for a person | |
Lens personAddress = new Lens( { p -> p.address }, { p, a -> new Person( p.name, a ) } ) | |
// And one for setting zipcode for an address | |
Lens addressZipcode = new Lens( { a -> a.zip }, { a, z -> new Address( a.street, z ) } ) |
Based on the Ruby version here, blogged about here by @otobrglez
macro protocol { | |
case { _ $name:ident { $fn:protocol_fn ... } } => { | |
// Probably not a good idea to rely on `__fresh`. Sweet.js should provide | |
// some sort of blessed gensym capability. | |
letstx $id = [makeValue(__fresh(), #{ here })]; | |
return #{ | |
function $name(proto, impl) { | |
if (!impl) { | |
impl = proto; | |
proto = {}; |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.