Skip to content

Instantly share code, notes, and snippets.

View aritode's full-sized avatar
🎼

Arian Deli aritode

🎼
View GitHub Profile
@aritode
aritode / cleanup_swap.md
Created July 19, 2023 13:13 — forked from anildigital/cleanup_swap.md
Cleanup swap space on macOS

To see current swap usage

sysctl -a | grep swap

Use only when when your system is in a very bad shape

$ sudo pkill -HUP -u _windowserver 
@aritode
aritode / clear_logs.rb
Created December 4, 2021 20:42 — forked from krsmurata/clear_logs.rb
Clear development logs
if Rails.env.development?
MAX_LOG_SIZE = 10.megabytes
logs = [ File.join(Rails.root, 'log', 'development.log'), File.join(Rails.root, 'log', 'test.log') ]
logs.each do |log|
log_size = File.size?(log).to_i
if log_size > MAX_LOG_SIZE
$stdout.puts "Removing Log: #{log}"
`rm #{log}`
@aritode
aritode / linux-mint-mate-20.2-install-docker.md
Created October 5, 2021 08:32 — forked from cstroe/linux-mint-mate-20.2-install-docker.md
Install Docker on Linux Mint 20.2 Mate Edition

Install Docker on Linux Mint 20.2 Mate Edition

Using the Graphical User Interface (GUI)

  1. Click the Linux Mint Menu Button at the bottom left of the screen to open the Linux Mint Menu.
  2. Under the "System" section, click "Software Manager".
  3. In the Software Manager window, use the search box at the top right and search for "docker".
  4. Click on "Docker.io - Linux Container Runtime".
  5. Click the green "Install" button at the top right. Enter your administrator password when prompted.
  6. Open the Linux Mint Menu again (see step 1), search for "Users and Groups", and click it to open the "User Settings".
@aritode
aritode / rails-jsonb-queries
Created January 18, 2021 14:42 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@aritode
aritode / Makefile
Created October 6, 2020 14:08 — forked from mpneuried/Makefile
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@aritode
aritode / web-fonts-asset-pipeline.md
Created November 28, 2019 20:26 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

Functional objects on Ruby programming language

Goals

  • Less questions asked. E.g:
  • More consistent style among classes definitions.

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@aritode
aritode / Embedding GoLang into a Ruby application.md
Created November 1, 2019 15:40 — forked from schweigert/Embedding GoLang into a Ruby application.md
Embedding GoLang into a Ruby application - Blogpost to Magrathealabs

Go Title

I am passionate about Ruby, but its execution time compared to other languages is extremely high, especially when we want to use more complex algorithms. In general, data structures in interpreted languages become incredibly slow compared to compiled languages. Some algorithms such as ´n-body´ and ´fannkuch-redux´ can be up to 30 times slower in Ruby than Go. This is one of the reasons I was interested in embedding Go code in a Ruby environment.

For those who do not know how shared libraries operate, they work in a similar way as DLLs in Windows. However, they have a native code with a direct interface to the C compiler.

Note Windows uses the DLL system, and in this case, this does not necessarily have to be in native code.

One example is DLLs written in C#, which runs on a virtual machine. Because I do not use windows, I ended up not testing if it is poss

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.