Skip to content

Instantly share code, notes, and snippets.

@w33ble
w33ble / Vagrantfile
Last active May 17, 2017 19:24
Elasticsearch + Kibana on CentOS 7 (bring your own JDK)
Vagrant.require_version ">= 1.8.0"
$elasticVersion = "5.3.1"
# download the jdk from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
$jdkVersion = "8u131"
$downloads = "https://artifacts.elastic.co/downloads"
$esConfig = <<SCRIPT
# dumb check to see if this already ran
if [ ! -d /usr/java ]; then
@w33ble
w33ble / index.js
Created May 3, 2017 18:40
requirebin sketch
var rison = require('rison-node');
var appState = {
filters: {},
query: {
querystring: {
analyze_wildcard: true,
query: "my query here",
}
}
@w33ble
w33ble / latest_change.js
Created April 24, 2017 19:57
latest change helper
export function latestChange(...firstArgs) {
let oldState = firstArgs;
let prevValue = null;
return (...args) => {
let found = false;
const newState = oldState.map((oldVal, i) => {
const val = args[i];
if (!found && oldVal !== val) {
@w33ble
w33ble / App.js
Last active May 25, 2017 22:47
managed form input - stateful HoC
import React from 'react';
// input MyInputComponent/index.js by convention, which is the wrapped version of the component
import { MyInputComponent } from './MyInputComponent';
export function App() {
return (
<div>
<h1>App!</h1>
<MyInputComponent expression="initial value" />
</div>
@w33ble
w33ble / make_watches.txt
Created April 4, 2017 20:46
reset and create watches
# A watch with only a trigger. As this watch
# has no actions there is no question of them
# ever executing.
DELETE _xpack/watcher/watch/only-trigger
PUT _xpack/watcher/watch/only-trigger
{
"trigger": {
"schedule": {
"interval": "5m"
}
# Generated by iptables-save v1.6.0 on Fri Mar 31 20:28:53 2017
*security
:INPUT ACCEPT [18529451:10839683327]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [18575080:10168614356]
COMMIT
# Completed on Fri Mar 31 20:28:53 2017
# Generated by iptables-save v1.6.0 on Fri Mar 31 20:28:53 2017
*raw
:PREROUTING ACCEPT [18547623:10841082102]
@w33ble
w33ble / nested_state.js
Last active March 28, 2017 22:07
redux reducer examples
import { findIndex } from 'lodash';
export const initialState = {
users: [{
id: 'cpo5ienzpf',
name: 'joe',
active: true,
}],
lists: [{
id: '9fve86satx',
@w33ble
w33ble / TodoList.js
Created March 21, 2017 23:19
curse you propTypes!
import React from 'react';
import { TodoListItem } from './TodoListItem';
export function TodoList(props) {
if (props.todos.length === 0) return null;
const handleOnToggle = (todo) => () => props.onToggle(todo);
const handleOnSave = (todo) => (value) => props.onSave(todo, value);
const handleOnDestroy = (todo) => () => props.onDestroy(todo);
@w33ble
w33ble / groupby.js
Created March 16, 2017 18:37
to _.groupBy, or not to _.groupBy
const docTypes = _.groupBy(docs, doc => {
switch (doc._type) {
case 'search':
return 'searches'
default:
return 'other'
}
});
@w33ble
w33ble / 01-query_parameter_original.js
Last active January 18, 2017 23:18
comparing query_parameter_actions
import _ from 'lodash';
const MIN_CONTEXT_SIZE = 0;
const QUERY_PARAMETER_KEYS = Object.keys(createInitialQueryParametersState());
function QueryParameterActionsProvider(config) {
const defaultSizeStep = parseInt(config.get('context:step'), 10);
const setPredecessorCount = (state) => (predecessorCount) => (