version control – How do I clone a Github repository?

I have successfully created a GitHub repository and uploaded the module I have created. I used the Github application for that, and it was pretty easy to do so.

I want to use the same module and upload it Drupal.org, so people can download and use it.

How do I do it so it is the same repository with the same files? Is there any possibility to configure the github app to use Drupal repositories as well?

I want the files to be synced, so deployment of the updates happens in the same time on both repositories.

Uploading something to a repository – is this normally a .api service function?

Is the act of uploading to a repository like git controlled by an API service like api.github.upload which could then be restricted on our firewalls, rather than blocking the entire domain.

version control – Repository naming conventions

My workplace is trying to implement a standard of naming new repositories as the domain name they might eventually have. Like a repository for a gambling company being called gambleexample.com. What are people’s thought on this?

To me this doesn’t feel like a good idea for a couple of reasons:

  • If the live domain ends up being different to the name of the repository then this will be a point of confusion
  • I suppose you can rename the repository but that may required some reconfiguring of deployment solutions and git configs to match the new urls of the repo.
  • For new developers to the project it might be difficult to work out which repo to use if there are multiple with similar names, although I suppose this extends to any project regardless of the naming conventions.

Are there any standard conventions that people use for this purpose. For web projects that have separate repos for front-end and back-end is clent-side and server-side acceptable names?

python – How can I git clone a repository, change directory, and install its requirements.txt file using requirements.txt

I have to run the following lines to install a github repo:

git clone https://github.com/speechbrain/speechbrain/
cd /content/speechbrain/
pip install -r requirements.txt
pip install -e .

I want to create a requirements.txt file in my local project that when ran, executes these commands. How can I do this?

I tried searching but couldn’t find anything, any help will be appreciated.

architecture – Some thoughts on the Repository pattern

There is more than one way to skin a cat.

Your question is asking how something is done, but it’s hard to provide an accurate answer when there are many possible different approaches. I’ve decided to pick the most commonly used one to answer with. Keep in mind that this is not the only possible approach.

Imagine we have an “IItemRepo” interface implemented by the Persistence mechanism.

  • Where this object will be instantiated?

Services (i.e. objects that aren’t DTOs) are generally instantiated by the DI container. You don’t actually have to do anything here, other than register the concrete type to the interface:

services.AddScoped<IItemRepository, MyItemRepository>();

In short, what this config line does is the same as telling the DI container:

Hey, whenever you are creating an object, and its constructor asks for an IItemRepository parameter, I want you to pass it an instance of MyItemRepository.

You effectively do this registration for each and every service in your codebase. Then, when you want to instantiate your top level service (e.g. web controller), the DI container is capable of providing each related service, all the way down to the bottom of the call stack, with all of the dependency that they need injection.

  • Who will have knowledge of this object?

Of the object, not type? That depends on how you configure your DI container. In the example above, the method name specifies the approach.

  • AddTransient means that all injected IItemRepository dependencies will always get a freshly generated MyItemRepository instance, it is never reused.
  • AddSingleton means that all injected IItemRepository dependencies will refer back to the same singular MyItemRepository instance.
  • AddScoped behaves just like AddSingleton, but on a smaller level. Instead of reusing it across the entire runtime, it reuses it in a smaller scope. For web based applications, that scope is defined as the incoming web request. For a given web request, the same service instance will be reused, but a different web request will get a different service instance. Because of that, AddScoped is the most commonly preferred option.

As to the “who has knowledge” part of the question, it’s essentially anyone who has a dependency on the given type.

  • How the information that it provides will end up be used by the Domain/Application layer? Factories, but how exactly?

This question is unclear. I suspect that you’re thinking of factories in terms of creating the services (in this case the repository instance).

The DI container I’ve been speaking of is a kind of factory. It’s just a really intelligent and customizable one, which is able to generate an instance of any registered type.

  • Will this object be passed around from layer to layer?

Yes and no. Yes, some of the things you observe are correct, but no, your conclusion does not follow.

