Skip to content

Instantly share code, notes, and snippets.

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

Allison Zadrozny allizad

💭
I may be slow to respond.
View GitHub Profile
@allizad
allizad / evenOdd.js
Last active June 25, 2019 20:43
psuedocode example from Suchita - original
/*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
@allizad
allizad / snippets.cson
Created November 21, 2017 17:51
My atom snippets configuration
# 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:
#
@allizad
allizad / function_score inside rescore
Last active July 28, 2017 13:10
Tuning Elasticsearch results
POST /_search
{
"_source": [ "title", "weight" ],
"query": {
"bool": {
"must": {
"multi_match": {
"query": "Upgrade",
"fields": [
"title^16",
// 1. Import Dependencies. =====================================================
import React, {Component} from 'react';
import Searchkit, {
Pagination,
PaginationSelect,
RefinementListFilter,
Hits,
HitItemProps,
DynamicRangeFilter,
NoHits
---
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>
// 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'));
// 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>
"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"
}
---
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>
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+/, " ")
})