teleren/devto huggingface dataset:
bitwise06_05.java
Tags: java, beginners, programming, tutorial
Published: 2021-11-02 04:48:08

```java
// ~Bitwise Operators
	// problem:
	// bitwise06_05.java{write java program showing the working of all Bitwise Operators.}	
	
class bitwise06_05
{
	public static void main(String args[])
	{
		int a= 2, b=3;
		System.out.println("Value of a = "+a+" and value of b = "+b);
		System.out.println("Binary value of a and b is = "+Integer.toBinaryString(a)+"  "+Integer.toBinaryString(b));
		
		// System.out.println("The Bitwise operators work on the terms of binary notation. ");
		System.out.println("Bitwise OR "+a+" | "+b+" => "+(a|b));
		System.out.println("The Binary notation of a and b is = 00000010 00000011");
		System.out.println("The Truth Table of OR Bitwise Operator is \n A \t B \t OUTPUT \n ----------------------- \n 0 \t 0 \t 0 \n 1 \t 0 \t 1 \n 0 \t 1 \t 1 \n 1 \t 1 \t 1\n -----------------------  ");
		System.out.println("according to truth table answer is 00000010 | 00000011 = 00000011 = 3\n");
		
		
		
		System.out.println("Bitwise AND "+a+" & "+b+" => "+(a&b));
		System.out.println("The Binary notation of a and b is = 00000010 00000011");
		System.out.println("The Truth Table of AND Bitwise Operator is \n A \t B \t OUTPUT \n ----------------------- \n 0 \t 0 \t 0 \n 1 \t 0 \t 0 \n 0 \t 1 \t 0 \n 1 \t 1 \t 1\n -----------------------  ");
		System.out.println("according to truth table answer is 00000010 & 00000011 = 00000010 = 2\n");
		
		
		
		System.out.println("Bitwise XOR "+a+" ^ "+b+" => "+(a^b));
		System.out.println("The Binary notation of a and b is = 00000010 00000011");
		System.out.println("The Truth Table of XOR Bitwise Operator is \n A \t B \t OUTPUT \n ----------------------- \n 0 \t 0 \t 0 \n 1 \t 0 \t 1 \n 0 \t 1 \t 1 \n 1 \t 1 \t 0\n -----------------------  ");
		System.out.println("according to truth table answer is 00000010 ^ 00000011 = 00000001 = 1\n");
		
		
		System.out.println("Bitwise NOT  ~ "+a+" => "+(~a));
		System.out.println("The Binary notation of a is = 00000010");
		System.out.println("The Truth Table of NOT Bitwise Operator is \n A \t OUTPUT \n ----------------------- \n 0 \t 1 \n 1 \t 0 \n-----------------------  ");
		System.out.println("according to truth table answer is ~00000010  = 11111101 = -3\n");

		System.out.println("ENDING THE PROGRAM...\n:-) THANK YOU (-:");
	}
}
```
logical06_04.java
Tags: java, beginners, programming, tutorial
Published: 2021-11-02 04:45:54

```java
 // ~Logical Operators
	// problem:
	// logical06_04.java{wirte java program showing the waorking of Logical Operators.}
class logical06_04
{
	public static void main(String args[])
	{
		int a= 2, b=3;
		System.out.println("Value of a and b is = "+a+" "+b);
		
		System.out.println("Logical OR "+a+" > "+b+" || "+a+" < "+b+" => "+((a>b)||(a<b)));
		System.out.println("Logical OR "+a+" > "+b+" || "+a+" > "+b+" => "+((a>b)||(a>b)));
	
		System.out.println("\nLogical AND "+a+" < "+b+" && "+a+" < "+b+" => "+((a<b)&&(a<b)));
		System.out.println("Logical AND "+a+" > "+b+" && "+a+" < "+b+" => "+((a>b)&&(a<b)));
		
		System.out.println("\nLogical NOT{!}   !("+a+" == "+b+") => "+(!(a == b)) );
		System.out.println("Logical NOT{!}   !("+a+" < "+b+") => "+(!(a < b)) );
	
		System.out.println("ENDING THE PROGRAM...\n:-) THANK YOU (-:");
	}
}
```
Python Terminal Game
Tags: python, programming, gamedev, github
Published: 2021-11-02 04:40:57

## Direction Dungeon

After spending a fair amount of time with JavaScript and the MERN technology stack, I decided to learn a new language. Everyone has heard the buzz of Python of course and I wanted to see for myself what the language had to offer. I find the best way for me to learn is through several different approaches. I currently have an internship in which I am just now beginning to use Python, but I also wanted a more structured teaching environment as well.