Yes, it is possible for services from multiple layers to both have a dependency of the same type. Yes, when that dependency is not configured to be transient, that means that both of these services from multiple layers will receive the same instance of that dependency.
On a larger scope, yes, the DI container and its configuration must contain a whole lot of information on all of your layers, aggregated together. That is the top-level application’s responsibility (e.g. your Web project).

No, this does not count as “passing around data”. Object initialization is different from object usage, when dealing with dependency injection.
In any application, to some degree all of its classes are connected into a single web of dependency/references. If there were two completely separated webs in your codebase, you’d have two completely different applications.
When using dependency injection, that “web” is defined using the constructor parameters. Therefore, the constructors no longer conceptually count as the data highway, but rather as application architecture.

Aren’t DTO’s the only objects allowed this kind of behavior?

You’re inverting the logic here. It’s not that DTO’s are the only one allowed to cross the layer boundary. It’s that we call something a DTO when it crosses the layer boundary.

But similar as mentioned above, when using dependency injection, constructors are part of the architecture club in your codebase, which excludes their usage as being considered data-related, but rather architecture-related. And that’s a different ballgame with different rules.

node.js – I’d like to DI for repository interface and service interface like Spring using typedi

I’d like to DI for repository interface and service interface like Spring using typedi.

Below code (example code of DI for repository) is working correctly when calling api.

Repository

import { Service } from "typedi";
import { EntityRepository, Repository } from "typeorm";
import { User } from "../entity/User";

export interface IUserRepository {
  findAllUsers();

  findUserByUserId(id: number);

  addUser(user: any);

  removeUserByUserId(user: any);
}

@Service()
@EntityRepository(User)
export class UserRepository
  extends Repository<User>
  implements IUserRepository {
  findAllUsers() {
    return this.find();
  }

  findUserByUserId(id: number) {
    return this.findOne({ id });
  }

  addUser(user: any) {
    return this.save(user);
  }

  removeUserByUserId(user: any) {
    return this.remove(user);
  }
}

Service

import { Service } from "typedi";
import { InjectRepository } from "typeorm-typedi-extensions";
import { User } from "../entity/User";
import { UserRepository } from "../repository/userRepository";

export interface IUserService {
  all();

  one(id: any);

  save(user: any);

  remove(id: any);
}

@Service()
export class UserService implements IUserService {
  @InjectRepository(User)
  private userRepository: UserRepository;

  async all() {
    return this.userRepository.findAllUsers();
  }

  async one(id: any) {
    let user = await this.userRepository.findUserByUserId(id);
    if (typeof user === "undefined") {
      throw new Error(`userId ${id} is not found.`);
    }
    return user;
  }

  async save(user: any) {
    return this.userRepository.addUser(user);
  }

  async remove(id: any) {
    let userToRemove = await this.userRepository.findUserByUserId(id);
    if (typeof userToRemove === "undefined") {
      throw new Error(`userId ${id} is not found.`);
    }
    return this.userRepository.removeUserByUserId(userToRemove);
  }
}

However, when I’d like to inject repository using interface, it does not work correctly and occur the error message.
The build is succes. The error message is occur when calling api
In addition, error message are different for the first time and the second time later when call api.
like this

Repository


import { Service } from "typedi";
import { InjectRepository } from "typeorm-typedi-extensions";
import { User } from "../entity/User";
import { UserRepository } from "../repository/userRepository";

...

@Service()
export class UserService implements IUserService {
  @InjectRepository(User)
  private userRepository: UserRepository;

  async all() {
    return this.userRepository.findAllUsers();
  }

  ...
}

Error message of first time.

{
  "name": "CustomRepositoryNotFoundError",
  "message": "Custom repository Object was not found. Did you forgot to put @EntityRepository decorator on it?",
  "stack": "CustomRepositoryNotFoundError: Custom repository Object was not found. Did you forgot to put @EntityRepository decorator on it? (The following is omitted)"
}

Error message of second time later.

{
  "name": "TypeError",
  "message": "Cannot read property 'all' of undefined",
  "stack": "TypeError: Cannot read property 'all' of undefined(The following is omitted)"
}

