Skip to content

Instantly share code, notes, and snippets.

View alekpopovic's full-sized avatar
🏠
Working from home

Aleksandar Popovic alekpopovic

🏠
Working from home
View GitHub Profile
@alekpopovic
alekpopovic / rails_new_options_help.md
Created September 22, 2022 14:26 — forked from kirillshevch/rails_new_options_help.md
List of "rails new" options to generate a new Rails 7 application

Run rails new --help to view all of the options you can use to generate new Rails application:

Output for Rails 7+

Usage:
  rails new APP_PATH [options]

Options:
      [--skip-namespace], [--no-skip-namespace]              # Skip namespace (affects only isolated engines)

Ruby Metaprogramming techniques

Use the singleton-class

Many ways of manipulating single objects are based on manipulations on the singleton class and having this available will make metaprogramming easier. The classic way to get at the singleton class is to execute something like this:

  sclass = (class << self; self; end)
@alekpopovic
alekpopovic / gist:e63e03055c2da9d18f5e685291e64112
Created August 10, 2022 09:14 — forked from dkam/gist:9755012
Postgresql pub/sub in Ruby
require 'sequel'
DB = Sequel.connect('postgres://user:pass@localhost/db')
DB.listen(:my_channel, loop: true) {|channel, pid, payload| puts "Got payload '#{payload}' on channel '#{channel}'" }
@alekpopovic
alekpopovic / README
Created June 21, 2022 23:31 — forked from deeja/README
Kubernetes Dashboard on Docker for Windows
## Instructions
https://collabnix.com/kubernetes-dashboard-on-docker-desktop-for-windows-2-0-0-3-in-2-minutes/
## Dashboard URL
http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default
@alekpopovic
alekpopovic / 1 Setup vps.md
Created May 5, 2022 15:46 — forked from deHelden/"torn" 1 Setup vps.md
Deploy Rails 6.0.0 to VPS(DigitalOcean Ubuntu 19). Nginx, Puma, Capistrano3, PostgreSQL, Rbenv.

SETUP VPS

based on DigitalOcean guide

Create local project

local$ rails new appname -T -d postgresql
local$ rails g scaffold Story title:string body:text
local$ rails db:migrate
@alekpopovic
alekpopovic / nginx_global_domains.config
Created April 27, 2022 22:13 — forked from Greegko/nginx_global_domains.config
nginx setup for dynamic domains and their subdomains
# Source: https://stackoverflow.com/questions/8199231/how-to-setup-mass-dynamic-virtual-hosts-in-nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
# Match any server name with the format [subdomain.[.subdomain...]].domain.tld.dev
server_name ~^(?<subdomain>([\w-]+\.)*)?(?<domain>[\w-]+\.[\w-]+)\.dev$;
# Map by default to (projects_root_path)/(domain.tld)/www;
@alekpopovic
alekpopovic / WSL2_VPN_Workaround_Instructions.md
Created April 19, 2022 10:40 — forked from machuu/WSL2_VPN_Workaround_Instructions.md
Workaround for WSL2 network broken on VPN

Overview

Internet connection and DNS routing are broken from WSL2 instances, when some VPNs are active. The workaround breaks down into two problems:

  1. Network connection to internet
  2. DNS in WSL2

This problem is tracked in multiple microsoft/WSL issues including, but not limited to:

@alekpopovic
alekpopovic / application.rb
Created April 12, 2022 19:04 — forked from steve9001/application.rb
Rails middleware to provide information about errors during requests
module MyApp
class Application < Rails::Application
if Rails.env == 'test'
require 'diagnostic'
config.middleware.use(MyApp::DiagnosticMiddleware)
end
end
end
@alekpopovic
alekpopovic / application.js
Created March 7, 2022 15:36 — forked from dbkbali/application.js
Application.JS file for Backbone Problem with JST/Handlebars Template
/*!
* jQuery JavaScript Library v1.7.2
* http://jquery.com/
*
* Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
@alekpopovic
alekpopovic / application_controller.rb
Created February 8, 2022 15:36 — forked from coffeeaddict/application_controller.rb
Add a doorkeeper session token to the current user
class ApplicationControler < AC::Base
include FayeHelper
# ... existing code
before_filter {
return if current_user.nil?
if current_user.refresh_session_token
# make a new client with the new token
client = setup_faye_client