Skip to content

Instantly share code, notes, and snippets.

View doron2402's full-sized avatar

Doron Segal doron2402

View GitHub Profile
@doron2402
doron2402 / sort.rb
Created July 25, 2013 05:25 — forked from aspyct/sort.rb
# Sample implementation of quicksort and mergesort in ruby
# Both algorithm sort in O(n * lg(n)) time
# Quicksort works inplace, where mergesort works in a new array
def quicksort(array, from=0, to=nil)
if to == nil
# Sort the whole array, by default
to = array.count - 1
end
@doron2402
doron2402 / gist:8312330
Created January 8, 2014 05:38
hapi slide show, great example how slide show look like
<!doctype html>
<html lang="en-GB" class="h-entry">
<head>
<meta charset="UTF-8">
<title class="p-name">Be more hapi</title>
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="620">
<meta name="viewport" content="width=device-width">
@doron2402
doron2402 / gist:8373176
Created January 11, 2014 16:37
Interview question for Mysql
CREATE TABLE `payments` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`amount` DECIMAL(8,2) NOT NULL,
`date` DATE NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;
INSERT INTO `payments` (`amount`,`date`) VALUES ('3.44','2012-01-01');
INSERT INTO `payments` (`amount`,`date`) VALUES ('344','2012-02-01');
INSERT INTO `payments` (`amount`,`date`) VALUES ('66.48','2012-03-01');
@doron2402
doron2402 / es6_fib.js
Created January 13, 2015 23:49
es6/7 fib
function* fib(num) {
var prev = 0;
var curr = 1;
while (curr < num) {
var tmp = prev;
prev = curr;
curr = tmp + curr;
yield curr;
}
}
@doron2402
doron2402 / quicksort.js
Last active August 29, 2015 14:14
quick sort using javascript
/*
Swap values using two index
@param items {Array}
@param firstIndex {Integer}
@param secondIndex {Integer}
@return 'undefined'
*/
var swap = function(items, firstIndex, secondIndex){
var temp = items[firstIndex];
items[firstIndex] = items[secondIndex];
@doron2402
doron2402 / navBarStep.js
Created November 21, 2015 00:13
Dynamic nav bar
var steps = {
floorplan: {
display: 'ResourceService.FloorPlan',
url: "/floorplan",
icon: "floorplan",
isEnabled: true,
position: 6
},
combinations: {
display: 'ResourceService.TableCombinations',
var steps = {
floorplan: {
display: 'ResourceService.FloorPlan',
url: "/floorplan",
icon: "floorplan",
isEnabled: true,
position: 6
},
combinations: {
display: 'ResourceService.TableCombinations',
@doron2402
doron2402 / execute_promise.js
Created January 11, 2017 05:37
Execute promise by Mozilla
'use strict';
var promiseCount = 0;
function testPromise() {
var thisPromiseCount = ++promiseCount;
var log = document.getElementById('log');
log.insertAdjacentHTML('beforeend', thisPromiseCount +
') Started (<small>Sync code started</small>)<br/>');
// We make a new promise: we promise a numeric count of this promise, starting from 1 (after waiting 3s)
var p1 = new Promise(
// The resolver function is called with the ability to resolve or