Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
CurrentPath=$(pwd)
# a directory where two repositories will get fetched to
SynchLocation="/C/git-synch/"
# bundle file location - typicly on a media that transfers the file (like USB-stick)
BundleLocation="/E/bundlefile.bundle"
# remote location and alias name for repository A
RemoteA="https://github.com/LocationOfRepoA.git"
RepoA="RepoA"
# remote location and alias name for repository B
@andriybuday
andriybuday / ObjectExtensions.cs
Created November 27, 2016 23:07
ObjectExtensions Map method to abstract AutoMapper Map method
public static class ObjectExtensions
{
public static T Map<T>(this object source)
{
return AutoMapper.Mapper.Map<T>(source);
}
}
public class BusinessMappingProfile : Profile
{
public BusinessMappingProfile()
{
CreateMap<Cat, CatDTO>()
.ReverseMap();
CreateMap<Dog, DogDTO>()
.ReverseMap();
}
// AutoMapper will scan the assemblies passed in for Profile instances and add each to the configuration
Mapper.Initialize(config =>
config.AddProfiles(new[]
{
// Marker types for assemblies
// Only one type from assembly
typeof (BusinessMappingProfile),
typeof (ClassFromSomeOtherAssemblyWithMappings)
}));
return cats.Map<List<CatDTO>>();
public class Car {
protected String BrandName;
public void Go() {
System.out.println("I'm " + BrandName + " and I'm on my way...");
}
}
public class MercedesCar extends Car {
public MercedesCar() {
BrandName = "Mercedes";
public class CarDecorator extends Car {
protected Car decoratedCar;
public CarDecorator(Car car) {
decoratedCar = car;
}
@Override
public void Go() {
decoratedCar.Go();
}
}
public class AmbulanceCar extends CarDecorator {
public AmbulanceCar(Car car) {
super(car);
}
@Override
public void Go() {
super.Go();
System.out.println("...beep-beep-beep-...");
}
}
Car doctorsDream = new AmbulanceCar(new MercedesCar());
doctorsDream.Go();
#!/bin/bash
db_set () {
echo "$1,$2" >> database
}
db_get () {
grep "^$1," database | sed -e "s/^$1,//" || tail -n 1
}