Service does not work well either.

Below code is success code.

Controller

import {
  Get,
  JsonController,
  OnUndefined,
  Param,
  Post,
  Body,
  Delete,
} from "routing-controllers";
import { Inject, Service } from "typedi";
import { UserService } from "../service/userService";

@Service()
@JsonController("/users")
export class UserRestController {
  @Inject()
  private userService: UserService;

  @Get("/")
  getAll() {
    return this.userService.all();
  }

  @Get("/:id")
  @OnUndefined(404)
  getOne(@Param("id") id: number) {
    return this.userService.one(id);
  }

  @Post("/")
  add(@Body() user: any) {
    return this.userService.save(user);
  }

  @Delete("/:id")
  delete(@Param("id") id: number) {
    return this.userService.remove(id);
  }
}

But the below is not work well.
In this case, even the build does not work.

Controller

import {
  Get,
  JsonController,
  OnUndefined,
  Param,
  Post,
  Body,
  Delete,
} from "routing-controllers";
import { Inject, Service } from "typedi";
import { IUserService } from "../service/userService";

@Service()
@JsonController("/users")
export class UserRestController {
  @Inject()
  private userService: IUserService;

  @Get("/")
  getAll() {
    return this.userService.all();
  }

  @Get("/:id")
  @OnUndefined(404)
  getOne(@Param("id") id: number) {
    return this.userService.one(id);
  }

  @Post("/")
  add(@Body() user: any) {
    return this.userService.save(user);
  }

  @Delete("/:id")
  delete(@Param("id") id: number) {
    return this.userService.remove(id);
  }
}

Error Message

CannotInjectValueError: Cannot inject value into "UserRestController.userService". Please make sure you setup reflect-metadata properly and you don't use interfaces without service tokens as injection value.

As described at the beginning, I’d like to DI for repository interface and service interface like Spring using typedi.
TypeDI cannnot using like this?
or my code is wrong?
Please help me.
Thank you.

ubuntu – Cannot install boost-win32.yml as updating apt-get repository fails

ubuntu – Cannot install boost-win32.yml as updating apt-get repository fails – Server Fault

Q: In Android recommended MVVM architecture should repository be using AppDatabase or DAO directly?

hope you’re doing fine.

I’m going straight to the point, I’m trying to implement Android recommended MVVM architecture with repository pattern using Room as local data source, currently I’m at modelling the model and repository.

Following the android developers guide and what i understood from it is that the all the app needed to get or store data it goes through the repository and repository in turn communicates with room database abstract class like so:

But when i looked at some sample code provided by android team it looked something like this:

In their sample code the repository class has a reference to the DAO and it skips AppDatabase completely which confused me which one is correct? if android team sample code is correct then what is the use of the AppDatabase then if it’s not going to act as the local data main access point?

How to restore an old release of a GitHub repository?

Say for example I fork the https://github.com/videolan project.

How can I restore the version 3.0.0 ?

I would like to restore that version, to make some changes and then to make a new release, named 3.0.0.1

Is it possible to do that? If yes, is it possible to do it from the browser (Chrome)?

c# – Proper architecture for a ASP.NET MVC5 application (repository / services / dto)

This is a follow up question on my previous question about better architecture design: Naming for services/workers ect

In my question I got a nice reply which helped me a lot with a better divide of my entities / dto’s. I had some trouble implementing a proper N-tier application and used my entities in the frontend directly. I have now updated my program to be better according the tips of @flater , but I still have some questions.

The main problem I have now is that I’ve put everything into “Repositorys”. A repository, in my eyes, is a class that manages one, or a few tables in the database (or api’s) and spits out “DTO’s”, which contain all the information combined for those datasources.

I also created a “LoadingProfile” class that I pass with each (loading)call to a repository. This profile has a list of attributes that can be specified to be loaded into the dto’s, like: LoadImages, LoadChildren, LoadComplexAttributes ect.

