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
public class SimpleRealmApp extends Application { | |
private static SimpleRealmApp instance; | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
instance = this; | |
RealmConfiguration config = new RealmConfiguration.Builder(getApplicationContext()).setModules(new SimpleRealmModule()).build(); | |
Realm.setDefaultConfiguration(config); |
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
public class UniversityRepository implements IUniversityRepository { | |
@Override | |
public void addUniversity(University university, OnAddUniversityCallback callback) { | |
Realm realm = Realm.getInstance(SimpleRealmApp.getInstance()); | |
realm.beginTransaction(); | |
University u = realm.createObject(University.class); | |
u.setId(UUID.randomUUID().toString()); | |
u.setName(university.getName()); | |
realm.commitTransaction(); |
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
public class StudentRepository implements IStudentRepository { | |
@Override | |
public void addStudent(Student student, OnSaveStudentCallback callback) { | |
Realm realm = Realm.getInstance(SimpleRealmApp.getInstance()); | |
realm.beginTransaction(); | |
Student realmStudent = realm.createObject(Student.class); | |
realmStudent.setId(UUID.randomUUID().toString()); | |
realmStudent.setName(student.getName()); | |
realmStudent.setBirthday(student.getBirthday()); |
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
contract MyToken { | |
/* This creates an array with all balances */ | |
mapping (address => uint256) public balanceOf; | |
} |
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
/* Send coins */ | |
function transfer(address _to, uint256 _value) { | |
/* Add and subtract new balances */ | |
balanceOf[msg.sender] -= _value; | |
balanceOf[_to] += _value; | |
} |
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 transfer(address _to, uint256 _value) { | |
/* Check if sender has balance and for overflows */ | |
require(balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_to]); | |
/* Add and subtract new balances */ | |
balanceOf[msg.sender] -= _value; | |
balanceOf[_to] += _value; | |
} |
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
/* Initializes contract with initial supply tokens to the creator of the contract */ | |
function MyToken(uint256 initialSupply, string tokenName, string tokenSymbol, uint8 decimalUnits) { | |
balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens | |
name = tokenName; // Set the name for display purposes | |
symbol = tokenSymbol; // Set the symbol for display purposes | |
decimals = decimalUnits; // Amount of decimals for display purposes | |
} |
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
Rails.application.configure do | |
config.generators do |g| | |
g.orm :active_record, migration: true | |
g.test_framework :rspec, fixtures: false | |
g.helper false | |
g.decorator false | |
g.controller assets: false | |
end | |
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
... | |
group :development, :test do | |
gem 'rspec-rails' | |
end | |
group :test do | |
gem 'shoulda-matchers' | |
gem 'rspec-activemodel-mocks' | |
gem 'rspec-its' |
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
namespace :api do | |
end |