Skip to content

Instantly share code, notes, and snippets.

/**
* An implementation for Quicksort. Doesn't
* perform as well as the native Array.sort
* and also runs the risk of a stack overflow
*
* Tests with:
*
* var array = [];
* for(var i = 0; i < 20; i++) {
* array.push(Math.round(Math.random() * 100));
@tarzak
tarzak / FriendsNamesIlljaVer.js
Created July 4, 2014 08:46
Illja's ver of Friends names for The West
var objArr = WestUi.FriendsBar.friendsBarUi.friendsBar.getAllPlayers(),
friendsNames = objArr.map(function(item) {
return item.name;
});
console.log(friendsNames);
@tarzak
tarzak / FriendsNames.js
Created July 3, 2014 12:55
Getting names of all your friends in The-west.ru
var objArr = WestUi.FriendsBar.friendsBarUi.friendsBar.getAllPlayers(),
friendsNames = [],
i = 0;
for (i = 0; i < objArr.length; i++)
friendsNames[i] = objArr[i].name;
console.log(friendsNames);
/* module update cloud commander */
(function(){
'use strict';
if(!global.cloudcmd)
return console.log(
'# update.js' + '\n' +
'# -----------' + '\n' +
'# Module is part of Cloud Commander,' + '\n' +
var fs = require('fs');
var buf = fs.readFileSync('les01.js');//process.argv[2]
var str = buf.toString();
var arr = str.split("\n");
console.log(arr.length - 1);
@tarzak
tarzak / farlike.css
Created June 17, 2014 11:45
cloudcmd template Far like
body {
background-color: #000080;
color: #0FF;
}
a {
color: #0FF;
}
.cmd-button {
@tarzak
tarzak / gist:9ce3bb224cedb79ce45e
Last active August 29, 2015 14:02
job exercise
function Animal(name) {
this.name = name;
this.getName = function() {
console.log(this.name);
}
}
function Cat(name) {
this.name = name;
this.meow = function() {
@tarzak
tarzak / Array element count.js
Last active August 29, 2015 13:58
Counting of Array Elements
var arr = [7,3,1,2,2,1,7,1,1,1,4], arrObj = {};
function elementCount(arr) {
var i = 0, prop, name;
for (i = 0; i < arr.length; i++) {
name = arr[i];
if (!arrObj[name]) {
arrObj[name] = 0;
}
@tarzak
tarzak / index.js
Last active August 29, 2015 13:57
Обидва файли
var myFirstModule = require("./myFirstModule");
myFirstModule.start();
var i, j,
arr = [2,5,1,0],
max = 0,
n = arr.length;
for (i = 1; i < n; i++)
for (j = 0; j < n - 1 ; j++) {
max = arr[j + 1];
if (arr[j] > max) {