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 / 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
@alekpopovic
alekpopovic / postgres.md
Created February 1, 2022 11:51 — forked from phortuin/postgres.md
Set up postgres + database on MacOS (M1)

Based on this blogpost.

Install with Homebrew:

$ brew install postgresql

Run server:

@alekpopovic
alekpopovic / fileutils_example.rb
Created January 4, 2022 20:34 — forked from jensendarren/fileutils_example.rb
An example of using FileUtils in Ruby
require 'fileutils'
# __FILE__ keyword in ruby
puts "The current ruby file being executed is #{__FILE__}"
# Gets the directory name of the file being executed
current_directory = File.dirname(__FILE__)
puts "The current directory is #{current_directory}"
# expands to reveal the pwd (Present working directory)
@alekpopovic
alekpopovic / gist:f32525fcdbe1daab94d8d851e7f8ca3c
Created December 20, 2021 21:06 — forked from rkuzsma/gist:b9a0e342c56479f5e58d654b1341f01e
Example Kubernetes yaml to pull a private DockerHub image
Step by step how to pull a private DockerHub hosted image in a Kubernetes YML.
export DOCKER_REGISTRY_SERVER=https://index.docker.io/v1/
export DOCKER_USER=Type your dockerhub username, same as when you `docker login`
export DOCKER_EMAIL=Type your dockerhub email, same as when you `docker login`
export DOCKER_PASSWORD=Type your dockerhub pw, same as when you `docker login`
kubectl create secret docker-registry myregistrykey \
--docker-server=$DOCKER_REGISTRY_SERVER \
--docker-username=$DOCKER_USER \
@alekpopovic
alekpopovic / .1_webpacker_coffee2_vue_jsx.md
Created December 6, 2021 16:38 — forked from gtarsia/.1_webpacker_coffee2_vue_jsx.md
(rails + webpacker + coffeescript 2 + vue + vuex + jsx) from an existing rails project, with proper structure

Caveats

Remember that using vue jsx has some caveats. Most importantly that most vue builtin directives are not supported (for example, v-for, v-model, etc.), expect for v-show. Some of them can be implemented manually, but v-model for example is kind of a pain in the ass.
https://vuejs.org/v2/guide/render-function.html#Replacing-Template-Features-with-Plain-JavaScript
https://github.com/vuejs/babel-plugin-transform-vue-jsx#vue-directives
There's this though:
https://github.com/nickmessing/babel-plugin-jsx-v-model

Also the sourcemap result is kind of crappy, things like @ are not mapped correctly, I resorted to just using 'eval' as webpack config.devtool, it's good enough for what I'm doing.

Instructions