Skip to content

Instantly share code, notes, and snippets.

View tylerjohnst's full-sized avatar
:fishsticks:

Tyler Johnston tylerjohnst

:fishsticks:
  • GitHub Staff
  • Saint Petersburg, FL
View GitHub Profile
App.WidgetRoute = Ember.Route.extend({
model: function(params) {
return Ember.RSVP.hash({
widget: this.store.find('widget' params.id),
cogs: App.MyCustomAjax()
})
},
setupController: function (controller, rsvp) {
controller.set('model', rsvp.widget);
moduleFor('controller:application', 'Application controller');
test('it has access to the currentUser object', function() {
var controller = this.subject();
Ember.run(function() {
var user = controller.get('currentUser');
ok(user, "User should exist but doesn't");
});
});
Ember.Application.initializer({
name: 'currentUser',
initialize: function(container, application) {
var user = App.User.create({});
container.optionsForType('user', { instantiate: false, singleton: true });
container.register('type:user', 'current', user);
}
});
App.RaceResultRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('raceResult', params.race_result_id);
},
setupController: function(controller, model) {
this.store.find('raceEvent').then(function(events) {
controller.set('raceEvents', events);
});
}
App.RaceLap = DS.Model.extend({
race_results: DS.belongsTo('race_result')
});
App.RaceResult = DS.Model.extend({
race_laps: DS.hasMany('race_lap')
});
DS.RESTAdapter.reopen({
namespace: 'api/v1'
Error: Sprockets::Rails::Helper::AssetFilteredError: Asset filtered out and will not be served: add `Rails.application.config.assets.precompile += %w( teaspoon.css )` to `config/initializers/assets.rb` and restart your server
def foo
myblock = Proc.new
myblock.call
end
foo do
puts "ZOMG"
end
"ZOMG"
=> nil
# Start an HTTP server from a directory, optionally specifying the port
function server() {
local port="${1:-8000}"
open "http://localhost:${port}/"
# Set the default Content-Type to `text/plain` instead of `application/octet-stream`
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
}
@tylerjohnst
tylerjohnst / 1.9.3-p125-perf
Created May 29, 2012 16:25
rbenv install of 1.9.2-p128 with falcon patch including shard libraries
build_package_combined_patch() {
local package_name="$1"
{
curl https://github.com/ruby/ruby/pull/47.diff | git apply
curl https://raw.github.com/gist/1859082/performance_and_backport_gc.patch | patch -p1
autoconf
./configure --prefix="$PREFIX_PATH" --enable-shared $CONFIGURE_OPTS
make -j 8
make install
{
"current_page":1,
"total_pages":1,
"per_page":50,
"forms":[
{
"id":"4f9ab1bf21c79826c600001e",
"name":"Park Mantinence",
"description":"Form for inspection of park's state of maintenance.",
"created_at":"2012-04-27T14:48:31Z",