wroc_love.rb 2018

Lightning Talks Day 3

wroc_love.rb 2018

00:00:15.980 Let's talk about Ethereum's distributed database structure. About 90 percent of smart contracts in Ethereum are distributed in a unique way. It stores the same data across all computers, ensuring redundancy and reliability. The good thing about Ethereum is that it is not just a database for data; it also functions as a database for code. You can write code and store it in Ethereum in what is called a smart contract. A smart contract is essentially a set of functions along with a storage area for data. One critical aspect to note is that you cannot randomly change this data once it has been uploaded to Ethereum. You can only modify this data in accordance with the functions you defined during the upload. When you need to change your smart contract data, you simply create a transaction that invokes the appropriate function, and the changes are applied. One interesting feature of smart contracts is that they allow for imaginative applications. People have come up with very creative ways to utilize smart contracts, including creating their own currencies. The process involves creating a smart contract that maps addresses to values, indicating the amount of tokens or currency associated with each address. Once set, everyone can create transactions that update this mapping according to the defined functions.
00:01:14.220 For example, if I issue a transaction on Ethereum using a specific function, this function will add value to my balance, allowing me to transfer tokens or perform other operations. If you're interested in learning more about this, you can visit Ethereum's website where they provide good tutorials. In fact, you can even create your own tokens and launch an Initial Coin Offering (ICO). If you plan to do that, consider doing it in Belarus where it is legal. Thank you for your attention. So, months ago, I had an idea for a project and wanted to quickly present it. It’s not a jam or anything elaborate, just a technique I used to do some tasks. In my previous talk, I discussed commands and events but didn't touch on the interesting way to decouple things. What I have here is a small code example that demonstrates how we register command handlers to process commands. It's quite simple: you build a registry to add and fetch various handlers for commands and events. Unlike commands, events can be handled by multiple handlers simultaneously.
00:02:55.470 During the registration phase, which occurs at boot time, we register all command and event handlers. When we want to handle a command, we simply tell the bus to process it. The same applies when handling events. The beauty of this decoupling is that publishers do not need to know what handlers will manage their messages. They just instruct the bus to handle them. Could this be a good idea? I don't know for certain; it's a pattern that some often use. If you have thoughts on it, please share with me later. I also want to delve into refinements and discuss when they might be useful. I previously talked about balance reduction and certain examples, and I mentioned modernization. When wanting to utilize features unavailable in previous versions of Ruby or frameworks, you can employ this simple technique. Moving on to perfect privacy in Ruby—using the private keyword does not guarantee that your code is safe from invocation by other parts. Someone can still leverage 'send' to access methods marked as private. However, refinements can help maintain true encapsulation.
00:05:30.580 The most common use case for refinements is to build classes without polluting the global namespace, keeping changes confined to specific files. For instance, a gem can utilize refinements to enhance its functionality without affecting the broader Ruby environment. There are other examples, such as a gem of mine that transforms lambdas into procs, highlighting the subtle distinctions between them. We often prefer to use procs for various syntax conveniences accessible with refinements. As a broad tip, remember that you can use information about activated models through refinements in Ruby. This aspect tends to be overlooked, but most of you may have heard of Ractor, which is an upcoming implementation in Ruby that will also support refinements, suggesting their longevity in the language. However, refinements have presented some challenges.
00:08:11.050 There are numerous tickets documented in the Ruby issue tracker, indicating unusual behaviors when certain conditions are met. For instance, refinements may be activated when using 'send' but not with 'public_send'. This discrepancy can lead to unexpected results, so be cautious of it when working with refinements. Additionally, there are several incomplete implementations of refinements in environments like JRuby where you might encounter different behaviors. Nevertheless, they generally work well. To conclude my talk, I want to highlight a project of mine called JamCheck, which encompasses all the refinements I've discussed as part of a broader effort to provide guidance for gem authors. It's essentially a collection of tips I've compiled from my experiences in developing Ruby gems, aimed at simplifying usage for other developers.
00:09:39.000 It isn't designed for commercial applications but rather as a resource for gem authors to help them create better software. The checklist covers crucial properties every gem should possess, especially since very few gems adhere to these standards. As I share this, there are useful links and tools incorporated to assist in enhancing documentation, linting, and more. That's it for now, and I appreciate your attention. Please raise your hand if you feel you’re often distracted from your real work. Now raise your hand if you acknowledge that you are the one who distracts yourself with social media or other activities. Interestingly enough, distractions can make you less productive than being under the influence. To combat this, I've devised a workflow strategy to help regain focus.
00:10:22.760 I call it the 'sandwich workflow.' First, work offline—without distractions. Then, transition to an online phase where you can collaborate with others, and afterward, move to an off-topic phase allowing yourself time to relax. You might structure this around four rounds per day, where you first work on your primary tasks for 90 minutes, followed by interaction with colleagues for a similar duration, and finally, allow yourself time for browsing or other distractions for about 30 minutes. Engage in this cycle throughout the day to maintain productivity while still allowing room for off-topic activities.
00:12:26.250 This method has helped me regain focus and make more productive use of my time. It essentially creates an immersion-driven workflow that allows you to dive deep into your work without distractions. Begin your offline phase with a clear plan of what you wish to accomplish and strive to achieve something during that time. Completing a task provides an instant sense of gratification, which is often sought after in distractions. Although this strategy may not suit every work environment—it works best in remote, asynchronous settings with autonomy—you might consider discussing it with your boss to see if adaptations can be made.
00:14:29.500 In this lightning talk, I wanted to take a step back and discuss Ruby's standard library. I decided to explore its features and share my findings. Among my discoveries was the 'Brief' class, designed to define abbreviations for a range of strings, which is certainly useful. The library also includes the 'Matrix' class for regular operations on matrices, a standard expectation across various programming languages. Additionally, there's functionality for calculating prime numbers and their divisions, which is also readily available in Ruby.
00:15:46.000 Digging a bit deeper, there are classes such as DBM, DBM, and GDBM that differ mainly in their internal implementations. They act as embedded key-value stores for strings, allowing you to manage large hashes of strings effectively. On a more complex note, 'PStore' lets you save a keymap of objects along with their states, which can simplify data management in your application. You can implement a hierarchy of states and connect them with named labels. Consequently, when stored, they can be easily retrieved later. Ruby also offers 'Distributed Ruby,' enabling you to create classes and expose them via a Ruby protocol, allowing interaction across processes.
00:17:14.000 Moreover, there are options for parsing command-line arguments through the 'OptionParser' class, which provides a convenient alternative to environment variables. The Ruby standard library has a wealth of features, including topological sorting of directed graphs, making it a versatile tool for developers. I encourage you to explore it further, as you might find utility within its offerings. Lastly, I wanted to share my experiences orchestrating games using Ruby. It all began with my excitement to play 'Black and White 2' on my desktop computer, running into various complications due to compatibility with Windows 10. After several unsuccessful attempts to install the game, I took to utilizing VMware, attempting to create an emulated setup using various graphics cards.
00:29:31.000 After significant technical challenges, I established a system that allowed me to use multiple screens and graphics cards effectively by leveraging PCI pass-through in Linux. Each setup necessitated careful management of USB devices and peripherals, including keyboards, mouse setups, and audio interfaces. Throughout the process, I recognized the importance of establishing a standardized method to navigate these complexities, leading me to innovate solutions for game emulation within different virtual environments. Thank you for your attention.