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
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| "net/http" | |
| "os" | |
| "time" | |
| ) | |
| func main() { | |
| t := time.After(10 * time.Second) |
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
| https://stackoverflow.com/questions/37063267/high-cpu-usage-with-android-emulator-qemu-system-i386-exe | |
| The cause of the constant CPU usage is the sound. If you do not need sound in your emulator you can disable it by editing the AVD's config file. | |
| Change/add those two lines | |
| hw.audioInput=no | |
| hw.audioOutput=no | |
| On Linux/Mac the file is located at ~/.android/avd/<AVD_Name>.avd/config.ini | |
| On Windows the file is located at C:\Users\<username>\.android\avd\<AVD_Name>.avd\config.ini |
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
| /** | |
| * Create an array of length 'N' by executing repeaterFn for each item. | |
| * This is useful where a method like `getItem()` can return a random item, | |
| * and it can be repeated over N times. | |
| * | |
| * @param {function} repeaterFn | |
| * @param {number} N=5 | |
| * @returns {Array} | |
| */ | |
| const repeat = (repeaterFn, N = 5) => Array(...Array(N)).map(repeaterFn) |
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
| struct Calculator; | |
| impl Calculator { | |
| fn new() -> Calculator { | |
| Calculator {} | |
| } | |
| // Add a vector of numbers. | |
| fn add(&self, nums: Vec<i64>) -> i64 { | |
| nums.iter().sum::<i64>() |
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
| extern crate neovim_lib; | |
| use neovim_lib::{Neovim, NeovimApi, Session}; | |
| struct EventHandler { | |
| nvim: Neovim, | |
| calculator: Calculator, | |
| } | |
| impl EventHandler { |
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
| enum Messages { | |
| Add, | |
| Multiply, | |
| Unknown(String), | |
| } | |
| impl From<String> for Messages { | |
| fn from(event: String) -> Self { | |
| match &event[..] { | |
| "add" => Messages::Add, |
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
| // Rest of the stuff remains the same. | |
| fn recv(&mut self) { | |
| let receiver = self.nvim.session.start_event_loop_channel(); | |
| for (event, values) in receiver { | |
| match Messages::from(event) { | |
| Messages::Add => { | |
| // do stuff | |
| } |
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
| fn recv(&mut self) { | |
| let receiver = self.nvim.session.start_event_loop_channel(); | |
| for (event, values) in receiver { | |
| match Messages::from(event) { | |
| // Handle 'Add' | |
| Messages::Add => { | |
| let nums = values | |
| .iter() | |
| .map(|v| v.as_i64().unwrap()) |
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
| fn recv(&mut self) { | |
| let receiver = self.nvim.session.start_event_loop_channel(); | |
| for (event, values) in receiver { | |
| match Messages::from(event) { | |
| // Handle 'Add' | |
| Messages::Add => { | |
| let nums = values | |
| .iter() | |
| .map(|v| v.as_i64().unwrap()) |
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
| " Initialize the channel | |
| if !exists('s:calculatorJobId') | |
| let s:calculatorJobId = 0 | |
| endif | |
| " The path to the binary that was created out of 'cargo build' or 'cargo build --release". This will generally be 'target/release/name' | |
| let s:bin = '/path/to/rust-binary' | |
| " Entry point. Initialize RPC. If it succeeds, then attach commands to the `rpcnotify` invocations. | |
| function! s:connect() |