This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Given a string of even and odd numbers, find which is the sole even number or | |
the sole odd number. | |
The return value should be 1-indexed, not 0-indexed. | |
Examples : | |
detectOutlierValue("2 4 7 8 10"); // => 3 - Third number is odd, while the rest of the numbers are even | |
detectOutlierValue("1 10 1 1"); //=> 2 - Second number is even, while the rest of the numbers are odd*/ | |
/* input = string of numbers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST /_search | |
{ | |
"_source": [ "title", "weight" ], | |
"query": { | |
"bool": { | |
"must": { | |
"multi_match": { | |
"query": "Upgrade", | |
"fields": [ | |
"title^16", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Import Dependencies. ===================================================== | |
import React, {Component} from 'react'; | |
import Searchkit, { | |
Pagination, | |
PaginationSelect, | |
RefinementListFilter, | |
Hits, | |
HitItemProps, | |
DynamicRangeFilter, | |
NoHits |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
layout: default | |
--- | |
<div class="home"> | |
<p class="lead"> | |
The fastest way to search Shakespeare's texts and explore his language statistics. | |
</p> | |
<!-- Example React component --> | |
<div id="react-search"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dependencies. | |
import React from 'react'; | |
import {render} from 'react-dom'; | |
// Custom components. | |
import Search from './components/Search'; | |
// Mount apps to DOM. | |
render(<Search/>, document.getElementById('react-search')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Import dependencies. | |
import React, {Component} from 'react'; | |
// 2. Set up example react component. | |
class Search extends Component { | |
render(){ | |
return ( | |
<div className="_Search"> | |
<h3>Search Component!</h3> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"dependencies": { | |
"babel-core": "^6.10.4", | |
"babel-loader": "^6.2.4", | |
"babel-preset-es2015": "^6.9.0", | |
"babel-preset-react": "^6.11.1", | |
"react": "^15.2.1", | |
"react-addons-update": "^15.2.1", | |
"searchkit": "^0.10.0", | |
"webpack": "^1.13.1" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
layout: default | |
--- | |
<div class="post"> | |
<h1 class="post-title">{{ page.title }}</h1> | |
<!-- this will be sent to elasticsearch, along with full post metadata --> | |
<article class="post-content"> | |
{{ content }} | |
</article> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jekyll::Hooks.register :posts, :post_render do |post| | |
# strip html | |
nokogiri_doc = Nokogiri::HTML(post.output) | |
puts %(indexing #{post.url}) | |
indexer = indexers[post.site] | |
indexer << post.data.merge({ | |
id: post.id, | |
url: post.url, | |
text: nokogiri_doc.xpath("//article//text()").to_s.gsub(/\s+/, " ") | |
}) |
NewerOlder