Skip to content

Instantly share code, notes, and snippets.

View nejdetkadir's full-sized avatar

Nejdet Kadir Bektaş nejdetkadir

View GitHub Profile
@nejdetkadir
nejdetkadir / Dockerfile
Last active May 6, 2021 05:04
Docker basics for Ruby on Rails
FROM ruby:3.0.0-alpine
RUN apk add --update --virtual \
runtime-deps \
postgresql-dev \
postgresql-client \
build-base \
libxml2-dev \
libxslt-dev \
nodejs \
@nejdetkadir
nejdetkadir / qrcode-generator.rb
Created August 8, 2021 15:04
How to generate qrcode with Ruby
require "rqrcode"
qrcode = RQRCode::QRCode.new("http://github.com/")
# NOTE: showing with default options specified explicitly
svg = qrcode.as_svg(
color: "000",
shape_rendering: "crispEdges",
module_size: 11,
standalone: true,
@nejdetkadir
nejdetkadir / config.yml
Last active November 28, 2021 21:26
Circleci setup for Ruby on Rails application with RSpec & Rubocop.
version: 2.1
orbs:
ruby: circleci/ruby@1.0
node: circleci/node@2
jobs:
build:
docker:
- image: cimg/ruby:3.0.0-node
@nejdetkadir
nejdetkadir / update.rake
Last active December 21, 2021 17:52
fixer.io task for currencies rates
namespace :currency do
task :update do
uri = URI("http://data.fixer.io/api/latest")
params = { :access_key => ENV['FIXERIO_ACCESS_KEY'] }
uri.query = URI.encode_www_form(params)
res = Net::HTTP.get_response(uri)
if res.is_a?(Net::HTTPSuccess)
body = JSON.parse(res.body)
@nejdetkadir
nejdetkadir / devise.rb
Created December 22, 2021 19:19
How to use Devise gem with Rails 7 (devise.rb)
# frozen_string_literal: true
#! config/initializers/devise.rb
#! Create custom failure for turbo
class TurboFailureApp < Devise::FailureApp
def respond
if request_format == :turbo_stream
redirect
else
super
@nejdetkadir
nejdetkadir / devise_controller.rb
Created December 23, 2021 08:56
How to use Devise gem with Rails 7 (devise_controller.rb)
class Users::DeviseController < ApplicationController
class Responder < ActionController::Responder
def to_turbo_stream
controller.render(options.merge(formats: :html))
rescue ActionView::MissingTemplate => error
if get?
raise error
elsif has_errors? && default_action
render rendering_options.merge(formats: :html, status: :unprocessable_entity)
else

WEB DESIGN WORKSHEET

HTML dosyası oluşturduğumuzda, uzantısı .html olmalıdır. Sayfamız açıldıktan sonra, html:5 yazıp TAB tuşuna basarak, VSCODE bizim için HTML iskeletini oluşturur.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
@nejdetkadir
nejdetkadir / colorized.rb
Created January 25, 2022 15:33
Colorization for ruby strings
class String
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
end
def green
require "fileutils"
# Copied from: https://github.com/mattbrictson/rails-template
# Add this template directory to source_paths so that Thor actions like
# copy_file and template resolve against our source files. If this file was
# invoked remotely via HTTP, that means the files are not present locally.
# In that case, use `git clone` to download them to a local temporary dir.
def add_template_repository_to_source_path
if __FILE__ =~ %r{\Ahttps?://}
require "tmpdir"
[{"id":"tt15097216","title":"Jai Bhim","cover_url":"https://m.media-amazon.com/images/M/MV5BY2Y5ZWMwZDgtZDQxYy00Mjk0LThhY2YtMmU1MTRmMjVhMjRiXkEyXkFqcGdeQXVyMTI1NDEyNTM5._V1_UY98_CR5,0,67,98_AL_.jpg","summary":"When a tribal man is arrested for a case of alleged theft, his wife turns to a human-rights lawyer to help bring justice.","min_age":"16+","runtime":"164 min","categories":["Crime","Drama"],"imdb":"9,3","casting":["T.J. Gnanavel","Suriya","Lijo Mol Jose","Manikandan","Rajisha Vijayan"]},{"id":"tt0111161","title":"The Shawshank Redemption","cover_url":"https://m.media-amazon.com/images/M/MV5BMDFkYTc0MGEtZmNhMC00ZDIzLWFmNTEtODM1ZmRlYWMwMWFmXkEyXkFqcGdeQXVyMTMxODk2OTU@._V1_UX67_CR0,0,67,98_AL_.jpg","summary":"Two imprisoned men bond over a number of years, finding solace and eventual redemption through acts of common decency.","min_age":"13+","runtime":"142 min","categories":["Drama"],"imdb":"9,3","casting":["Frank Darabont","Tim Robbins","Morgan Freeman","Bob Gunton","William Sadler"]},{"id":"tt0068646","