Best practices for C project git submodule building - c

I have a C project using autotools and make to build my project. I need to use code that as far as I can tell is only available on github. What is the best practice for including this code in my project? How would I do it?
This is the code I want to use

The best I can think of is to probably use Git Submodules so that you bundle your dependencies with your repository without having them to be inside your repository. This will provide you with 2 advantages, your library dependency will always be (latest), your git repository won't be bloated of all the unnecessary data and objects that the library would have brought. Make sure to build with the lib and to query the user if he does not have it on his system.
C does not have any native dependency manager.
If any tool could do something like you want and for basically anything, you could look into Conda

Related

How to create a reusable component in another applications in reactjs?

I'm studying React, and would like to know how best way to create a private component to reuse it in other projects.
Thanks!
Probably npm private package is what you are looking for. Then, you can just install your package by npm install and use components from it everywhere you want. However, this is paid feature of npm.
The alternative is an npm proxy registry. For example Verdaccio allows something like that. Similiar solution to the previous one, but you have to configure the registry yourself and use it in all your projects instead of default npm registry.
You can also just publish a public npm package if it's ok for you that it'll be available for everyone. It's probably the easiest solution for starters.
Alternatively, what we used in our project, were Git submodules. You place your shared components into a separate Git repository. Then, you link that as a submodule in you main project and you can use your components just like they were a part of your project. If you use Git, it might be the easiest option for you.
And finally, if you treat you projects as playground, you always can use copy-paste approach :) I don't recommend it in any commercial projects as maintaining the code in many places is pain in the neck.

Deploy React components to many personal projects

I hope this is a reasonable forum for this question.
I have a library of React components that I've developed that I'd like to use in multiple personal projects. When I update/improve that library I'd like it to allow me to update in all projects where it is used.
I'm using Meteor as a build tool, which will prompt me when there is an update available for a dependency it's using, so I assume it'd be an NPM module or something. It is checked in to GitHub and I don't mind if it's public.
What would be the best way to achieve this?
I know two ways:
Publish your module on NPM
Link using npm link
For the first one, your module will be public unless you pay NPM for a private module.
The second one, make your module available locally only (It is used for a development purpose, but it fits your needs).
https://docs.npmjs.com/cli/link
If you have your package published on GitHub, you can simply create dependency by linking to tarball/master. If your path is https://github.com/my-nick/my-package, just add to your dependencies in your project's package.json:
"my-package": "https://github.com/my-nick/my-package/tarball/master"
If you have your package well described (package.json file with name, main and version attributes) it should works after meteor npm install.
Of course it works for Meteor 1.3 and higher only, lower versions don't support npm.
I did not use is personally yet, but an frequently mentioned tool for this purpose is https://lernajs.io/, which is e.g. used by create-react-app.

Reactjs flux without npm

I want to write my application using flux architecture, but I want to do this without any external libraries, npm, etc. Is this possible?
Yes, indeed it's possible
You could either:
Write your own flux implementation, it's really quite simple.
OR - if it's the idea of referencing external NPM packages that you don't like, just download the package once only and then copy the code into your source code so that you're not relying on NPM.

Reusing react components across projects

I want to split my web project into three: front-end, back-end and super-admin.
What is the best way to re-use the components across code bases? Npm packages? That seems hard to maintain:
Open component dev package
Make changes
Push changes
Tag version
Update all projects
Seems complex and prone to errors. Is there a better way?
Depends on if you need to use different versions of the shared components from different projects. If so, you probably need to make a versioned npm package. However, if you just want to share the packages and use the same version everywhere, you have other options. For one, you don't have to actually build and publish an npm packge, you can just use npm link. This will basically create a symlink to your shared code in node_modules of the other projects.
Alternatively, you can do it without any npm package at all, just have the shared components in a separate project (directory) and import them in javascript through an alias, using a bundling system (webpack alias / browserify aliasify).

Proprietary C extension for Ruby

I've written some proprietary business logic in C that I want to run from Ruby. I attempted to write it as a gem that was simply included by Bundler from a path internal to the main project; however, Bundler "doesn't build native extensions in that case" (tmoore in the #bundler irc channel).
I would rather not create a separate private repository for this C extension gem. I would also rather not precompile native versions for all the environments. RubyInline does not appear to be an option because the C is more than just a couple functions, makes heavy use of pointers to structs passed between functions, etc.
Are there any options for building C into a project such that the C will be compiled on the target machine via standard bundle installation?
Thanks to tmoore in the #bundler irc channel for pointing me to the following:
http://bundler.io/v1.5/man/gemfile.5.html#PATH-path-
https://github.com/bundler/bundler/issues/1679#issuecomment-11162403
From the former:
Unlike :git, bundler does not compile C extensions for gems specified
as paths.
And from the latter:
I think I'm going to go with "please use git gems if you need to
compile extensions". :path, as an option, is a way to add directories
that you are managing manually to the load path. If you need an
extension built in those directories, you should be doing it yourself
as part of managing that directory manually. :)
So that's the official word. If you want Bundler to compile a proprietary extension, load your extension gem from a private Git repository. (This was helpful: https://gist.github.com/masonforest/4048732.) In order to avoid overly wide privileges, you can:
create a new Github account dedicated to your private repos
grant it read only access to only your private extension repos
create an oauth token for that dedicated Github user: https://help.github.com/articles/creating-an-access-token-for-command-line-use/
incorporate that oauthtoken into your git url in your gemfile:
gem 'your_gem_name', git:
'https://your_oauth_token:x-oauth-basic#github.com/account/project.git'

Resources