Skip to content

Instantly share code, notes, and snippets.

View farynaio's full-sized avatar
🎯
Focusing

Adam Faryna farynaio

🎯
Focusing
  • London, UK
View GitHub Profile
@farynaio
farynaio / gist:2a1eb382e65ab67b44d396fa44f3100f
Last active December 12, 2023 16:05
prettier.el output
;; Please create a Gist with the contents of this buffer.
;; MAKE SURE TO REMOVE ANY SENSITIVE INFORMATION FIRST
(:emacs-version
"GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0)\n of 2023-09-29"
:prettier-el-version "1.3.0" :buffer-file-name
"/home/user/foo/app/dashboard/layout.tsx"
:remote-id nil :major-mode rjsx-mode :exec-path
("/home/user/.nvm/versions/node/v20.6.1/bin")
@farynaio
farynaio / edebug-on-entry-on-point.el
Last active August 16, 2023 23:09
Enhanced edebug-on-entry which sets function symbol on point as initial suggestion.
(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 ".*"))
@farynaio
farynaio / read-only-folders.el
Last active August 15, 2023 16:01
Prevent opening native and straight files in editable mode.
(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)
@farynaio
farynaio / python3_keywords.md
Last active April 22, 2020 19:51
Python 3 Build-in And Reserved Keywords
@farynaio
farynaio / gitaliases.md
Last active April 22, 2020 19:52
47 Git Aliases That Will Make You More Productive
[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
@farynaio
farynaio / gist:f3039cf4a1dcaecda98906fcbe1ba8e3
Created August 31, 2019 13:18
post-receive hook: push to alternative Github repo
#!/bin/sh
read oldrev newrev refname
prefix="refs/heads/"
branch=${$refname#$prefix}
git push github $branch
@farynaio
farynaio / wordpress-plugin-svn-to-git.md
Created June 11, 2019 08:18 — forked from kasparsd/wordpress-plugin-svn-to-git.md
Using Git with Subversion Mirroring for WordPress Plugin Development
@farynaio
farynaio / index.js
Created October 8, 2018 17:37
Node.js flatten()
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])
@farynaio
farynaio / gist:0349b1c430b37115e34e3fc600a6178e
Last active October 8, 2018 17:56
Javascript Order Objects by Average Rank
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;
}
@farynaio
farynaio / gist:ac52085387504d13ddabe43926fa3aee
Last active October 8, 2018 17:54
Javascript Objects by Rank
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;
}