Skip to content

Instantly share code, notes, and snippets.

@bultas
bultas / Dispatch.js
Created August 30, 2016 13:30
Dispatch - traverse functions as long as any function return something else then undefined
import {isNil} from 'ramda';
export function dispatch(...funcs) {
return function(...args) {
for (let fun of funcs) {
let ret = fun(...args);
if (!isNil(ret)) return ret;
}
@bultas
bultas / script.js
Last active November 13, 2016 14:39
Gmail - Google Apps Script - permanently delete all messages from specific sender
function myFunction() {
var senderEmail = "[email protected]";
var threads = GmailApp.search("from:"+senderEmail);
for (var i = 0; i < threads.length; i++) {
Gmail.Users.Messages.remove('me', threads[i].getId());
}
}
@bultas
bultas / es6.js
Last active November 16, 2016 16:30
ES6 Awesomeness (;
// DESTRUCTURING
// http://www.2ality.com/2015/01/es6-destructuring.html
let obj = { first: 'Jane', last: 'Doe' };
let { first: f, last } = obj;
// f = 'Jane'; last = 'Doe'
@bultas
bultas / filter.js
Last active February 20, 2017 17:40
Filter and Aggregation - immutable, functional, reduce example
import { Map } from 'immutable';
const items = Map({
id1: Map({
name: 'Item Name',
isActive: true
@bultas
bultas / transducer.js
Last active February 21, 2017 23:47
Transducer to transform and convert JS iterable data types
function reduce(input, transformator, initialValue = null) {
let response = new Map(initialValue);
for (kv of input.entries()) {
response = transformator((result, [key, value]) => {
return result.set(key, value);
})(response, kv)
@bultas
bultas / fetching.js
Last active March 6, 2017 19:57
fetching data in React - DataFetcher concept
BucketActions.createBucket(
initValue
);
// > bucketID
BucketActions.addToBucket(
bucketID,
value
);
// > true
@bultas
bultas / normalize.css
Created April 5, 2017 10:47
minimalistic CSS Normalize
html {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
font: 16px/1 sans-serif;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}
@bultas
bultas / Editor.jsx
Last active May 24, 2017 13:12
Draft JS - ability to "not continue" mutable entity (with property contiguous) (ex.: LINK)
function CustomEditor() {
...
return (
<Editor
editorState={editorState}
onChange={onChange}
blockStyleFn={myBlockStyleFn}
handleReturn={createHandleReturn(editorState, onChange)}
@bultas
bultas / anotherSources.html
Last active May 31, 2017 16:16
DraftJS - Text Alignment via block metadata
https://gist.github.com/joshdover/7c5e61ed68cc5552dc8a25463e357960
https://github.com/jpuri/react-draft-wysiwyg/blob/master/js/src/components/Controls/TextAlign/index.js
@bultas
bultas / check.sh
Created June 13, 2017 15:25
Git Hooks
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"