teleren/devto huggingface dataset:
How to store radio button value in database PHP?
Tags: php, programming, webdev
Published: 2020-11-28 08:54:14

#Solution:

##Step 1: Create Database

**Code**
```
<?php  
$con = mysql_connect("localhost","root","");  
if (!$con)  
  {  
  die('Could not connect: ' . mysql_error());  
  }   
if (mysql_query("CREATE DATABASE ABC",$con))  
  {  
  echo "Your Database created !!";  
  }  
else  
  {  
  echo "Error creating database: " . mysql_error();  
  }  
mysql_close($con);  
?>  
```
##Step 2: Create Table
**Code**
```
<?php  
$con = mysql_connect ("localhost","root","");  
if (!$con)  
  {  
  die ('Could not connect: ' . mysql_error());  
  }  
mysql_select_db ("ABC", $con);  
$sql = "CREATE TABLE employee  
(  
name VARCHAR( 50 ) ,  
sex VARCHAR( 50 ) ,  
)";  
mysql_query($sql,$con);  
echo "Your Table Created !!";  
mysql_close($con);  
?>  
```
[Read more](https://www.kodlogs.com/blog/377/how-to-store-radio-button-value-in-database-php)
Can a subclass access private members of a superclass?
Tags: java, oop, programming
Published: 2020-11-28 08:51:18

When you state the inst var of a class private, you cannot reach them in additional class if you attempt to do so a compile time blunder will be created.

Nonetheless, if you accede to a class that has private var, as well as all other participants of the class the private var are also inherited and accessible for the subclass.

However, you cannot reach them openly, if you do so a compile time error will be produced.

#Example
```
class Person1{
   private String name1;
   public Person(String name1){
      this.name1 = name1;
   }
   public void displayPerson() {
      System.out.println("Person class data: ");
      System.out.println("Name of the person: "+this.name1);
   }
}
public class Student1 extends Person1 {
   public Student(String name1){
      super(name1);
   }
   public void displayStudentRecord() {
      System.out.println("Student class data: ");
      System.out.println("Name: "+super.name1);
   }
   public static void main(String[] args) {
      Student std = new Student1("Trump");
   }
}
```
##Compile-time error
`
Student1.java:17: error: name1 has private access in Person
   System.out.println("Name: "+super.name1);
                                    ^
1 error
`
To reach the private instances of the superclass you necessitly  use setter and getter functions and invoke them using the subclass obj.

###Example
[Read more](https://www.kodlogs.com/blog/2324/can-a-subclass-access-private-members-of-a-superclass)
Difference between session and cookies in PHP
Tags: programming, php, webdev
Published: 2020-11-28 08:48:30

In Php Sessions and Cookies are used to store information either on the client-side or on both client and server-side. one of the major differences between sessions and cookies in Php is that cookies store information on client machines while session can store information on both client as well as a server machine. 

#How Session is defined? 

The session can maintain users' records on both server and client-side, usually, they store information on the server-side where session variables store that information. sessions are used to store sensitive information and to keep them secure. for example, user information is stored during online shopping, shopping carts for online sites. Session expires automatically when you closed your browser or after a time span of 30 minutes.

##What are Cookies? 
[Read more](https://www.kodlogs.com/blog/2342/difference-between-session-and-cookies-in-php)
Cookies are used to store information on the user's machine,
Python print on same line without space
Tags: python, programming
Published: 2020-11-28 08:47:26

This Python tutorial is on how to print string and int in the same line in Python. This is a very common scenario when you need to print string and int value in the same line in Python.

#How to print string and int in the same line in python?

Printing string and integer value in the same line mean that you are trying to concatenate int value with strings.

##Some examples:
`
Hey the value of variable a is 452
You just entered 845
`
Here we will see how to concatenate string and int in Python.

In general, if you run this below Python code:
`
a = 5
print ("the value of a is" + a)
` 
You will get an error like this:
**TypeError: can only concatenate str (not “int”) to str**

##Do you know why you are getting an error like this?
Because you are trying to concatenate an integer value with a string using + operator. In Python, the + operator can only concertante strings as Python is a strongly typed programming language.

In order to solve this problem and to achieve our goal to concatenate strings with int we can use these below methods:
[Read more](https://www.kodlogs.com/blog/2357/python-print-on-same-line-without-space)
Flappy Bird Game in pure CSS3
Tags: css3game, cssgame, csss, 100daysofcode
Published: 2020-11-28 08:45:23

Trying to recreate Flappy Bird game in pure CSS3, Built on CSS modelling logic without the involvement of javascript. This Flappy Bird will not fly on mobile because it's all about mouse hover event and mobile doesn't have one 😉
Demo: https://codepen.io/vineethtrv/full/MWjYYNd
Source Code: https://codepen.io/vineethtrv/pen/MWjYYNd
React Proxy-State dengan Valtio
Tags: react, valtio, proxy
Published: 2020-11-28 07:16:07

Dari pengalaman saya mengajar fullstack web development, banyak sekali murid yang bilang bahwa mereka lebih enjoy menggunakan Vue daripada React. Dan salah satu penyebabnya adalah karena manipulasi state di React tidak senyaman di Vue (Ini menurut beberapa orang yang pernah saya tanya).

Berangkat dari hal itu, sekitar 3 bulan yang lalu saya menulis artikel tentang bagaimana menggunakan library Vue reactivity di React

{% link https://dev.to/armedi/menggunakan-vue-reactivity-pada-komponen-react-2j08 %}

Ide dasarnya adalah tentang bagaimana menggunakan state yang mutable pada React. Dan waktu itu saya menggunakan library [@vue/reactivity](https://www.npmjs.com/package/@vue/reactivity).

`@vue/reactivity` ini pada dasarnya menggunakan [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) untuk _change detection_. Yaitu proses bagaimana perubahan state dideteksi dan kemudian men-_trigger update_ pada UI menyesuaikan dengan state terbaru.

Dan jujur saja ketika library ini saya pakai di React, code yang dibuat tidak menjadi lebih sederhana dan lebih mudah dipahami dibandingkan menggunakan bawaan dari React seperti `useState` hook. Tapi idenya sendiri (_mutable state_ di React) saya yakin sangat sangat legit.

Nah di artikel ini saya akan bahas sebuah library baru yang lagi ngehits.

{% github pmndrs/valtio no-readme %}

Pada waktu tulisan ini dibuat, `valtio` baru berumur sepuluh hari semenjak versi 0.1 dirilis namun telah memperoleh sebanyak **1,2k stars** di github. Suatu pertanda baik bahwa library ini punya masa depan yang sangat cerah, hehe.

Di bawah ini adalah contoh resmi dari githubnya valtio. Di sini kamu liat betapa simpelnya cara penggunaannya

{% codesandbox valtio-simple-counter-qqljs %}

Benar gampang kan?

```javascript
import { proxy, useProxy } from 'valtio';

const state = proxy({ number: 0 });

function Figure() {
  const snapshot = useProxy(state);

  return <div className="figure">{snapshot.number}</div>;
}
```

State valtio bebas kamu mau mutate dimana saja, dan bahkan sudah support Suspense.

Langsung aja kamu bisa cek githubnya di [https://github.com/pmndrs/valtio](https://github.com/pmndrs/valtio) untuk melihat fitur-fitur keren apa aja yang tersedia.

Semoga berguna!!!
👨‍💻 Basics of Views and Routing in Django ( Part 8 ) - Django For Beginners
Tags: python, django, webdev, beginners
Published: 2020-11-28 08:43:43


This is part of the series [Django For Beginners](https://bit.ly/django-for-beginners) we are going to see about apps in app and we will see about models in django in this part.

You can this read complete post [here](https://www.ketaniralepatil.com/python/django/urls-and-views-in-django/).

In this post we are going to understand the idea of views and routing from scratch and see some types of responses and then we will learn about basic routing and to separate `urls.py` in separate files files.

## what are views ?

Views are like middle man between request and response on your server they contain all you logic for a route, we will talk about route later in this post. They essentially process get the data needed for the request and process it and the return it as a response. This response can be of a variety of types, `text`, `html` , `json` , `xml` to name a few. 

Now let's see a example of a view,

```python
from django.http import HttpResponse

def home_response(request):
    return HttpResponse("Hello World 😊.")
```

I tried to make is as basic as possible. What is happening above is when we receive a request and we call this `view function` it will return an simple text response, that is `Hello World 😊.` .

You may have noticed about `request` argument in the `home_response` view above it is compulsory argument it is a `dictionary` object and contains lot, by lot, I mean really a lot of information about the request of which most of the times you are not going to use directly.  With `request` object we can access headers, user agent, ip, cookies to name a few.

In above example we returned `text` response but it is not what happens in real world, right 🤔 ? In real world scenarios we need to either prove a html response or a `json` or `xml`  as a response.  So let us see how to pass `html` as response for now.

```python
from django.http import HttpResponse

def home_response(request):
    return HttpResponse("<h1>Hello World 😊.</h1>")
```



### Returning HTML Pages in Response

I am lazy so I copied above code and just added `<h1></h1>` tags around our plane text response and wallah, it is now a `html` response but don't you think it would be bad for long  html responses with which we have to deal most of the times, so for that we keep `html` away from `views` all together so to keep code clean and follow the `DRY` principle .  

Sorry to interrupt you but I want to tell you one thing that I have started a small blog you may continue reading it [here](https://www.ketaniralepatil.com/python/django/urls-and-views-in-django/) it will help me a lot.
Too much deprecated information online!
Tags: datascience, discuss, programming, productivity
Published: 2020-11-28 08:37:14

As we go along with the years, information and even old articles have remained, perhaps giving deprecated information, this seems to me a risk, you are not always careful about the date of what you read, but it can also be that it is valid, and can be confusing.
What do you think about it? Or do you know any site that publishes articles (in the field of software development / data science), which has the courage to delete its own old articles because it considers deprecated or modifying them properly?
An example can be courses about windows form
IT Staff Augmentation: Location Doesn’t Matter
Tags: remote, discuss, startup
Published: 2020-11-28 08:29:28

This blog was originally published on [Bacancy Technology] (https://www.bacancytechnology.com/blog/why-location-does-not-matter-in-it-staff-augmentation-services)

I was surfing on the internet, and I come across research conducted by Korn Ferry – a global management consulting firm predicting the challenges and more difficult times for technology companies. The study was conducted back in 2018 for the specific US region; it stated that telecommunications, media, and technology to be shorted with 1.1 Million skilled resources, and the gap will have a significant rise to 4.3 million by 2030. 

Due to COVID 19 Pandemic, who would have thought that outsourcing software development and IT team augmentation will have a significant rise all of a sudden? If you are to weighing options, whether to hire a dedicated offshore development team or should go for onshore? 

Then to help you answer your questions, I am writing this blog post exploring some significant considerations that will help you make viable decision-taking realist business goals.
#Onshore vs. Offshore Software Development:
Restricting your software development outsourcing to your region might require you to spend a considerable budget, mostly when it belongs to the US or European region. That’s the reason the offshore model is highly preferable then onshore. My personal preference if offshore software development and the reasons are apparently visible. The offshore engagement model is not only a cost-effective approach, but it also saves your valuable time as well as money. Upscale, upskill, and flexibility of the developers and development are added advantages of the offshore software model. 

What I mean by flexibility is you can hire dedicated offshore software development team just like your in-house team. So you don’t have to worry about different time zones and communication hurdles. The offshore developers are streamlined, well-versed, and efficient, be it offshore software development services or IT [staff augmentation services] (https://www.bacancytechnology.com/it-staff-augmentation-services). 

Expanding your search to the global market has a much broader range of talented individuals. For the ideal preferred IT outsourcing, you can consider India and Ukraine as these countries are the most preferred and top IT outsourcing destinations. 

All you are required to take into consideration is the Agile software development approach and the right set of skills and technologies as it makes the team productive and project development enjoyable.
#IT Staff Augmentation: Technology, Tools and Techniques Matters a Lot
Read More [here] (https://www.bacancytechnology.com/blog/why-location-does-not-matter-in-it-staff-augmentation-services)
Shorten your link with my #Smartcontract.
Tags: blockchain, xinfin, xdc
Published: 2020-11-28 08:02:00

Shorten the link #smartcontract has been deployed on #XinFin Network and the transaction fees to deploy this smartcontract was 0.00007 XDC. Let me know the transaction fees for deploying the same smartcontract on your #Network.

Here the #smartcontract:
`pragma solidity ^0.4.24;
contract e0x {
 event LinkVisited(string url, uint linkId);
 event LinkAdded(uint linkId, string url);
 struct LinkTemplate {
  address userAddress;
  string url;
 }
 uint lastLinkId;
 mapping (uint => LinkTemplate) public linkMapping;
 constructor() public {
  lastLinkId = 0;
 }
 function createNewLink(string url) public returns (uint) {
     lastLinkId++;
  linkMapping[lastLinkId] = LinkTemplate(msg.sender, url);
  emit LinkAdded(lastLinkId, url);
  return lastLinkId;
 }
 modifier linkExists(uint linkId) {
     //link with the given hash does not exist
  if(linkMapping[linkId].userAddress == 0x0000000000000000000000000000000000000000) {
   revert();
  }
  _;
 }
 function getLink(uint linkId) linkExists(linkId) public constant
  returns(
   address,
   string
  ) {
      //emit LinkVisited(linkId, link.url);
      LinkTemplate memory link = linkMapping[linkId];
   return(
      link.userAddress,
      link.url
   );
  }
}`
How to Remove a Substring from a String in Python?
Tags: python, programming, oop
Published: 2020-11-28 07:43:30

A substring is a chain of sequential characters inside a bigger string. Removing a substring from a fixed of strings deletes this substring from every detail within the set.Use str.replace() inside a for-loop to get rid of a substring from all strings in a fixed set of strings.

**Use str.replace(old, new) with new as "" to remove substring old from str.**

`_string = "programming"

new_string = a_string.replace("ing", "")


print(new_string)

Output

programm
`
Use **str.replace() in a for loop** to remove a substring from all elements in the set. Add each modified string to a new set.

```
string_set = {"learning", "enjoying", "programming"}

new_set = set()


for a_string in string_set:

    new_string = a_string.replace("ing", "")

    new_set.add(new_string)


print(new_set)

Output

{'enjoy', 'learn', 'programm'}
```
Use a set comprehension for a more compact implementation. [Read more](https://www.kodlogs.com/blog/2377/how-to-remove-a-substring-from-a-string-in-python)
RCT002 React Components
Tags: react
Published: 2020-11-28 07:43:21

# react.js的组件

我的笔记里对react.js的学习包含了以下8个内容：

1. import react.js 
2. JSX
3. 渲染
4. Components and props   (This note)
5. react 生命周期    (This note)
6. 事件处理
7. 条件渲染 if-else
8. 列表渲染 for loop

# 创建react组件

组件允许用户将 UI 拆分为独立可复用的代码片段，并对每个片段进行独立构思。

组件，从概念上类似于 JavaScript 函数。它接受任意的入参（即 “props”），并返回用于描述页面展示内容的 React 元素。

有三种方式来创建组件：

- React.createClass (基本上不再使用)
- 编写 JavaScript 函数 (stateless)
- class 继承 React.Component (stateful)

# 无状态组件 / 函数式组件

编写一个js函数，函数名就是组件的标签名，函数里面可以通过`props`来获取标签的属性。

```html
<script type="text/babel">
  function Profile(props) {
    return <div className="profile">
      <h3>Welcome</h3>
      <p>Name: {props.name}</p>
      <p>Age: {props.age}岁</p>
      <p>Likes: {props.likes}</p>
    </div>;
  }

  ReactDOM.render(
    <Profile name="马保国" age="69" likes="耗子尾汁" />,
    document.getElementById('react_container')
  );
</script>
```

需要注意的是，上面例子的第三行`return <div ...>`必须写在一起，两者之间不能换行。

# 状态组件

通过继承`React.Component`类并重写里面的`render()`函数来构造react组件。

```html
<script type="text/babel">
  class Profile extends React.Component {
    render() {
      return <div className="profile">
      <h3>Welcome</h3>
      <p>Name: {this.props.name}</p>
      <p>Age: {this.props.age}岁</p>
      <p>Likes: {this.props.likes}</p>
    </div>;
    }
  }
  ReactDOM.render(
    <Profile name="马保国" age="69" likes="耗子尾汁" />,
    document.getElementById('react_container')
  );
</script>
```

**注意**：以上代码中的数据依然是使用`this.props.xxx`来获取的。对于有状态的组件，我们也可以通过`this.state.xxx`获取，不过这种情况下JSX里面的property就没有意义了。

# 有状态组件的生命周期

生命周期关系着代码的执行，react组件的生命周期主要分为以下4个阶段：

- Initialisation 初始化阶段
- Mounting 加载阶段
- Updation 更新阶段
- Unmounting 销毁阶段

对于每个阶段，具体的执行流程如下：

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0yndp0qmldc2u2qfcl3s.png)

图中每一个结点都是一个可以重写的函数，我们可以重写它们来实现我们想要的效果。

下面是实例代码：
```javascript
class Baoguo extends React.Component {

  constructor(props) {
    // here we set some initial value to the component
    console.log('component initialisation')
    super(props);
    this.state = {
      skill1: '正蹬',
      skill2: '鞭腿',
      skill3: '刺拳',
      age: 69,
      item: '耗子尾汁',
      virtue: '武德'
    }
  }
  componentWillMount() {
    // here normally we have ajax request to get data
    console.log('before mounting the conponent')
    
  }
  render() {
    // on mounting the component
    return <div className="raw-text">
    <p>我说小伙子你不讲武德，你不懂。(他说) 马老师，对不 对不起，我不懂规矩，啊我是 他说他是乱打的。</p>
    <p>他可不是乱打的啊，{this.state.skill1}、{this.state.skill2}、{this.state.skill3}，训练有素。</p>
    <p>后来他说他练过 三四年泰拳。啊，看来是有备而来。</p>
    <p>这两个 年轻人不讲武德，来骗，来偷袭！我{this.state.age}岁的 老同志。这好吗？这不好。我劝 这位 年轻人，{this.state.item}，好好反思。</p>
    <p>以后不要再犯 这样的聪明，小聪明 啊！额...武林 要以和为贵，要讲{this.state.virtue}。 不要搞 窝里斗。</p>
    <p>谢谢朋友们！</p>
    <button onClick={()=>alert('chicken you are too beautiful~')}>Click me</button>
  </div>;
  }
  componentDidMount() {
    console.log('after mounting the component')
  }
}
ReactDOM.render(
  <Baoguo />,
  document.getElementById('react_container')
);
```
Nhan dinh bong da Southampton vs MU, 21h00 Ngày 29/11 - Ngoai hang Anh
Published: 2020-11-28 07:41:54

Cùng các chuyen gia du doan ket qua bong da hom nay giữa Southampton vs MU và đưa ra những ý kiến chuyên sâu về các trận đấu. Cập nhật thông tin nhan dinh bong da 24h nhanh và chính xác nhất từ các giải vô địch quốc gia hàng đầu thế giới hiện nay. Tham gia dudoanbongda, nhandinhbongda trước trận đấu cực chính xác dựa trên những phân tích, đánh giá trước giờ bóng lăn.
Nhận định tỷ lệ kèo Southampton vs MU

Nhan dinh bong da Southampton vs MU - Kèo Châu Á
* Chọn MU - 0.5

Nhandinhbongda Southampton vs MU - Kèo Châu Âu:
* Tỷ lệ kèo Châu Âu: 3.75*2.00*3.30

Dudoanbongda Southampton vs MU - Kèo Tài Xỉu:
* Chọn Xỉu 

Đội hình dự kiến Southampton vs MU

Southampton: McCarthy, Walker-Peters, Stephens, Bednarek, Bertrand, Armstrong, Ward-Prowse, Romeu, Djenepo, Adams, Ings.

MU: de Gea, Wan-Bissaka, Lindelof, Maguire, Shaw, Pogba, McTominay, James, Fernandes, Rashford, Martial.

* Nhận định bóng đá Southampton vs MU: Chọn MU - 0.5

* Dự đoán bóng đá tỷ số Southampton vs MU: 0 - 1

Nhan dinh bong da dem nay nhanh và chính xác nhất với những phân tích kỹ lưỡng trước trận đấu. Cùng đội ngũ chuyên gia nhandinhbongda đưa ra những đánh giá về tình hình chuẩn bị của 2 đội bóng trước giờ bóng lăn. Du doan bong da dem nay dựa trên các thông tin về phong độ, đội hình, chiến thuật của đội bóng. Tham gia dudoanbongda tỷ số trận đấu, soi kèo đặt cược cực chính xác tại: https://tinbong.vn/nhan-dinh-southampton-vs-mu-29-11-ngoai-hang-anh
Eclipse red exclamation mark on project folder
Tags: java, programming, oop
Published: 2020-11-28 07:41:14

When you right-click the Eclipse Proj build path==>organize build Path , in the pop-up window, find the Libraries tab, and you can get that some jar sets are red forks.Jar package  does not discover the equivalent file , producing a red exclamation mark(!) in opposite of the Eclipse project, maybe due to an outsided introduced item or due to some files were erased, causing in a red exclamation point. Find the jar packages that are not in these eclipse projects, remove them, and then re-import the compulsory jars manually.

**Red exclamation shows that somewhat goes incorrect with occupied copy
working.**

##Case 1 & Solution
Maximum common situation is using outsided build process which make some hurt to occupied copy. For instance it can duplicate svn folders from source folders into equivalent binaries folders. In that situation derivative .svn folders is located in incorrect path. So, mistaken working copy portions are striking with red exclamation.
To escape this state you can precise your build procedure in stop repetition of .svn folders. Alternative  way is do not use external builders.

## Case 2 & solution
[Read more](https://www.kodlogs.com/blog/2386/eclipse-red-exclamation-mark-on-project-folder)
Custom role based authorization in asp.net mvc
Tags: programming, webdev
Published: 2020-11-28 07:38:23

In this post I am going to explain the logic that I use to implement roles and permissions with ASP.NET MVC, for this, I have created 4 tables.
#Database
* **User:** this table manages all the users of our system, and has a field called Rol_id, which refers to the following table.
* **Role:** it manages the roles that our systems will implement, eg: Super Administrator, Administrator, Moderator, Super User, etc.
* **Permission:** this table handles all the permissions that our business requires, eg: Can you create a new student? Can you view a student? Can you add a note to a student?
* **PermissionDeniedByRol:** this table works the other way around since the normal thing would be to assign permissions to a user, for me, a user has permission for everything, so it is easier to add the permissions to which they cannot implement. I do this because it is easier, otherwise, we would have to add all the available permissions and remove them.

##MOdel Layer
In this layer what I have done is create a class called FrontUser, this class allows us to know which user is authenticated in our system and also implements a method to know if they have permission or not.
```
public class FrontUser
{
     public static bool HasPermission (RolesPermisos value)
     {
         var user = FrontUser.Get ();
         return! user.Rol.Permission.Where (x => x.PermissionID == value)
                            .Any ();
     }

     public static User Get ()
     {
         return new User (). Get (SessionHelper.GetUser ());
     }
}
```
If you noticed, the HasPermission method does the reverse, if it is true it returns false, otherwise true. In addition, it receives an Enum as a parameter. Why[Read more](https://www.kodlogs.com/blog/2399/custom-role-based-authorization-in-asp-net-mvc)