Skip to content

Instantly share code, notes, and snippets.

View olegkalyta's full-sized avatar

Oleg Kalyta olegkalyta

View GitHub Profile
@olegkalyta
olegkalyta / gist:5676418
Last active December 17, 2015 21:39
binary search
public static int FindEleme(int[] array, int elem, int start, int end)
{
if (start > end)
return -1;
int middle = start + (end - start) / 2;
if (array[middle] == elem)
return array[middle];
if (array[middle] > elem)
public class TrieNode
{
public char Letter { get; set; }
public TrieNode[] Links;
public bool[] Markers { get; set; }
private static short K = 0;
private static int maxCommonSubsring = 0;
public static string LCS {get; private set;}
@olegkalyta
olegkalyta / Coffe-Script.sublime-build
Last active December 31, 2015 03:59
sublime config for coffe-script
{
"cmd": ["coffee.cmd","-c","-b","$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.coffee",
"variants":
[
{a
"name": "Run",
"cmd": ["coffee.cmd","$file"]
}
var ar = [1, 2, 3, 4, 5];
function filter(el) {
return el % 3 > 0;
}
var filterManager = (
function filterArray(arr, filter) {
if (arr === undefined || arr.length === 0) return 0;
@olegkalyta
olegkalyta / gist:8538113
Created January 21, 2014 11:05
sum(1)(2)
function sum(a) {
return function(b) {
return a + b; // возьмет a из внешнего LexicalEnvironment
};
}
alert( sum(1)(2) );
var page = require('webpage').create();
page.viewportSize = {
width: 320,
height: 480
};
page.onConsoleMessage = function(msg) {
console.log(msg);
};
import React, { Component, PropTypes } from 'react';
import { reduxForm, addArrayValue } from 'redux-form';
import router from 'react-router';
export const fields = ['arr[].name'];
@reduxForm({ form: 'simple', fields }, undefined, { addValue: addArrayValue })
export default class SimpleForm extends Component {
static propTypes = {
addValue: PropTypes.func.isRequired,
fields: PropTypes.object.isRequired,
const reducers = {
form: formReducer.plugin({
simple: (state, action) => {
switch (action.type) {
case 'redux-form/ADD_ARRAY_VALUE':
{
return {arr: state.arr.slice()};
};
case 'redux-form/REMOVE_ARRAY_VALUE':
{
const path = require('path');
const config = {
context: __dirname,
entry: {
app: [
path.join(__dirname, 'index.js'),
],
},
output: {
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;