teleren/devto huggingface dataset:
Bug Report #2 - Lazy Select In C#
Tags: bugreport, csharp, linq, post
Published: 2019-01-20 15:18:46

---
title: Bug Report #2 - Lazy Select In C#
published: true
tags: bug_report,csharp,linq,post
canonical_url: https://horia141.com/bug-report-2.html
series: "Bug Report"
---

This is the second in a series of articles about bugs I encounter while working. The [first one](http://horia141.com/bug-report-1.html) was about `GETUTCDATE()` and how it complicates things in longer queries.

Today’s bug is about [LINQ](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/getting-started-with-linq) and the lazy `IEnumerables` it produces. A one-off script on which I spent way too much time worked something like this:

```
IEnumerable<Item> items = RawItems().Select(i => i.Transform());
foreach (var item in items)
    item.name = $"{item.name} #Modified";
UpdateItems(items);
```

Granted, not the most elegant code. But I thought it was enough to do it’s job. Turns out there’s a simple yet subtle bug occurring. Turns out that `Select` is quite lazy, so `items` is more like a promise that if you’re iterating it you’ll get the result of `Transform()` applied to each element from `RawItems`. But every time the iterator is used, that computation gets redone.

So the `foreach` loop actually modified each resulting element from one invocation of the iterator, but all that data was thrown away. When `UpdateItems` used `items` it obtained a new version of the derived data, without any of the modifications.

The solution is simple. Either include the modification as part of the `Select` and alongside `Transform`. Or make `items` non-lazy, by turning it into an `List` or `Array`, which is what I ended up doing for simplicity’s sake in my actual setup. So the code was now just:

```
IEnumerable<Item> items = RawItems().Select(i => i.Transform()).ToList();
foreach (var item in items)
    item.name = $"{item.name} #Modified";
UpdateItems(items);
```

Since the `foreach` loop and `UpdateItems` now referenced a list, instead of the iterator over something, the desired behaviour was achieved.
I created @ThePracticalDev and dev.to, ask me anything!
Tags: ama
Published: 2017-09-20 17:42:17

---
title: I created @ThePracticalDev and dev.to, ask me anything!
published: true
description: I am a software developer from Canada who started this thing you're using right now if you are reading this AMA. Ask me ANYTHING!
tags: ama
cover_image: https://thepracticaldev.s3.amazonaws.com/i/5jpy8tb052sl8qs9oxnx.png
---

Ask away, I'd love to share! â¤ï¸
HtC: SD — Week 3: Designing Worlds and Compound Data
Tags: learntocode, programming
Published: 2020-01-14 00:06:01

---
title: HtC: SD — Week 3: Designing Worlds and Compound Data
published: true
date: 2017-09-20 17:18:17 UTC
tags: learn-to-code,programming
canonical_url: 
---

I learned a lot this week, no surprise there. The first half of the week focuses on designing worlds via the big-bang function in Racket. Think of the big-bang as a sort of event loop (but it’s much different in implementation due to Racket being a functional language). So as big-bang runs, you need to tell it what to do by writing different functions. But well before that, you need to address your data! The most important thing is always the data definition, and with compound data even moreso.

Compound data is data that is “naturally” linked together. Think x,y coordinates, speed and position, or name and age. If you want to track more than one piece of data, then you’ll need compound data. It’s fairly simple to initialize via define-struct your-struct . Luckily this course has a language reference because I keep forgetting where parens should go.

OK next I learned to design worlds with this compound data, the lecture topic was a cow that walked back and forth across a screen and changed directions when it hit a wall or the user pressed the space bar. Again, we have these recipes to guide our design. The most difficult part for me is writing the check-expect which is the test you write before even coding the function to compare inputs with expected outputs. Usually a good check-expect will write your function for you. To give an example if I write (check-expect (double 2) (\* 2 2)) I mean to say that when I run double on 2 I expect to get out 2\*2 or 4. Writing 2\*2 instead of 4 actually illuminates what the function should do, which helps you and any future user.

I also worked through all the practice problems this week before attempting the “Design Quiz” I’ll tell you nothing gave me more grief than rolling this little bastard back + forth across the screen.

![](https://cdn-images-1.medium.com/max/589/1*-WGNQSrtIKF3oF7yrpsKrA.png)<figcaption>I hate you lambda man!</figcaption>

The first part of the problems was just to slide back and forth, which was relatively simple because we had worked through a similar problem in class. The second part was to make it rotate while spinning. This was harder as I had to modify my data structures to account for rotation, luckily the rotate function can accept negative numbers, so it can change directions of rotation.

Finally we had to adjust rotational speed based on radius to actually “roll” it back and forth. Man this was a nightmare, the formula was given to change degrees rotation to distance required to travel, but I only had a velocity component. After some time I realized that a velocity dx scaled by rotational speed (2pi\*r/360) would give the required change in angle dr. Anyway that guy rolls! These recipes make the design process more straightforward, and if you force yourself to stick with them you won’t get sidetracked or forget edge cases.
At least 36 millions of WordPress websites vulnerable
Tags: wordpress, security, xss, sqlinjection
Published: 2017-09-20 17:18:09

---
title: "At least 36 millions of WordPress websites vulnerable"
published: true
description: WordPress 4.8.2 comes with fixes for 9 vulnerabilities, but refuses to fix CVE-2017-8295 WORDPRESS 4.8.2 COMES WITH FIXES FOR 9 VULNERABILITIES, BUT REFUSES TO FIX CVE-2017-8295 

tags: WordPress, security, xss, sql injection
---


On 19 Sep, 2017, WordPress 4.8.2 was released to the public. Nine high security issues are fixed but Core Team still refuses to fix CVE-2017-8295 - Host Header Attack Vulnerability. 36 millions of websites affected.

Read full article [here](https://learnwebdevelopment.review/article/wordpress-482-fixed-9-vulnerabilities-but-still-refuses-to-fix-cve-2017-8295)
Why I made Unnamed?
Tags: unnamed, css, dev
Published: 2018-09-23 14:14:30

---
title: Why I made Unnamed?
published: true
tags: unnamed, css, dev
canonical_url: https://smakosh.com/unnamed
---

> This article was originally published on my personal blog [Smakosh](https://smakosh.com/blog).

[![Unnamed](https://smakosh.com/static/unnamed_blog-f08c898f6c12d7c0fe89b6eb3fb974ed-f7d78.jpeg)](/static/unnamed_blog-f08c898f6c12d7c0fe89b6eb3fb974ed-f7d78.jpeg)

I hate when I use a known css framework like Skeleton or Bulma… and specially frameworks like Bootstrap or Foundation…

Because of many reasons but here’s the main reason: “since I’m also an UI designer, I always have to rewrite the entire css code of the UI elements like buttons, forms, cards…”.

So I started going deep in css, like the trick to style a radio or checkbox button (hiding the input and styling the span tag), learned a lot about flexbox, about the standard way to make a grid system (floats & widths), flexbox grids & also cssgrid & a lot more…, and so I started posting pens of each styled element on my [codepen](https://codepen.io/smakosh) until one day I was designing an UI kit at 2 am — lol — and I thought about coding each element & that’s when I started coding the framework, I didn’t think about sharing it or open sourcing it but then I thought why not? some would love to use it too right? & so, I published it, made it open source & included everything on the github repository for the front end developers who would love to edit everything.

Unnamed is easy to use & to edit!, there is also a npm module

```
$ nmp i unnamed
```

& import it if you’re using webpack

```
import 'unnamed'
```

There is also a CDN if you’re not used to the node eco-system

```
https://unpkg.com/unnamed
```

I got a positive & negative feedback on Product hunt that really made me go forward and make more useful products so expect more soon!

Docs: [https://unnamed.smakosh.com](https://unnamed.smakosh.com)

On github: [https://github.com/smakosh/unnamed-css-framework](https://github.com/smakosh/unnamed-css-framework)
Why There Is A Need For AngularJS Technology in Any Business?
Tags: angularjs4, angularjsdevelopment, angularjscompany
Published: 2017-09-20 09:05:22

---
title: Why There Is A Need For AngularJS Technology in Any Business?
published: True
description: Every now and then, there comes a trend that takes over everything, from décor to fashion to food and technology is the mastermind behind all these changes. Over the past few years, there was a trend of modern style website that came up on a single page. Today, a new trend has been developed with a better technology named AngularJS. And it is one of those trends, but instead of getting tired of it, I continue to be amazed by all the ways it has incorporated into our businesses.
tags: angularjs 4, angularjs development, angularjs company
---

<p>For those who have no idea about Angular JS, it is an open source structural framework featuring dynamic web application technology. Developed by Misko Hevery and Adam Abrons in 2009, the technology turns out to be so amazing that you do not have to depend much on coding that was done previously. Besides, It is very much compatible with the browser that makes it unique operating with any server technology.</p>

![AngularJS framework](https://thepracticaldev.s3.amazonaws.com/i/7qde0r088uej7sz973qo.png)

##Its key features include:
•    Powerful JavaScript-based framework
•    Allows developers to write a client-end application
•    Holds the Model View Controller pattern
•    Free and licensed under the Apache License version 2.0
•    Open source software framework which is used by thousands of developers. 

###Why Use AngularJS Web Application Development Programs For Your Business?
•  Large community- One can hire a well-founded AngularJS development company[AngularJS development company] or contact freelancers who are available in large masses to sort out issues for the web application. 
•  Easy Code pattern- The application designed with AngularJS is designed in such a way that HTML turns out to be the main structure for design. The coding gets light-weighted and easy with the proper end result.
•  POJO- Plain Old JavaScript Objects is a simple model used by AngularJS through which one can modify things on the direct basis and can also loop over the objects as well. 
•  Simple Directives- The directives enable the coders to make their own HTML elements. Apart from that, it also helps the MVC to update the view of new data separately. However, this view solely depends on the directives.
•	Filter options- Filters arrange the data before reaching the view and can create a format of simple decimal places. These are also basically concerned with data transformation.
Conclusion

<p>By incorporating AngularJS and its features, one can end up having a better user experience for your entire web application. So all I can say is save your time and money with fewer days of coding, but with better technology.</p>
Hi, I'm Roger Stach
Tags: introductions
Published: 2017-09-19 22:33:34

---
title: Hi, I'm Roger Stach
published: true
description: 
tags: introductions
---

> I know I have created older posts before this, I just want to introduce myself.

I have been coding for 2 years.
You can find me on GitHub as [klopango](https://github.com/klopango)
I live in Jakarta, Indonesia.
I work as a freelancer.
I mostly program in these languages: JavaScript, Python & NodeJS.
In my spare time, I usually [write about stuffs](https://roger.js.org), [tweet random stuffs](https://twitter.com/klopango_) & [capture random stuffs](https://instagram.com/klopango).
Python: bare except statement - why it is bad.
Tags: python
Published: 2019-11-12 20:27:20

---
title: Python: bare except statement - why it is bad.
published: true
date: 2017-09-19 22:00:00 UTC
tags: python
canonical_url: http://moserei.de/2017/09/20/python-bare-except.html
---

The bare `except` statement is something I often see in the main loop of a script that should run indefinitely. [Pylint will warn](http://pylint-messages.wikidot.com/messages:w0702) you about this problem, but in my opinion we should start to treat this as an error.

Consider the following code snippet:

```python
import sys
import time

def risky_business():
  time.sleep(1)

while(True):
  try:
    risky_business()
  except:
    print("Problems?", sys.exc_info())
```

This will work nicely to keep your program running whatever happends inside you`risky_business` function. But let’s try to stop your program by pressing CTRL-C.

```
$ python a.py 
^C('Problems?', (<type 'exceptions.KeyboardInterrupt'>, KeyboardInterrupt(), <traceback object at 0x7f234f6c9dd0>))
```

We caught the `KeyboardInterrupt` exception and just carried on. But we catch more which we should not. Let’s try to exit the program from the business function, maybe because the user asked for it or we got signaled.

```python
def risky_business():
  time.sleep(1)
  sys.exit(0)
```
```
$ python a.py 
('Problems?', (<type 'exceptions.SystemExit'>, SystemExit(0,), <traceback object at 0x7f49b7ab5e18>))
('Problems?', (<type 'exceptions.SystemExit'>, SystemExit(0,), <traceback object at 0x7f49b7ab5ea8>))
...
```

So why is this happening? Both `KeyboardInterrupt` and `SystemExit` are exceptions (derived from `BaseException`). An `except` statement without any restriction will catch any exception derived from `BaseException`. [Here is the complete hierachy of the builtin exceptions.](https://docs.python.org/3.5/library/exceptions.html#exception-hierarchy)

We can fix our problem by restricting the kind of exception that we want to catch:

```python
def risky_business():
  time.sleep(1)

while(True):
  try:
    risky_business()
  except Exception:
    print("Problems?", sys.exc_info())
```

When we press CTRL-C now, the program exits with the right exception.

```
$ python a.py
^CTraceback (most recent call last):
  File "a.py", line 10, in <module>
    risky_business()
  File "a.py", line 6, in risky_business
    time.sleep(1)
KeyboardInterrupt
```

Pylint will still [warn](http://pylint-messages.wikidot.com/messages:w0703) you about this line, because catching `Exception` is still very broad and you should only do this when you have a good reason, e.g. the reason mentioned above (to keep a service running even if it could not handle a certain input or request).

So next time you see a bare `except` statement in your code, take a moment to reconsider if you really want to catch `SystemExit`, `KeyboardInterrupt` (and`GeneratorExit` which I did not mention above). If that is the case, you might want to make it explicit so that the next person reading the code does not have to check again.
Explore Bucharest -- Traian Area
Tags: bucharest, explore, traian, post
Published: 2019-01-20 15:18:43

---
title: Explore Bucharest -- Traian Area
published: true
tags: bucharest,explore,traian,post
canonical_url: https://horia141.com/explore-bucharest-traian.html
series: "Explore Bucharest"
---

Pictures taken in July. I forgot about them and finally managed to upload them.

![Traian 1](https://horia141.com/assets/traian-1.jpg)

![Traian 2](https://horia141.com/assets/traian-2.jpg)

![Traian 3](https://horia141.com/assets/traian-3.jpg)

![Traian 4](https://horia141.com/assets/traian-4.jpg)

![Traian 5](https://horia141.com/assets/traian-5.jpg)

![Traian 6](https://horia141.com/assets/traian-6.jpg)

![Traian 7](https://horia141.com/assets/traian-7.jpg)
Explore Bucharest -- Around The Catholic Cathedral
Tags: bucharest, explore, victoriei, cathedral
Published: 2019-01-20 15:18:40

---
title: Explore Bucharest -- Around The Catholic Cathedral
published: true
tags: bucharest,explore,victoriei,cathedral
canonical_url: https://horia141.com/explore-bucharest-victoriei.html
series: "Explore Bucharest"
---

Pictures taken in June. I forgot about them and finally managed to upload them.

![Victoriei 1](https://horia141.com/assets/victoriei-1.jpg)

![Victoriei 2](https://horia141.com/assets/victoriei-2.jpg)

![Victoriei 3](https://horia141.com/assets/victoriei-3.jpg)

![Victoriei 4](https://horia141.com/assets/victoriei-4.jpg)

![Victoriei 5](https://horia141.com/assets/victoriei-5.jpg)
Who Cares?
Tags: developer
Published: 2017-09-18 22:05:48

---
title: Who Cares?
published: true
description: We constantly question our intentions against an ever-changing industry. There is no better time than now to ask if something really matters, and if it should go with, or against, the grain. 
tags: developer
---

* Does your app work with Vue.js even though all your friends are using React.js? If yes, then who cares.

* Do you still get work without having a portfolio? If yes, then who cares?

* Do you learn better from reading books instead of watching videos? If yes, then who cares? 

* Do you earn money by building sites with PHP instead of a Ruby (on Rails)? If yes, then who cares?

* Did you just buy new running shoes right before the new All Birds released? If yes, who cares?

* Did you learn JavaScript by way of  jQuery? If yes, who cares?

This list could go on forever but you get the picture. The reality with our work, and our lives, is we all do things differently. Unless you’re doing something really wrong, who cares?

If your intentions are well-formed and your work is well-crafted all that matters is helping someone, or something, progress forward. 

You may not work at the hottest startup or on the newest product. If you enjoy your life, work and everything in between then who cares about what others are doing? You don’t need to follow the "herd" to be happy. You can achieve your personal, professional and financial (or any other) goals by following your intuition, gut and common sense. You can be you and still be happy.

We could spend our days arguing over skeuomorphic design vs flat and the "resurgence" of brutalist sites but will it make our lives, our customers’ lives, or families’ lives better?

Sure, you can have an opinion, you can voice it, you can scream it from the tallest rooftops but here's the kicker, **your opinion may not be someone’s fact**. It isn’t a truth to be told and held over the heads of others in or outside our industry. Your way of doing something may be right for you and your organization, but it may wrong for a friend or another company. 

Our peers are a good barometer for quality but we still must trust our gut to find the right fit, tool, direction. And ultimately, who cares if the decision you make goes directly against the herd as long as you’re happy and it’s positive for you without negatively impacting others. 

Continue to be you, try new things and be open. If you pause because of what other’s may think just ask yourself one question - who cares?

Big thanks to [Pavan Trikutam](http://graybike.co/), [Monte Brown](http://sandpiper.co/), [Corey Grusden](http://www.sofetch.io/) and [Kyle Crawford](http://www.kylecrawford.co/) for reviewing and editing this post before publishing. 

_This was originally published on May 24, 2017 on [pbj.me/writing/who-cares.html](http://pbj.me/writing/who-cares.html)._
IDE-isms - How does your IDE affect your coding style?
Tags: discuss
Published: 2017-09-19 16:12:58

---
title: IDE-isms - How does your IDE affect your coding style?
published: true
tags: discuss
---

IDEs are really nice tools. With refactoring, auto-completion, and various types of analysis. But they are not perfect. To circumvent IDE bugs, I often alter my coding style to match the IDE and avoid false-warnings.

Do you have any such IDE-specific coding styles?
The non-broken promise of static typing
Tags: typesystem, programming, discuss, javascript
Published: 2017-09-19 13:16:22

---
layout: post
title: The non-broken promise of static typing
published: true
tags: type system, programming, discuss, javascript
---
*Originally posted on [my blog](http://anthonybruno.com.au/2017/09/19/The-non-broken-promise-of-static-typing.html)*

A while back I read an article about how static typing does not prevent
bugs being added to software. The article is appropriately named: [The broken promise of static typing](https://dev.to/danlebrero/the-broken-promise-of-static-typing). The author conducted research by generating and comparing 'bug density' scores for GitHub repositories. The bug density score was determined by getting the average number of issues labelled 'bug' per repository. 

The results showed that there were not any less bugs in statically typed languages vs dynamically typed languages. The author concludes on the results:

> "the lack of evidence in the charts that more advanced type languages are going to save us from writing bugs is very disturbing."

While this article brings up good points and makes an effort at original research, I've always felt that the claims made were wrong. I strongly believe less bugs will occur when a statically typed language is used. However, I've never had any proper evidence to back up my claims...**until now!**

Enter: [The Morning Paper](https://blog.acolyer.org), a blog that summarises tech white papers. It recently released an article talking about the same subject called: [To type or not to type: quantifying detectable bugs in JavaScript](https://blog.acolyer.org/2017/09/19/to-type-or-not-to-type-quantifying-detectable-bugs-in-javascript/).

The article covers a study of the same name. In it, researchers looked at 400 fixed bugs in JavaScript projects hosted on GitHub. For each bug, the researchers tried to see if adding type annotations (using TypeScript and Flow) would detect the bug. The results? A substantial **15%** of bugs could be detected using type annotations. With this reduction in bugs, it's hard to deny the value of static typing.

While these results show a benefit from using static typing, people will continue to prefer a specific type system. So, let's hear from you! What type system do you prefer, and why?
navigator.storage
Tags: javascript
Published: 2017-09-19 12:47:16

---
title: navigator.storage
published: true
description: 
tags: javascript
---

`navigator.storage` is a read-only property that returns a singleton `StorageManager` that will help use fetch the overall storage capabilities of the browser for the current context. 

`StorageManager` helps us to estimate how much more space is available for local storage, it also helps to configure persistence of data stores.


__IDL:__

```idl
[SecureContext,
 Exposed=(Window,Worker)]
interface StorageManager {
  Promise<boolean> persisted();
  [Exposed=Window] Promise<boolean> persist();

  Promise<StorageEstimate> estimate();
};

dictionary StorageEstimate {
  unsigned long long usage;
  unsigned long long quota;
};
```

__Usage:__

Checks for `storage` API existence.

```js
const hasStorage = navigator.storage;
const hasPersist = hasStorage && navigator.storage.persist;

```

Create an stroageManager instance.

```js
const storageManager = hasStorage && navigator.storage;
```

Estimate the available storage space.

```js

const estimate = await storageManager.estimate();

/*
Would give us something like:

{
  quota: 32571287142, 
  usage: 3351594
}
*/
```

Can persist?

```js
const canPersist = hasPersist && await navigator.storage.persist();

// ^ Will be true of false.

/*

true -> Storage will not be cleared until explicitly cleared. 

false -> Storage might be cleared based on UA need.
*/

```



```js
const persisted = hasPersisted && await navigator.storage.persisted();

/*

true -> box mode is persistent for the site's storage.

A box, the primitive these APIs store their data in.
A way of making that box persistent.
A way of getting usage and quota estimates for an origin.

*/

```

__GIF FTW!__

![navigator.storage.gif](https://thepracticaldev.s3.amazonaws.com/i/99bmexjyrri731ffispr.gif)