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 / 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
@alekpopovic
alekpopovic / importing.module.ts
Created December 10, 2020 18:07 — forked from evolkmann/importing.module.ts
Create Nest.js modules with custom config
import { Module } from '@nestjs/common';
import { MyLibModule } from './my-lib.module';
@Module({
imports: [
MyLibModule.register({ name: 'Enzo' }),
]
})
export class ImportingModule {}
@alekpopovic
alekpopovic / working_url.rb
Created December 1, 2020 19:53 — forked from tb/working_url.rb
Check if URL exists in Ruby
require 'net/http'
def working_url?(url_str)
url = URI.parse(url_str)
Net::HTTP.start(url.host, url.port) do |http|
http.head(url.request_uri).code == '200'
end
rescue
false
end