teleren/devto huggingface dataset:
PHP vs Java: Which is Best for Development?
Tags: webdev, php, java
Published: 2019-11-14 13:49:06

PHP is a standout amongst the most developed, pervasive server-side contents on the web. Java is universally useful, ordered programming language structured in light of one mantra—"compose once, run anyplace." Both power dynamic web applications and locales, with their very own qualities and subtleties.

##PHP or Java: Which is best for web application development?

When you pick a language for your product venture, it very well may be quite hard to switch gears except if you play out a noteworthy update down the line. That is the reason for picking the correct language in advance is basic to building an adaptable, fruitful site that achieves your business objectives.

You've most likely completed a little investigation into the correct language, however, it tends to be hard for somebody without programming advancement mastery to figure out which one is correct. Here's a glance at two of the most prevalent programming dialects, Java and PHP. A software developer can help you best choose the two dependent on your undertaking, however here are a few essentials to enable you to settle on the correct choice.

###What is PHP?

PHP is a broadly useful scripting language that rapidly turned into the accepted server-side language of decision for web developers after its underlying discharge in 1995. It has a bit of leeway in that it was structured and made for the web, versus languages that were adjusted to the web (like Ruby or Python). Today, a dominant part of sites keep running on PHP, and PHP programmers are still in extreme interest on account of its job as the establishment for substance the executives frameworks (CMS) like WordPress, Drupal, and Joomla and various present-day systems like Laravel, Symfony, and CakePHP that have quickened development with this full-grown language.

###What is JAVA?

Java was structured as a broadly useful programming language for structure independent applications. At the point when Java was discharged by Sun in 1991, it was at first being utilized to program customer gadgets like VCRs.

Java is an incorporated language, so when you accumulate code it's gone to halfway twofold for the particular working framework running your product. Its applications are accumulated into bytecode that can keep running on the usage of the Java Virtual Machine (JVM). The JVM helps overcome any issues between source code and the 0s that the PC gets it. Any machine that has the JVM introduced can run Java.

In development, Java is basically a server-side language for the web and the programming language of decision for versatile development on the Android stage. It additionally still has a not too bad nearness toward the front as a Java applet, in spite of the fact that this is dropping out of support because of security concerns.

##Java and PHP Differences: 

###Read the full article here: [PHP vs. Java](https://www.decipherzone.com/blog-detail/PHP-vs--Java--Which-is-Better-for--Software-Development-)
Stepping Through Recursive Fibonacci Function
Tags: beginners, javascript, challenge, todayilearned
Published: 2019-11-14 13:35:23

The Fibonacci Sequence is such that each number is the sum of the previous two numbers.

<b>Fibonacci Sequence:</b> 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 . . .

This is a great use case for recursion.

We will build our Fibonacci algorithm using recursion. We will define a function that takes in a number called <i>position</i> as a parameter.This position will indicate which number from the Fibonacci sequence we want returned to us.

For example:
   fibonacci(4) // returns 3
   fibonacci(9) // returns 34

This algorithm does not require a lot of code, so we will not over complicate it.

Let's define the function ``fibonacci`` that takes in a number ``position`` . 

```javascript
function fibonacci(position){
   
}
```

Next, let's go-ahead to define our base case. So, we can ask ourselves, what is the situation that we immediately know one number is found at the given position in our Fibonacci sequence? There are two situations:
1. Since the first two numbers in the Fibonacci sequence are always 1 and 1, if the position equals 1 it should return 1 or if it equals 2 it should return 1 still 

```javascript
function fibonacci(position){
   if(position < 3) return 1;
}
```

Now we write our recursive code:

```javascript
function fibonacci(position){
   if(position < 3) return 1;
   else return fibonacci(position - 1) + fibonacci(position - 2)
}
```

We know that the number in the position is a result of the sum of the two previous numbers before it ``position -1 `` and ``position - 2``. We return the result of adding our Fibonacci function using these two cases as passed in parameters of each. The function will call itself until the base case is attained then it will stop.

To see a visualization of the breakdown of how each function is called, here's a link to a video that explains it.

https://www.youtube.com/watch?v=zg-ddPbzcKM&t=319s

