Skip to content

Instantly share code, notes, and snippets.

View agjs's full-sized avatar
⌨️

Aleksandar Grbic agjs

⌨️
View GitHub Profile
// Fluent api
function Chai() {}
Chai.prototype.expect = function(number) {
this.number = number;
return this;
};
Chai.prototype.increment = function() {
function foo(role, level) {
console.log(`Your role is ${role} and your level is ${level}.`);
console.log(this);
}
foo();
var person = {
name: 'Julie'
};
@agjs
agjs / how-to-format-erb-vscode.json
Created March 26, 2021 10:53
Format .erb templates and ruby files inside VSCode
Details at: https://aleksandar.xyz/blog/formatting-ruby-and-erb-in-vscode/
"files.associations": {
"*.erb": "erb"
},
"[erb]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "aliariff.vscode-erb-beautify",
}
@agjs
agjs / em.js
Created February 22, 2023 20:55
event emitter
import { EventEmitter } from "events";
class NotificationSystem extends EventEmitter {
constructor() {
this.#init()
}
#init() {
this.on("follow", async (targetId, metadata) => {
const notification = await Models.notification.create({
{
"editor.minimap.enabled": false,
"editor.wordWrap": "on",
"editor.fontSize": 14,
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": "'ss01', 'ss02', 'ss03', 'ss04', 'ss05', 'ss06', 'zero', 'onum'",
"editor.renderWhitespace": "none",
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": true,
"workbench.sideBar.location": "right",
@agjs
agjs / demo.js
Created May 22, 2023 20:15
axios twitch
// @ts-nocheck
import Axios from "axios";
import { setupCache } from "axios-cache-interceptor";
import { CUSTOM_ERRORS_ENUM } from "@Utils/constants";
import { BASE_API_URL } from "@Services/constants";
const axios = setupCache(Axios);
@agjs
agjs / test.json
Created July 27, 2023 20:45
VSCode Alex
{
"workbench.sideBar.location": "right",
"editor.fontFamily": "JetBrains Mono",
"editor.fontLigatures": true,
"background.backgroundOpacity": [
0.85,
0.9,
0.9,
0.5
],
@agjs
agjs / gist.json
Created October 29, 2023 12:20
gist
{
"workbench.sideBar.location": "right",
"editor.fontFamily": "JetBrains Mono",
"editor.fontSize": 12,
"editor.fontLigatures": "'ss02' on, 'ss04' on, 'ss07' on, 'ss08' on, 'ss10' on, 'ss12' on",
"editor.lineHeight": 18,
"editor.fontVariations": true,
"background.backgroundOpacity": [0.95, 0.9, 0.9, 0.5],
"background.backgroundAlignment": [
"Center Center",
@agjs
agjs / tiptap.js
Created November 13, 2023 20:25
tiptap
export const tiptapToHtml = ({ string, idToLabel, enableSuggestions, controls }) => {
try {
if (!string) {
return "";
}
const htmlContent = sanitize(
generateHTML(JSON.parse(string), editorConfig({ controls, suggestionItems: () => [], idToLabel, enableSuggestions }).extensions),
{
allowedTags: ["p", "span", "a", "iframe", "img", ...getControls(controls)],
@agjs
agjs / settings.json
Created December 15, 2023 22:46
settings
{
"workbench.sideBar.location": "right",
"editor.fontFamily": "JetBrains Mono",
"editor.fontSize": 12,
"editor.fontLigatures": "'ss02' on, 'ss04' on, 'ss07' on, 'ss08' on, 'ss10' on, 'ss12' on",
"editor.lineHeight": 18,
"editor.fontVariations": true,
"background.backgroundOpacity": [0.85, 0.9, 0.9, 0.5],
"background.backgroundAlignment": [
"Center Center",