- this.store.find('modelType'); always hits the server, because no ID is given, and there may be new records on the server. Use find in the application route, and all in other places to avoid polling the server every time.
- this.store.find('modelType', model_id); only hits the server if the model with the given type and ID is not already in the cache.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
var m map[int]string | |
fmt.Printf("m = %v; m == nil? %t\n", m, m == nil) | |
// it is safe to range over a nil map | |
for i, v := range m { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define -> | |
rAF = window["requestAnimationFrame"] | |
cAF = window["cancelAnimationFrame"] | |
# based on polyfill by Erik Möller, | |
# with fixes from Paul Irish and Tino Zijdel. | |
# https://gist.github.com/1579671 | |
if !rAF or !cAF then do -> | |
for v in ['ms', 'moz', 'webkit', 'o'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
// loop all elements that specify an ownp attribute, | |
// and activate those in a parent matching the specified selector. | |
$("[ownp]").each(function(){ | |
if ($(this).closest($(this).attr("ownp")).length) { | |
$(this).addClass("active"); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dopen = 0 | |
debug = (o...) -> if settings.debug | |
console.debug o... | |
debugWarn = (o...) -> if settings.debug | |
console.warn o... | |
debugGroup = (o...) -> if settings.debug | |
console.group o... | |
dopen++ | |
debugClose = -> if dopen > 0 | |
console.groupEnd() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form data-includes="#anotherForm,[name=someField]" method="get"> | |
<p>Fields from elsewhere in the document will be included on submit.</p> | |
<input type="submit" value="Submit!" /> | |
</form> | |
<form id="anotherForm"> | |
<input type="hidden" name="willBeIncluded" value=":)" /> | |
<input type="number" name="willBeIncludedAndSanitized" min="1" data-sanitize="int" /> | |
<input type="checkbox" name="willBeIncludedIfChecked" value="itWasChecked" /> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// prevent all forms from submitting on pressing Enter in an input | |
// unless the input specifies the `submit13` class. | |
$("input").on("keypress", function(e) { | |
if (e.which == 13) { | |
// prevent all first, and trigger manually to bypass the quirk | |
// where browsers will submit single-input forms on pressing Enter. | |
// otherwise two submit events would be generated in quirk cases. | |
e.preventDefault(); | |
if ($(this).is(".submit13")) { | |
$(this).closest("form").trigger("submit"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if f, ok := x.(interface { Foo() }); ok { | |
f.Foo() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/x-handlebars"> | |
The application template (outer scaffold) has no name, or has the name "application". | |
{{outlet}} | |
</script> | |
<script type="text/x-handlebars" data-template-name="dashboard"> | |
This template embeds another view/controller/template combo with a hyphenated name. | |
{{render "users-list" visibleUsers}} | |
</script> |
OlderNewer