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
@Daniel-Hug
Daniel-Hug / unwrap.js
Last active June 16, 2019 07:22
JS: unwrap element (remove parent without removing child nodes). Demo: http://jsbin.com/hipahu/edit?html,js,output
// remove parent without removing childen
function unwrap(wrapper) {
// place childNodes in document fragment
var docFrag = document.createDocumentFragment();
while (wrapper.firstChild) {
var child = wrapper.removeChild(wrapper.firstChild);
docFrag.appendChild(child);
}
// replace wrapper with document fragment
@internetimagery
internetimagery / bounds.py
Created December 23, 2015 11:04
bezier bounding box
# http://stackoverflow.com/questions/2587751/an-algorithm-to-find-bounding-box-of-closed-bezier-curves
from __future__ import division
import math
def getBoundsOfCurve(x0, y0, x1, y1, x2, y2, x3, y3):
tvalues = []
bounds = [[], []]
points = []
@lobster1234
lobster1234 / WaitNotifyExample..java
Created March 6, 2013 08:05
A very simple wait/notify example
public class WaitNotifyExample {
public static void main(String[] args) {
Integer lock = new Integer(0);
Thread waiter = new Thread(new Waiter(lock));
waiter.start();
Thread notifier = new Thread(new Notifier(lock));
notifier.start();
}
@weepy
weepy / gist:6009631
Last active March 16, 2022 18:18
Cubic Roots Solver Function in JS
function CubicSolve(a, b, c, d){
b /= a;
c /= a;
d /= a;
var discrim, q, r, dum1, s, t, term1, r13;
q = (3.0*c - (b*b))/9.0;
r = -(27.0*d) + b*(9.0*c - 2.0*(b*b));
@jesgs
jesgs / deploying-from-github-to-vps-using-travis-ci.md
Last active September 12, 2022 19:39
Deploying from Github to VPS using Travis CI

From: https://www.jesgs.com/blog/2017/12/18/deploying-from-github-to-vps-using-travis-ci

Recently, I spent around 14 to 16 hours learning all of the necessary steps to getting an existing repo set up with Travis CI to run unit tests, and then once successful, connect to a remote server that isn't a PaaS (in this case, Linode) and then proceeds to use Git hooks to do post deployment things.

Starting with your local machine and you have your project already checked out from Github.

Setting Up

  • Assuming you have Ruby (at least 2.3.1) installed, run gem install travis. This installs the Travis CI command-line tools. We're going to use these tools to encrypt RSA keys that Travis will use to connect to your remote server.
  • This tutorial also assumes that you have a working repo and a Travis-CI account set up.
@valentijnnieman
valentijnnieman / soundfont_builder.rb
Last active October 10, 2023 20:09
Script for transforming sf2 file to Magenta Soundfont format
#!/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 / 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
@hugosp
hugosp / app.js
Created April 4, 2016 22:37
Minimal express-ws broadcast to all clients
var express = require('express');
var expressWs = require('express-ws');
var expressWs = expressWs(express());
var app = expressWs.app;
app.use(express.static('public'));
var aWss = expressWs.getWss('/');
app.ws('/', function(ws, req) {
@hsablonniere
hsablonniere / README.md
Created May 2, 2012 22:42
scrollIntoViewIfNeeded 4 everyone!!!

scrollIntoViewIfNeeded 4 everyone!!!

This gist provides a simple JavaScript implementation of the non-standard WebKit method scrollIntoViewIfNeeded that can be called on DOM elements.

Usage

Just use the code in index.js in your app or website. You can see usage in the test page test.html.

The parent element will only scroll if the element being called is out of the view. The boolean can force the element to be centered in the scrolling area.

@kolosovsky
kolosovsky / aabb.md
Last active February 3, 2024 14:16
The computation of the axis-aligned bounding box (AABB) in JavaScript

The computation of the axis-aligned bounding box (AABB) in JavaScript

Polygon (rectangle, triangle, etc.)

Live demo https://jsfiddle.net/Kolosovsky/tdqv6pk2/

let points = [
	{ x: 125, y: 50 },
	{ x: 250, y: 65 },