Skip to content

Instantly share code, notes, and snippets.

@iburlakov
iburlakov / SerilogLambda.cs
Created May 4, 2022 19:50
Use serilog in Lambda
// setup
var services = new ServiceCollection();
services.AddLogging(logging =>
{
logging.AddSerilog(new LoggerConfiguration().ReadFrom.Configuration(Configuration).Enrich.FromLogContext().CreateLogger());
});
var serviceProvider = services.BuildServiceProvider();
// using
var logger = _serviceProvider.GetRequiredService<ILogger<Function>>();
function isPalindrome(str) {
if (!str) return false;
let i = 0;
do {
if (str[i] != str[str.length - 1 - i]) {
return false;
}
i++;
}while(i < str.length - i);
// calculate the number of "ones" on tan integer
function calculate(num) {
let count = 0;
do {
count += num & 1;
num = num >> 1;
} while (num);
return count;
@iburlakov
iburlakov / docker-help.md
Created January 24, 2019 18:12 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@iburlakov
iburlakov / hackerrank-quicksort.cs
Created October 11, 2016 21:25
Quicksort in-place implementation in c#
int partition(int[] arr, int si, int ei)
{
var pivot = arr[ei];
var pivotIndex = si;
for (var i = si; i < ei; i++)
{
// swap if current is lesser than pivot
if (arr[i] < pivot)
{
var t = arr[pivotIndex];
@iburlakov
iburlakov / mass-iconutil.sh
Created April 18, 2016 09:36
Batch convert icns/iconset
#!/bin/bash
DIR=$1
FORMAT=$2
FILES=$DIR/*
for file in $FILES
do
filename="${file##*/}"
name="${filename%.*}"
@iburlakov
iburlakov / TaskLauncher.h
Last active December 11, 2015 07:51
nstask output 2 console
//
// TaskLauncher.h
// sandbox-nstask
//
// Created by Ivan Burlakov on 11/12/15.
// Copyright © 2015 Ivan Burlakov. All rights reserved.
//
#import <Foundation/Foundation.h>
@iburlakov
iburlakov / calc.js
Created November 25, 2015 21:53
Calculate amount of 1 digits in given number
// calculate amount of 1 digits in given number
function calc(num) {
var digits = 0;
do {
if (num & 1) {
digits++;
}
num = num >>> 1
} while (num != 0);
@iburlakov
iburlakov / DomainInfo.m
Created October 9, 2014 11:44
Get domain name from dsconfigad
NSString *
getDomainName() {
// "dsconfigad --show" command returns domain which mac joined to or nothing if mac is not joined to any domain
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/sbin/dsconfigad"];
[task setArguments: [NSArray arrayWithObjects:@"--show", nil]];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
@iburlakov
iburlakov / CalloutBorder.cs
Created December 11, 2013 13:13
A sample of inherit from Decorator class. CalloutBorder wraps content with custom shape border, parameters of pointer are customizable. Sample is also attached.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace iburlakov
{
public class CalloutBorder : Decorator
{
private const double DEFAULT_POINTER_HEIGTH = 20D;
private const double DEFAULT_POINTER_WIDTH = 10D;