# This example does an AJAX lookup and is in CoffeeScript
$('.typeahead').typeahead(
# source can be a function
source: (typeahead, query) ->
# this function receives the typeahead object and the query string
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
# These are my notes from the PragProg book on CoffeeScript of things that either | |
# aren't in the main CS language reference or I didn't pick them up there. I wrote | |
# them down before I forgot, and put it here for others but mainly as a reference for | |
# myself. | |
# assign arguments in constructor to properties of the same name: | |
class Thingie | |
constructor: (@name, @url) -> | |
# is the same as: |
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
require 'sinatra' | |
require 'redis' | |
require 'json' | |
require 'date' | |
class String | |
def &(str) | |
result = '' | |
result.force_encoding("BINARY") |
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
# Ranking algorithm | |
def set_rank | |
find_id = matching_id || id | |
shared_song = Song.find(find_id) if find_id | |
if shared_song | |
favs_count = shared_song.user_broadcasts_count | |
time_created = shared_song.created_at | |
else | |
favs_count = 1 | |
time_created = created_at |
WARNING
This gist is outdated! For the most up-to-date information, please see http://emberjs.com/guides/routing/!
An Ember application starts with its main template. Put your header, footer, and any other decorative content in application.handlebars
.
<header>
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 we save a record using ember-data's RESTadapter, and it fails, Rails | |
# returns the validation errors of the model as JSON hash: | |
# | |
# {"errors":{"name":["may not be blank"]}} | |
# | |
# This patches the RESTadapter to add these errors to the invalid record. It | |
# can be removed when the following Pull Request was merged into ember-data: | |
# https://github.com/emberjs/data/pull/376 | |
DS.RESTAdapter.reopen |
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
#ack is a tool like grep, designed for programmers with large trees of heterogeneous source code | |
#to install ack, see http://betterthangrep.com/ | |
#to use ack, launch terminal (mac osx) and type 'ack <some_keywords>' | |
#ack will search all files in the current directory & sub-directories | |
#here's how I have my config file setup. this file is located on mac osx here | |
# ~/.ackrc | |
# Always sort the files |
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" | |
"net/url" | |
"reflect" | |
"strconv" | |
) | |
type Person struct { |
Prerequisites:
- One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
- A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.
Software components used:
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
{ | |
"app/adapters/*.js": { | |
"command": "adapter", | |
"template": [ | |
"// export default DS.{capitalize}Adapter.extend();", | |
] | |
}, | |
"app/components/*.js": { | |
"command": "component", |
OlderNewer