View concurrent_parallel_procs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby 2.6.5 | |
# concurrent-ruby (1.1.5) | |
# parallel (1.19.1) | |
gem 'concurrent-ruby' | |
gem 'parallel' | |
require 'parallel' | |
require 'concurrent-ruby' |
View commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
View ruby_custom_field_with_postgresql_and_metaprogramming.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
View docker-and-docker-compose-commands.bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
View person.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
View usefull commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Change ssh port | |
sudo vi /etc/ssh/sshd_config | |
port 22 | |
sudo service ssh restart | |
# Language problem solution | |
sudo vi /etc/environment | |
LC_ALL="en_US.utf8" | |
LANGUAGE="en_US.utf8" | |
sudo dpkg-reconfigure locales |
View add-ssh-keys.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deploy user | |
deploy_user=deploy | |
# Github usernames for access with ssh to deploy user. They should be separater with one space. | |
usernames=(ismailakbudak) | |
# Check user is exist, maybe some errors occurred | |
id -u $deploy_user &> /dev/null | |
if [ $? -ne 0 ] | |
then |
View server-base.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Run this script with root user | |
# After installation check this | |
# vi /etc/ssh/sshd_config # Change ssh post | |
# vi /etc/environment # Write below locales | |
# LANGUAGE="en_US.utf8" | |
# LC_ALL="en_US.utf8" | |
# dpkg-reconfigure locales # Configure locales | |
## Fancy echo | |
fancy_echo() { |
View deploy-user-ruby-environment.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Run this command with deploy user | |
# define user home path | |
user_path=/home/deploy | |
## Fancy echo | |
fancy_echo() { | |
printf "\n%b\n" "$1" | |
} | |
fancy_echo "Installing rbenv..." | |
git clone git://github.com/sstephenson/rbenv.git $user_path/.rbenv |
View deploy-user.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deploy group | |
deploy_group=deploy | |
# Deploy user | |
deploy_user=deploy | |
# Github usernames for access with ssh to deploy user | |
usernames=(tayfunoziserikan ismailakbudak) | |
# Check user is exist | |
id -u $deploy_user &> /dev/null | |
if [ $? -ne 0 ] |
NewerOlder