Skip to content

Instantly share code, notes, and snippets.

View sergiks's full-sized avatar

Sergei Sokolov sergiks

  • Russia | Europe | Thailand
View GitHub Profile
@sergiks
sergiks / script
Created April 27, 2015 18:00
All combinations of at least two array elements
/**
* Test to figure out combinations of at least two elements of provided array.
*
* by Sergei Sokolov, hello@sergeisokolov.com, 2015 April 27, St. Petersburg.
* Fiddle: http://jsfiddle.net/sergiks/2ojgqxk1/
*/
function comb(a) {
var l, cursor, mask, tail, out=[];
l = a.length;
if( l<2 || l>32) {
@sergiks
sergiks / index.html
Last active September 24, 2015 21:49
GET parameters in JavaScript
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="robots" content="">
@sergiks
sergiks / diffcalendar.js
Last active July 20, 2016 12:32
Difference between two Date objects
var diff
,I = new Date('2016-01-01T00:00:02')
,O = new Date('2017-01-01T00:00:01')
;
/**
* Calendar difference between two dates
*
* It takes into account the number of days in a month,
#!/bin/bash
#
# Backup database and files of a Wordpress blog running in a Docker container
#
# by Sergei Sokolov hello@sergeisokolov.com
# Moscow, 2016 September 08
#
DC_MYSQL=dockerwp_mysql_1
@sergiks
sergiks / apps-centrum-sum.js
Created February 8, 2017 08:44
Букмарклет для подсчёта выплат за месяц на AppsCentrum (несжатый код)
/**
* Bookmarklet for my.appscentrum.com
* to display agregated payouts by month
* for the last 3 months.
*
* Minify with command:
*
* uglifyjs -m -c negate-iife=false apps-centrum-sum.js
*
* by Sergei Sokolov hello@sergeisokolov.com
@sergiks
sergiks / apps-centrum-sum.min.js
Created February 8, 2017 08:53
Букмарклет для подсчёта выплат за месяц на AppsCentrum (минифицирован)
(function(t){var e,n,a,h=$("table"),r={},o=new Date,l="";if(!("my.appscentrum.com"!=window.location.hostname||h.length<4)){for(o.setDate(1),a=0;t>a;a++)e=("0"+(parseInt(o.getMonth())+1)).substr(-2),n=""+o.getFullYear(),r[""+e+"."+n]=0,o.setMonth(o.getMonth()-1);h=h[3],$("tr",h).each(function(t,e){var n,a,h=$("td:nth-child(5)",this).text().split(/[\ \.]/);h.length>=2&&(a=""+h[1]+"."+h[2],r.hasOwnProperty(a)&&(n=$("td:nth-child(3)",this).text(),(n=n.replace(/[^0-9\.]+/g,"")).length&&(r[a]+=parseFloat(n))))});for(key in r)l+=""+Math.round(100*r[key])/100+" руб. за "+key+"\r\n";alert(l)}})(5);
@sergiks
sergiks / NumText.php
Created March 12, 2017 09:08
PHP class for convertion between Russian text and numbers. First draft.
<?php
/**
* Перевод численных в числа и чисел в текст на Русском языке.
*
* Сергей Соколов hello@sergeisokolov.com Москва 2017.
*/
class NumText {
@sergiks
sergiks / zigzag.js
Created April 8, 2017 16:01
Rail Fence (zigzag) cipher JavaScript implementation
/**
* Rail Fence (zigzag) cipher JavaScript implementation.
* https://en.wikipedia.org/wiki/Rail_fence_cipher
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
@sergiks
sergiks / vkscript.php
Last active December 3, 2017 09:51
calling VKScript
<?php
$params = array(
'code' => " говнокод here ",
'access_token' => $token,
'v' => 5.64,
);
$url = 'https://api.vk.com/method/execute'. '?' . http_build_query( $params);
@sergiks
sergiks / console.js
Last active June 9, 2017 12:44
VK send message via browser console JS
/**
* Отправка ЛС во ВКонтакте скриптом из консоли браузера.
* Эксперимент для валидации идеи с Electron-приложением.
* Работает 2017-06-09 в Firefox 53.0.3 (64-bit) / Mac OS X 10.11.6
*
* Выполнять на странице диалога с нужным пользователем
* https://vk.com/im?sel=755074 цифры в конце это id пользователя ВК.
*
* by Sergei Sokolov, hello@sergeisokolov.com, 2017-06-09, Moscow.
*/