Skip to content

Instantly share code, notes, and snippets.

View mehdi-farsi's full-sized avatar

Mehdi FARSI mehdi-farsi

View GitHub Profile
trap("SIGINT") { exit! }
total_width = `stty size`.scan(/\d+/)[1].to_i # terminal width
snowflakes = {}
puts "\033[2J"; # clearing output
loop do
snowflakes[rand(total_width)] = 0
@patrixr
patrixr / Palapa.rb
Last active February 27, 2021 06:38
page :home do
header do
add_link 'Home', to: :home
add_link 'Posts', to: :posts
end
section :description, layout: :horizontal do
section :image do
add_image '/some/image'
@nogweii
nogweii / xmas_tree.rb
Created December 22, 2018 20:50 — forked from mehdi-farsi/xmas_tree.rb
A light-up christmas tree in your terminal
class ChristmasTree
FIRST_LINE_LENGTH = 1
LEVEL_HEIGHT = 3
COLORS = ["\033[0m", "\033[0m", "\033[0m", "\033[31m", "\033[33m", "\033[32m", "\033[34m"] # red, yellow, blue
def initialize(levels)
@levels = levels.to_i < 1 ? 3 : levels.to_i
@last_line_length = 5 + ((@levels - 1) * 2)
@current_line_length = FIRST_LINE_LENGTH
end
@nicolashery
nicolashery / elasticsearch.md
Last active December 30, 2023 19:03
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,