Skip to content

Instantly share code, notes, and snippets.

Damir Arh damirarh

View GitHub Profile
damirarh / UpdateAWStats.ps1
Created Oct 4, 2015
Script for downloading IIS logs from Azure and updating AWStats
View UpdateAWStats.ps1
# FTP details
$ftpServer = ''
$ftpUsername = ''
$ftpPassword = ''
# local paths
$perlPath = 'C:\Perl\bin\perl.exe'
$awstatsPath = 'C:\WWW\Internal\awstats-7.3\wwwroot\cgi-bin\'
$downloadDir = 'C:\WWW\_Logs\Azure'
damirarh / SetWinStoreSetting.ps1
Created Jan 17, 2015
Function for changing a windows Store app setting directly in its file
View SetWinStoreSetting.ps1
function Set-WinStoreSetting {
param (
[Parameter(Mandatory=$true, Position=0)][string]$PackageName,
[Parameter(Mandatory=$true, Position=1)][string]$SettingName,
[Parameter(Mandatory=$true, Position=2)][string]$SettingValue
$settingsFile = [IO.Path]::Combine($env:LOCALAPPDATA, 'Packages', $PackageName, 'Settings\settings.dat')
# temporary paths
View DownloadStringAsync.cs
private Task<string> DownloadStringAsync(Uri uri)
var taskSource = new TaskCompletionSource<string>();
var webClient = new WebClient();
webClient.DownloadStringCompleted += (sender, args) =>
if (args.Error != null)
View ReadAsync.cs
private async Task<byte[]> ReadAsync(string filename)
var fileInfo = new FileInfo(filename);
using (var stream = new FileStream(filename, FileMode.Open))
var buffer = new byte[fileInfo.Length];
await Task<int>.Factory.FromAsync(stream.BeginRead, stream.EndRead, buffer, 0, buffer.Length, null);
return buffer;
View EnumToImageConverter.cs
public class EnumToImageConverter : IValueConverter
public string SubFolder { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
if (value is Enum && targetType == typeof(ImageSource))
var enumType = value.GetType();
var format = String.IsNullOrEmpty(SubFolder) ? "/Assets/{0}/{2}.png" : "/Assets/{0}/{1}/{2}.png";
View Tile.xaml
<Grid Width="60" Height="60"
Background="{StaticResource PhoneAccentBrush}">
<Image Source="{Binding LogType, Converter={StaticResource EnumToImageConverter}}" />
View NameScopeBinding.xaml
<b:NameScopeBinding x:Key="ListView" Source="{Binding ElementName=ListView}" />
<ListView x:Name="ListView"
ItemsSource="{Binding Items}">
<i:EventTrigger EventName="ItemClick">
View InvokeCommandAction.xaml
<ListView IsItemClickEnabled="True"
ItemsSource="{Binding Items}">
<i:EventTrigger EventName="ItemClick">
<i:InvokeCommandAction Command="{Binding ItemClickedCommand}" />
View Behavior.xaml
<ListView IsItemClickEnabled="True"
ItemsSource="{Binding Items}">
<local:ItemClickedBehavior ItemClickedCommand="{Binding ItemClickedCommand}" />
View AttachedProperties.cs
public static class AttachedProperties
public static DependencyProperty ItemClickCommandProperty =
new PropertyMetadata(null, OnItemClickCommandChanged));
public static void SetItemClickCommand(DependencyObject target, ICommand value)
You can’t perform that action at this time.