Skip to content

Instantly share code, notes, and snippets.

View nickovchinnikov's full-sized avatar

Nick Ovchinnikov nickovchinnikov

View GitHub Profile
@nickovchinnikov
nickovchinnikov / nginx
Last active February 3, 2016 15:53
Nginx phpmyadmin config
server {
listen 80;
server_name phpmyadmin.ru;
access_log /var/log/nginx/phpmyadmin.local.access.log;
error_log /var/log/nginx/phpmyadmin.local.error.log;
root /usr/share/phpmyadmin;
<?php
namespace app\models\search;
use app\models\Access;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use app\models\Calendar;
function isinValidate(isin) {
isin = isin.toUpperCase();
if (!/^[0-9A-Z]{12}$/.test(isin)) {
return false;
}
if (isin.length != 12) return false;
var v = [];
for (var i = isin.length - 2; i >= 0; i--) {
@nickovchinnikov
nickovchinnikov / cusip-validate.js
Created December 8, 2016 12:55
CUSIP validator
function cusipValidate(cusip) {
cusip = cusip.toUpperCase();
if (!/^[0-9A-Z@#*]{9}$/.test(cusip)) {
return false;
}
var sum = 0,
cusipChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ*@#".split('');
@nickovchinnikov
nickovchinnikov / iban-validator.js
Created December 8, 2016 12:56
IBAN validator
function ibanValidate(input) {
function mod97(string) {
var checksum = string.slice(0, 2), fragment;
for (var offset = 2; offset < string.length; offset += 7) {
fragment = String(checksum) + string.substring(offset, offset + 7);
checksum = parseInt(fragment, 10) % 97;
}
return checksum;
}
//implement missing "Parallel" please
//try to do so with a minimal amount of code
function Parallel (options) {
var parallelJob = options.parallelJob || 1;
var jobs = [];
var result = [];
function runJobs() {
return new Promise(function(resolve) {
const itemsToTable = items => {
return items.reduce((prevItem, currentItem) => {
const cursor = prevItem.length > 0 ? prevItem.length - 1 : 0
if (!Array.isArray(prevItem[cursor])) {
prevItem[cursor] = []
}
const currentColumn = cursor >= 0 ? prevItem[cursor] : []
const MockData = require('./MockData')
const formatColumns = (data, columnLength = 6) => {
const pushItem = ({ boardMatrix = [], columnCursor = 0, rowCursor = 0, currentItem }) => {
const currentArrayItem = boardMatrix[columnCursor]
if (!currentArrayItem) {
boardMatrix[columnCursor] = [currentItem]
} else {
boardMatrix[columnCursor][rowCursor] = currentItem
}
/*
Write a function
function solution(A);
that, given an array A consisting of N integers, returns the number of distinct values in array A.
Assume that:
N is an integer within the range [0..100,000];
@nickovchinnikov
nickovchinnikov / History|-14a6bd0a|entries.json
Last active November 3, 2022 13:23
Visual Studio Code Settings Sync Gist
{"version":1,"resource":"file:///media/Data/Projects/pytorch-tutorial/udemy/analys.py","entries":[{"id":"Owdk.py","timestamp":1665577929873},{"id":"NKvF.py","timestamp":1665577953119},{"id":"jCjq.py","timestamp":1665577976723},{"id":"Dmrq.py","timestamp":1665578052538},{"id":"1zqY.py","timestamp":1665578075067},{"id":"qzA0.py","timestamp":1665578086865},{"id":"cMRX.py","timestamp":1665578117117},{"id":"2VE2.py","timestamp":1665578131814},{"id":"FALi.py","timestamp":1665578164632},{"id":"1xAk.py","timestamp":1665578794209},{"id":"karU.py","timestamp":1665584521411}]}