Skip to content

Instantly share code, notes, and snippets.

View amrdruid's full-sized avatar
🌌
Ruby is weird 💎

Druid amrdruid

🌌
Ruby is weird 💎
View GitHub Profile
@amrdruid
amrdruid / github_score_example.rb
Last active August 25, 2021 13:58
Github Score - Amr Solution - Understanding and implementing - 1 hour
require 'net/http'
require 'uri'
require 'json'
require 'rspec/autorun'
class GithubScore
SCORING_PARAMS = {
"IssuesEvent" => 1,
"IssueCommentEvent" => 2,
"PushEvent" => 3,
@amrdruid
amrdruid / gist:66109336178a77819905aad1636d379e
Last active January 27, 2020 13:27
Guide to Ruby on Rails developer
Ruby developer path
----------------------
* General:
1- Starting rails general knowledge with Odin: https://www.theodinproject.com/tracks/1
2- Reddit Rails community: https://www.reddit.com/r/rails/
3- Slack Rails community: https://www.rubyonrails.link/
4- Ruby Inside for the latest ruby/rails news and top notch articles: http://www.rubyinside.com/
5- Get feedback on your code and how to refactor through Code exchange: https://codereview.stackexchange.com/
6- Ruby Weekly: https://rubyweekly.com/
@amrdruid
amrdruid / Interpreter and Interactive Ruby
Last active February 12, 2017 14:10
Ruby Interpreter commands
1) Check for any syntax errors in your ruby file and print them:
ruby -wc example.rb
-c : Check Syntax
-w : Enable warnings
---------------
2) Print Ruby version:
@amrdruid
amrdruid / Books_and_Courses.txt
Last active February 7, 2017 18:04
Books and Courses that I encounter
Books:
Tech:
The well grounded Rubyist
Eloquent Javascript
HTML And CSS - Design and build Websites
Cracking the coding interview
Programming Interviews Exposed
Clean Code
The Mythical Man-Month: Essays on Software Engineering, Anniversary Edition
Don't make me think - Revisited
@amrdruid
amrdruid / gitflow-breakdown.md
Created February 2, 2017 11:48 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

@amrdruid
amrdruid / server.md
Created January 22, 2017 12:34 — forked from jtadeulopes/server.md
Server setup with ubuntu, nginx and puma for rails app.

Update and upgrade the system

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove
sudo reboot

Configure timezone

@amrdruid
amrdruid / caesar_cipher.rb
Created January 13, 2017 17:05
Caesar Cipher
class String
Caesar_lower_case_letters = ('a'..'z').to_a
Caesar_upper_case_letters = ('A'..'Z').to_a
def caesar_shift(n)
letters = [Caesar_lower_case_letters, Caesar_upper_case_letters].find{|t| t.index(self) }
return self.dup unless letters
new_index = (letters.index(self) + n) % letters.length
letters[new_index]
end
@amrdruid
amrdruid / db.rake
Created January 11, 2017 13:20 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@amrdruid
amrdruid / directions_reduction.rb
Created January 5, 2017 21:29
["NORTH", "SOUTH", "SOUTH", "EAST", "WEST", "NORTH", "WEST"] You can immediatly see that going "NORTH" and then "SOUTH" is not reasonable, better stay to the same place! So the task is to give to the man a simplified version of the plan. A better plan in this case is simply: ["WEST"]
def dirReduc(arr)
check = {north: "SOUTH", south: "NORTH", east: "WEST", west: "EAST"}
res = []
for i in 0...arr.length
if res.last && check[res.last.downcase.to_sym] == arr[i]
res.pop
else
res << arr[i]
end
class Node
attr_accessor :data, :next
def initialize(data)
@data = data
@next = nil
end
end
def length(node)
return 0 unless node