Skip to content

Instantly share code, notes, and snippets.

package main
import (
"golang.org/x/tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(node *tree.Tree, ch chan int) {
@v-zo
v-zo / System Design.md
Created November 26, 2020 06:25 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@v-zo
v-zo / myCustomCommand.ts
Created November 18, 2020 12:28 — forked from NicholasBoll/myCustomCommand.ts
Adding Custom Cypress command
declare namespace Cypress {
interface Chainable<Subject> {
myCustomCommand(username: string, password: string): Cypress.Chainable<Response>
}
}
Cypress.Commands.add('myCustomCommand', (username: string, password: string) => {
Cypress.log({
name: 'loginByForm',
@v-zo
v-zo / CreateJob.sh
Created November 17, 2020 22:39 — forked from stuart-warren/CreateJob.sh
Create a job in Jenkins (or folder) using the HTTP API
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# create folder
@v-zo
v-zo / foo
Last active October 30, 2020 10:56
// пример 1
// что выведется в консоли?
const bar = ({ x }) => (A = $ =>`{${$}$}`) => (...foo) => {
return A(x)
console.log(foo)
};
console.log( bar({ foo: 43, x: 42})()(6,7,8) );
@v-zo
v-zo / slim-redux.js
Created May 2, 2020 17:13 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@v-zo
v-zo / BackboneJS API fetch and parse
Created February 1, 2019 14:15 — forked from daniel-234/BackboneJS API fetch and parse
BackboneJS - Fetch data from an API and parse the response populating models inside a collection
About this gist
With this gist I wanted to freeze some concepts about BackboneJS that could
save some time in the future either to me if I needed to use this functionality
again, or to somebody else.
This implementation addresses the need to retrieve some data from an API and
to populate a BackboneJS collection accordingly, storing the retrieved items
as Models inside the Collection.
If you want to see this functionality built into an application, have a look
@v-zo
v-zo / tests.html
Created July 14, 2018 18:52
Разработайте юнит-тесты проверяющие корректность работы функции. Удалось ли найти какие-либо дефекты в этой функции, полагаясь на ее назначение исходя из описания?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- подключаем стили Mocha, для отображения результатов -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.css">
<!-- подключаем библиотеку Mocha -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.js"></script>
@v-zo
v-zo / matrix.js
Created July 14, 2018 18:45
разработайте реализацию функции sumUpDiagonals() на JavaScript таким образом, чтобы она возвращала суммы основной и вторичной диагоналей квадратной матрицы
var matrixExample = [
[ 1, 2, 3, 4 ],
[ 4, 5, 6, 5 ],
[ 7, 8, 9, 7 ],
[ 7, 8, 9, 7 ]
];
function sumUpDiagonals(matrix) {
var diag = {
sumMainD : 0,