How to migrate to different infrastructure using Djuno


by Michal, CRO
https://www.linkedin.com/in/michalbacia/

This post is to show how easy it is to migrate to different infrastructure with Djuno. It’s so easy, that even a business person like myself can do it. In fact, the process of actually doing it won’t take any more time and effort than reading this post. Definitely less than writing this post… ūüėČ

Here are the steps:

  1. Make sure your services are running in Global Mode.
  2. Create new nodes on the new infrastructure of your choice (on or off premise servers, any private or public cloud).
  3. Delete the nodes on the old infrastructure that you don’t want to use anymore.

That’s it! Enjoy the live, on-the-fly, near zero downtime, near zero cost migration with Djuno!


JavaScript VS Python


By Saeed, Full Stack Developer

https://www.linkedin.com/in/saeed-eivazi-563898107/

Choosing the right programming language for your work is a priority before starting to write your first lines of code. You might have encountered two languages that interest you: Python and JavaScript. In some ways, these two languages are comparable, but their use cases, syntax, and approaches to programming differ significantly.

JavaScript

JavaScript has become a revolutionary web technology. The field of JavaScript is massive, so the language has its fair share of well documented some pros and cons.

Since JavaScript is a scripting language, it does not require an individual compilation step.

Browsers have built-in engines that understand and execute JavaScript commands. Therefore, you can include the JavaScript code directly into your HTML document (write commands within the <script> tags). This means no need for additional compilers.

It should be pointed out that browsers are the ones that run the JavaScript code. Developers can even write JavaScript code in such simple programs as Notepad++.

Currently the main use cases include Web Development and Mobile Development (React Native, Ionic).

Python

It is a general-purpose language used on the backend of web applications. Because of its simplicity, flexibility, versatility, and other useful features, Python is growing and becoming one of the most popular programming languages around.

Scripting languages such as JavaScript provide instructions that browsers execute. However, object-oriented languages like Python work with building blocks (objects). They let developers create objects, assign attributes to them, or set them to perform actions.

JavaScript and Python Popularity Comparison

According to the Developer Survey of 2020, JavaScript is still the leading programming language. However, the popularity of Python has risen significantly over the last couple of years, beating such languages as Java, C#, PHP, and C++.

Advantages of JavaScript

1. Speed

Since JavaScript is an ‚Äėinterpreted‚Äô language, it reduces the time required by other programming languages like Java for compilation. JavaScript is also a client-side script, speeding up the execution of the program as it saves the time required to connect to the server.

2. Simplicity

JavaScript is easy to understand and learn. The structure is simple for the users as well as the developers.

3. Popularity

Since all modern browsers support JavaScript, it is seen almost everywhere. All the famous companies use JavaScript as a tool including Google, Amazon, PayPal, etc. This explains why it’s the most popular programming language in the world.

4. Interoperability

JavaScript works perfect with other programming languages and therefore numerous developers prefer it in developing many applications. We can embed it into any webpage or inside the script of another programming language.

5. Server Load

As JavaScript operates on the client-side, data validation is possible on the browser itself rather than sending it off to the server. In case of any discrepancy, the whole website needs not to be reloaded. The browser updates only the selected segment of the page.

6. Rich Interfaces

JavaScript provides various interfaces to developers for creating catchy webpages. Drag and drop components or sliders may give a rich interface to the webpages. This leads to improved user-interactivity on the webpage.

7. Extended Functionality

Third-party add-ons like Greasemonkey (a Mozilla Firefox extension) allow the developers to add snippets of predefined code in their code to save time and money. These add-ons help the developers build JavaScript applications a lot faster and with much more ease than other programming languages.

8. Versatility

JavaScript is now capable of front-end as well as back-end development. Back-end development uses NodeJS while many libraries help in front-end development like AngularJS, ReactJS, etc.

9. Less Overhead

JavaScript improves the performance of websites and web applications by reducing the code length. The codes contain less overhead with the use of various built-in functions for loops, DOM access, etc.

JavaScript for data science?

Data science is a field in which specialists analyse and manipulate raw or structured data. Data scientists usually use several programming languages together (one of them being Python).

While data science is possible with JavaScript as well, specialists do not choose it regularly. Here are the main reasons why Python wins in terms of data analysis:

  • JavaScript does not offer many data science packages and built-in functions compared to Python.
  • With JavaScript, you would take longer to perform data science tasks and solve issues. In this case, Python is a better choice since you can easily find how-to tutorials and other tips for data science.
  • Overall, doing data science in JavaScript is technically possible, but people who want to perform actions quickly will probably go with using Python or R languages.

JavaScript also has some perks when it comes to data science:

  • It offers visualization with its D3.js, Plotly.js, and other libraries. By using them, it is easier to create impressive data visualization and dashboards.
  • The release of the Tensorflow.js library provided opportunities for people to perform machine learning with JavaScript. It is an open-source project that lets you define, test, and run machine learning models on the browser.

JavaScript might slowly become a rival of Python in terms of data science. However, currently Python still guarantees a more efficient, structured, and guided performance.

Conclusion

  • You might still ask: should I learn Python or Javascript? If web development is your drive, the better choice is to consider the holy trio of HTML, CSS, and JavaScript.
  • People interested in machine learning, data science, and neural networks should consider learning Python.
  • Additionally, the end of Python vs. JavaScript debate relates to your experiences and preferences. For instance, beginners might choose Python because of its simplistic syntax.
  • While technically Python is usable as a frontend language, transpilers that convert Python code to JavaScript make applications slower. Therefore, it is better to use Python for backend development and stick to JavaScript for frontend.


Kanboard: Add Fields to Subtasks


by Behnam, Head Developer

https://www.linkedin.com/in/behnam-safari-65593440/

