Skip to content

Instantly share code, notes, and snippets.

#include <iostream>
using namespace std;
int main()
{
int one = 1;
int two = 2;
cout << one + two << "\n";
return 0;
#include <iostream>
using namespace std;
int main()
{
int one = 1;
int two = 2;
cout << one + two << "\n";
return 0;
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();
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();
console.time('local');
var myObject = {
key1: {
key2: {
key3: 1
}
}
}
console.time('non-local');
var myObject = {
key1: {
key2: {
key3: 1
}
}
}
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,
def update
@user = current_user
if @user.update_attributes(params[:user])
render :json => @user
else
render :json => @user.errors
end
end
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
class FooController
caches_action :foo, :cache_path => Proc.new { |c| current_user.foo_cache_key }
end