Skip to content

Instantly share code, notes, and snippets.

View dmikis's full-sized avatar

Kirill Dmitrenko dmikis

  • Cinemersive Labs
  • Edinburgh, UK
  • X @dmikis
View GitHub Profile
@dmikis
dmikis / .screenrc
Created April 13, 2012 20:12
Configuration for GNU Screen
defutf8 on # default encoding
defflow on # mode of control window stream
deflogin on # enable login mode
vbell off # disable visual bell
defmonitor on # enable activity monitor
activity "Activity on %n" # activity message
defscrollback 10000 # count of saved rows
crlf off # use symbols CR — LF for differentiation between rows (for copy)
startup_message off # disable startup message
@dmikis
dmikis / gist:2466750
Created April 22, 2012 20:41
Jaccard Coefficients
(defconstant +main-set-length+ 1000)
(defconstant +subset-length+ 129)
(defconstant +subsets-quantity+ 1000)
(defun create-first-set ()
(let ((*set* (make-array +main-set-length+ :fill-pointer 0)))
(dotimes (i +main-set-length+)
(vector-push (random 1000) *set*))
(return-from create-first-set *set*)))
@dmikis
dmikis / percolation.lisp
Created June 3, 2012 17:42
Percolation problem
(defconstant +L+ 8)
(defconstant +p+ (random 1.0))
(setf *random-state* (make-random-state t))
(defun cluster-contains-the-point-predicate (point grid-size)
(let ((*surrounding-points* (list (- point grid-size)
(if (= (mod point grid-size) 0)
-1
(1- point)))))
[
100000,
200000,
300000
]
// vs
[100000,
200000,
@dmikis
dmikis / gist:3417784
Created August 21, 2012 17:45
Class vs Mixin
// class
function Foo() {};
Foo.prototype.foo = function () {};
// mixin
var Bar = {
__init: function () {},
bar: function () {}
};
function get_todo_status {
TODO_COUNT=
local FILE_LINE_COUNT=0
[[ -f "$HOME/.todo" ]] && FILE_LINE_COUNT=$(cat "$HOME/.todo" | wc -l)
[[ $FILE_LINE_COUNT -ne "0" ]] && TODO_COUNT=$FILE_LINE_COUNT
}
function todos {
[[ -f "$HOME/.todo" ]] && cat -n "$HOME/.todo"
}
Process: ControlPlane [501]
Path: /Applications/ControlPlane.app/Contents/MacOS/ControlPlane
Identifier: com.dustinrue.ControlPlane
Version: 1.3.14 (47)
Code Type: X86-64 (Native)
Parent Process: launchd [340]
Date/Time: 2013-05-06 23:53:46.840 +0400
OS Version: Mac OS X 10.7.5 (11G63)
Report Version: 9
@dmikis
dmikis / 1.js
Last active December 19, 2015 13:58
Proper inherit
function inherit(base, props, statics) {
if (typeof base !== 'function') {
statics = props;
props = base;
base = Object;
}
props.constructor.prototype = Object.create(base.prototype);
Object.keys(props).forEach(function (prop) {
@dmikis
dmikis / a.js
Created July 26, 2013 22:42
Thought on Node.js modules testing: instead of creating separate file with tests just write test within module. For example, here `b.js` - some module, and `a.js` uses it. If we call `node a.js`, it'll just output `Hello, world` without running assertions in `b.js`. But if we call `node b.js` it'll call assertions as module tests.
var b = require('./b');
console.log(b.hello('world'));
@dmikis
dmikis / simple.js
Created July 30, 2013 08:15
AMD && CommonJS && Plain
(function () {
function factory(dep1, dep2) {
/* simple modile */
return function () { return dep1 + dep2; };
}
if (typeof define === 'function' && define.amd) {
define('simple', ['dep1', 'dep2'], factory);
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = factory(requrie('dep1'), require('dep2'));