Skip to content

Instantly share code, notes, and snippets.

Introduction to ElasticSearch:

Elastic is a search server based on Apache Lucene, and provides a distributable full text search engine that’s accessible through a restful interface.

ElasticSearch is schema-less, and uses JSON instead of XML. It is open-source and built in Java, which means you can run ElasticSearch on any platform, as Java is platform independent.

ElasticSearch is a document-based store. It is an alternative to traditional document stores, so it can be used to replace other document stores like MongoDB or RavenDB.

Fast and Scalable:

@sahinakyol
sahinakyol / LoginWebFilter.java
Created January 2, 2020 11:25 — forked from itzg/LoginWebFilter.java
Custom Spring WebFlux AuthenticationWebFilter
import org.springframework.http.HttpMethod;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.security.authentication.ReactiveAuthenticationManager;
import org.springframework.security.web.server.authentication.AuthenticationWebFilter;
import org.springframework.security.web.server.util.matcher.ServerWebExchangeMatchers;
public class LoginWebFilter extends AuthenticationWebFilter {
private final ServerCodecConfigurer serverCodecConfigurer;
/**
@sahinakyol
sahinakyol / shopping_cart.md
Created December 3, 2019 13:12 — forked from anaclair/shopping_cart.md
Implementing Redis Shopping Cart

What is Redis?
Redis is an open source, advanced in-memory key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

######1. If you're running OS X, install redis in terminal using Homebrew : brew install redis

######2. Add the redis and hiredis gems to the project's Gemfile (remember to bundle install after you do this) :

@sahinakyol
sahinakyol / README.md
Created November 30, 2019 16:23 — forked from ssaunier/README.md
Use ES6 in your Rails Asset Pipeline

Rails 5.1 introduces a new way of coding JavaScript. You would use yarn, webpack and a new folder, app/javascript.

Setup

If you want to stick with the "old" way (before 5.1) and use the asset pipeline, you need to do this:

# Gemfile

gem 'sprockets', '>= 3.0.0'
List<Map<String, Object>> rows = new ArrayList<Map<String, Object>>();
ResultSetMetaData metaData = resultSet.getMetaData();
int columnCount = metaData.getColumnCount();
while (resultSet.next()) {
Map<String, Object> columns = new LinkedHashMap<String, Object>();
for (int i = 1; i <= columnCount; i++) {
columns.put(metaData.getColumnLabel(i), resultSet.getObject(i));
}
@sahinakyol
sahinakyol / System Design.md
Created November 7, 2019 06:57 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@sahinakyol
sahinakyol / migrate.sql
Created November 5, 2019 07:40 — forked from joshuadavidnelson/migrate.sql
Migrating database queries
UPDATE wp_options SET option_value = replace(option_value, 'http://oldurl', 'http://newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://oldurl', 'http://newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://oldurl', 'http://newurl');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://oldurl','http://newurl');
@sahinakyol
sahinakyol / gzip-sample.scala
Created August 26, 2019 14:06 — forked from sasaki-shigeo/gzip-sample.scala
A sample code of gzip in Scala. The API of gzip is defined in the package java.util.zip that provides GZIPOutputStream and GZIPInputStream, the subclasses of DeflatterOutputStream and InflatterInputStream, respectively. GZIPOutputStream compresses data into a given output stream and GZIPInputStream decompresses data from an input one.
import java.io._
import java.util.zip._
val pi = new PipedInputStream
val po = new PipedOutputStream(pi)
val zo = new GZIPOutputStream(po)
val zi = new GZIPInputStream(pi)
val w = new PrintWriter(zo)
val r = new BufferedReader(new InputStreamReader(zi))