Skip to content

Instantly share code, notes, and snippets.

View shadeglare's full-sized avatar
👨‍💻
Pressing keys

Max Koverdyaev shadeglare

👨‍💻
Pressing keys
View GitHub Profile
var storage = {
"passenger": {
"properties": {
"firstName": "",
"lastName": "",
"email": {},
"birthDate": {
"day": 0,
"month": 0,
<?xml version="1.0" encoding="UTF-8" ?>
<passenger>
<properties>
<firstName></firstName>
<lastName></lastName>
<email />
<birthDate>
<day>0</day>
<month>0</month>
<year>0</year>
{
"passenger": {
"properties": {
"firstName": "",
"lastName": "",
"email": {},
"birthDate": {
"day": 0,
"month": 0,
"year": 0
var parsePattern = function(pattern) {
var placeholders = [];
var substrings = [];
var putSubstring = function(startPosition, endPosition, isPlaceholder) {
var substring = pattern.substring(startPosition, endPosition);
if (substring.length > 0) {
substrings.push(substring);
if (isPlaceholder) {
placeholders.push(substrings.length - 1);
@shadeglare
shadeglare / ObjectMimicry.js
Last active December 27, 2015 01:29
How to mimicry an Object ({ }) to an Array ([]) with index rearranging
var object = {
1: "lorem",
2: "ipsum",
3: "dolor",
4: "sit",
5: "amet"
};
var calculateKeyPosition = function(object, key) {
var props = Object.getOwnPropertyNames(object);
[
{
"firstName": "Ivan",
"lastName": "Ivanov",
"number": 13873214,
"birthData": "10.10.1980"
},
{
"firstName": "Ivan",
"lastName": "Iva^1-.",
@shadeglare
shadeglare / Pool.cs
Created December 2, 2013 12:38
We call it the Pool
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace TravelAgency.Infrastructure.Pooling
{
public sealed class ResourcePool<T> : IDisposable
@shadeglare
shadeglare / train.cs
Created December 3, 2013 11:49
for PHP-man
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TrainSelector
{
class Program
{
using System;
using NUnit.Framework;
using Rhino.Mocks;
using TravelAgency.Infrastructure;
using TravelAgency.Infrastructure.Pooling;
namespace TravelAgency.Tests
{
var Railway = Railway || {};
(function(Railway) {
var Train = function(settings) {
settings = settings || {};
this.mainCoupeSize = settings.mainCoupeSize || 4;
this.leftCoupeSize = settings.leftCoupeSize || 2;
this.coupeCount = settings.coupeCount || 9;