teleren/devto huggingface dataset:
Daily Coding Problem #1
Tags: dev, practice, algorithms, challenge
Published: 2018-11-24 08:48:38

---
title: Daily Coding Problem #1
published: true
description: Daily Coding Problem sends you a coding task every day for you to practice for coding interview tasks
tags: 
- dev
- practice
- algorithms
- challenge
---

For quite some time I found my time procastinating after getting home from work. Untill a few days ago I stumbled upon the [Daily Coding Problem](https://www.dailycodingproblem.com/) (DCP) and decided to give it a shot. 
The code is in C#.

## How it works?
The folks at DCP send you a problem that was asked at a top company everyday for you to solve. The premium membership also offers the opportunity to verify your solution.

# Problem #1
This problem was recently asked by Google.

Given a list of numbers and a number k, return whether any two numbers from the list add up to k.

For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.

Bonus: Can you do this in one pass?

# My solution
```
using System;
using System.Collections.Generic;
using System.Linq;

namespace Problem01
{
	public class Program
	{
		public static void Main(string[] args)
		{
			var numbers = Console.ReadLine()
				.Split(' ')
				.Select(int.Parse)
				.ToList();

			var k = int.Parse(Console.ReadLine());

			var result = TwoNumbersEqual(numbers, k);
			Console.WriteLine(result);
		}

		public static bool TwoNumbersEqual(List<int> numbers, int k)
		{
			var set = new HashSet<int>();

			foreach (var number in numbers)
			{
				var remaining = k - number;

				if (set.Contains(remaining))
				{
					return true;
				}

				set.Add(number);
			}

			return false;
		}
	}
}
```

# Explanation
The naive solution would be to do two nested for loops and check if any of the combinations gives the `k` we desire.
But because I wanted the bonus tag and after some tought, I realized that you could foreach the input array and for each item check find the difference between it and `k`. After you find the difference, you can check if you have already seen this number before and the `HashSet` data structure allows for constant lookups (because it is a hash table).

I will try to do the daily problem everyday, but sometimes life gets in the way :)
Solutions are posted in my github account

{% github cwetanow/DailyCodingProblem %}. 

Feel free to leave a like and let me know in the comments if I should continue to post my solutions.

If you also have any better solution in mind, by all means share it, so we can learn from each other.
The limits of story maps
Tags: manifestingagile
Published: 2018-11-24 11:16:44

