Skip to content

Instantly share code, notes, and snippets.

View cpoDesign's full-sized avatar

Pavel cpoDesign

View GitHub Profile
@cpoDesign
cpoDesign / layout.vash
Last active August 29, 2015 14:05
NodeJs allow access to public folder when loading css file from layout page __dirname => root of directory where server.js is running from app.use(express.static(__dirname +'/public'));
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>@model.title</title>
<link href="/css/site.css" rel="stylesheet">
</head>
<body>
@html.block("body")
</body>
@cpoDesign
cpoDesign / TCconfig.txt
Last active August 29, 2015 14:05
PhantomJS and Team cityAdded description how to put test runner together Source for the script: - http://stackoverflow.com/questions/21185246/how-to-run-jasmine-tests-in-teamcity
Runner type: Command line
Step name: your step name
Execute step: your condition
Working directory: MyDemoProject
- (Project with tests directory - I have the jstests.js and jstests.html files there. Optional, set if differs from the checkout directory where the command will be executed)
Run: Execute with parameters
Command executable: C:\phantomjs-1.9.7\phantomjs.exe
- (update to your correct configuration)
@cpoDesign
cpoDesign / BlogController.cs
Created September 3, 2014 13:10
Unit testing RedirectToAction in controller MVC5.
public class BlogController : Controller
{
private IArticleRepository ArticleData { get; set; }
private IUserRepository UserRepository { get; set; }
public BlogController(IArticleRepository articleRepository, IUserRepository userRepository)
{
if(articleRepository == null) throw new ArgumentNullException("articleRepository");
if (userRepository == null) throw new ArgumentNullException("userRepository");
@cpoDesign
cpoDesign / index.html
Created December 5, 2014 17:08
Nice example how to use checkbox and bind data to model
<div ng-controller="Ctrl">
<span ng-repeat="category in categories">
<label class="checkbox" for="{{category.id}}">
<input type="checkbox" ng-model="selection.ids[category.id]" name="group" id="{{category.id}}" />
{{category.name}}
</label>
</span>
<pre ng-bind="selection.ids | json"></pre>
</div>
@cpoDesign
cpoDesign / CpoDesign.Service.Core.Composition.cs
Created December 29, 2014 21:53
MEF CompositionClass - allows user to implement MEF into application using couple lines of code.
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.IO;
namespace CpoDesign.Service.Core
{
/// <summary>
/// MEF Compositon class
/// </summary>
using (var context = new PrincipalContext( ContextType.Domain ))
{
using (var user = UserPrincipal.FindByIdentity( context, IdentityType.SamAccountName, userName ))
{
user.SetPassword( "newpassword" );
// or
user.ChangePassword( "oldPassword", "newpassword" );
}
}
@cpoDesign
cpoDesign / CreateQuote.cshtml
Created January 23, 2015 17:23
Form wizard mvc with partial views with
@{
ViewBag.Title = "CreateQuote";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>CreateQuote</h2>
@cpoDesign
cpoDesign / index.html
Created February 6, 2015 15:40
Currency formatting in input
<input type="text" class="inputNumber" value="123456789" />
<input type="text" class="inputNumber" value="123456789" />
<button>click</button>
@cpoDesign
cpoDesign / pdf.cs
Created February 9, 2015 12:46
Generating pdf
using (var pdfDoc = new Pdf().GetPdfDoc())
{
pdfDoc.Color.String = "255 0 0";
pdfDoc.Rect.String = pdfDoc.MediaBox.String = "A4";
pdfDoc.HtmlOptions.UseScript = false; // set to true if your layout is JavaScript dependent
pdfDoc.Page = pdfDoc.AddPage();
pdfDoc.Color.String = "255 0 0";
int theID;
theID = pdfDoc.AddImageUrl(url);
@cpoDesign
cpoDesign / index.html
Created February 23, 2015 11:02
JS - Example of replacing text with html
<div id="parent"> Text to update
<div>Child1</div>
<div>Child2</div>
<div>Child3</div>
<div>Child4</div>
</div>