Other repositorys and the user interface can then use these DTO’s to do their thing. The way to access other repositorys can be done through a “Context” class that get’s passed to the constructor of the repository along with the ApplicationDbContext of its datasource. The ApplicationDbContext and Context are stored inside a repository as a readonly private properties, but not in the context.

So a context has a reference to each repository, so other repositorys and the user interface can use them. When they use them they get business dto’s, or have to supply business dto’s or basic types like long/string/DateTime.

Next to DTO’s I also made “ViewModels”, which are predefined models to use on the userinterface. These contain dto’s for the ui to use. I also made a repository for these viewmodels, so the userinterface now looks like this:

ControllersBaseController.cs:

public void Init(long? requestid = null)
{
     context = context ?? ContextFactory.Create(HttpContext);
     request = request ?? context.Requests.GetRequestDTO(requestid);
     ViewBag.request = request; // For usage on layout
}

ControllersShoppingCartController.cs:

public ActionResult AddProduct(int? id)
{
    Init();

    var model = context.ViewModels.ShoppingCart.AddProduct(request, id);
    if (model == null) return HttpNotFound();

    return View(model);
}

BusinessRepositorysBaseRepository.cs:

public class BaseDbRepository : IDisposable
{
    internal BaseDbRepository(Context context, ApplicationDbContext db)
    {
        this.context = context;
        this.db = db;
    }

    internal Context context { get; }
    internal ApplicationDbContext db { get; }

    public void Dispose()
    {
        db.Dispose();
    }
}

BusinessRepositorysControllersShoppingCartRepository:

public class ShoppingCartRepository : BaseDbRepository
{
    internal ShoppingCartRepository(Context context, ApplicationDbContext db) : base(context, db)
    {
    }
    public AddProductModel AddProduct(RequestDTO request, int? id)
    {
        if (id == null) return null;

        var productdto = context.Products.GetProductDTO(id, LoadProfileDTOFactory.None());
        if (productdto == null) return null;

        var shoppingcartdto = request.ShoppingCart;
        if (shoppingcartdto == null) return null;

        Context.ShoppingCarts.AddShoppingCartItem(shoppingcartdto, productdto);

        return new AddProductModel()
        {
            Request = request
        };
    }

...

BusinessRepositorysShoppingCartRepository.cs:

public class ShoppingCartRepository : BaseDbRepository
{
    internal ShoppingCartRepository(Context context, ApplicationDbContext db) : base(context, db)
    {
    }

    internal void AddShoppingCartItem(ShoppingCartDTO shoppingcartdto, ProductDTO productdto)
    {
        var shoppingcartitem = new ShoppingCartItem()
        {
             ShoppingCartId = shoppingcartdto.Id,
             ProductId = productdto.Id
        };
        db.ShoppingCartItems.Add(shoppingcartitem);
        db.SaveChanges();

        shoppingcartdto.AddProduct(productdto);
    }

As you can see the context also has a reference to a ViewModelRepository, which contains a controller repository for each controller. These supply the viewmodels to the userinterface.

Remaining question 1: Where do I fit in “Services”? I mean, everything is a repository now, I can understand I can divide the repositories even further into “methods that get datasource related things” and “methods that do things with dto’s” but that seems a bit absurt. Also in naming of the repositorys inside the context I get a problem that I have to divide “Users” (which is a UsersRepository) in to “UserRepository” and “UserServices”, which feel alot like a anti pattern.

Remaining question 2: Before I mentioned I started using static Factory’s for everytime I use the keyword “new”. I get that this really is a anti pattern, but I really like the way I can backtrace everything now. What I don’t get is where I should put these if they should not be static? I mean, static is bad, but do I really have to make a new “factoryrepository or something” for this?

Remaining question 3: How do I best store the Context? Make it a static property of my basecontroller? Or use the cache for this? Or is there a way inside MVC5 to do this I never learned? Also shouldn’t the ApplicationDbContext be newed up every request? Do I then have to supply this with each public method call? Or should the repository construct it’s own each time a public method is called?

Remaining question 4: I tried to cut the cord between UI and DAL entities, but a lot of MVC stuff relys on this. Whay should I do with these? Move them to business layer too?

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123