Skip to content

Instantly share code, notes, and snippets.

View cpoDesign's full-sized avatar

Pavel cpoDesign

View GitHub Profile
@cpoDesign
cpoDesign / stopAndUninstallService.nsi
Last active August 12, 2024 08:15
Example of stopping and uninstalling service using nsis
!define APPNAME "App Name"
!define COMPANYNAME "Company Name"
!define DESCRIPTION "A short description goes here"
# These three must be integers
!define VERSIONMAJOR 1
!define VERSIONMINOR 1
!define VERSIONBUILD 1
# These will be displayed by the "Click here for support information" link in "Add/Remove Programs"
# It is possible to use "mailto:" links in here to open the email client
!define HELPURL "http://..." # "Support Information" link
@cpoDesign
cpoDesign / Model.cs
Created March 14, 2016 08:15
Model binding to the partial view
public class ExamResultsFormViewModel
{
public PreliminaryInformationViewModel PreliminaryInformation { get; set; }
public string MemberID { get; set; }
public string MemberName { get; set; }
public int PatientID { get; set; }
@cpoDesign
cpoDesign / example.cs
Last active March 11, 2016 21:03
Get User details from active directory
using (var context = new PrincipalContext(ContextType.Domain, "spacenation"))
{
using (var searcher = new PrincipalSearcher(new UserPrincipal(context)))
{
foreach (var result in searcher.FindAll().Where(x => x.SamAccountName.Contains("UserName")))
{
DirectoryEntry de = result.GetUnderlyingObject() as DirectoryEntry;
Console.WriteLine("First Name: " + de.Properties["givenName"].Value);
Console.WriteLine("Last Name : " + de.Properties["sn"].Value);
Console.WriteLine("User principal name: " + de.Properties["userPrincipalName"].Value);
@cpoDesign
cpoDesign / DemoController_v4.cs
Created February 17, 2016 23:42
Example of implementation of @Html.DropDownListFor
public class DemoController : Controller
{
public ActionResult Index()
{
var model = new DemoModel();
model.Items = new List<SelectListItem>()
{
new SelectListItem()
{
Text = "one",
@cpoDesign
cpoDesign / storedProcWithReturnValue.vb
Created February 3, 2016 10:03
example to read return value from sp and output value in vb
Dim returnValue As String = ""
Try
Using tmsCommand As New SqlCommand("dbo.getUserXml", _tmsConnection)
If _tmsConnection.State = ConnectionState.Closed Then _tmsConnection.Open()
tmsCommand.CommandType = CommandType.StoredProcedure
tmsCommand.Parameters.Add(New SqlParameter("@UserId", SqlDbType.Int, ParameterDirection.Input)).Value = userID
tmsCommand.Parameters.Add(New SqlParameter("@UserXml", SqlDbType.Xml, 1)).Direction = ParameterDirection.Output
Dim returnSpValue = New SqlParameter("@ReturnVal", SqlDbType.Int)
tmsCommand.Parameters.Add(returnSpValue).Direction = ParameterDirection.ReturnValue
tmsCommand.ExecuteNonQuery()
@cpoDesign
cpoDesign / disqus_in_razor
Created February 2, 2016 21:57
Implementation of disqus using razor
<script>
var disqus_config = function () {
this.page.url = @Html.Raw(string.Format("'{0}'", Request.Url.AbsoluteUri));
this.page.identifier = @Html.Raw(string.Format("'{0}'", Model.Id));
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//domain.disqus.com/embed.js';
@cpoDesign
cpoDesign / SpExecutionExample.cs
Last active January 25, 2016 14:02
execution of sp using ef and dbo
using System;
using System.Data;
using System.Data.Entity;
using System.Data.SqlClient;
namespace Examples
{
public class SpExample
{
private readonly DbContext _context;
@cpoDesign
cpoDesign / angular_post_test_and_model_validation.js
Last active January 25, 2016 14:18
Angular example of writing test with post request validation
/// <reference path="/scripts/jquery-1.10.2.js" />
/// <reference path="/scripts/angular/angular.js" />
/// <reference path="/scripts/angular/angular-resource.js" />
/// <reference path="/scripts/angular/angular-filter.js" />
/// <reference path="/scripts/angular/angular-mocks.js" />
/// <reference path="/scripts/services/dataservice.js" />
/// <reference path="/scripts/controllers/example.js" />
/// <reference path="/scripts/app.js" />
@cpoDesign
cpoDesign / helper.cs
Last active November 6, 2015 22:25
Creating self closing html helpers in ASP.NET MVC using Razor
using System;
using System.Web.Mvc;
public class ContainerSection : IDisposable
{
protected HtmlHelper _helper;
public ContainerSection(HtmlHelper helper, string title)
{
_helper = helper;
@cpoDesign
cpoDesign / DelAllJsGeneratedByTs.bat
Created September 25, 2015 14:00
Delete all scripts generated by ts
attrib -r /s "$(ProjectDir)*.js"