Skip to content

Instantly share code, notes, and snippets.

View dmi3y's full-sized avatar
🌵
Dill with it

Dmitry Lapshukov dmi3y

🌵
Dill with it
  • Planet Earth
View GitHub Profile
@dmi3y
dmi3y / factorial.js
Created February 24, 2015 01:20
Reccursive factorial finder
function factorial(n) {
var
out = 1;
if ( n > 1 ) {
out = n * factorial(n - 1);
}
return out;
function findSumPairs(arr, sum) {
'use strict';
var
i = 0,
j = 0,
isum,
imatch,
out = [],
larr;
@dmi3y
dmi3y / invert.jl
Created January 4, 2015 17:55
invert number mathematically
function invert(num)
rev = 0
while num >= 10
rev = (rev + num % 10) * 10
num = fld(num, 10)
end
return (rev + num)
end
@dmi3y
dmi3y / seqSumFinder.js
Created December 15, 2014 23:51
Find sequence of numbers which form specified sum
function checkNumSeq(sum, chunks) {
var
i,
hchunks,
chunk,
out = [];
if ( sum % chunks === 0 && chunks % 2 ) {
chunk = sum / chunks;
td {
height: 50px;
width: 50px;
border: 1px solid gray;
text-align: center;
}
@dmi3y
dmi3y / index.js
Created November 14, 2014 17:11
Events precedence across browsers http://jsbin.com/zidap/2/edit
// Chrome 41 a>b>c
// FF 31 a>b>c
// IE10 a>b>c
// IE9 a>b>c
// IE8 b>c>a (opposite order, taking events wtih .onclick with higher precedence)
(function() {
var
myDiv = document.getElementById('myDiv'),
evt = 'click';
bukvy = new Set();
word = 'world asdf a asdf asdf asdf asd fasdf sadf asdf asdf asdf as234234df asdf sadf asdf 5 alkjlkjkjsdf asdf asdf asd fasdfasd fasdf';
out = [];
word.replace(/\d|\s/g, '').split('').forEach(
function(bukva) {
bukvy.add(bukva);
}
);
bukvy.forEach(function(bukva) {
@dmi3y
dmi3y / deepEqual.js
Last active August 29, 2015 14:06
Deep equal - data structures object, eloquent javascript
function deepEqual(a, b) {
var
isAobj = (typeof a === 'object'),
isBobj = (typeof b === 'object'),
isABobjs = (isAobj && isBobj),
out = (a === b);
function checkX (x) {
var
ix,
/// should be inside
/// static function OnBeforeRequest(oSession: Session) { ... }
if ( true/*some condition*/ ) {
var fso = new ActiveXObject("Scripting.FileSystemObject"),
fl = fso.OpenTextFile("c:\\path\\mocks\\manifest.json", 1),
content = fl.ReadAll(),
mockCalls,
@dmi3y
dmi3y / palindromeFinder.js
Created August 5, 2014 19:42
One word palindrome finder
function isPalindrome(word) {
var
normalizedWord = word.toLowerCase(),
reversedWord = normalizedWord.split('').reverse().join('');
return normalizedWord === reversedWord
}