Skip to content

Instantly share code, notes, and snippets.

View Lucasus's full-sized avatar
🔨
Building new apps

Łukasz Wiatrak Lucasus

🔨
Building new apps
View GitHub Profile
@Lucasus
Lucasus / Jenkins plugin dependencies tree fetcher
Last active September 8, 2021 10:18
Fetches names and versions of all dependencies of particular Jenkins Plugin. Useful for automatic plugin installations via DevOps tools like Ansible, when all required plugin dependencies have to be manually installed via Jenkins CLI
// This is app.js file
var request = require("request"),
cheerio = require("cheerio"),
_ = require("lodash");
var foundDependencies = [];
function findDependencies(error, response, body, currentDependency) {
if (error) {
console.log("We’ve encountered an error: " + error);
@Lucasus
Lucasus / gist:609dbf2a5cdc00f6ab3b
Created April 19, 2015 15:08
Helper unit of work methods
private Action Do(Action<UnitOfWork> work)
{
return () => _unitOfWorkFactory.Create().Do(work);
}
private Func<T> Do<T>(Func<UnitOfWork, T> work)
{
return () => _unitOfWorkFactory.Create().Do(work);
}
@Lucasus
Lucasus / BindingConfig
Created April 19, 2015 08:05
Custom binder for Validated<T> parameters for Web API 2, used in LucAdm
public static class BindingConfig
{
public static void Register(HttpConfiguration config)
{
config.ParameterBindingRules.Add(FindDescriptor);
}
private static HttpParameterBinding FindDescriptor(HttpParameterDescriptor descriptor)
{
if (descriptor.ParameterType.IsGenericType &&
@Lucasus
Lucasus / WinDatePicker.ts
Last active December 27, 2015 18:09
AngularJS directive for WinJS DatePicker control.
//Usage example: <div id="txtStartDate" data-win-datepicker="" data-ng-model="task.startDate">
module dt
{
"use strict";
export function WinDatePicker($parse): ng.IDirective
{
return {
restrict: 'A',
link(scope, element, attrs)
{
@Lucasus
Lucasus / LucValidationExample1.cs
Last active December 13, 2015 21:48
This example shows how to decorate method with LucValidation validation attributes and rules.
[ValidateArguments]
public virtual void RegisterUser([Required, UserName]string userName, [Required, Email]string email, [Required, Password]string password, [Required, Password]string rePassword)
{
if (CheckAllRules(new PasswordsAreSame() { Password = password, RePassword = rePassword},
new UserNameUnique() { UserName = userName },
new EmailUnique() { Email = email }))
{
User newUser = new User()
{
UserName = userName,