Skip to content

Instantly share code, notes, and snippets.

View julienbourdeau's full-sized avatar
🏠
Working from home

Julien Bourdeau julienbourdeau

🏠
Working from home
View GitHub Profile
Bundler could not find compatible versions for gem "actionmailer":
In Gemfile:
devise_invitable was resolved to 2.0.1, which depends on
actionmailer (>= 5.0)
rails (= 5.0.7.2) was resolved to 5.0.7.2, which depends on
actionmailer (= 5.0.7.2)
Bundler could not find compatible versions for gem "activemodel":
In Gemfile:

Using sprockets 2.12.5

sprockets-rails 2.3.3

$ ab -c 1 -n 100 http://localhost:3000/posts/1
This is ApacheBench, Version 2.3 <$Revision: 1826891 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done
@julienbourdeau
julienbourdeau / algolia.test.conf
Last active July 5, 2019 21:46
Nginx config for Rails app (used with Laravel Valet)
# /usr/local/etc/nginx/servers/algolia.test
upstream myapp {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
server {
listen 80;
@julienbourdeau
julienbourdeau / contact.rb
Created March 19, 2019 16:52
Rails Algolia: Create subindex but without main index.
class Contact < ApplicationRecord
include AlgoliaSearch
algoliasearch per_environment: true, if: :turn_off_main_index do
add_index "CONTACT_subset", if: :subset? do
attributes :name, :email, :company, :state
searchableAttributes ['name', 'company', 'unordered(email)']
@julienbourdeau
julienbourdeau / dedup.sql
Created March 2, 2019 20:57
Delete duplicate entries from db with single SQL query
-- example from www.lasceneparisienne.com DB
DELETE n1 FROM calendar_events n1,
calendar_events n2
WHERE n1.id < n2.id
AND n1.id_facebook = n2.id_facebook
AND n1.calendar_id = 2;
@julienbourdeau
julienbourdeau / HtmlSplitter.php
Last active January 25, 2019 09:29
Algolia record split - HtmlSplitter
<?php
declare(strict_types=1);
/**
* This file is part of Scout Extended.
*
* (c) Algolia Team <contact@algolia.com>
*
* For the full copyright and license information, please view the LICENSE
@julienbourdeau
julienbourdeau / DNS prefetching
Created January 13, 2019 08:37
Common Prefetch Links
<!-- Amazon S3 -->
<link rel="dns-prefetch" href="//s3.amazonaws.com">
<!-- Google CDN -->
<link rel="dns-prefetch" href="//ajax.googleapis.com">
<!-- Microsoft CDN -->
<link rel="dns-prefetch" href="//ajax.microsoft.com">
<link rel="dns-prefetch" href="//ajax.aspnetcdn.com">
@julienbourdeau
julienbourdeau / proxy.md
Last active December 19, 2018 16:09
Algolia PHP client with Proxy

If you're using a proxy, you can either override the HttpClient or use environment variable.

Setting the HttpClient

If you're using the default Guzzle6HttpClient (recommended):

use Algolia\AlgoliaSearch\Algolia;