---
title: The limits of story maps
published: true
description: A small experiment in poking at dev practices
tags: manifestingagile
---
![The limits of story maps](https://thepracticaldev.s3.amazonaws.com/i/57mx95c4mch13xrw0dnl.png)

I really enjoy using sticky notes - it creates visual interaction and keeps participants focussed on the discussion. The only problem is that I sometimes get distracted by things such as looking for a different colour sticky or checking whether I'm using a whiteboard marker on stickies.
Accepting the inevitable
Tags: manifestingagile
Published: 2018-11-24 11:10:21

---
title: Accepting the inevitable
published: true
description: A small experiment in poking at dev practices
tags: manifestingagile
---
![Accepting the inevitable](https://thepracticaldev.s3.amazonaws.com/i/cdtp8y6db911qqmk1dhy.jpeg)

Like many ppl involved in dev I really like a well written story with decent acceptance criteria, it's just that there always seems to be something I miss while either writing or reading them. Worst case scenario would be that my machine decides it needs a coffee break just as I'm about to do my last build or test...
Recommend: Five Language Stories
Tags: language, compare, tir
Published: 2018-11-24 09:52:15

---
title: Recommend: Five Language Stories
published: true
description: 
tags: language, compare, tir
---

Today I read this post about five languages. A post worth reading.

[link-->](https://medium.com/@kari.marttila/five-languages-five-stories-1afd7b0b583f)
Set up your own endpoint using the WP REST API.
Tags: wordpress, api, rest
Published: 2018-11-24 08:41:13

---
title: Set up your own endpoint using the WP REST API.
published: true
description: wordpress,API 
tags: wordpress,API,REST
---

# Set up your own endpoint using the WP REST API.


### Reference material
WP REST API Official Document
https://www.sofplant.com/blog/tech/wp-rest-api-tips/

From WordPress 4.7 onwards, we set up our own endpoint using [WP REST API] which became available as standard, and acquire and display data in cross domain.

Wordpress site hogehoge.jp

Assume that the site that receives and displays data is fugafuga.jp.

hogehoge.jp

Please describe it in functions.php.

```php:functions.php
<?php
//wordpressに用意されているアクションフックで独自APIを作成します。

add_action('rest_api_init', function() {
	register_rest_route( 'wp/v2', '/org_api', array(
		'methods' => 'GET',
		'callback' => 'org_api',
	));
});
function org_api( ) {

	$contents = array();//return用の配列を準備
	$myQuery = new WP_Query();//取得したいデータを設定
	$param = array(
		'post_type' => 'blog',
		'posts_per_page' => 3,
		'order' => 'DESC'
	);
	$myQuery->query($param);
	 if($myQuery->have_posts()):
		 while ( $myQuery->have_posts() ) : $myQuery->the_post();
				$ID = get_the_ID();
				$title = get_the_title();
				array_push($contents, array(
					"title" => $title,
					"id" => $ID
				));
		 endwhile;
	 endif;
	 return $contents;// WP REST APIを利用するときはjsonで返ってくる様に設定されているので、json_encodeは必要ありません。
 }
```


Please visit http://hogehoge.jp/wp-json/wp/v2/org_api and check that json will come back.

If an error occurs at this point, there may be syntax errors on the php side.

Receive data.
When using in cross domain, specify jsonp as dataType.
fugafuga.jp

```html:index.html
<p id="view_area"></p>
```


```html:wp_rest_api.js
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>
	$(function(){
			$.ajax({
			type: 'GET',
			url: 'http://hogehoge.jp/wp-json/wp/v2/org_api?_jsonp=callback',//コールバック関数名を指定する。 
			dataType: 'jsonp',
			jsonpCallback: 'callback',//コールバック関数名を指定する。
			success: function (jsonp) {
					$(jsonp).each(function(index,el){
                    let id = (jsonp[index]['id']);
					let title = (jsonp[index]['title']);
						$('#view_area').append(
						'<p>' + id + '</p>'
                         + '<p>' + title  + '</p>'
						);
				});
			}
		});
	});
</script>
```


I think whether data display is possible with the above.
Processing etc. when data could not be acquired are omitted.
By using your own endpoint, data that is difficult to acquire a bit with the standard API, (custom posting etc.)
I think that it is possible to obtain flexible data by passing a favorite parameter to the request url and using it on the php side.


```javascript:wp_rest_api.js
data : {
	'param' : 'key_word'
}
```

```php:functions.php

<?php
//wordpressに用意されているアクションフックで独自APIを取得します。

add_action('rest_api_init', function() {
	register_rest_route( 'wp/v2', '/org_api', array(
		'methods' => 'GET',
		'callback' => 'org_api',
	));
});
function org_api( ) {
$param = $_GET['param'];
}
```



Thanks!
Roll over text CSS Animation
Tags: css, animation
Published: 2018-11-24 08:31:05

---
title: Roll over text CSS Animation
published: true
description: CSS Animation
tags: CSS,Animation
---


Hello!

I created [Roll over text ] with CSS 

https://codepen.io/Rin_T_T/details/GwMWQV

I liked CSS Animation ! 

please tell me interesting css POST ! 


Thanks Good bye !!
What is the difference between callback and promise?
Tags: javascript, react, reactnative
Published: 2018-11-24 04:59:50

---
title: What is the difference between callback and promise?
published: true
description: What is the difference between callback and promise?
tags: #js #javascript #react #react native
---

Post Link : <a href="https://www.skptricks.com/2018/11/what-is-difference-between-callback-and-promise.html" >What is the difference between callback and promise? </a>

This tutorial we are going to discuss on difference between callback and promise. Nowadays callback and promise widely used in web application development like react js, javascript etc.

<a href="https://www.skptricks.com/2018/11/what-is-difference-between-callback-and-promise.html" >What is the difference between callback and promise? </a>

<img src="https://1.bp.blogspot.com/-CNARJj5Q4Uo/W_jMg80meOI/AAAAAAAACKY/M6Q_wNnlqrU6Gei6qMkZInyKkc3eKCDYgCLcBGAs/s1600/po.png" />
Bitwise Operations in C/C++
Tags: c, cpp, bitwise, operations
Published: 2018-11-24 03:19:34

Maybe you've stumbled across a perplexing and scary looking line of code: 

```cpp
((value << 2) & 32)
```

You don't know what this is and after some time scouring the internet for answers you come across what is known as bitwise operations. In this post, we'll go over all the bitwise operations possible in C and C++.


Bitwise operations are operations that operate on bit(s). If a bit is 1 then it is said to be "true" or "on". If it is a 0, then it is "false" or "off". Just like arithmetic operators, bitwise operators give a result when the computation is done.

## AND

For one bit values, the AND operator gives the result of "on" if both bits are in the "on" state. Otherwise, it produces the value of "off".

```cpp
1 & 1 == 1
1 & 0 == 0
0 & 1 == 0
0 & 0 == 0
```

For bytes, it goes over each bit and applies the AND operation individually.

```cpp
10000000 & 01111111 == 00000000
11000000 & 11100011 == 11000000
10100110 & 10000111 == 10000110
10101010 & 11011011 == 10001010
```

## OR

Denoted by `|` in C and C++, this operation produces the state of "on" if any of the bit is in the "on" state.

```cpp
1 | 1 == 1
1 | 0 == 1
0 | 1 == 1
0 | 0 == 0
```

Just like with the AND operator, the same thing is done with multi-bit values.

## XOR

Denoted by `^` it is short for exclusive OR. This produces the "on" state if only ONE of the bits is true.

```cpp
1 ^ 1 == 0
1 ^ 0 == 1
0 ^ 1 == 1
0 ^ 0 == 0
```

Operations applied to multi-bit values like bytes are done at the bit level just like with AND and OR.

## NEG

Negates the state of a bit. The symbol `~` is used to denote this operation.

```cpp
~1 == 0
~0 == 1
```

Same with multi-bit values.

## Bitmasks

This isn't an operation but something programmers use sometimes when dealing with bitwise operations. You can think of a bitmask as a filter to extract bits from a multi-bit value.

Say we have the byte `10100111` and we want to get the first two bits. We can use a bitmask to accomplish this goal. A bit of 0 in bitmask means to ignore and 1 means to extract. In our case, the bitmask would like this: `000000011`. To apply the bitmask, we use the AND operator.

```cpp
10100111 & 00000011 == 00000011
```

## Shift operators

You've seen these before with `<<` and `>>`. They mean "shift to the left" and "shift to the right", respectively.

The operand on the left side is the value being shifted while the operand on the right side is the shift amount.

Unlike the other operators we have looked at, these only work on multi-bit values like bytes.

For demonstration purposes, we will have the value `11001011` to play around with.

These operators shift each bit to the direction specified by the type of shifting operator used by a certain amount. Bits that are shifted out of the byte completely are discarded and padded with a zero on the opposite side.

```cpp
11001011 << 1 == 10010110
11001011 >> 2 == 00110010
```

This was a quick article I decided to do after my main Using SDL2 post was released.

Edit:

Thanks to @ccmg for the corrections.
Amazing new webAPI - PictureInPicture 
Tags: pictureinpicture, webapi, html, javascript
Published: 2018-11-24 02:55:53

---
title: Amazing new webAPI - PictureInPicture 
published: true
description: A very simple sample of the new *PictureInPicture* webAPI
tags: pictureInPicture, WebAPI, html5, javascript
cover_image: https://thepracticaldev.s3.amazonaws.com/i/3hegu68j72xks0vmkp6s.gif
---

This is an example of the new PIP webAPI.. Open the webpage, click on the *toggle pnp mode* button.. and see the magic.

[Open webpage](https://iamruhul.github.io/picnpic/)
[Source](https://github.com/iamruhul/picnpic)
Remember phonebooks?
Tags: discuss, random
Published: 2018-11-23 21:56:12

I’m old enough to remember what things were like before the Internet, but young enough to have mostly grown up with it.

It has been an interesting time to see the Internet pick things off one by one.

Phonebooks will be technical artifacts that will be hard to even describe to future generations.

What other technology/practice vanish without much fanfare?
React hooks - Effect
Tags: javascript, react, hooks
Published: 2018-11-23 21:31:57

En el [artículo anterior](https://dev.to/gugadev/react-hooks---state-5g64) vimos un ejemplo del _hook_ `useState`, el cual nos provee una forma de acceder al estado en componentes _stateless_. Pues bien, el otro _hook_ que nos provee React es `effect`.

### useEffect

El hook `useEffect` nos permite "subscribirnos" al ciclo de vida del componente. Puedes pensar en que este hook es la combinación de `componentDidMount`, `componentDidUpdate` y `componentWillUnmount`.

Veamos un ejemplo para comprenderlo mejor.

{% codepen https://codepen.io/gugadev/pen/zMjKaY default-tab=js %}

En este ejemplo hemos usado tanto los hooks `useState` para actualizar el valor que se ingresa en el input y también `useEffect` para realizar ciertas acciones cada vez que el componente sea re-renderizado.

Cada vez que se actualiza el estado con el nuevo valor ingresado en la caja de texto, el componente se re-renderiza y se ejecuta el callback pasado a `useEffect`. Puedes pensar en `useEffect` como un listener para los renders de tu componente; es por esto que se dice que es una combinación de los métodos del ciclo de vida de un componente *stateful*.

Por último, cada vez que se ejecuta el *hook*, vemos si contiene un email válido para, por medio de un `ref` y mostrar u ocultar el mensaje de error respectivamente. Fíjate que no volvemos a actualizar el estado dentro de `setEffect` porque en este caso entraríamos en un loop infinito.

---

Y eso es todo 😉, en el próximo post haremos una pequeña aplicación para poner en práctica todo lo aprendido sobre los _hooks_.
We need so little to be happy. The problem is that we need a lot of experience to understand it.
Tags: discuss, happiness, experience, thoughts
Published: 2018-11-23 21:30:11

---
title: We need so little to be happy. The problem is that we need a lot of experience to understand it.
published: true
description: We need so little to be happy. The problem is that we need a lot of experience to understand it.
tags: discuss, happiness, experience, thoughts
---

Thoughts?
Todo List Dapp on Ethereum - Full tutorial series Post + Videos (9 steps)
Tags: ethereum, dapps, truffle, web3
Published: 2018-11-23 21:19:18

---
title: Todo List Dapp on Ethereum - Full tutorial series Post + Videos (9 steps)
published: true
description: 
tags: Ethereum, Dapps, Truffle, Web3
---

https://thepracticaldev.s3.amazonaws.com/i/6u4bea7b21m4fz91db9v.png

I have just completed the step 9 (last step) of the tutorial series for building a todo list dapp on ethereum.

In this step we mark the task as done and keep the frontend and the smart contract in sync, without having to manually reload the page

Post:  https://eattheblocks.com/todo-list-ethereum-dapp-step9
Video: https://youtu.be/qVxEtDSuXoU
ebook with 2 bonus chapters on React & Drizzle integration with the Dapp):
https://eattheblocks.com/learn-to-build-an-ethereum-dapp-step-by-step-ebook-tutorial-for-beginners/
What is Cubicle Buddha + How We’re Gonna Get Happy
Tags: productivity, motivation, agile, career
Published: 2019-04-07 21:39:17

---
title: What is Cubicle Buddha + How We’re Gonna Get Happy
published: true
tags: productivity, motivation, agile, career
cover_image: https://i1.wp.com/cubiclebuddha.com/wp-content/uploads/2018/11/community1200x600.png
canonical_url: https://cubiclebuddha.com/what-is-cubicle-buddha-how-were-gonna-get-happy/
---

Happiness. It’s what we all basically want. We want the peace that comes with finally being okay.

Sure, but you (rightfully) ask: “What about me? I can meditate just fine at Yoga class… but I work in a fast-paced business that is always pushing me for more results.” Peace exists for you, too. We can even bring calmness into the workplace.

So how do we balance the quest for serenity in a world that won’t settle down?

We’ll answer that and more. Come back soon for practical articles such as tips on how to meditate without even knowing that you’re meditating. I’ll share my failures in the workplace (_of which there are many_) and what I’ve learned about my mind in the process. I won’t be doing it alone– every discovery process works best with community. I love this quote from Thich Nhat Hanh who describes community (or “sangha”) as:

> “The role of meditation, the role of community building, the role of healing and transforming in our daily life is crucial for the environment. You cannot just have projects and initiatives without taking care of the suffering inside.“

See that’s why I consider Thich Nhat Hanh a part of my community (even though I have never met him). It’s incredible how he speaks to the balance between projects/work and internal growth. It’s clear to me that becoming a better employee means becoming a better person. As I have been suspecting… happy people are more productive people.

I’m just starting on this adventure into a calmer, happier workplace, but I am so encouraged by what I’m learning from friends and coworkers about their experiences with mindfulness. So that’s were I’ll be depending on your questions and input. Share with us on [Twitter](https://www.twitter.com/cubiclebuddha), [Facebook](https://www.facebook.com/cubiclebuddha), or in the comments below about how mindfulness has impacted your work. I can’t believe how awesome it is that friends and coworkers have already reached out with questions and topics from only having read [the first article](https://dev.to/cubiclebuddha/samsara-5-agile-techniques-to-end-suffering-and-increase-learning-27cc-temp-slug-32809)! This is really inspiring. Let’s help each other learn how to find peace.
Black Friday Show Off
Tags: showdev, blackfriday, ecommerce, critique
Published: 2018-11-23 18:58:59

---
title: Black Friday Show Off
published: true
description: 
tags: showdev, blackfriday, eCommerce, critique
---

Tis the season for Coffee Pot Mobs and being thankful for credit cards. I just wanted to show off some of the material I've developed for [Shoolu.com](https://shoolu.com) for our Black Friday Sale.

> ## Feel Free to visit [Shoolu.com](https://shoolu.com) and use code BLACKFRIDAY for 25% Off. 
Black Friday Weekend Only. _Disclosure: I work here_

![Snow Falling Gif](https://thepracticaldev.s3.amazonaws.com/i/7iucmci8rttaw0p08ttc.gif)

The First thing you're greeted with on our homepage is a full width almost full screen banner. I used SVG for the `BLACK FRIDAY | Take An Additional 25% Off` and then just Canvas and JS for the snow falling. 

![Small Banner](https://thepracticaldev.s3.amazonaws.com/i/t6u4xdbw1omi4i9damhn.jpg)

Then if you navigate off the homepage, the banner shrinks and shuffles to not take up as much screen real estate, but still be prominently featured on every page.

![Shoolu Black Friday Landing Page](https://thepracticaldev.s3.amazonaws.com/i/kv6kav0t6kr6xslxo5dv.jpg)

This is the landing page for the sale. Detailing all of the rules and showing off some of the collections we wanted to emphasize on the sale. 

All of this was accompanied by stylistically similar email and social campaigns. 

It's a little late to make changes to any of this, but I'd love to know your feedback so I can improve for the next one!
Automatic Publish for your Android/iOS Apps (Azure Pipelines)
Tags: devops, android, ios, apps
Published: 2018-11-23 18:52:04

---
title: Automatic Publish for your Android/iOS Apps (Azure Pipelines)
published: true
description: Publish Android/iOS apps using Azure Pipelines
tags:  devops, Android, iOS, Apps
---


<h2>What is devops CI tool</h2>

It's wonderful I used it to build and publish my Android/iOS projects.

<a href="http://devops.azure.com" target="_blank">Azure Pipelines</a> is based on <a href="https://fastlane.tools/" target="_blank">Fastlane</a> but it's more user friendly and gives you <a href="https://azure.microsoft.com/en-us/pricing/details/devops/azure-pipelines/" target="_blank">10 free parallel jobs</a>.

<img src="https://thepracticaldev.s3.amazonaws.com/i/ah2eir0b0kekhar1zdkc.png"/>

<h2>Tips while building and publishing your Android App</h2>

- Better to use the Hosted macOS
- make sure that you entered the correct path to your gradlew file
- use the "Google Play - Release" task to release your signed APK to Alpha, Beta or production

<h2>Tips while building and publishing your iOS App</h2>

- Make sure to enter correct path of the workspace
- create an exportoptions.plist file that includes the bundle name and provisioning profile name
- better to use Xcode 9.4 to build your application, and before building it on azure pipeline make sure that all packages are compatible with this version
- make sure that the podfile.lock is not pushed to your git

Try it and let me know if you got any problems

Hazem Torab
<a href="https://www.enozom.com">Enozom</a>
Where to start - Front-end or Full Stack Javascript? 
Tags: discuss
Published: 2018-11-23 18:48:55

---
title: Where to start - Front-end or Full Stack Javascript? 
published: true
description: 
tags: discuss
---
Hiya! I'm just getting started, and is planning on doing a Treehouse techdegree course. I'm debating whether to start with Front-end or Full stack javascript. I look forward to building stuff with JS, but I'm afraid if it has a steep learning curve. Please advice? Thanks!
How to build a (Drake) Twitter bot
Tags: twitter, bot, twitterbot, ruby
Published: 2018-11-23 18:12:53

---
title: How to build a (Drake) Twitter bot
published: true
description: How to build a Twitter bot that replies to tweets containing Drake lyrics with the next line of the song
tags: twitter, bot, twitterbot, ruby
---

I was at a bar with an old group of friends over the 2017 holidays. While we were waiting in line, one of them mentioned that he heard about a Twitter-bot that replied to tweets containing Biggie Smalls lyrics with other Biggie Smalls lyrics.

I thought the idea was hilarious, and after one or six beers decided it was something I had to build! However, I wanted to do things a little differently:

- ~~I rep the 6~~ I live in Toronto, so the Twitter-bot would be for Drake - a.k.a the DrizzyBot
- The DrizzyBot should reply to tweets containing Drake lyrics with the next line of the song
- The DrizzyBot should run at regular intervals with no human interaction

After a day of programming, tinkering, and giggling, the DrizzyBot was born.

Follow the DrizzyBot here: [@The110God](https://twitter.com/The110God?lang=en) *(Note: 6 in binary is 110)* 😏

View the [source code for the DrizzyBot here](https://charliereese.ca/blog/7-a-drake-twitter-bot-automating-the-6-god). Note: the source code is in ruby and is only ~100 lines