Update: please note that I have since switched to using a set of bash scripts instead of poluting the Git repository with git svn.
Author: Kaspars Dambis
kaspars.net / @konstruktors
| function discriminator(data) { | |
| if (!data) { | |
| return null; | |
| } | |
| return data.filter(function(item) { | |
| return item.age >= 30 && item.age <= 40; | |
| }); | |
| } |
| function objectsByRanking(data) { | |
| return data.sort(function(a, b) { return a.ranking - b.ranking; }) | |
| } | |
| function averageRanking(data) { | |
| return data.reduce( | |
| function(prev, curr) { return { ranking: prev.ranking + curr.ranking }; }, { ranking: 0 } | |
| ).ranking / data.length; | |
| } |
| function orderByRank(array) { | |
| var arrayCopy = array.slice(); // if we don't want to modify org array | |
| arrayCopy.sort(function(a, b) { | |
| return a.ranking - b.ranking; | |
| }); | |
| return arrayCopy; | |
| } |
| const { expect } = require("chai") | |
| function flatten(array) { | |
| return array.reduce((acc, val) => acc.concat(Array.isArray(val) ? flatten(val) : val), []) | |
| } | |
| describe("#flatten", () => { | |
| it("should return flattened array", () => { | |
| const input = [[1, 2, [3]], 4] | |
| expect(flatten(input)).to.deep.equal([1, 2, 3, 4]) |
Update: please note that I have since switched to using a set of bash scripts instead of poluting the Git repository with git svn.
Author: Kaspars Dambis
kaspars.net / @konstruktors
| #!/bin/sh | |
| read oldrev newrev refname | |
| prefix="refs/heads/" | |
| branch=${$refname#$prefix} | |
| git push github $branch |
[alias]
# list all aliases
la = "!git config -l | grep alias | cut -c 7-"
# log as graph tree
ls = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all --branches
# formated log with stats
ll = log --pretty=format:'* %Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --decorate --numstat --all --branches
# log as series of patches
fl = log -p
| (defvar aok/read-only-folders | |
| '("/usr/share/emacs" "~/.emacs.d/straight") | |
| "Files in these folders will be opened in read-only mode.") | |
| (defun aok/file-set-read-only-if-listed () | |
| "Set current file buffer as `read-only' if it's in `aok/read-only-folders'." | |
| (when (seq-some (lambda (i) (string-prefix-p (expand-file-name i) buffer-file-name)) aok/read-only-folders) | |
| (read-only-mode 1))) | |
| (add-hook 'find-file-hook 'aok/file-set-read-only-if-listed) |
| (defun afa/edebug-on-entry-on-point (&optional flag) | |
| "Enhanced `edebug-on-entry'. | |
| ets function symbol on point as initial suggestion." | |
| (interactive "P") | |
| (let ((function-name | |
| (intern | |
| (funcall | |
| completing-read-function | |
| "Edebug on entry to: " | |
| (mapcar 'symbol-name (apropos-internal ".*")) |