Skip to content

Instantly share code, notes, and snippets.

View ismailakbudak's full-sized avatar

Ismail Akbudak ismailakbudak

View GitHub Profile
@ismailakbudak
ismailakbudak / person.rb
Created April 12, 2017 08:38
Ransacker examples of postgresql jsonb and hstore data types
class Person < ApplicationRecord
## HSTORE
# person.metadata = { number: '100', data: { nested_data: { value: 100 } }}
# Person.order("metadata -> 'number' DESC")
# Person.search({s:['metadata_number DESC']}).result
# Does not support
# Person.search({metadata_number_gteq: '100'}).result
ransacker :metadata_number do |parent|
@ismailakbudak
ismailakbudak / docker-and-docker-compose-commands.bash
Last active October 28, 2019 18:38
Usefull docker commands
docker build -t friendlyname . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to 80
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
docker ps # See a list of all running containers
docker stop <hash> # Gracefully stop the specified container
docker ps -a # See a list of all containers, even the ones not running
docker kill <hash> # Force shutdown of the specified container
docker rm <hash> # Remove the specified container from this machine
docker rm $(docker ps -a -q)
@ismailakbudak
ismailakbudak / ruby_custom_field_with_postgresql_and_metaprogramming.rb
Last active October 22, 2019 19:41
Custom field example for Ruby on Rails with Activerecord & PostgreSQL & Metaprogramming. Example: https://github.com/lab2023/postgresql_jsonb_ransack_rails_5 Demo: https://rails-custom-field-ransack.herokuapp.com
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '5.1.3'
@ismailakbudak
ismailakbudak / commands
Last active March 29, 2018 18:36
Useful git commands
$ git log --oneline
$ git log --oneline --decorate
$ git log --oneline --decorate --all
$ git log --oneline --decorate --all --graph
$ git log --oneline --decorate --all --graph --simplify-by-decoration
$ git reset ~HEAD
$ git commit --amend
# ruby 2.6.5
# concurrent-ruby (1.1.5)
# parallel (1.19.1)
gem 'concurrent-ruby'
gem 'parallel'
require 'parallel'
require 'concurrent-ruby'