Skip to content

Instantly share code, notes, and snippets.

View czj's full-sized avatar

Clément Joubert czj

View GitHub Profile
@czj
czj / prompt.txt
Created May 9, 2023 16:18
ChatGPT / LLM language detection prompt that does not work well at all
Different languages use different writing systems, such as the Latin alphabet, Cyrillic script, or Arabic script.
Examining the characters used in the text can provide clues about the language.
Identifying common words and phrases in the text can help narrow down the language.
Analyzing the patterns of grammar used in the text can help identify the language.
Languages have distinct grammar rules, including sentence structure, verb conjugation, and noun declension.
The way words are arranged in a sentence can also provide clues about the language.
By examining these and other linguistic features of a text, it is possible to make an educated guess about the language in which it is written.
Deducing the language of a text involves analyzing various linguistic features of the text and comparing them to patterns and characteristics of different languages. Seeing the name of a language inside the text does not automatically mean it is the language of the text.
@czj
czj / Gemfile
Last active August 28, 2022 09:06
Outputting Rails app logs to Logz.io via logstash
gem "lograge"
gem "logstash-event"
gem "logstash-logger"
@czj
czj / feed.xml
Created March 7, 2022 13:34
Le flux RSS de HomeCinéSolutions a déménagé
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="https://www.w3.org/2005/Atom">
<channel>
<atom:link href="https://www.homecinesolutions.fr/p.rss" rel="self" type="application/rss+xml"/>
<title>Notre flux RSS a déménagé !</title>
<description>Notre flux RSS a déménagé !</description>
<link>https://www.homecinesolutions.fr/p.rss</link>
<item>
<title>Notre flux RSS a déménagé !</title>
<pubDate>Sat, 05 Mar 2022 15:41:16 +0100</pubDate>
@czj
czj / rbenv_install.markdown
Last active February 22, 2022 11:20
Install rbenv on a Linux server, desktop or OSX, with bash or zsh

SERVER

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

DESKTOP

BASH

@czj
czj / app_config.rb
Created May 6, 2019 14:50
Sample Rack::Attack configuration file
class AppConfig
class << self
# Lookup via
# https://www.ultratools.com/tools/ipWhoisLookupResult
# https://www.whatismyip.com/ip-whois-lookup/
BLOCKED_IPS = Set.new(
[
"6.5.4.3",
"5.4.3.2",
"4.3.2.1",
@czj
czj / form_builder_errors.rb
Created September 13, 2021 11:49
Rails 6+ helpers to display a list of form errors, adapted for Bootstrap 5 syntax
# frozen_string_literal: true
# Nifty Generators - https://github.com/ryanb/nifty-generators
#
# copy from Nifty Generators,
# markup optimized for bootstrap
#
# Usage:
# <%= f.error_messages %>
# <%= error_messages_for(@object) %>
@czj
czj / RelatedFiles.sublime-settings.js
Created January 16, 2021 10:48
Related Files Plugin rules for view_component gem files in a Rails app
// https://github.com/fabiokr/sublime-related-files
{
"patterns": {
// Components Ruby classes
".+\/app\/components\/(.+).rb":
[
"app/components/$1.html.slim",
"app/components/$1.rb",
"app/components/$1.scss",
@czj
czj / example.rb
Created June 23, 2020 11:14
Ruby ceil() round() floor() with negative arguments
10.32.round(-1)
# 10
11.32.round(-1)
# 10
19.32.round(-1)
# 20
19.32.ceil(-1)
@czj
czj / TLDR.md
Created June 23, 2020 10:30
Comparing Ruby includes?() versus member?() performance

member? is a method of Enumerable, which is WAY slower for Array but not for Set

@czj
czj / array_vs_set_performance_test.rb
Created June 23, 2020 10:16
Ruby Array versus Set performance test
# frozen_string_literal: true
require "benchmark"
array = [4, 5, 6, 11, 12, 20, 40, 64, 65, 66, 81, 83].freeze
set = Set.new(array).freeze
n = 10_000_000
Benchmark.bm(7) do |x|
x.report("array found at position 0") { n.times { array.include?(4) } }