Skip to content

Instantly share code, notes, and snippets.

View kolomiichenko's full-sized avatar

Andrii Kolomiichenko kolomiichenko

View GitHub Profile
@kolomiichenko
kolomiichenko / curl.md
Created April 25, 2018 11:23 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@kolomiichenko
kolomiichenko / xpath.js
Created January 10, 2018 22:11 — forked from iimos/xpath.js
Micro function that gives xpath by element and elements by xpath.
function xpath(el) {
if (typeof el == "string") return document.evaluate(el, document, null, 0, null)
if (!el || el.nodeType != 1) return ''
if (el.id) return "//*[@id='" + el.id + "']"
var sames = [].filter.call(el.parentNode.children, function (x) { return x.tagName == el.tagName })
return xpath(el.parentNode) + '/' + el.tagName.toLowerCase() + (sames.length > 1 ? '['+([].indexOf.call(sames, el)+1)+']' : '')
}
// Usage:
@kolomiichenko
kolomiichenko / gist:8487d8c50d66f155dd6e6fa92d0f631b
Created September 19, 2016 12:16 — forked from moraes/gist:2141121
LIFO Stack and FIFO Queue in golang
package main
import (
"fmt"
)
type Node struct {
Value int
}
@kolomiichenko
kolomiichenko / SliceTricks.md
Created September 19, 2016 11:55
SliceTricks

Since the introduction of the append built-in, most of the functionality of the container/vector package, which was removed in Go 1, can be replicated using append and copy.

Here are the vector methods and their slice-manipulation analogues:

AppendVector

a = append(a, b...)

Copy

##
## Prefer mongodump/mongorestore instead of mongoexport/mongoimport,
## as it will "export" additional metadata, like indexes etc.
##
### Mongodump example
# Required: host, db, collection, out
# Optional: query (limit results)
mongodump --host mongodb1.example.net \
@kolomiichenko
kolomiichenko / multipart_upload.go
Created May 17, 2016 18:40 — forked from mattetti/multipart_upload.go
Example of doing a multipart upload in Go (golang)
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
@kolomiichenko
kolomiichenko / gitlab
Created June 10, 2015 06:11
start docker-compose as service
#! /bin/sh
#chkconfig: 2345 20 80
#description: gitlab server
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="gitlab server"
APP="gitlab"
DIR="/root/docker-compose/gitlab/"
@kolomiichenko
kolomiichenko / php-multisort-array.php
Created October 4, 2014 13:33
Функция сортировки 2-мерного масива по полю
<?php
/**
* Функция сортировки 2-мерного масива по полю
*
* @param array $rows Многомерный массив
* @param string $fieldName Поле, по которому производиться сортировка
* @param string $order Порядок сортировки SORT_ASC | SORT_DESC | SORT_REGULAR | SORT_NUMERIC | SORT_STRING
* @return array Отсортированный 2-мерный массив
**/