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
| 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: |
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" | |
| ) | |
| type Node struct { | |
| Value int | |
| } |
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
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
| ## | |
| ## 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 \ |
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 ( | |
| "bytes" | |
| "fmt" | |
| "io" | |
| "log" | |
| "mime/multipart" | |
| "net/http" | |
| "os" |
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
| #! /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/" |
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
| <?php | |
| /** | |
| * Функция сортировки 2-мерного масива по полю | |
| * | |
| * @param array $rows Многомерный массив | |
| * @param string $fieldName Поле, по которому производиться сортировка | |
| * @param string $order Порядок сортировки SORT_ASC | SORT_DESC | SORT_REGULAR | SORT_NUMERIC | SORT_STRING | |
| * @return array Отсортированный 2-мерный массив | |
| **/ |
NewerOlder