Skip to content

Instantly share code, notes, and snippets.

View sbrin's full-sized avatar

Mikhail Ilin sbrin

View GitHub Profile
function maxLength(a, k) {
let result = 0;
for (let i = 0; i < a.length; i++) {
let arr = [];
if (a[i] <= k) {
let arraySum = 0;
for (let j = i; j < a.length; j++) {
if (arraySum + a[j] <= k) {
arraySum += a[j];
arr.push(a[j]);
#!/usr/bin/env sh
# остановить публикацию при ошибках
set -e
# сборка
npm run build
# переход в каталог сборки
cd dist
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<style>
@sbrin
sbrin / popover_simple.js
Last active October 25, 2016 19:59
jQuery simple popover hides on click anywhere beside itself
$(function () {
var pop = {};
pop.shown = false;
pop.item = $('.popover');
$('body').on('click', function(e){
if ( e.target.className == 'button-block' ){
if ( pop.shown == true ){
pop.item.hide();
pop.shown = false;
@sbrin
sbrin / rsync.sh
Last active February 15, 2016 12:07
rsync -av --ignore-existing --exclude-from '[excludefile]' [srcpath] [dstpath]
@sbrin
sbrin / saveLog.php
Created November 24, 2014 16:28
simple php logging
function saveLog( $data )
{
$logname = date("Ymd") . ".log.txt";
$handle = fopen($logname, "a+");
if ($handle !== false) {
fwrite($handle, $data . PHP_EOL);
fclose($handle);
} else {
throw new Exception("saveLog fopen error");
@sbrin
sbrin / index.html
Last active February 10, 2023 22:23
Paste MS Word Text Jquery plugin
<!DOCTYPE html>
<html>
<body>
<div id="src">Source here...</div>
<div id="editor" contenteditable="true">
<p>Place MS-Word text here...</p>
</div>
</body>
</html>
@sbrin
sbrin / gist:6605987
Created September 18, 2013 07:55
bash FOR loop variables to skip spaces
OIFS="$IFS"
IFS=$'\n'
@sbrin
sbrin / gist:5927664
Last active December 19, 2015 08:39
Wget sitemap spider
wget --spider -o wget.log -e robots=off --wait 3 -r -p -S http://
grep -ri 'http://' wget.log | grep -E -v '(files/|\.jpg|\.jpeg|\.gif|\.css|\.js|\.pdf|\.png|\.xls)' | awk '{print $3}'|sort|uniq|sort > site_map.txt
cat $1 |grep -i -E -v '(\.jpg|\.jpeg|\.gif|\.css|\.js|\.pdf|\.png|\.xls|\.ico|\.txt|\.doc|yandexbot|googlebot|YandexDirect|\/upload\/|" 404 |" 301 |" 302 )'|perl -MURI::Escape -lne 'print uri_unescape($_)'|grep yandsearch|awk '{print $1}'|sort|uniq|wc -l
@sbrin
sbrin / gist:5635828
Created May 23, 2013 12:53
Copy website (wget recursive crawler)
wget -w 1 -r --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains DOMAIN --no-parent FOLDER/