Skip to content

Instantly share code, notes, and snippets.

@hogart
hogart / .gitconfig
Last active April 27, 2022 13:42
my .gitconfig
; on windows, this usually goes to c:\Users\MyLogin\.gitconfig
[alias]
st = status
ci = commit
co = checkout
br = branch
[color]
ui = true
@hogart
hogart / quantize.js
Last active October 3, 2015 04:37
quantize teturn nearest bigger to `value` number, which is multiple of `quant`
/**
* Return nearest bigger (by default, or lesser if the third parameter is true) to `value` number, which is multiple of `quant`
* @throws {Error} 'Illegal quantazing value'
* @param {Number} value
* @param {Number} quant must not be zero
* @param {Boolean} [toLower=false] return bigger rather than lesser nearest number
* @return {Number}
*/
function quantize(value, quant, toLower) {
if (quant === 0) {
@hogart
hogart / mpd.conf
Created April 21, 2012 21:19
mpd.conf for using with ubuntu systems
# supposed you have default mpd.conf and have read comments in it
music_directory "/media/g/Music"
# mpd starts from `mpd` user. So create homedir for this user.
# also, don't forget to chown all this files to mpd
# well, you can change `user` setting below
playlist_directory "/home/mpd/pl"
db_file "/home/mpd/db"
log_file "/home/mpd/log"
pid_file "/home/mpd/pid"
@hogart
hogart / index.js
Created November 4, 2014 05:18
django-like settings for node projects
'use strict';
var env = process.env.NODE_ENV || 'development'; // development by default
var config = {};
try {
config = require('./local'); // local.js has priority
} catch (e) {
config = require('./' + env); // if local.js is not present, get config with environment name
}
@hogart
hogart / aniLoop.js
Created December 16, 2014 10:43
Takes two function, one for state `update` and one for `render` that state, and organizes them into animation loop.
/**
* @author Konstantin Kitmanov <doctor.hogart@gmail.com>
* @license MIT
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) { // AMD anonymous module
define([], factory);
} else if (typeof exports === 'object') { // NodeJS/CommonJS-like module
module.exports = factory();
@hogart
hogart / setRandomInterval
Created December 16, 2014 10:50
setInterval with random intervals (in given bounds)
/**
* @author Konstantin Kitmanov <doctor.hogart@gmail.com>
* @license MIT
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) { // AMD anonymous module
define([], factory);
} else if (typeof exports === 'object') { // NodeJS/CommonJS-like module
module.exports = factory();
(function () {
var deg120 = Math.PI * 2/3;
var deg240 = Math.PI * 4/3;
var cos120 = Math.cos(deg120);
var sin120 = Math.sin(deg120);
var cos240 = Math.cos(deg240);
var sin240 = Math.sin(deg240);
/**
* Given center and radius of circumcircle, return points of triangle's vertices
@hogart
hogart / Backbone.AutoModel.js
Last active August 29, 2015 14:18
Backbone.Model with auto-properties
'use strict';
var Backbone = require('backbone');
var ModelAbstract = Backbone.Model.extend({
/**
* Create calculatable properties.
* @example
* __autos__: {
function MainController(model) {
this.model = model;
}
MainController.prototype = {
findAll: function (req, res) {
res.send(200, this.model + '.find({})');
},
findById: function (req, res) {
res.send(200, this.model + '.findById(req.params.id)');
},
@hogart
hogart / .editorconfig
Created June 13, 2015 10:21
.editorconfig
root = true
[*]
end_of_line = lf
insert_final_newline = false
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true