Skip to content

Instantly share code, notes, and snippets.

View locks's full-sized avatar
🌟
Ember Polaris

Ricardo Mendes locks

🌟
Ember Polaris
View GitHub Profile
@pixelhandler
pixelhandler / Ember-Component-Custom-Select-Box.md
Last active December 21, 2015 14:39
Ember.js component for a custom select box which can have a custom visual design and yet keep all standard browser behavior for selecting options. This `faux-select` is an Ember.Component which follows the intention of W3C web component draft for a "custom element"

Ember Components Example

  • With the select element using an opacity of zero (0), the element can have a custom background, and when clicking on the element the hidden select box still behaves normally (browser's default behavior)
  • The element with the class .faux-select-selected needs javascript functionality which updates the content binding to the value that is selected using the invisble select box (on change).

Steps to build a custom "faux" select box

(clone the emberjs/starter-kit to get started, see the components branch on this clone of starter kit...https://github.com/Ember-SC/starter-kit/commits/components)

  1. Start with removing the default index template/model from the emberjs/starter-kit
@joakimbeng
joakimbeng / router.html
Last active March 15, 2024 06:18
A really simple Javascript router
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Building a router</title>
<script>
// Put John's template engine code here...
(function () {
// A hash to store our routes:
@r00k
r00k / noodle.clj
Last active December 31, 2015 06:38
Parses zsh_history. It calculates the commands that you spend the most time typing (length of command * frequency of typing it) and returns the top-ten most costly commands with their frequencies.
(ns noodle.core)
(defn history-line->command
"Returns the command from a zsh_history-style line"
[line]
(nth (clojure.string/split line #"\s+") 2))
(defn weight
"Returns a number representing how much time you've spent typing a command"
[command invocation-count]

A future version of Ember will come with a new templating engine known as HTMLBars.

The original motivation for HTMLBars was to allow helpers and properties to have better contextual information about what they were bound to.

So for example, consider a template like this:

<a href="{{url}}">{{link}}</a>
@wycats
wycats / app.js
Last active August 2, 2024 09:53
App.Router.map(function() {
this.resource('post', { path: '/posts/:post_id' });
});
App.PostRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('post', params.post_id);
}
});
@haf
haf / thoughts.md
Last active January 1, 2016 13:09
Thoughts on client libraries

In a client library reading TCP, there are constraints.

  • Latency:
    • up <- larger frames, more batching
    • down <- smaller frames, send without waiting in buffers, disable nagles' algorithm
  • Throughput:
    • up <- larger frames, more batching
    • down <- smaller frames, less batching
  • Slow connections:
/* global google */
var GoogleMapComponent = Ember.Component.extend({
places: [],
width: 500,
height: 500,
attributeBindings: ['style'],
style: function () {
return 'width:'+this.width+'px; height:'+this.height+'px';
@tomdale
tomdale / logger.js
Last active March 13, 2025 07:11
Excerpt of the formatted, hierarchical logger in Skylight
/*
Example usage:
import logger from "app/system/logger";
var LOG = logger.loggerFor("topic"');
LOG.log({
event: "data received",
secondary: {
resource: "photo",
# Make sure to do detection so it will gracefully downgrade like:
# begin
require 'psych'
Psych.add_domain_type(nil, 'code') { |_,hash|
p hash['ruby']
}
# rescue
# do 1.8 stuff
# end