Skip to content

Instantly share code, notes, and snippets.

View Guseyn's full-sized avatar
🎵
Enjoying Writing Music With Words

Guseyn Ismayylov Guseyn

🎵
Enjoying Writing Music With Words
View GitHub Profile
@Guseyn
Guseyn / github-pages-godaddy.md
Created November 12, 2023 12:38
Create Simple Page (using GitHub pages + GoDaddy domain)

1. Create account on GitHub

  1. Go to https://github.com.
  2. Click on Sign Up and follow all steps to create an account.

2. Create a project for your site

  1. Click on button New (like in screenshot #1)
@Guseyn
Guseyn / generate-magenta-sound-font.rb
Last active October 12, 2023 12:41
generate-magenta-sound-font
#!/usr/bin/env ruby
#
# JavaScript Soundfont Builder for MIDI.js
# Author: 0xFE <mohit@muthanna.com>
# edited by Valentijn Nieman <valentijnnieman@gmail.com>
#
# Requires:
#
# FluidSynth
# Lame
@Guseyn
Guseyn / fill-map-from-array.js
Created March 22, 2022 13:54
Fill map from array
const keys = [ 'a', 'b', 'c' ]
const values = [ 1, 2, 3 ]
const map = {}
keys.forEach((k, i) => { map[k] = values[i] })
@Guseyn
Guseyn / bezier-svg-path-interpolation.js
Created June 20, 2020 10:06
Bezier curve interpolation as svg path
// Based on this excellent article (https://apoorvaj.io/cubic-bezier-through-four-points/)
const vectorLength = (p1, p2) => {
return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2))
}
const middleCurvePoints = (firstPoint, secondPoint, thirdPoint, fourthPoint, alpha, epsilon) => {
const d1 = Math.pow(vectorLength(secondPoint, firstPoint), alpha)
const d2 = Math.pow(vectorLength(thirdPoint, secondPoint), alpha)
const d3 = Math.pow(vectorLength(fourthPoint, thirdPoint), alpha)
@Guseyn
Guseyn / boundsOfCurve.js
Created April 29, 2020 12:15
Bezier Bounding Box
'use strict'
// based on the same code in python https://gist.github.com/internetimagery/642b9cfa8488ba9a4d7c
const boundsOfCurve = (x0, y0, x1, y1, x2, y2, x3, y3) => {
const tvalues = []
const bounds = [[], []]
const points = []
for (let i = 0; i <= 1; i++) {
let b
@Guseyn
Guseyn / declarative-interface.java
Created March 23, 2020 10:25
Declarative approach via interface with getters
interface User {
String name();
int age();
}
class SimpleUser implements User {
private String name;
private int age;
//...constructor
String name () {
@Guseyn
Guseyn / d.java
Last active March 23, 2020 10:24
Declarative approach via getters
class User {
private String name;
private int age;
// ... constructor
public String name() {
return this.name;
}
function foo() {
console.error('foo');
}
process.nextTick(foo);
console.error('bar');
console.error('bar');
process.nextTick(foo);
console.error('bar');
@Guseyn
Guseyn / invertTree.js
Last active April 9, 2019 16:22
Invert Tree In Pure OO style
class TreeNode {
constructor (value, left, right) {
this.value = value
this.left = left
this.right = right
}
invert () {
if (!this.left && !this.right) {
return this
@Guseyn
Guseyn / mapLimit.js
Last active April 16, 2019 06:41
mapLimit via callbacks
function mapLimit (col, limit, mapFunc, doneFunc, newCol = [], index = { value: 0 }, freeThreads = { value: limit }) {
if (freeThreads.value > 0 && index.value < col.length) {
// Save current index
const curIndex = index.value
// Now the number of free threads is lower on 1
freeThreads.value -= 1
mapFunc((err, newItem) => {
if (err) {
// Smth bad happend, we call doneFunc with err