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
var canvas = document.getElementById("myCanvas"); | |
var ctx = canvas.getContext("2d"); | |
var x = 0; | |
var y = 0; | |
function drawShape() { | |
ctx.fillRect(x, y, 150, 80); | |
} |
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 countCSSRules() { | |
var results = '', | |
log = ''; | |
if (!document.styleSheets) { | |
return; | |
} | |
for (var i = 0; i < document.styleSheets.length; i++) { | |
countSheet(document.styleSheets[i]); | |
} | |
function countSheet(sheet) { |
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
`import DS from 'ember-data'` | |
ApplicationAdapter = DS.ActiveModelAdapter.extend | |
namespace: 'api/v1' | |
headers: | |
"X-CSRF-Token": $('meta[name="csrf-token"]').attr('content') | |
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
`import Ember from 'ember'` | |
SavedIndicatorComponent = Ember.Component.extend | |
_saveCount: 0 | |
attrs: | |
saveCount: 0 | |
duration: 2000 | |
attributeBindings: ['style'] |
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
I recently upgraded my ember-cli app running on Ember 1.13.x to Ember 2.0.1. Here's how I did it: | |
1. I updated to Ember 1.13.10 by editing the bower.json file and then running bower update. | |
2. I fixed all Ember deprecation warnings. Some of the deprecation warnings were from my code while others were from external libraries that I was using. | |
3. To update to Ember 2.0.1 I did the following: | |
made the following changes to bower.json | |
- changed "ember": "1.13.10" to "ember": "2.0.1" | |
- changed "ember-data": "1.13.11" to "ember-data": "2.0.0" | |
- changed "ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3" to "ember-cli-shims": "ember-cli/ember-cli-shims#0.0.5" | |
- changed "ember-load-initializers": "ember-cli/ember-load-initializers#0.1.5" to "ember-load-initializers": "ember-cli/ember-load-initializers#0.1.7" |
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
# add to site_extension.rb | |
Checkout.class_eval do | |
state_machine do | |
before_transition :to => 'confirm' do |checkout, transition| | |
!checkout.payments.first.nil? && !checkout.payments.first.source_id.nil? | |
end | |
end | |
end | |
# override update method in CheckoutsController |
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() { | |
$( ".sortable" ).sortable({ | |
handle: '.handle', | |
cursor: 'crosshair', | |
update: function(){ | |
$.ajax({ | |
type: 'post', | |
data: $('.sortable').sortable('serialize'), | |
url: '/projects/<%= @project.id %>/sort_tasks'}); | |
} |
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
### output from running cucumber ### | |
Using the default profile... | |
Feature: Manage Projects | |
In order to manage my projects | |
As an authenticated user | |
I want to create and manage projects | |
Scenario: Projects List # features/manage_projects.feature:7 | |
Given I am logged in as user bob@test.com # features/step_definitions/project_steps.rb:1 | |
And I have 5 to 10 projects # features/step_definitions/project_steps.rb:10 |
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
def site_taxes | |
zones = Zone.match(self.shipment.address) | |
tax_rates = zones.map { |zone| zone.tax_rates}.flatten.uniq | |
calculated_taxes = {} | |
tax_rates.each do |tax_rate| | |
calculated_taxes[tax_rate.calculator.description] ||= 0 | |
calculated_taxes[tax_rate.calculator.description] += tax_rate.calculate_tax(self) | |
end | |
calculated_taxes.delete_if { |k, v| v == 0 } | |
end |
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
# put in config/application.rb | |
config.to_prepare do | |
::PagesController.module_eval do | |
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
end | |
::Page.module_eval do | |
after_save :clear_static_caching! | |
after_destroy :clear_static_caching! |
OlderNewer