Skip to content

Instantly share code, notes, and snippets.

View paveleremin's full-sized avatar

Pavel Eremin paveleremin

View GitHub Profile
<?php phpinfo(); ?>
@paveleremin
paveleremin / some-directive.js
Created May 12, 2015 18:42
[Examples] Directive
'use strict';
angular.module('SomeProject')
.directive('selectVehicleColor', function(){
return {
scope: {
model: '=',
colors: '=selectVehicleColor',
title: '@'
},
@paveleremin
paveleremin / some-view.html
Created May 12, 2015 18:49
[Examples] View
<ul class="nav nav-tabs mb20">
<li>
<a href="/batch-insert/">
<i class="fa fa-align-justify"></i>
Текст
</a>
</li>
<li>
<a href="/files/">
<i class="fa fa-th"></i>
@paveleremin
paveleremin / om_dashboard.jpg
Last active August 29, 2015 14:21
[Examples] Interface
om_dashboard.jpg
@paveleremin
paveleremin / 1.scss
Created May 13, 2015 14:34
[Examples] SCSS
@for $i from 1 through 10 {
.indent#{$i} {
@if $i > 1 {
margin-left: 16px * ($i - 1);
}
}
}
.top-offers {
margin-top: -2px;
@paveleremin
paveleremin / gist:86dafdb4341244fc3a94
Last active February 10, 2019 14:23
Brackets are correctly nested (two different approaches)
/**
* Implement function check (text) which checks whether brackets within text are correctly nested.
* You need to consider brackets of three kinds: (), [], {}.
*/
/**
* STACK approach
*/
function check(str){
var brackets = "()[]{}",
@paveleremin
paveleremin / array_reverse
Last active August 29, 2015 14:25
Implement array_reverse() without creating new array and usage of array_pop() array_shift()
function array_reverse($arr) {
$length = count($arr);
for ($i=0; $i < $length/2; $i++) {
$tmp = $arr[$i];
$arr[$i] = $arr[$length - 1 - $i];
$arr[$length - 1 - $i] = $tmp;
}
}
var_dump(array_reverse([1,2,3,4,5]))
@paveleremin
paveleremin / tickets.js
Last active September 10, 2015 09:29
Count lucky tickets regarding max length
var Tickets = function(maxLen){
if (maxLen % 2) {
throw Error('Max length must be even: 2, 4, 6, ...');
}
this.maxLen = parseInt((new Array(maxLen / 2 + 1)).join(9));
};
Tickets.prototype.count = function(num, undefined){
var digits = {},
i,
tmp;
@paveleremin
paveleremin / gist:f3ad1f6ec22447e8ce47
Created October 13, 2015 10:16
Array shuffle, without creating new array
var array = [1, 2, 3, 4, 5, 6];
Array.prototype.shuffle = function() {
var i = this.length,
tmp,
randIndex;
while (--i) {
randIndex = Math.floor(i * Math.random());
tmp = this[i];
this[i] = this[randIndex];
@paveleremin
paveleremin / index.js
Last active September 3, 2016 20:24
Siteimprove test
'strict mode';
/**
* > You choose programming language, any external libraries
* > and strategi for implementation.
* > You should build a solution from scratch.
*
* I chose Javascript that work on a server (NodeJS)
*/