I have a pro membership with Codecademy. I use their platform as an initial look at different languages before going out to gather my own information. I noticed that not only did they have Python available, but they also used it in their Computer Science Path as well. So I decided to learn something new (Python) while also brushing up on some skills that are language agnostic (Computer Science).

One of the requirements for the project is to create some type of CLI game. I choose to create a thriller/choose-your-own-adventure mash-up. Here is an image of one of the user input moments in the game: 

![Image of terminal game Direction Dungeon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tvnxswib7tfei3k0wan7.png)

Basically the game allows you to give a player options, then create different scenarios through a story narrative based on what the player chooses. It was a lot of fun to make, and I think I am going to add a few more enhancements after the Computer Science course is done! I found a cool library that made making [ascii art](https://pypi.org/project/art/) super simple and upped the game style just a bit, so that it is more than boring text. 

I have lately been working with Bitbucket for my Git version control, but it was nice to go back to GitHub after being away for awhile. I like the kanban style simplistic setup of "Projects" in GitHub. Although it is nice to spice things up with Trello in Bitbucket and add a little more stylistic spice! In any case if you want to check out my project you can view it in the GitHub repository for [Direction Dungeon](https://github.com/JohnBanas/Direction_Dungeon).

Thank you for reading and happy coding!
Hacktoberfest 2021 Reloaded
Tags: hacktoberfest, android, opensource
Published: 2021-11-02 04:37:28

I decided to write this post for summarizing my experience of my very first Hacktoberfest. Hacktoberfest 2021 has been a kind of a roller coaster ride for me. This is my first time making contribution to open source projects. Talking about the first PR, it was kind of overwhelming and challenging, it was in the android development domain. That one PR, on getting merged, boosted me and motivated me to make more quality contributions, there on I never looked back and went on to make a total of 17 successful PRs in the entire Hacktoberfest. The journey has been fantastic and I have learnt a hell lot of things from the project maintainers and fellow contributors.

Even though I won the Hacktoberfest , but I still consider myself a beginner in the field of Open Source and Software Development. But this journey has surely made me brave enough to make valuable contribution in the field of Open Source.

I would like to highlight few points about the Open Source Diaspora :

1. Read guidelines carefully before making any PR, I have made 
   this mistake few times but the maintainers were kind enough
   to prompt me.
2. Communicating actively is very important and crucial.
3. Never hesitate to ask for help from maintainers, they will be 
   more than happy to help and guide you.
4. Always look for beginner friendly issues i.e. issues with "good 
   first issue" tag, often they are easy to contribute
5. Often small contributions are good contributions , a 
   contribution doesn't always need to have large codebase, 
   remember that "a small contribution can bring a big change".
What is a Class, Object, Instance, Context in simple words?
Tags: programming, computerscience
Published: 2021-11-02 04:26:02

In class-based object oriented language

A **Class** is a blueprint of an object.

An **Object** is an instance of a class.

**Instance** is a context which is created in a computer system based on some some model.

**Context** is a frame that surrounds the event and provides resources for its appropriate interpretation.

References:[Instance](https://en.wikipedia.org/wiki/Instance_(computer_science))
Do you have aphantasia?
Tags: aphantasia
Published: 2021-11-02 04:06:49

Just learned I have aphantasia via Rubber Ninja on this Game Grumps Mario Maker episode: https://www.youtube.com/watch?v=LKwPJXIBsKY

I can't visualize anything mentally! Certainly makes sense why 3D modeling can be challenging some times.

Here's some more info for y'all: https://www.webmd.com/brain/what-is-aphantasia

![first aphantasia description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/79vzhsnfqsxy2at6p34u.png)
![second aphantasia description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zixtjee66aes2ivjhoz1.png)
![last aphantasia description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/98swcshyg2183hxvlcmk.png)
I found a tool to try open-source projects quickly!!
Tags: opensource, tooling, programming, productivity
Published: 2021-11-02 04:05:11

Recently my team has been working on a new project that requires a gateway. So I had to decide the technology pattern and started to try some open-source gateway projects. What I didn't expect is that I failed to complete the dev environment and got stuck at the first step. It was already one and a half hours past when I finally started the Etcd database!

So I turned to Henry, who's experienced at programming and knows many efficient tools. He recommended a tool Tin(https://www.teamcode.com/docs/en-US/tin/what-is-tin) From [TeamCode](https://www.teamcode.com/) Cloud Collaborative Development Platform that can auto-build applications in seconds. It seems that is exactly what I needed! I registered an account and started trying.
According to the guidebook, I had to setup the workspace and create a Tin application. Currently, it supports 3 ways: Git Repo, Docker Repo, Dockerfile.

Then I filled in the information as required, set the Ports, Variables and Entrypoint.
The whole process only took me a few minutes, and the Gateway app was created!
I turned off the logging interface and saw an Endpoint module below that provided the URL for public access. After copying the URL, the administration interface of the gateway appeared. I tried several other projects later, but I failed to build some open-source projects.
From the perspective of an engineer, I think Tin(https://www.teamcode.com/products/tin) is a very useful tool to improve R&D efficiency. It could avoid us from the cumbersome process of installing open-source projects and allows us to focus on the more important things at hand. Therefore, it has great value. But the team should focus on the user experience and support more open-source projects. So that we can experience more great projects easily and choose the technology architecture efficiently.
Final Hacktoberfest Pull Requests! 
Tags: hacktoberfest, javascript, webdev, opensource
Published: 2021-11-02 03:35:07

Wow! What an amazing month! We finally finished Hacktoberfest and it was one crazy ride! During this blog post I will be going over the issues and final PR I did for Hacktoberfest.

## The issues that were taken
The two issues I took were:
- [notifirehq](https://github.com/notifirehq/notifire/issues/57)
- [telescope](https://github.com/Seneca-CDOT/telescope/issues/2389)

### Notifirehq
This issue was a big step for me as I was contributing to a project I have never contributed to and was adding a feature to the repository. I had to integrate support for the whispir provider. It took a lot of time preparing and reviewing their rules to contributing. Since it is a small project there is not much support for it but, the people who are working on it are very motivated and inspired to work on it. If I ever had any questions the community was there always helping me! Submitting the first pull request took some time as I didn't have a template and I had to do research for the provider that needed to be added. The pull request is still being finished currently because I am fixing changes that are requested. You can find the pull request [here](https://github.com/notifirehq/notifire/pull/65).

### Telescope
Near the end of Hacktoberfest I was able to pick up two issues from the telescope project updating outdated dependencies. I wasn't able to create a pull request as I am currently in the process moving so I did not have the time to complete the issues but, will update you guys in a future blog post about the completion. 

## Conclusion 
Hacktoberfest was a lot of fun to contribute to and learn new code. This year was a rough start because some projects I tried to contribute to were not respondent or required a lot more time and support from the community. Although I had those tough obstacles, I am hoping next year to complete a lot more pull requests and to contribute to projects I personally use.  Thank you for reading my last Hacktoberfest blog until 2022!
No more Backend
Tags: database, programming, productivity
Published: 2021-11-02 03:21:28

I enjoy doing some consulting work on [Fiverr](https://www.fiverr.com/vjnvisakh?public_mode=true). I have this one particular [Gig](https://www.fiverr.com/share/jdZGko) where I write mongoDb queries. Lately I saw that was taking a lot of hits from Fiverr. Sure the rate is cheap but the reason why so many people were preferring it was unique.

## The Idea

Turns out customers around the globe are shifting to a minimum backend coding approach. They shift the entire load to the database. I was chatting with a customer and he said he usually hires some **interns** to do basic CRUD. So you have a project with basic fetch and updates to the database using some known framework. This again depends on what is the cheapest at the moment. They then find out all the different interfaces that can be driven completely by database queries. They then reach out to me to write queries which portray the interface exactly.

Personally I feel that is a great way of optimial use of resources. There isn't much of bug that will arise since the backend code is mostly a read/write. The cost is economical since the intern won't have much to do. The cost of writing all the queries is one time and that too is very economical. Nevetheless, it only works with applications that don't need a lot of server side processing. But what the heck, customers are doing a fine job with it. Good going I would say. 

The remote work has actually kicked off for good during the covid season. 

Happy coding!
HOW CAN I LIMIT THE MAXIMUM FILE UPLOAD LIMIT PER USER  IN PHP.
Tags: php, sql
Published: 2021-11-02 03:09:35

Hello guys,
i have been trying for some days now to make it possible for each user in my website to only **upload a maximum of 4 images** and when ever he/she wants to upload the fifth image an error massage would be echoed telling the user that **The maximum image to be uploaded have reached and cannot exceed 4 image**
###Below is the sample of the code on form submit

```
if (isset($_POST['upload'])) { 
// if upload button on the form is clicked
  
// name of the uploaded file
$filename = $_FILES['photo']['name'];

//location
$destination = '../images/business.cover/' . $filename;

// get the file extension
$extension = pathinfo($filename, PATHINFO_EXTENSION);

// the physical file on a temporary uploads directory on the server
$file = $_FILES['photo']['tmp_name'];
$size = $_FILES['photo']['size'];

// get id
$id=$_GET['id'];

//check is form is empty
if(empty($_POST['photo'])){
    $cover_msg= "<div class='alert alert-danger'>Empty cover phto field</div>";
}

//check file extension and maximum file size
if (!in_array($extension, ['jpg', 'gif', 'jpeg','png'])) {
    $cover_msg= "<div class='alert alert-danger'>You file extension must be .jpg .jpeg .gif .png</div>";
} elseif ($_FILES['photo']['size'] > 50000000) { // file shouldn't be larger than 1Megabyte
    $cover_msg= "<div class='alert alert-danger'>File too large!</div>";
   
} else {
    
   
// move the uploaded (temporary) file to the specified destination
    if (move_uploaded_file($file, $destination);) {
       
$sql = "INSERT INTO business(image) VALUES('$filename') WHERE id=$id";  

$cover_msg="<div class='alert alert-success'>Information uploaded Successfully</div>";
if (mysqli_query($conn, $sql)) {
} else {
die( "Failed to upload file".$conn->error);
}
            
}

}
}
```

##**PLEASE HELP, ANYONE**
Create `it.todo` in mocha
Tags: test, mocha
Published: 2021-11-02 02:55:46

As I mention in early post, I've been working on legacy project lately and always found an oldschool pattern and old library.

Again in mocha, I've face an error `it.todo is not a function` ... Come on! Are you serious!

Let's not angry with some small error, the solution is just use `it` without function, that test case will become pending or "todo" in Jest universe.

Ref: https://github.com/mochajs/mocha/issues/1510#issuecomment-142481408
code every day with me
Tags: javascript, programming, 100daysofcode, algorithms
Published: 2021-11-02 02:46:02

##--DAY 13--
Hi, I am going to make #100DaysOfCode Challenge. Everyday I will try solve 1 problem from leetcode or hackerrank. Hope you can go with me until end.
**Now let's solve problem today:**
- Problem: Climbing Stairs
- Detail: [here](https://leetcode.com/problems/climbing-stairs/)
- Idea: use recursion
 - There are two way to climb to n'th stair: climb 1 step from n'th-1 stair or climb 2 steps from n'th-2 stair
 - Similar to Fibonacci
- My solution (javascript):
With recursion
```
var climbStairs = function(n) {
    if(n==1||n==2) return n;
    return climbStairs(n-1)+climbStairs(n-2);
};
```
No recursion
```
var climbStairs = function(n) {
    if(n==1||n==2) return n;
    let dp=[];
    dp[0]=1; dp[1]=2;
    for(let i=2;i<n;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[n-1];
};
```
-->*If you have better solution or any question, please comment below. I will appreciate.*
Working on Generating API fixture
Tags: opensource, hacktoberfest, javascript, beginners
Published: 2021-11-02 02:20:26

In the second week of Hacktoberfest, I found an interesting project to work on_ [Medusa](https://www.medusajs.com/). Medusa is a headless commerce platform that enables developers to create a digital commerce experiences.
## Issue
The project owner want to generate fixtures for models returned by their API, so the users can see it as an example how data returns back when making an API call. I chose the [Region](https://github.com/medusajs/medusa/issues/468) model to work on. 
The first challenge I had is setting up the development environment to start contributing. I met several errors that was not discussed in the documentation. Luckily, they have a Discord group and it is really active. I found other contributors had same issues before so I followed their advice and resolved the problem. I also helped newer contributor to overcome the same challenge. It felt great that I can help other developers. 
## Solution
The process for creating API fixture was straightforward. The project owners were really thoughtful and they created a video to walkthrough the problem and solution. 
Basically, I had to write an integration test for GetRegionsRegion API call and the result of this call will be saved in the fixture folder.
The fixture I created is here
```javascript
{
  "region": {
    "id": "reg_01FHTESN727620KGC7KASK5KSM",
    "name": "Scandinavia",
    "currency_code": "dkk",
    "tax_rate": "0",
    "tax_code": null,
    "countries": [],
    "payment_providers": [
      {
        "id": "test-pay",
        "is_installed": true
      }
    ],
    "fulfillment_providers": [
      {
        "id": "test-ful",
        "is_installed": true
      }
    ],
    "created_at": "2021-10-12T14:34:10.528Z",
    "updated_at": "2021-10-12T14:34:10.528Z",
    "deleted_at": null,
    "metadata": null
  }
}
```
You can take a look on my Pull request [here](https://github.com/medusajs/medusa/pull/541).
In overall, it is great experience. The project owners was really nice and helpful. I would love to contribute more to this project.
#100DaysOfSwift: Project 15 
Tags: ios, beginners, swift
Published: 2021-11-02 01:44:28

Hello !!

This project taught me about animation. It was quite simple. We used a penguin to showcase different animations on the screen by using switch/case statements. 

Key Takeaways:

1. animate(withDuration:) takes two closures. One with the switch/case statements and the second one is a completion closure. 

2. Animation closures do not need [weak self] because there is no risk of strong reference cycles. 

3. CGAffineTransform is added to a views transform property. Example, self.imageView.transform = CGAffineTransform(scaleX: 2, y: 2). This make the image 2x bigger than its normal size. 

4. self.imageView.transform = .identity is used to clear the view of any animations added to the transform property. 

5.Two animations can happen at the same time. Example, the following code fades the penguin out and adds a background color of green. 

self.imageView.alpha = 0.1
self.imageView.backgroundColor = UIColor.green
ประกอบ slice ของ byte ด้วย bytes.Buffer
Tags: go
Published: 2021-11-02 01:04:50

ช่วงนี้ทำงานกับ binary data บ่อยๆเพื่อทำการ encode/decode ข้อมูลที่อยู่ในรูปแบบ binary สิ่งที่เราต้องทำประจำคือเอาข้อมูลแบบ binary ที่อยู่ใน slice ของ byte ([]byte) มารวมๆกันให้เป็น byte slice ก้อนใหญ่ก้อนนึง

ท่าในการเอา byte slice สองอันมารวมกันท่านึงที่นึกออกคือใช้ฟังก์ชัน `append` เช่นมีข้อมูลแบบนี้

```go
a := []byte("Hello")
b := []byte("World")
```

เอา a และ b มารวมกันด้วย `append` ได้แบบนี้

```go
s := append(a, b...)
```

แต่ว่านอกจากการใช้ `append` แล้วเรายังใช้ type `bytes.Buffer` ช่วยได้

`bytes.Buffer` (https://pkg.go.dev/bytes#Buffer) นั้นซ่อนข้อมูล `[]byte` เอาไว้แล้วเตรียม method ที่ implements interface Reader และ Writer เอาไว้ให้ ทำให้เราประกอบข้อมูล `[]byte` ผ่านทาง method พวกนี้ได้ และใช้ method/function อื่นๆที่ทำงานกับ Reader และ Writer ได้อีกด้วย

ตัวอย่างเราสามารถประกอบ a และ b ได้โดยการใช้ bytes.Buffer ได้ดังนี้

```go
var buf bytes.Buffer

buf.Write(a)
buf.Write(b)
s := buf.Bytes()
```

ตัวอย่างที่ซับซ้อนขึ้นเช่นถ้าเราต้องการแปลงตัวเลข 32 bits (4 bytes) เป็น binary format เช่นมีเลข 65535 แปลงเป็น 32 bits format จะได้ `00000000000000001111111111111111` เขียนอยู่ในรูป byte slice จะได้ `[]byte{0, 0, 255, 255}`

เราจะใช้ package binary ช่วยแปลงเลขเป็น byte slice แล้ว Write เข้าไปใน buffer แบบนี้

```go
i := uint32(65535)
c := make([]byte, 4)
binary.BigEndian.PutUint32(c, i)
buf.Write(c)
```

แต่เนื่องจากว่า bytes.Buffer นั้น implements Writer เอาไว้เราเลยเขียนแบบนี้ได้สั้นกว่า

```go
i := uint32(65535)
binary.Write(&buf, binary.BigEndian, i)
```

เพราะ binary.Write ค่าแรกนั้นรับ Writer นั่นเอง
Laravel 8 Storage Link on Server
Published: 2021-11-02 00:47:51

Put the below code on route/web.php

```
Route::get('/linkstorage', function () {
    Artisan::call('storage:link'); // this will do the command line job
});

```
Go to https://yourdomainname.com/linkstorage once. 
That's it. 

> You can put above code on comment once it is done.