- Declaring an empty vector and then pushing values
// creates an empty vector
std::vector<int> vec;
// push values into vector
vec.push_back(10);
vec.push_back(20);
vec.push_back(30);| # Install wll_paginate (https://github.com/mislav/will_paginate) | |
| bundle add will_paginate | |
| # controllers/users_controller.rb | |
| class UsersController < ApplicationController | |
| def index | |
| @users = User.paginate(page: params[:page], per_page: 3) | |
| end | |
| end |
| var blake = require('blakejs') | |
| const main = async () => { | |
| const hex_value = "0a0b"; | |
| console.log(hex_value) | |
| // Output: 0a0b | |
| const buffer = Buffer.from(hex_value, 'hex') | |
| console.log(buffer) | |
| // Output: <Buffer 0a 0b> |
| OK, Let's begin. Hello, Everybody. | |
| My name is Narihiro Nakamura. | |
| Today, I'm talking about "Parallel worlds of CRuby's GC". | |
| I'm very happy now, because I'm meeting attendee in rubyconf. | |
| And, one of my dreams is to talk in rubyconf. | |
| So, I'm very happy and exciting. | |
| Today is my first presentation in English. | |
| My English is not good. |
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
| require 'casper_network' | |
| # We'll use this to connect to the Casper Network. | |
| client = Casper::CasperClient.new('YOUR_CASPER_NETWORK_NODE_IP_ADDRESS') | |
| # A block hash is a Digest over the contents of the block Header. | |
| block_hash = "53943d39b0ea69dbdd3e255cfafbe0a3d610ccd0e83d86c83ee6d2f623b92e84" | |
| block = client.chain_get_block(block_hash) | |
| # How to access and print the Era ID in which this block was created. |
| require 'casper_network' | |
| # Following IP addres is taken from https://testnet.cspr.live/tools/peers | |
| YOUR_CASPER_NETWORK_NODE_IP_ADDRESS = "65.108.73.113" | |
| # We'll use this to connect to the Casper Network. | |
| client = Casper::CasperClient.new(YOUR_CASPER_NETWORK_NODE_IP_ADDRESS) | |
| block_hash = "53943d39b0ea69dbdd3e255cfafbe0a3d610ccd0e83d86c83ee6d2f623b92e84" | |
| block = client.chain_get_block(block_hash) | |
| # A Block object | |
| puts block |
| require 'casper_network' | |
| # Following IP addres is taken https://testnet.cspr.live/tools/peers | |
| node_ip_address = "65.21.235.219" | |
| client = Casper::CasperClient.new(node_ip_address) | |
| block = client.get_block_by_height(1271722) | |
| # A Block object | |
| puts block | |
| # To retrieve BlockHeader object |
| var blake = require('blakejs') | |
| const main = async () => { | |
| const input = "abc" | |
| console.log(Buffer.from(input, 'hex')) | |
| const array = Uint8Array.from(Buffer.from(input, 'hex')); | |
| console.log("array is ",array) | |
| // Output : Uint8Array(1) [171] | |
| const byte_array = blake.blake2b(array, null, 32); |
| require 'blake2b' | |
| input = "020e0000006361737065722d6578616d706c65130000006578616d706c652d656e7472792d706f696e7401000000080000007175616e7469747904000000e803000001050100000006000000616d6f756e7404000000e803000001" | |
| key = Blake2b::Key.none | |
| hex = Blake2b.hex(input, key, 32) # It does not give the same result that we got from js | |
| body_uint8_array = [input].pack("H*").unpack("C*").inspect | |
| body_hash_array = Blake2b.bytes(body_uint8_array, key, 32) | |
| puts body_hash_array.pack("C*").unpack("H*").first |