Skip to content

Instantly share code, notes, and snippets.

View rakannimer's full-sized avatar
💭
I may be slow to respond.

Rakan Nimer rakannimer

💭
I may be slow to respond.
View GitHub Profile
const log = (...args) => {
console.log(" ".repeat(new Error().stack.match(/\n/g).length - 2), ...args);
};
Array.from(new Set(Array.from(document.querySelectorAll('[data-testid]')).map(el => el["dataset"]["testid"])))
@rakannimer
rakannimer / index.html
Last active August 26, 2018 07:17
parcel ts react starter
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
@rakannimer
rakannimer / mobx-reactions-example.js
Last active August 31, 2017 09:46
mobx reactions quick tldr
import { reaction, observable, runInAction } from 'mobx';
const myObservableMap = observable.map({});
const disposeReaction = reaction(() => myObservableMap, (newObservableValue) => {
console.warn('Someone changed the observable map. new value : ', newObservableValue);
})
myObservableMap.set('some', {data: 'of any type'})
myObservableMap.set('someOther', 'data')
@rakannimer
rakannimer / jest-photoshoot.js
Created January 15, 2017 12:28
Jest Photoshoot micro helper function
const photoshoot = (...args) => {
args.forEach(arg =>
expect(arg).toMatchSnapshot()
);
};
@rakannimer
rakannimer / add-jest-to-nwb.sh
Last active April 14, 2019 02:29
Adding jest tests to nwb project
yarn add -D jest babel-jest babel-preset-es2015 babel-preset-react react-test-renderer
#Edit package.json adding the jest command :
"scripts": {
"build": "nwb build-react-component",
"clean": "nwb clean-module && npm clean-demo",
"start": "nwb serve-react-demo",
"test": "nwb test",
"test:coverage": "nwb test --coverage",
"test:watch": "nwb test --server",
"test:jest": "jest"
@rakannimer
rakannimer / add-react-jest-airbnb-linting.sh
Last active August 14, 2018 07:42
Adding react-airbnb styleguide linting to create-react-app
( export PKG=eslint-config-airbnb; npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs yarn add -D "$PKG@latest"; )
yarn add babel-eslint
echo "{
\"parser\": \"babel-eslint\",
\"env\": {
\"browser\": true,
\"node\": true,
\"jest\": true,
},
\"extends\": \"airbnb\",
@rakannimer
rakannimer / some atom snippets.cson
Last active November 25, 2016 13:59
Some atom snippets
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#

command

adb shell input keyevent 0

Name

KEYCODE_UNKNOWNI

index

C

@rakannimer
rakannimer / .eslintrc
Created October 20, 2016 12:35
My eslint
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true
},
"extends": "airbnb",
"rules": {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"import/prefer-default-export": "off",