Skip to content

Instantly share code, notes, and snippets.

View timscott's full-sized avatar

Tim Scott timscott

  • Lunaverse Software
View GitHub Profile
@timscott
timscott / bindingInRender.js
Last active July 5, 2017 14:50 — forked from coryhouse/bindingInRender.js
Example of binding in render to pass relevant data to a click handler.
import React from 'react';
class App extends React.Component {
constructor() {
this.state = {
users: [
{ id: 1, name: 'Cory' },
{ id: 2, name: 'Meg' }
]
};
@timscott
timscott / coffee_to_js_builder.rb
Last active April 4, 2016 19:09
A utility class to build Javascript from CoffeeScript. Builds single file, a folder, or a tree. Optional rebuild supports lazy building in production. Specify a lib directory.
require 'coffee-rails'
require 'fileutils'
class JsBuilder
def initialize(base_directory:, bin_folder: 'bin', lib_directory: File.join(base_directory, 'lib'), rebuild: false)
@base_directory = base_directory
@lib_directory = lib_directory
@bin_folder = bin_folder
@rebuild = rebuild
{
"Stops": [
{
"MustFollowLocationId": 0,
"MappingMethod": null,
"MappingPlaceName": null,
"PickupSequence": null,
"DeliverySequence": null,
"StopSequence": null,
"IsStore": true,
@timscott
timscott / PercolatorProblem.bash
Created June 1, 2011 21:25
The same percolator behaves differently in different indicies
> curl -XGET localhost:9200/_percolator/test3/percwild
> {"_index":"_percolator","_type":"test3","_id":"percwild","_version":2, "_source" : {"query":{"bool":{"should":[],"must":[{"wildcard":{"EmailSubject":{"value":"*txtag*"}}}],"must_not":[{"field":{"Trashed":{"query":true}}}]}}}}
> curl -XGET localhost:9200/test3/type1/_percolate -d'
{"doc":{"EmailSubject":"TxTAG Activity Statement Too", "Trashed":false}}'
> {"ok":true,"matches":["percwild"]}
> curl -XGET localhost:9200/_percolator/9494a77d-04a4-4e19-8b7f-4eea5cdf27d6/d52e6ff7-6239-4f0e-b25c-9ef500ae3abf
curl -XPUT localhost:9200/test -d'
> {"settings":{"index":{"number_of_shards":3, "number_of_replicas":2}}}
{"ok":true,"acknowledged":true}
curl -XPUT localhost:9200/test/tweet/_mapping -d'
> {
> "tweet" : {
> "properties" : {
> "message" : {"type" : "string", "store" : "yes"}
> }
@timscott
timscott / AlreadyClosedException When Creating Percolator
Created March 16, 2011 22:37
Shows how to recreate AlreadyClosedException when creating a percolator in 0.15.2
curl -XPUT localhost:9200/test/test/1?pretty=true -d'
{"Content": "foo bar"}'
{
"ok" : true,
"_index" : "test",
"_type" : "test",
"_id" : "1",
"_version" : 1
}