Now, this algorithm is not conducive because when we want to return the position of a very large number say 1500, the chain of recursion will result in what we call a stack overflow! Different browsers have limits to how large a call stack is supposed to be and if you reach that limit, the function will throw in an error stating that you've to exceed the maximum call stack limit.

This algorithm has an exponential O(2^n) time complexity because the chain of recursion grows exponentially by each call making it a bad way to solve this.

We will look at a much faster algorithm in the next one.

Happy Hacking!
"Angular can waste your time" Youtube video series
Tags: angular, rxjs, webdev
Published: 2019-11-14 13:26:15

---
title: "Angular can waste your time" Youtube video series
published: true
description: I started a video tutorial series “Angular can waste your time” on Youtube. There I will be publishing videos about resolving tricky cases with Angular and RxJS. Take a look!
tags: Angular, rxjs, webdev
cover_image: https://thepracticaldev.s3.amazonaws.com/i/h057gd9yq6x60nhp6x8f.png
---

Hi!

As you may already know Angular can do everything — or almost everything. But sometimes this ‘almost’ makes you waste time looking for workarounds or trying to find out why something happens or doesn’t work as expected. 

I want to save you some time and describe these angular gotchas from my work experience in this video series. [Take a look!](https://www.youtube.com/watch?v=HI5f6naJdJ8&list=PLNadw4d8-KMVSOffiYBuOlzvF38sO9pdu)

{% youtube HI5f6naJdJ8 %}

This video series will possibly become a part of my future video-course with advanced techniques of mastering Angular. Want to get a notification when it is done? [Subcribe!](http://eepurl.com/gHF0av)

[![Subscribe][image]][hyperlink]


[hyperlink]: http://eepurl.com/gHF0av
  [image]: https://thepracticaldev.s3.amazonaws.com/i/e0h1vtsdz40dgzowjcbe.png (tooltip)
Data Binding in Angular
Tags: angular
Published: 2019-11-14 13:11:06

Data Binding is regarded as the most vital feature in Angular as it defines the communication between Angular Component and View.

Some examples of Data binding are: Storing input value in a variable, styling html tags,… etc.

Based on the flow of data, Data Binding can be classified into four types.

The different forms of Data Binding are:

1) Property Binding 
2) Interpolation 
3) Event Binding 
4) Two-way binding 

