This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int one = 1; | |
int two = 2; | |
cout << one + two << "\n"; | |
return 0; |
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
int one = 1; | |
int two = 2; | |
cout << one + two << "\n"; | |
return 0; |
This file contains hidden or 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
console.time('fast array'); | |
var myClass = function() { | |
this.array_one = [1,2,3,4,5]; | |
this.array_two = [1,2,3,4,5]; | |
this.total = 0; | |
} | |
var my_instance = new myClass(); |
This file contains hidden or 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
console.time('slow array'); | |
var myClass = function() { | |
this.array_one = [1,2,3,4,5]; | |
this.array_two = [1,2,3,4,5]; | |
this.total = 0; | |
} | |
var my_instance = new myClass(); |
This file contains hidden or 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
console.time('local'); | |
var myObject = { | |
key1: { | |
key2: { | |
key3: 1 | |
} | |
} | |
} |
This file contains hidden or 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
console.time('non-local'); | |
var myObject = { | |
key1: { | |
key2: { | |
key3: 1 | |
} | |
} | |
} |
This file contains hidden or 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 formData = new FormData(), | |
$input = $('#avatar'); | |
formData.append('user[avatar]', $input[0].files[0]); | |
$.ajax({ | |
url: this.model.url(), | |
data: formData, | |
cache: false, | |
contentType: false, |
This file contains hidden or 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 update | |
@user = current_user | |
if @user.update_attributes(params[:user]) | |
render :json => @user | |
else | |
render :json => @user.errors | |
end | |
end |
This file contains hidden or 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
class User | |
def eager_load_foo | |
if Rails.cache.fetch(self.foo_cache_key).nil? # a cache of the current iterator doesn't exist, so create it | |
Rails.cache.write(self.foo_cache_key, Foo.to_json) | |
end | |
end | |
end |
This file contains hidden or 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
class FooController | |
caches_action :foo, :cache_path => Proc.new { |c| current_user.foo_cache_key } | |
end |