Skip to content

Instantly share code, notes, and snippets.

@iburlakov
iburlakov / LimitFormatter.h
Created August 2, 2011 07:39
Simple implementation of NSFormatter class.
#import <Foundation/Foundation.h>
@interface LimitFormatter : NSFormatter {
}
@property int maxLength;
@end
@iburlakov
iburlakov / Foo.cs
Created December 30, 2011 08:12
Determimes a caller of a method
public class Foo
{
public void Do(int bar, string baz)
{
Console.WriteLine(GetCallerMethodName());
}
public void Do(int bar)
{
this.Do(bar, null);
@iburlakov
iburlakov / CFDictionaryGetValueIfPresent_Sample.c
Created September 27, 2012 19:18
Using of CFDictionaryGetValueIfPresent
CFDictionaryRef dict;
/*
Get some dictionary...
*/
SInt32 intVal = 0;
CFNumberRef cfIntVal;
char* strVal;
CFStringRef cfStrVal;
@iburlakov
iburlakov / ArbitraryShapeForm.xaml
Created February 22, 2013 13:53
WPF form of arbitrary shape
<Window x:Class="Test.ArbitraryShapeForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ArbitraryShapeForm"
AllowsTransparency="True"
Background="Transparent"
WindowStyle="None">
<Canvas Width="300" Height="300">
<Path Stroke="Gray" StrokeThickness="2">
@iburlakov
iburlakov / PathEllipsisConverter.cs
Created June 25, 2013 13:20
Ellipsis path by replacing path parts with some ellipsis const, ... in this particular case.
using System;
using System.IO;
using System.Linq;
using System.Windows.Data;
namespace Converters
{
public class PathEllipsisConverter : IValueConverter
{
private const string EllipsisChars = "...";
@iburlakov
iburlakov / MainWindow.xaml
Created July 17, 2013 16:48
How to show custom template for ListView when it has no items to show.
<Window x:Class="TabControlExp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
@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;
@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 / 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 / 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>