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
/** | |
* Flattens a nested object into a flat form delimited by "." character at | |
* each level. Check tests for an example. | |
* | |
* @param {Object} nestedObject | |
* @returns {Object} | |
*/ | |
export const flattenObject = nestedObject => { | |
const flattenedObject = {} | |
const keys = Object.keys(nestedObject) |
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
git for-each-ref --format '%(refname:short)' refs/heads | grep -Ev `git ls-remote --quiet --heads origin | awk '{print substr($2, 12)}'| paste -sd "|" -` | xargs git branch -D |
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" | |
func main() { | |
sortAndPrint([]int{5, 2, 4, 6, 1, 3}) | |
sortAndPrint([]int{5, 6, 7, 1, 2, 3}) | |
sortAndPrint([]int{500, 400, 300, 200, 100, 0}) | |
} |
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
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png |
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
" Entry point. Initialize RPC. If it succeeds, then attach commands to the `rpcnotify` invocations. | |
function! s:connect() | |
let id = s:initRpc() | |
if 0 == id | |
echoerr "calculator: cannot start rpc process" | |
elseif -1 == id | |
echoerr "calculator: rpc process is not executable" | |
else | |
" Mutate our jobId variable to hold the channel ID |
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() |
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
// 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
enum Messages { | |
Add, | |
Multiply, | |
Unknown(String), | |
} | |
impl From<String> for Messages { | |
fn from(event: String) -> Self { | |
match &event[..] { | |
"add" => Messages::Add, |