For the detailed explanation of each type of data binding with examples, check my article on [Data Binding in Angular] (https://www.madhantutorials.com/data-binding-in-angular/).
контекстные менеджеры
Tags: python, contextmanager, cursor
Published: 2019-11-14 12:51:31

---
title: контекстные менеджеры
published: true
description: контекстные менеджеры в питоне
tags: python, contextmanager, cursor
---

https://docs.python.org/3/library/contextlib.html

в случае, когда у вас есть скоуп для применения ресурса, оч классно использовать контекстные менеджеры
объявляется декоратором **@contextmanager**, дальше при помощи **with** используется
вы наверняка встречали, когда работали с файлами: 
**with open('workfile') as f:** позволяет вам провести все операции с файлом — он закроется автоматически при выходе из скоупа

пример кейса — коннекшн к бд, открываем его, в нем открываем курсор (контекстный менеджер в контекстном менеджере), в скоупе делаем что-то и конекшн закроется при выходе автоматом, и дальше его можно переиспользовать

объявление
```python
@contextmanager
def connection(driver, server, database, user, password):
    params = f'DRIVER={{{driver}}};SERVER={server};DATABASE={database};' \
             f'Trusted_Connection=no;UID={user};PWD={password}'
    conn = pyodbc.connect(params)
    yield conn
    conn.close()


@contextmanager
def cursor(driver, server, database, user, password):
    with connection(driver, server, database, user, password) as conn:
        csr = conn.cursor()
        yield csr
        csr.close()
```

пример использования
```python
        with cursor(driver=self.config.driver, server=self.config.address, database=database,
                    user=self.config.user, password=self.config.password) as curs:
            curs.execute(f'truncate table {table_name}')
            curs.commit()
```

или можно использовать конекшн, а не курсор напрямую (пандас работает через конекшн)
```python
        with connection(driver=self.config.driver, server=self.config.address, database=database,
                        user=self.config.user, password=self.config.password) as conn:
            df = pandas.read_sql(script, conn)
```
How to add Admob Ads to Ionic Apps Using React.js ?
Tags: ionic
Published: 2019-11-14 12:42:06

---
title: How to add Admob Ads to Ionic Apps Using React.js ?
published: true
tags: help, ionic
---

Please,

How to add Admob Ads to Ionic/React.js applications ?

I did find [this example](https://ionicframework.com/docs/native/admob-free) on their documentation but it's for Angular.

Thank you!
Some Of The Most Essential Data Science Tools
Tags: discuss
Published: 2019-11-14 12:24:03

As per the Harvard Business Review, Data science jobs are amongst the most sought after and lucrative careers of the 21st century. Apparently, it has become a major and significant part of many businesses like marketing, risk control, agriculture, fraud discovery, retailing analytics, and common policy.

Data scientists use various scientific methods, processes, algorithms, and systems to extract knowledge from structured and unstructured data. Their concept is similar to data mining and big data, where they use the most powerful programming systems and algorithms to solve problems. The tasks performed by data scientists demand them to identify relevant questions, collect data from various different sources, organization of data, the transformation of data and communicating these findings for a better business outcome/ solution.

A data scientist is responsible for manipulating, extracting, pre-processing and generating predictions out of data and he requires a plethora of statistical essential data science tools and programming languages to achieve that goal.
for more details, you can use this ref link:- https://codersera.com/blog/essential-data-science-tools/
[Vim問題] ファイルやディレクトリのパスを挿入する方法とは？
Published: 2019-11-14 12:02:46

この記事では、Vim / neovim でプラグインを使わずに「ファイルやディレクトリのパスを挿入する」方法について、ご紹介します。 [解答] Ctrl-x Ctrl-f または OSコマンド Vimキーバインド （イン

つづきは[こちら](https://vim.blue/vim-insert-file-path/)。
[https://vim.blue/vim-insert-file-path/](https://vim.blue/vim-insert-file-path/)
[Vim問題] OSコマンドの実行結果を挿入する方法とは？
Published: 2019-11-14 12:02:29

この記事では、Vim / neovim でプラグインを使わずに「OSコマンドの実行結果を挿入する」方法について、ご紹介します。 [解答] :read !{OSコマンド} Vimコマンド （ノーマルモードで） :read!

つづきは[こちら](https://vim.blue/vim-read-command-paste/)。
[https://vim.blue/vim-read-command-paste/](https://vim.blue/vim-read-command-paste/)
[Vim問題] 記録した操作を繰り返す「マクロ」の実行方法とは？
Published: 2019-11-14 12:02:13

この記事では、Vim / neovim でプラグインを使わずに、記録したコマンドまたは操作を繰り返す「マクロ（複雑な繰り返し）」について、ご紹介します。 汎用性も高く、とても便利な機能ですから必ず習得しましょう。 ちなみ

つづきは[こちら](https://vim.blue/vim-macro-complex-repeat/)。
[https://vim.blue/vim-macro-complex-repeat/](https://vim.blue/vim-macro-complex-repeat/)
[Vim問題] コマンドラインウインドウを表示する方法は？
Published: 2019-11-14 12:01:56

この記事では、Vim / neovim でプラグインを使わずに「コマンドラインウインドウを表示する」ためのコマンドについて、ご紹介します。 [解答] Vimコマンド q: または : + Ctrl-f （ノーマルモード）

つづきは[こちら](https://vim.blue/command-line-window-display/)。
[https://vim.blue/command-line-window-display/](https://vim.blue/command-line-window-display/)
A week full of JavaScript, IT and Community
Tags: uncategorized, community, diversityintech, javascript
Published: 2020-04-30 18:54:36

---
title: A week full of JavaScript, IT and Community
published: true
date: 2019-11-14 12:01:02 UTC
tags: Uncategorized,Community,Diversity In Tech,JavaScript
canonical_url: https://js-kongress.com/2019/11/14/a-week-full-of-javascript-it-and-community/?utm_source=rss&utm_medium=rss&utm_campaign=a-week-full-of-javascript-it-and-community
---

… taking place in April 2020 in Munich, Germany ![📅](https://s.w.org/images/core/emoji/12.0.0-1/72x72/1f4c5.png)

![](https://cdn-images-1.medium.com/max/1200/1*B3iEuDxzOLcxw6rCtBhNQQ.jpeg)<figcaption>We and our events stand for Diversity — not just in Tech, A balance between professional work, fun, and community, Bias for Action, Thinking one step ahead, A connection to open source and community-driven projects, Party hard with the community</figcaption>

We have been very inspired by the community effort to bring even more JS into the week of JS Kongress. We thought about it for a long time to bring together not only 2 days, not 3, not 4 but a whole week of #JSCommunity in Munich.

So we thought about, what we can do to support the community and these are the very first results:

1. we offer a [**shared coordination sheet**](https://docs.google.com/spreadsheets/d/1bfRd80BCD_FUYuXupyQBrpGc45e3u7ymhmDw0FL-338/edit?usp=sharing), where you can put your proposals and ideas into

2. we will include the [**Meetups and community-driven events**](https://js-kongress.com/meetups/) in a special section of our program and website

3. we will help to **reach out to people** who could be interested

4. we will include your actives in our social media communication

5. if you need any assistance e.g.regarding location scouting, we will try to support you

So let’s make a #JSCommunity week full of JavaScipt in Munich around JSKongress. Our many domestic and international guests and speakers can join these activities and have a greater stay in Munich.

* * *

[Subscribe to our Newsletter](https://js-kongress.us13.list-manage.com/subscribe/post?u=9c3420f6b5269855b07422fb5&id=f490a69da5)to stay up-to-date …

… and follow us to stay in touch:

#jskongress on [Twitter](https://twitter.com/jskongress), [LinkedIn](https://www.linkedin.com/in/js-kongress-munich-9a8070150/), [Instagram](https://www.instagram.com/jskongress/), [YouTube](https://www.youtube.com/jskongress), [Facebook](https://www.facebook.com/JSKongress)

The post [A week full of JavaScript, IT and Community](https://js-kongress.com/2019/11/14/a-week-full-of-javascript-it-and-community/) appeared first on [JS KONGRESS 2020: Scaling JS – Pushing the Limits: Massive Platforms, Data-Driven Architectures, and Modern APIs.](https://js-kongress.com).
A quick tip for dynamic SQL
Tags: sql, database
Published: 2019-11-14 11:37:46

Anyone that's ever worked with dynamic SQL before knows it can get really messy and hard to read and maintain - which is why before actually executing the dynamic SQL, it's best to first just print it just so you could check it visually to make sure everything looks alright before executing it - Here's where this tip comes in handy: Add couple of variables to your script - one for line breaks and one for tabs, and use them when building your dynamic SQL - so when you finally print it, it's going to be nicely formatted and easy to read.  

This code example is in T-SQL, but of course this tip can be used in any rdbms:


```sql

DECLARE @Sql nvarchar(max), 
    @Tab nchar(1) = NCHAR(9),
    @LineBreak nchar(2) = NCHAR(13) + NCHAR(10),
    @ColumnSeperaor nchar(5);
 
SET @ColumnSeperaor = N',' + @LineBreak + @Tab + @Tab;
 
SELECT @Sql = N'SELECT  '+ STRING_AGG(QUOTENAME(@tableName) + N'.'+ QUOTENAME(Column_name), @ColumnSeperaor) + @LineBreak
FROM Information_Schema.Columns
WHERE Table_Name = @TableName
 
SELECT @Sql = @Sql + N'FROM '+ QUOTENAME(@TableName)
 
PRINT @SQL 
```
This will result with a nicely formatted, readable SQL such as:
 
```sql
SELECT [TableName].[Col1], 
       [TableName].[Col2], 
       [TableName].[Col3] 
FROM [TableName]
```

This was also edited into my blog post entitled [The do’s and don’ts of dynamic SQL for SQL Server](https://zoharpeled.wordpress.com/2019/09/12/the-does-and-donts-of-dynamic-sql-for-sql-server-%ef%bb%bf/)
Cheat-sheet for Laws, Principles & the such
Tags: computerscience
Published: 2019-11-14 11:15:10

*This was originally published on my blog, https://unremarkabletester.com/.*

Have you ever been in a conversation where somebody ends an argument with something like "But as we all know this will never work because of Conway's Law"? And even worse, have you found yourself thoughtfully nodding even though you are not 100% sure what Conway's Law exactly says?

I for one admit to have been in such a situation so I thought of noting down some of the laws, principles, theories or what have you, I often hear referenced in software development discussions. I included only the definitions and leave it up to the readers to look deeper into each one of them.

[Conway's Law](https://en.wikipedia.org/wiki/Conway%27s_law)
> Organizations which design systems... are constrained to produce designs which are copies of the communication structures of these organizations.

[Occam's Razor Principle](https://en.wikipedia.org/wiki/Occam%27s_razor)
> Entities should not be multiplied without necessity.

Often paraphrased as:

> The simplest solution is most likely the right one.

[Halting Problem](https://en.wikipedia.org/wiki/Halting_problem)
> The problem of determining, from a description of an arbitrary computer program and an input, whether the program will finish running, or continue to run forever.

[Brook's Law](https://en.wikipedia.org/wiki/Brooks%27s_law)
> Adding human resources to a late software project makes it later.

[Theory of Constraints](https://www.leanproduction.com/theory-of-constraints.html)
> A methodology for identifying the most important limiting factor (i.e. constraint) that stands in the way of achieving a goal and then systematically improving that constraint until it is no longer the limiting factor. In manufacturing, the constraint is often referred to as a bottleneck.

[Pareto Principle](https://en.wikipedia.org/wiki/Pareto_principle)
> For many events, roughly 80% of the effects come from 20% of the causes.

[Conjunction Fallacy aka Linda Problem](https://en.wikipedia.org/wiki/Conjunction_fallacy)
> Assuming that specific conditions are more probable than a single general one.

This list is far from being complete, so any suggestions to enrich it are more than welcome.

Just quoting some of this wisdom won't get us very far. But maybe by taking another look to the truths we use, we can apply them better in the future.

*Cover photo by Negative Space*
Bypassing GitHub's OAuth flow
Tags: security, oauth, infosec, api
Published: 2019-11-14 11:10:42

---
title: "Bypassing GitHub's OAuth flow"
cover_image: "https://thepracticaldev.s3.amazonaws.com/i/63uckwrjdlwh8ikfnogb.png"
published: true
description: "Abusing HTTP HEAD request to bypass Github OAuth flow."
tags: "security,oauth,infosec,api"
---

> Cover image credit goes to the Author of the blog, [Tedy Katz](https://blog.teddykatz.com/about/)

In [this article](https://blog.teddykatz.com/2019/11/05/github-oauth-bypass.html) from [Teddy Katz](https://twitter.com/not_aardvark) we can understand how Github OAuth can be bypassed by abusing the HTPP HEAD requests, and how the culprit his in part a feature of the framework being used, that implements a behaviour for making easier the developer life, but that can backfire.


## TLDR

### Same endpoint for the Authorization page and Authorize button

> Interestingly, the endpoint URL for the “Authorize” button is /login/oauth/authorize, which happens to be the same as the URL for the authorization page itself. GitHub figures out which response to send based on the HTTP request method (GET requests return the HTML authorization page, and POST requests grant permissions to the app).
> This behavior switch actually happens within application code. The router forwards both GET and POST requests to the same controller:

### Abusing the HEAD requests to Bypass Github OAuth flow

> What happens if we send an authenticated HEAD request to https://github.com/login/oauth/authorize? We’ve concluded that the router will treat it like a GET request, so it will get sent to the controller. But once it’s there, the controller will realize that it’s not a GET request, and so the request will be handled by the controller as if it was an authenticated POST request. As a result, GitHub will find the OAuth app specified in the request, and grant it access to the authenticated user’s data.

### Why is this even possible?

> Naturally, people writing web apps usually don’t want to take the time to implement behavior for HEAD requests. Getting a product that works is understandably considered more important than compliance with niche parts of the HTTP spec. But in general, it’s nice if HEAD requests can be processed correctly, provided that app developers don’t have to deal with them manually. So Rails (along with some other web frameworks) implements a clever hack: it [tries to route HEAD requests to the same place as it would route GET requests](https://github.com/rails/rails/blob/bc5d9567be44e6241a049c01605ad6cfefe42e10/actionpack/lib/action_dispatch/journey/router.rb#L133-L147). Then it runs the controller code, and just omits the response body.


## Let's Discuss

Do you will start looking into how HTTP HEAD requests are handled by your framework of choice?