Skip to content

Instantly share code, notes, and snippets.

moka Maksims

Block or report user

Report or block Maksims

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pc.angle.js
pc.Angle = function(degrees) {
this._theta = (degrees * pc.Angle.RA) || 0;
this._normalize();
};
// constant to convert between radians and degrees
pc.Angle.RA = 180 / Math.PI;
pc.Angle.prototype = {
copy: function(angle) {
@Maksims
Maksims / map-style.json
Created Oct 14, 2014
Google Maps custom dark style
View map-style.json
[
{
"elementType": "geometry.fill",
"stylers": [
{ "visibility": "on" },
{ "color": "#324447" }
]
}, {
"elementType": "geometry.stroke",
"stylers": [
@Maksims
Maksims / vec2.js
Last active Jan 3, 2016
"rude" extension to Float32Array, implementing 2D Vector Math.
View vec2.js
// degree to radians constant
var rd = Math.PI / 180.0;
// 2d vector [x, y] library
var Vec2 = {
cacheSize: 64,
cache: [ ],
clear: function() {
this.cache = [ ];
},
@Maksims
Maksims / class.js
Last active Jan 19, 2017
Small implementation of classes with: extend, implement, and check methods
View class.js
// base class
function Class() { }
// base class name
Class.prototype.className = 'Class';
// lists all parent classes and outputs JSON with it
Class.prototype.toString = function() {
var str = '';
var next = this.__proto__;
@Maksims
Maksims / collection.js
Last active Dec 20, 2015
Collections that promise for single appearance of object in collection as well as use hashing based on key (if defined) for collection to speed up checks. In small collections that slows down (nearly unmeasurable) but in 'big' collections (32+) it is a great win to prevent iterations for searches.
View collection.js
'use strict';
var Collection = this.Collection = exports.Collection = function Collection(key) {
this.list = [ ];
this.length = 0;
this.key = key || null;
this.map = { };
}
@Maksims
Maksims / wifi_rssi_windows.js
Created Jul 25, 2013
node.js function (for Windows) to get list of SSIDs of wifi networks available, their BSSID and RSSI (Signal Strength). It uses `netsh` windows command line tool to get data. (tested on win7)
View wifi_rssi_windows.js
var spawn = require('child_process').spawn;
wifiNetworksRSSI(function(err, data, raw) {
if (!err) {
console.log(data); // formatted data with SSID, BSSID, RSSI
// console.log(raw); // raw output from netsh
} else {
console.log(err);
}
});
@Maksims
Maksims / jobsQueue.js
Last active Dec 16, 2015
async / sync queue of functions.
View jobsQueue.js
function jobsQueue(jobs) {
if (jobs && jobs instanceof Array && jobs.length > 0) {
var count = jobs.length;
var i = -1;
var next = function() {
if (++i < count) jobs[i](next);
}
next();
}
}
@Maksims
Maksims / blueprint.css
Created Apr 25, 2013
CSS to generate blueprint grid (blue with white lines), "stolen" from http://tformerjs.com/
View blueprint.css
background-color : #4e9ad5;
background-size : 100px 100px, 100px 100px, 20px 20px, 20px 20px;
background-position : -11px -1px;
background-image : linear-gradient(rgba(255, 255, 255, .3) 1px, transparent 1px), linear-gradient(0, rgba(255, 255, 255, .3) 1px, transparent 1px), linear-gradient(rgba(255, 255, 255, .1) 1px, transparent 1px), linear-gradient(0, rgba(255, 255, 255, .1) 1px, transparent 1px);
background-image : -webkit-linear-gradient(rgba(255, 255, 255, .3) 1px, transparent 1px), -webkit-linear-gradient(0, rgba(255, 255, 255, .3) 1px, transparent 1px), -webkit-linear-gradient(rgba(255, 255, 255, .1) 1px, transparent 1px), -webkit-linear-gradient(0, rgba(255, 255, 255, .1) 1px, transparent 1px);
background-image : -moz-linear-gradient(rgba(255, 255, 255, .3) 1px, transparent 1px), -moz-linear-gradient(0, rgba(255, 255, 255, .3) 1px, transparent 1px), -moz-linear-gradient(rgba(255, 255, 255, .1) 1px, transparent 1px), -moz-linear-gradient(0, rgba(255, 255, 255, .1) 1px, transparent 1px
@Maksims
Maksims / DOMClass.js
Last active Dec 8, 2018
HTMLElement extension to add, remove, toggle, detect Classes.
View DOMClass.js
HTMLElement = typeof(HTMLElement) != 'undefiend' ? HTMLElement : Element;
HTMLElement.prototype.addClass = function(string) {
if (!(string instanceof Array)) {
string = string.split(' ');
}
for(var i = 0, len = string.length; i < len; ++i) {
if (string[i] && !new RegExp('(\\s+|^)' + string[i] + '(\\s+|$)').test(this.className)) {
this.className = this.className.trim() + ' ' + string[i];
}
You can’t perform that action at this time.