Kanboard (https://kanboard.org/) РI love it! It’s a free, Open Source, professional and easy to use project management software with a clean and readable code. Thank You Dear Contributors! I use it both for managing my own projects and as a code base for creating new solutions. 

Today I planned to add some extra fields to subtasks of the Kanboard service that is used for the VCfund.me project we‚Äôre currently working on. We‚Äôre using the Kanboard APIs to populate data in boards, tasks and subtasks.  

So, we have two steps: 

– Add fields to DB and make Kanboard to view this fields 

– Change the `createSubtask` method of API to fill this new column 

Adding field into DB: 

===================== 

Kanboard can use several types of relational DBs. We are using SQLite because it’s easy and lightweight. So, follow these steps to add a field to `subtasks` table: 

– Login to Kanboard as admin 

– Go to setting: http://<YOUR_KANBOARD_ROOT>/?controller=ConfigController&action=index 

– Click `Download the database` and save it 

– Extract downloaded file 

– Open the SQLite with a DB client (I use DBeaver) 

– Run `ALTER TABLE subtasks ADD my_new_field TEXT(2000);` 

– Now compress the SQLite file to a .gz file (Ex: gzip db.sqlite) 

– Upload the compressed DB by clicking `Upload the database` in http://<YOUR_KANBOARD_ROOT>/?controller=ConfigController&action=index 

Now the field is added to the subtask table. If you have any other RDBMS you can connect to it and alter the `subtasks` table to add you new field. 

If you want to change the default schema of DB you should change this file: `app/Schema/Sqlite.php` . But we just wanted to add fields to the existing Kanboard. 

View the new field in Subtasks: 

=============================== 

Subtask view PHP file is in `app/Template/subtask/table.php`. add a new `<th>` in `<thead><tr>` and a new `<td>` in `<tbody>` like this: 

“` 

<td> 

      <?= $subtask['image'] ?>

</td> 

“` 

Now save the file and check the web page: http://<YOUR_KANBOARD_ROOT>/?controller=TaskViewController&action=show&task_id=<TASK_ID>&project_id=<PROJECT_ID> 

Change `createSubtask` and `updateSubtask` methods of the API 

============================================================== 

Open `app/Api/Procedure/SubtaskProcedure.php`, find `createSubtask` method, add a new argument to the method `$values` array like this: 

“` 

public function createSubtask($task_id, $title, $user_id = 0, $time_estimated = 0, $time_spent = 0, $status = 0,$my_new_field= null) 
    { 
        TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'createSubtask', $task_id); 
        $values = array( 
            'title' => $title, 
            'task_id' => $task_id, 
            'user_id' => $user_id, 
            'time_estimated' => $time_estimated, 
            'time_spent' => $time_spent, 
            'my_new_field' => $my_new_field, 
            'status' => $status, 
        ); 
        list($valid, ) = $this->subtaskValidator->validateCreation($values); 
        return $valid ? $this->subtaskModel->create($values) : false; 
    } 

“` 

do this for `updateSubtask` method too. 

now you can add a subtask via API with an additional field: 

“`

{ 
    "jsonrpc": "2.0", 
    "method": "createSubtask", 
    "id": 191749979, 
    "params": { 
        "id": 1, 
        "task_id": 1, 
    "my_new_field": "Test Field" 
    } 
} 

“` 

(change ‘my_new_field’ to your preferred field name)  

Easy,¬†isn’t it?¬†


Dockerize R, expose as API


by Moe, CEO
https://github.com/mohamadDev
https://www.linkedin.com/in/mohammadsayadi/

A few month ago, there was a requirement to use some R lang code in production. Porting it to other languages (c#) was not only time consuming but not reliable to be used in production, because we were worried new code may generate different result. Here is my solution, hope it helps you as it did help me.

#plumberapi #rlanguage #dockerfile

dockerize_R_expose_as_api

imagine you have an peice of code developed by your data scientist/ Mathematician/Statistician or whoever else that is happy to work with R, now your devs are required to plug in that peice of code to your project. i do not need to imagine it cuz it happened for me and this is how i solved it

step 0

lets start from creating a folder for this project

$ mkdir exposemyRcodeasAPI
$ cd  exposemyRcodeasAPI/

create a text file name it plumber.r

$ touch plumber.r 

then open plumber file with your text editor

$ nano plumber.r 

step 1

add following to head of your file

library(fitdistrplus)
library(scales)
library(actuar)
library(plumber)

step 2

source the R code (lets call it func.R)

source("funcs.R")

step 3

at run time your plumber file will generate swagger docs by adding following line you will set your apititle (append following text to plumber.R file after sourcing the R code)

#* @apiTitle yourapinamehere

step 4

wrapp whichever function that you want to expose in a function with following declaration

#* Echo back the input
#* @param msg The message to echo
#* @get /echo
function(msg = "") {
    somefuncInFuncdotRFile(msg)
}

if you want to have post method use (#* @post instead of get) to read more click [https://www.rplumber.io/][HERE]

step 5

now everything should be fine, you can dockerise your code and ship it anywhere you want

$ touch Dockerfile

append following lines

FROM trestletech/plumber

#to install packages uncoment following line
#RUN R -e "install.packages('whatever it is used in the code')"


#for apt-get uncomment & modify following line 
#RUN apt-get update -qq && apt-get install whatever is needed 

#expose a port 
EXPOSE 8000

#make a folder and copy your files 
RUN mkdir /app
COPY funcs.R /app
COPY plumber.R /app
WORKDIR /app

#set entrypoint
ENTRYPOINT ["R", "-e", "pr <- plumber::plumb('plumber.R'); pr$run(host='0.0.0.0', port=8000,swagger=TRUE)"]

build your docker and forward port 8000 from your container to any port you want on host