Skip to content

Instantly share code, notes, and snippets.

View dkalamari's full-sized avatar

Dino Kalamari dkalamari

  • Međimurje IPC d.d.
  • Čakovec, Croatia
View GitHub Profile
@dkalamari
dkalamari / ByteArrayToString
Created June 16, 2014 08:25
ByteArrayToString
protected static String ByteArrayToString(byte[] inArray)
{
StringBuilder outString = new StringBuilder("");
for (int i = 0; i < inArray.Length; i++)
{
outString.Append(inArray[i].ToString("X2"));
}
return outString.ToString();
}
@dkalamari
dkalamari / SHA1 Encrypt
Created June 16, 2014 08:24
SHA1 Encrypt
protected static String SHA1Encrypt(String phrase)
{
UTF8Encoding encoder = new UTF8Encoding();
SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
byte[] hashedDataBytes = sha1.ComputeHash(encoder.GetBytes(phrase));
return ByteArrayToString(hashedDataBytes);
}
@dkalamari
dkalamari / gist:bc0d8340421cd1c405c5
Created May 2, 2014 11:24
C# Oracle last inserted id
string sqlInsert = "INSERT INTO users (name, surname) VALUES (:name, :surname) RETURNING id_user INTO :LASTID";
OracleParameter lastId = new OracleParameter(":LASTID", OracleDbType.Int32);
lastId.Direction = ParameterDirection.Output;
...
cmdInsert.Parameters.Add(lastId);
@dkalamari
dkalamari / gist:11243535
Created April 24, 2014 06:21
WCF Request logging
...
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
@dkalamari
dkalamari / gist:11167794
Created April 22, 2014 06:52
WPF image opacity in button style
<Style x:Key="btnCustom" TargetType="{x:Type Button}">
<Setter Property="Height" Value="50"/>
<Setter Property="Width" Value="80"/>
<Setter Property="Margin" Value="5,2,0,5"/>
<Style.Resources>
<Style TargetType="Image">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.5" />
</Trigger>
@dkalamari
dkalamari / gist:11030646
Created April 18, 2014 08:02
WPF datagrid row alternate color
<Style TargetType="{x:Type DataGrid}">
<Setter Property="Background" Value="#FFF" />
<Setter Property="AlternationCount" Value="2" />
</Style>
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="#EFEFEF"></Setter>
</Trigger>
@dkalamari
dkalamari / gist:11027379
Created April 18, 2014 06:20
ListBox item selected
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True" >
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="Black" />
</Trigger>
</Style.Triggers>
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
@dkalamari
dkalamari / gist:10975989
Created April 17, 2014 11:32
WPF Event to Command
NuGet installation
PM> Install-Package System.Windows.Interactivity.WPF
Must be installed in Main project also!!!
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding SetUserCommand}"/>
</i:EventTrigger>
@dkalamari
dkalamari / gist:10963821
Created April 17, 2014 08:17
WPF TextBox focus through MVVM
<Style x:Key="NormalTextBox" TargetType="{x:Type TextBox}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsFocused}" Value="True">
<Setter Property="FocusManager.FocusedElement"
Value="{Binding RelativeSource={RelativeSource Self}}" />
</DataTrigger>
</Style.Triggers>
</Style>
@dkalamari
dkalamari / .NET Oracle procedure call
Last active January 3, 2016 20:39
.NET calling Oracle procedure with Date input parameter and String output parameter
Dim conn As New OracleConnection(oradb)
conn.Open()
Dim cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandText = "procedure1"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("p1", OracleDbType.Varchar2).Value = "Test 123"
cmd.Parameters.Add("p2", OracleDbType.Date).Value = System.DateTime.Now