Skip to content

Instantly share code, notes, and snippets.

View amiralies's full-sized avatar
🎯
Focusing

Amirali Esmaeili amiralies

🎯
Focusing
View GitHub Profile
@amiralies
amiralies / SelectList.js
Created January 8, 2019 16:40
How to use extraData prop to update your react native FlatList efficiently
class SelectableItem extends React.Component {
constructor() {
super();
this.handleOnPress = this.handleOnPress.bind(this);
}
shouldComponentUpdate(nextProps) {
const { isSelected } = this.props;
return isSelected !== nextProps.isSelected;
@amiralies
amiralies / map.js
Created July 25, 2019 15:33
Object map
const map = (obj, fun) =>
Object.entries(obj).reduce(
(prev, [key, value]) => ({
...prev,
[key]: fun(key, value)
}),
{}
);
const filter = (obj, fun) =>
Object.entries(obj).reduce(
(prev, [key, value]) => ({
...prev,
...(fun(key, value) ? { [key]: value } : {})
}),
{}
);
const reduce = (obj, fun, initialValue) =>
Object.entries(obj).reduce(
(prev, [key, value]) => fun(prev, key, value),
initialValue
);
@amiralies
amiralies / config.lua
Created October 8, 2022 02:48
Ensime TNG nvim lspconfig
local configs = require 'lspconfig.configs'
local lspconfig = require 'lspconfig'
-- Check if the config is already defined (useful when reloading this file)
if not configs.ensime then
configs.ensime = {
default_config = {
cmd = {
'java', '-jar', os.getenv("HOME") .. '/.cache/ensime/lib/ensime-lsp.jar'
},