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 / 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
@alekpopovic
alekpopovic / head.js
Created August 22, 2021 09:57 — forked from garethredfern/head.js
The full head tag for a Nuxt website, including social media and SEO tags. Put this in your nuxt.config.js file.
head: {
htmlAttrs: {
lang: "en-GB",
},
title: "Articles focused on learning Laravel and VueJS",
meta: [
{ charset: "utf-8" },
{ name: "HandheldFriendly", content: "True" },
{ name: "viewport", content: "width=device-width, initial-scale=1" },
{
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@alekpopovic
alekpopovic / symfony4-fos-oauth-server-bundle.md
Created May 15, 2021 19:08 — forked from mirkorap/symfony4-fos-oauth-server-bundle.md
Basic examples how to implement a REST API with Symfony 4 + FOSRestBundle + FOSUserBundle + FOSOauthServerBundle with all oauth2 code flow
@alekpopovic
alekpopovic / wma_hash.rb
Created April 22, 2021 23:03 — forked from iogakos/wma_hash.rb
Weighted Moving Average - Ruby Implementation
# Weighted Moving Average (WMA)
# http://en.wikipedia.org/wiki/Moving_average#Weighted_moving_average
#
# Given a hash, calculates the weighted moving averages of its values within
# a window size given. Modifies the original hash values.
#
# @param hash [Hash] the hash for whom values calculate the weighted moving
# averages.
# @param maws [Fixnum] the Moving Average Window Size. The greatest this
# number is the smoothest the calculated averages will be.
@alekpopovic
alekpopovic / dsl.ts
Created February 16, 2021 23:56 — forked from freddi301/dsl.ts
Typescript example DSL
interface MyProgramDSL<T> {
read: () => Promise<string>;
write: (value: string) => Promise<void>
done: (value: T) => Promise<T>
}
const MyProgram = async ({ read, write, done }: MyProgramDSL<string>) => {
await write("Hello, what is your name?");
const name = await read();
@alekpopovic
alekpopovic / DSL.ts
Created February 16, 2021 23:56 — forked from ulve/DSL.ts
Sample DSL with interpreter in TypeScript
type Program<T> = Read<T> | Write<T> | Done<T>;
interface Read<T> {
kind: "Read";
next: (data: T) => Program<T>;
}
interface Write<T> {
kind: "Write";
valToWrite: string;
@alekpopovic
alekpopovic / environment.js
Created February 7, 2021 00:01 — forked from KonnorRogers/environment.js
ESBuild with Webpacker < 6 in Rails. Bye Babel <3
// DONT FORGET TO `yarn add esbuild-loader` !!!
// config/webpacker/environment.js
const { environment } = require('@rails/webpacker')
const { ESBuildPlugin } = require('esbuild-loader')
const esBuildUse = [
{
loader: require.resolve('esbuild-loader'),
// What you want to compile to, in this case, ES7
@alekpopovic
alekpopovic / dynamic-method.ts
Created January 1, 2021 16:58 — forked from mfdeveloper/dynamic-method.ts
This is a example of a dynamic class method on Typescript. Until here, is not possible access class properties inside the overrided/new method
/**
* Typescript dynamic class method example
*
* REFERENCES:
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html
* @see https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Mixins.md
* @see http://blog.brillskills.com/2013/09/exploring-javascript-prototypes-via-typescripts-class-pattern
* @see https://github.com/Microsoft/TypeScript/wiki/%27this%27-in-TypeScript
*
* For this example, using IONIC 2/3 Toast component to override a method