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
| require 'benchmark' | |
| size = 100 | |
| list = [] | |
| size.times { |i| list << {name: "item #{i}"} } | |
| n = 5000 | |
| Benchmark.bmbm(16) do |bm| | |
| bm.report('each_with_object') { n.times { list.each_with_object({}) { |item, map| map[item[:name]] = item } } } | |
| bm.report('inject+merge') { n.times { list.inject({}) { |map, item| map.merge(item[:name] => item) } } } |
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/bash | |
| # Example: | |
| # $ explode-path ~ | |
| # / | |
| # /Users | |
| # /Users/seb | |
| # Great for recursively checking permissions |
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
| ``` | |
| $ time GIT_TRACE=1 git -c http.proxy=http://localhost:8888 clone --mirror https://github.com/Shopify/shopify.git /tmp/g.git | |
| 10:45:42.059182 git.c:415 trace: built-in: git clone --mirror https://github.com/Shopify/shopify.git /tmp/g.git | |
| Cloning into bare repository '/tmp/g.git'... | |
| 10:45:42.071336 run-command.c:637 trace: run_command: git-remote-galaxy origin Shopify/shopify.git | |
| 10:45:42.152772 git.c:415 trace: built-in: git config --get remote.origin.url | |
| 10:45:42.168087 git.c:415 trace: built-in: git config --get remote.origin.pushurl | |
| 10:45:42.193176 git.c:415 trace: built-in: git config --get user.email | |
| 10:45:42.199199 git.c:659 trace: exec: git-remote-http origin https://git-mirror.shopifycloud.com/Shopify/shopify.git | |
| 10:45:42.199637 run-command.c:637 trace: run_command: git-remote-http origin https://git-mirror.shopifycloud.com/Shopify/shopify.git |
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 log --since=2018-01-01 --pretty='%H %ae' | awk '{ users[$2] = $1 } END { for (u in users) { print users[u] } }' | sed -E 's/^(.+)$/object(oid: "\1") { ...author }/' | |
| # c_9678fb4f85eeb6fd91a89caa255d7a80131a6fc5: object(oid: "9678fb4f85eeb6fd91a89caa255d7a80131a6fc5") { ...author } | |
| curl -H "Authorization: token xxx" 'https://api.github.com/graphql' -X POST -d "{\"query\":\"$(sed 's/"/\\\\\\"/g' users.graphql | xargs echo)\"}" > output.json | |
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
| // ==UserScript== | |
| // @name Remove Vendor | |
| // @namespace https://gist.github.com/lavoiesl/4484f406915c7180e72f3c57f24bd40b | |
| // @version 0.1 | |
| // @description Remove all file diffs in a PR when path starts with vendor/ | |
| // @author Julian Nadeau | |
| // @match https://github.com/*/*/pull/*/files | |
| // @grant none | |
| // ==/UserScript== |
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/zsh | |
| # Inspired from https://github.com/fredsmith/history-db | |
| ZSH_RECORD_HISTORY_SQLITE="${ZSH_RECORD_HISTORY_SQLITE:-$HOME/.zsh_history.sqlite}" | |
| if [[ -x "$(which sqlite3 2>/dev/null)" ]]; then | |
| zsh_record_history_preexec() { | |
| zsh_record_history_cmd="$1" | |
| zsh_record_history_time="$(date +%s)" |
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
| ## | |
| # Sort all files by their filename, independently of their folder | |
| # Example: ls -1 /a/* /b/* | sort_by_filename | |
| # | |
| # @input One path per line | |
| # @outputs One path per line | |
| function sort_by_filename() { | |
| while read filename; do | |
| echo "${filename}" | sed -E 's/^(.+)\/([^/]+)$/\2#\1\/\2/'; | |
| done | sort -n | cut -d '#' -f 2 |
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 | |
| function implode_oxford(array $pieces) | |
| { | |
| $pieces = array_values($pieces); | |
| switch (count($pieces)) { | |
| case 0: | |
| return ''; |
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 | |
| namespace Acme\UserBundle\EventListener; | |
| use Doctrine\ODM\MongoDB\Event\LoadClassMetadataEventArgs; | |
| /** | |
| * Ran when Mongo metadata is loaded. | |
| */ | |
| class ClassMetadataListener |
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
| dig SOA lavoie.sl @8.8.8.8 | |
| Works | |
| ---------- | |
| ; <<>> DiG 9.9.5-3ubuntu0.1-Ubuntu <<>> SOA lavoie.sl @8.8.8.8 | |
| ;; global options: +cmd | |
| ;; Got answer: | |
| ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20696 | |
| ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 |