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 / 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

@alekpopovic
alekpopovic / docker-compose.yml
Created October 12, 2021 22:26 — forked from BretFisher/docker-compose.yml
Docker Compose local development with wildcard DNS for multi-domain development
version: '3'
# vcap.me is a wildcard domain that resolves to localhost
# in case you need to pass URL's around from browser to
# containers this could help you get around localhost problem
services:
# use www.vcap.me to access web containter from host
# use api.vcap.me to access api container from host
proxy:
@alekpopovic
alekpopovic / typescript-vue.md
Created September 18, 2021 11:21 — forked from RISCfuture/typescript-vue.md
Adding TypeScript to a Rails + Webpacker + Vue project

Adding TypeScript to a Rails + Webpacker + Vue project

These instructions assume you already have a Rails 5.2 project using Webpacker 4 with Vue 2 and Vuex 3. I'll show you how to add TypeScript to the project, and type-safe your Vue components, including single-file components (SFCs). This document will not teach you TypeScript syntax or type theory. It also assumes your code already works without TypeScript. You shouldn't use this article to, for example, get started with Vuex, because I'm leaving out lots of necessary boilerplate code and focusing just on TypeScript changes.

If you want to see a commit on a project accomplishing this migration, visit https://github.com/RISCfuture/AvFacts/commit/666a02e58b4626a074a03812ccdd193a3891a954.

Setup

  1. Run rails webpacker:install:typescript. This should modify config/webpacker.yml and config/webpack/environment.js (leave those changes), add tsconfig.json and config/webpack/loaders/typescript.js (leave those files), and add some other files in `a