Skip to content

Instantly share code, notes, and snippets.

View vhyza's full-sized avatar

Vojtěch Hýža vhyza

View GitHub Profile
@caspg
caspg / 1_searchbar_live.ex
Last active May 2, 2024 12:40
Example of real-time search bar implementation in Phoenix LiveView and Tailwind. Working example on https://travelermap.net/parks/usa
defmodule TravelerWeb.SearchbarLive do
use TravelerWeb, :live_view
alias Phoenix.LiveView.JS
alias Traveler.Places
def mount(_params, _session, socket) do
socket = assign(socket, places: [])
{:ok, socket, layout: false}
end
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@dadoonet
dadoonet / search_kibana_console.txt
Last active April 23, 2024 21:06
Demo script for "A NoSQL search engine to find..." talk
### REINIT
DELETE user
PUT user
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"comments": {
@fernandoaleman
fernandoaleman / mysql2-apple-silicon-macos-sonoma.md
Created November 2, 2023 16:32
How to install mysql2 gem on apple silicon M1, M2 or M3 macOS Sonoma

Problem

Installing mysql2 gem errors on Apple silicon M1, M2 or M3 Mac running macOS Sonoma.

Solution

Make sure mysql-client, openssl and zstd are installed on Mac via Homebrew.

Replace mysql-client with whichever mysql package you are using

@karmi
karmi / elastic_search_ngram_analyzer_for_urls.sh
Created May 24, 2011 15:32
NGram Analyzer in ElasticSearch
# ========================================
# Testing n-gram analysis in ElasticSearch
# ========================================
curl -X DELETE localhost:9200/ngram_test
curl -X PUT localhost:9200/ngram_test -d '
{
"settings" : {
"index" : {
"analysis" : {
@dhh
dhh / tracker_blocking.rb
Last active July 27, 2023 14:19
Current list of spy pixels named'n'shamed in HEY, as of April 23, 2020
module Entry::TrackerBlocking
extend ActiveSupport::Concern
included do
has_many :blocked_trackers
end
email_service_blockers = {
"ActiveCampaign" => /lt\.php(.*)?l\=open/,
"AWeber" => "openrate.aweber.com",
@karmi
karmi / nginx-elasticsearch-proxy.conf
Created May 23, 2011 08:16
Route requests to ElasticSearch to authenticated user's own index with an Nginx reverse-proxy
# Run me with:
#
# $ nginx -p /path/to/this/file/ -c nginx.conf
#
# All requests are then routed to authenticated user's index, so
#
# GET http://user:password@localhost:8080/_search?q=*
#
# is rewritten to:
#
.DS_Store
tmp/*
@cool-Blue
cool-Blue / data.js
Last active October 26, 2017 08:43
canvas-based-wind-with-d3
dispatch.data([{"12":0.461,"id":1001,"04":0.52,"08":0.478,"x":-86.641,"y":32.539},{"12":0.558,"id":1003,"04":0.539,"08":0.514,"x":-87.725,"y":30.743},{"12":-0.029,"id":1005,"04":0.099,"08":0.015,"x":-85.392,"y":31.877},{"12":0.468,"id":1007,"04":0.445,"08":0.458,"x":-87.128,"y":33},{"12":0.741,"id":1009,"04":0.625,"08":0.695,"x":-86.567,"y":33.983},{"12":-0.528,"id":1011,"04":-0.364,"08":-0.484,"x":-85.716,"y":32.106},{"12":0.075,"id":1013,"04":0.186,"08":0.134,"x":-86.685,"y":31.758},{"12":0.32,"id":1015,"04":0.326,"08":0.325,"x":-85.825,"y":33.776},{"12":0.051,"id":1017,"04":0.175,"08":0.085,"x":-85.39,"y":32.92},{"12":0.55,"id":1019,"04":0.319,"08":0.512,"x":-85.6,"y":34.176},{"12":0.603,"id":1021,"04":0.542,"08":0.578,"x":-86.718,"y":32.855},{"12":0.046,"id":1023,"04":0.082,"08":0.074,"x":-88.263,"y":32.023},{"12":0.083,"id":1025,"04":0.185,"08":0.116,"x":-87.827,"y":31.685},{"12":0.457,"id":1027,"04":0.415,"08":0.473,"x":-85.862,"y":33.275},{"12":0.682,"id":1029,"04":0.514,"08":0.624,"x":-85.52,"y":33.67