Skip to content

Instantly share code, notes, and snippets.

View ikr's full-sized avatar

Ivan Krechetov ikr

View GitHub Profile
@ikr
ikr / my_toolbox.h
Last active June 9, 2024 07:19
Competitive programming snippets
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
@ikr
ikr / SumTypes.java
Last active July 27, 2018 07:49
ADT / sum types in Java demo inspired by Philip Wadler's “Category Theory for the Working Hacker” talk
import java.util.function.Function;
interface Either<A, B> {
public <C> C caseExpr(Function<A, C> f, Function<B, C> g);
}
class Left<A, B> implements Either<A, B> {
private A x;
public Left(A x) {
@ikr
ikr / contexts.js
Last active August 29, 2015 14:24
Nested contexts for tests
describe('RedBlackTree', () => {
beforeEach(() => {
// Set-up code
});
it('does this', () => {
// Asserts
});
it('does that', () => {
@ikr
ikr / .eslintrc.yaml
Last active August 29, 2015 14:22
My ESLint config for React/ES6/JSX code
env:
browser: true
mocha: true
es6: true
plugins:
- react
ecmaFeatures:
modules: true
TITLE: Lead software engineer
COMPANY: XIAG AG is a custom software development company with offices in Winterthur, Switzerland and
Novosibirsk, Russia. We build versatile Web and native applications, sometimes involving special
hardware integration, to meet our customers' needs with the maximum value.
We've successfully shipped dozens of software-centric solutions: touristic portals and agency tools,
booking engines, job platforms, inventory control systems, e-shops and e-commerce platforms – both
closed and public-facing, information gathering and analysis systems. Our code runs on the Web,
mobile devices, desktops, and interactive kiosks.
@ikr
ikr / StringReader.js
Created December 12, 2013 13:29
Read stream out of a string. Needed for node.js < 0.10.0
(function () {
'use strict';
var util = require('util'),
Stream = require('stream');
/**
* A StringReader is paused by default. Only when resume() is called will it begin emitting
* events. It will do the following:
*
<?php
$errorsArray = function ($listObj) {
$result = [];
foreach ($listObj as $error) {
$result[] = ['field' => $error->getPropertyPath(), 'message' => $error->getMessage()];
}
return $result;
#!/bin/bash
for locale in de_ch en_us fr_fr it_it es_es nl_nl
do
curl -s "http://127.0.0.1:5984/translations_$locale/_design/main/_view/empty_namespace"\
| json rows | json -a value | sed 's/}$/}\n,/' | head -n -1\
| (echo '['; cat -; echo ']') | json -e 'namespace = ["default"]' | (echo '{"docs":'; cat -; echo '}')\
| curl -f -H 'Content-Type: application/json' -d @- -X POST "http://127.0.0.1:5984/translations_$locale/_bulk_docs"
done
@ikr
ikr / jshintrc.json
Created July 5, 2013 14:23
Pure JSON version of my .jsonrc -- https://gist.github.com/ikr/5676468
{
"bitwise" : true,
"curly" : true,
"eqeqeq" : true,
"forin" : true,
"immed" : true,
"latedef" : true,
"newcap" : true,
"noarg" : true,
"noempty" : true,
@ikr
ikr / index.php
Last active December 18, 2015 03:58
Hide a xiag (dev) domain from Google
<?php
$app->get('/robots.txt', function () {
return new Response(
(
(stripos($_SERVER['HTTP_HOST'], 'xiag') !== false) ?
"User-agent: *\nDisallow: /\n" :
"User-agent: *\n"
),