Skip to content

Instantly share code, notes, and snippets.

@ruthenium
ruthenium / gist:7e8620b6974f151d52809c0b2075b59f
Created February 24, 2017 17:18 — forked from keiya/gist:1190856
convert polar - cartesian
// thx tomy! http://www5.airnet.ne.jp/tomy/cpro/sslib12.htm
function cartesian2polar(x,y,z) {
var obj = new Object;
obj.r = Math.sqrt( x*x + y*y + z*z );
if (x != 0.0)
obj.phi = Math.atan2( y, x );
else {
if (y < 0.0)
@ruthenium
ruthenium / polarToCartesian.js
Created February 24, 2017 17:19 — forked from cevherkarakoc/polarToCartesian.js
Converting polar coordinates to cartesian coordinates
function polarToCartesian(radius,radian){
return {
x:radius*Math.cos(radian),
y:radius*Math.sin(radian)
}
}
@ruthenium
ruthenium / cartesianToPolar.js
Created February 24, 2017 17:19 — forked from cevherkarakoc/cartesianToPolar.js
Converting cartesian coordinates to polar coordinates
function cartesianToPolar(x,y){
return {
radius: Math.sqrt( Math.pow(x, 2) + Math.pow(y, 2) ),
alpha: Math.atan2(y, x)
}
}
@ruthenium
ruthenium / polarToCartesian.js
Created February 24, 2017 17:19 — forked from Raisi/polarToCartesian.js
Transform Polar to Cartsian Coordinats
/**
* Coordinates Transformations
*
* http://stackoverflow.com/questions/5736398/how-to-calculate-the-svg-path-for-an-arc-of-a-circle
*
* @param centerX
* @param centerY
* @param radius
* @param angleInDegrees
* @returns {string}
@ruthenium
ruthenium / import_string.py
Created January 10, 2018 23:02
import_string from django
# -*- coding: utf8 -*-
# this is from django.utils.module_loading
from importlib import import_module
def import_string(dotted_path):
"""
Import a dotted module path and return the attribute/class designated by the
last name in the path. Raise ImportError if the import failed.
"""
@ruthenium
ruthenium / hide.full.js
Last active August 8, 2018 14:46
Hide all posts without media at the Invision forums
(function(){
function addLink(target) {
var div = document.createElement('div');
var a = document.createElement('a');
a.setAttribute('href', '#');
a.textContent = 'No media in post';
a.addEventListener('click', function(e){
if (target.style.display == "none") {
target.removeAttribute('style');
} else {