// jQuery
$(document).ready(function() {
// code
})
!!! 5 | |
html(class='no-js') | |
head | |
meta(charset='utf-8') | |
meta(http-equiv='X-UA-Compatible', content='IE=edge') | |
title | |
meta(name='description', content='') | |
meta(name='viewport', content='width=device-width, initial-scale=1') |
// swap the keybindings for paste and paste_and_indent | |
{ "keys": ["super+v"], "command": "paste_and_indent" }, | |
{ "keys": ["super+shift+v"], "command": "paste" } |
I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.
If you want to roll up all of these into a single jQuery plugin check out Sharrre
Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.
var less = require('less'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var SourceMapGenerator = require('source-map').SourceMapGenerator | |
function errfn(callback) { | |
return function (err) { | |
if (err) callback.call(this, err); | |
else callback.apply(this, [].slice.apply(arguments).slice(1)); | |
} |
<?php | |
return array( | |
'title' => 'Widget Title', | |
'html' => function() { | |
// any data for the template | |
$data = array(); | |
return tpl::load(__DIR__ . DS . 'template.php', $data); | |
} | |
); |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent
/** | |
* A quick way of using Markdown inside JSX: via tagged templates | |
* | |
* Downsides: | |
* – Works completely dynamically (no static compilation) | |
* – Big downside: You must escape backticks. | |
* Potential work-around in template tag function: result.replace(/∆/ug, '`') | |
* | |
* Upsides: | |
* – Preserves line breaks (JSX doesn’t) |