teleren/devto huggingface dataset:
Streaming Images & Videos to Google Cloud Storage with Node.js, Express, and Multer 
Tags: node, googlecloudstorage, aws, programming
Published: 2019-05-29 08:00:05

---
title: Streaming Images & Videos to Google Cloud Storage with Node.js, Express, and Multer 
published: true
tags: nodejs,google-cloud-storage,aws,programming
canonical_url: https://hackernoon.com/streaming-images-videos-to-google-cloud-storage-with-node-js-express-and-multer-%EF%B8%8F-7455c60f310
---

![](https://cdn-images-1.medium.com/max/1024/1*Z68F4SMRusBjJ7Q8ox4Waw.jpeg)

### **The Problem** 😒

I was tasked with transitioning code that's primary focus was to upload high-resolution images and large video files. It had to be highly reliable and more importantly, no longer live on AWS S3. I’m not going to get into the details of S3 vs. other storage providers, but I will say that Google’s infrastructure was extremely pleasing to work me when I chose to use Cloud Storage — a beautiful UI, amazing file explorer, and dozens of options that actually make sense (to me) opposed to S3.

One problem… Google has almost zero examples for uploading images that are **NOT** on disk to Cloud Storage. And, if they do have them, they appeared to be way out of date for my liking. After a giant headache and hours of researching StackOverflow, looking at the SDKs source code, etc., I can now say that I’ve accomplished the task… I can _finally_ upload images using Express.js and Multer, and I’m happy to share the code that makes it all work.

### Requirements 📜

1. Upload **any** media file (audio, video, image, etc.)
2. Custom **UUID** for the name
3. Append proper **extension** to end
4. Get **MIME** type to pass to Google Cloud Storage
5. Set object ACL to “ **public”** so that we can view in the browser

### **Solution** 🚨

[Express](http://expressjs.com/), [Multer](https://www.npmjs.com/package/multer), and the [Google Cloud Storage](https://www.npmjs.com/package/@google-cloud/storage) package for Node.js. See below for code examples:

#### 1. Route File 🚓

{% gist https://gist.github.com/nparsons08/e4db5a7a3c198c8f2bb9bd18c387b80b %}

#### 2. Controller 🚂

{% gist https://gist.github.com/nparsons08/4eb23c5a8e205272e3b382730be617fe %}

#### 3. Config 🛠

{% gist https://gist.github.com/nparsons08/312561c61c71ec0a9e163bff58707069 %}

### That’s it! 👏

Pretty simple, right? If you have any questions about your implementation, drop them in the comments below or hit me up on [Twitter](https://twitter.com/nickparsons). I’m always happy to help!

* * *
Ethereum / Solidity Smart Contract Debugging Course
Tags: solidity, debugging, smartcontract, ethereum
Published: 2019-01-22 01:37:51

---
title: Ethereum / Solidity Smart Contract Debugging Course
published: true
description: 
tags: Solidity, debugging, smart contract, Ethereum
---

I have just released a course on [Smart contract debugging with Solidity](https://eattheblocks-pro.teachable.com/p/smart-contract-debugging). Covers Remix debugger, Truffle debugger, how to console.log in Solidity like you do with Javascript and tons of other insights.

For [10 USD / month](https://eattheblocks-pro.teachable.com/p/all-access-monthly-subscription) you can get access to not only this course but all the other videos on EatTheBlocks Pro - more than 70 videos, 10h of exclusive content, 1 new video a day, that's the largest learning resource for Ethereum / Solidity, always kept up-to-date (Solidity 0.5.0, Truffle 0.5.0...).

[Link](https://eattheblocks-pro.teachable.com/p/smart-contract-debugging)

![Ethereum / Solidity Smart Contract Debugging Course](https://thepracticaldev.s3.amazonaws.com/i/utwcia2v8dvy0dxr00qd.png)
The best and easy way to handle database migrations (version control)
Tags: database, migrations, mysql, sqlserver
Published: 2019-04-21 15:20:08

---
title: The best and easy way to handle database migrations (version control)
published: true
tags: database,migrations,mysql,sql-server
canonical_url: https://dev.to/arojunior/the-best-and-easy-way-to-handle-database-migrations-version-control
---

Do know about database version control? It's called migrations and here I will tell you how to do it in a simple way.

If you know about it and work with JavaScript, you probably have tried one of these tools to handle database migrations: Sequelize, TypeORM, Bookshelf, etc… But, seriously… Are you happy with these options? I'm not.

Since I started to work with Java and met the beautiful [Flyway](https://flywaydb.org/), I was missing a tool as great as it is in another languages. And now comes the good news: there's a "dockerized" version that you can use with any language you want!

![](https://cdn-images-1.medium.com/max/400/1*i1CR1OLgeD_FWxkiMyRmnQ.png)

So if you trust me, keep reading about this magical tool.

The examples bellow are here: [https://github.com/arojunior/tests-with-nodejs-graphql](https://github.com/arojunior/tests-with-nodejs-graphql)

{% gist https://gist.github.com/arojunior/4d4d73ff2ee51ede4e2c891bdd29efa3 %}

Then we can create the config file and the migrations, as you can see in the volumes arguments.

![](https://cdn-images-1.medium.com/max/816/1*N5-KXLyg7yAfOog089qzUw.png)<figcaption>folder tree</figcaption>

{% gist https://gist.github.com/arojunior/49f76899c6b9c9537b401355edaac107 %}

Those names for the migration files are following a convention that you can find [here in the documentation](https://flywaydb.org/documentation/migrations#naming), but it's very simple:

![](https://cdn-images-1.medium.com/max/1024/1*qt1hz-aaq3hh1d3mMoKn_w.png)<figcaption>filenames convention</figcaption>

Did you notice that the file extension is .sql? Yes! You are able to write plain SQL scripts and don't need to learn a new syntax or object mappings. That's what I love in this tool.

{% gist https://gist.github.com/arojunior/68eecee3ef215830000e1a43d907cb4d %}

{% gist https://gist.github.com/arojunior/018a09679b8da04e7f9da4c5a56a7cfb %}

Flyway will create a table to manage the migrations and it runs automagically every time you start the container. It will check the applied scripts and run the new ones. No additional command is needed, you just have to create the new files in the specified folder.

Flyway supports also SQL Server, Postgres, Oracle, MariaDB and more…

Take a look in the documentation for more infos: [https://flywaydb.org/documentation/migrations](https://flywaydb.org/documentation/migrations)

Now clap your hands for this amazing tool.

* * *
Monday Music Exchange
Tags: discuss, music, musicexchange
Published: 2019-01-22 00:34:59

---
title: Monday Music Exchange
published: true
description: 🎧 Music to Fuel Your Week 🔥 Leave a Song and Take a Song
tags: discuss, music, musicexchange
series: Monday Music Exchange
cover_image: https://radiostaticphilly.files.wordpress.com/2014/04/040814_fishtown_record_swap_iv.jpg
---

Hey fellow DEV's!

I am always on the hunt for good music to listen to while programming and can quickly find myself in musical ruts. Let's all avoid musical ruts together and post some of our favorite tunes in the comments.

I'd love to make this a weekly thing if there is enough interest. I'll post a playlist of everything shared from the previous week in the following week's post.

P.S. Spotify URI's are [now embeddable](https://github.com/thepracticaldev/dev.to/pull/1573) 😁
Carpe Diem
Tags: writing, beginners, showdev
Published: 2019-01-22 00:29:16

---
title: Carpe Diem
published: true
description: seize the day
tags: writing, beginner, showdev
---

# I've made it Mom
I finally landed my *first post* here [@dev.to](https://dev.to). It's been **5 months** when I started to join this awesome community of developers and I've always wanted to post or write something but there is always someone holding me back **(myself)**.


## maybe I can do it too...
This post may not be the best post for you since english is my secondary language and I'm just an 18 y/o high school drop-out, frontend web developer, and autonomous young adult who don't know really that much about life. but the thing is I'm passionate in learning and exploring new things :).


### thanks.
I really thank this wonderful community of developers here at dev.to who taught me a lot of lessons about (programming, ethics, etc...).
Analytics for developers
Tags: analytics, web
Published: 2019-04-01 06:53:47

---
title: Analytics for developers
published: true
tags: analytics, web
canonical_url: https://stitcher.io/blog/analytics-for-developers
---

I've been running this blog for almost three years now. I've used Google Analytics, not only to track the amount of users, but also to actively improve my blog.

I'm no marketeer, just a simple developer. Today I want to share from my technical experience, how I use traffic data and react to it.

## Filtering data

First and foremost, the boring part. It takes less than five minutes to set up, but will improve the correctness of your data: filters.

As you know, Google Analytics works with a tracking code which you can place everywhere. That tracking code can easily be used somewhere else, polluting your data. I'm thinking of local development environments or, more malicious: people who steal your tracking code as a deliberate attack.

Luckily this can easily be prevented with filters. So take five minutes to set up some filters in the admin section:

![](https://www.stitcher.io/resources/img/blog/analytics/filter-1.png)

With filters, you can build a whitelist of traffic you want to include. I usually make a separate view called "Filtered", and keep the "All Web Site Data" view as is, for testing.

Here's an example of a filter I set up, to only include traffic from the "stitcher.io" domain:

![](https://www.stitcher.io/resources/img/blog/analytics/filter-2.png)

You can also filter out local domains, whitelist IP addresses and more. If you want to be really safe, you could whitelist the IP address of your host, in combination with the host name.

With the correct filters set up, it's time to interpret data.

## Decreasing bounce rate

Here's a good question to start with: "should I want to decrease my bounce rate"? The corporate marketeer will of course scream "YES".

Continue reading on [https://stitcher.io/blog/analytics-for-developers](https://stitcher.io/blog/analytics-for-developers)
Tracing requests in Node.js?
Tags: api, node, discuss, help
Published: 2019-01-21 23:49:36

---
title: Tracing requests in Node.js?
published: true
description: 
tags: api, nodejs, discuss, help
---



TLDR;
- How can I maintain request context without having to pass the logger (or requestId) around and without using `cls-hooked`?
- If there's no better way than passing the logger, how do I the carry the type info of the logger(ideally without JSDocs)?

Any one using a different pattern that's cleaner than passing the logger around? I've tried using [express-http-context](https://www.npmjs.com/package/express-http-context) (and other `cls-hooked` based libraries), but it isn't very reliable because the context gets lost in some cases.
The only [slightly better approach](#improved-solution) I've come up with is to make all modules into classes so that only the constructor needs the logger, but then the logger still has to be passed down from the caller.

Another problem with passing the logger around is that the typing information is lost, so I have to remember the structure of the object. It's not a big deal for me, but it leads to subtle bugs, especially for developer that aren't as familiar with the codebase as I am.


## Current solution

```javascript
// routes.js

app.get(
    '/api/v1/customer/:id',
    async (req, res, next) => {
        const id = req.params.id
        // The logger contains multiple fields request-specific fields like
        // request ID and authorization level
        const logger = req.logger
        const customer = await customerService.get(id, logger)

        /// ... process and return response
    }
)
```

```javascript
// customer-service.js

module.exports.get = async (id, logger) {
    /// ...
}

module.exports.create = async (customer, logger) {
    // ...
}
```


## Improved solution

```javascript
// routes.js

app.get(
    '/api/v1/customer/:id',
    async (req, res, next) => {
        const id = req.params.id
        // The logger contains multiple fields request-specific fields like
        // request ID and authorization level
        const logger = req.logger
        const customerService = new CustomerService(logger)
        const customer = await customerService.get(id)

        /// ... process and return response
    }
)

app.post(
    '/api/v1/customer',
    async (req, res, next) => {
        const customer = req.body
        const logger = req.logger
        // Downside: still have to pass logger to constructors
        const customerService = new CustomerService(logger)
        const customer = await customerService.create(customer)

        // ... process and return response
    }
)
```

```javascript
// customer-service.js

class CustomerService {
    constructor(logger) {
        // logger is only passed into the constructor
        this.logger = logger
    }

    module.exports.get = async (id) {
        // ...
        this.logger.info(/*data to log*/)
        // ...
    }

    module.exports.create = async (customer, logger) {
        // ...
        this.logger.info(/*data to log*/)
        // ...
    }
}
```

Any solutions or tips are greatly appreciated :)
Is there a drop in JS Array-compatible React/Vue-friendly linked-list library?
Tags: help, vue, javascript, datastructures
Published: 2019-01-21 23:30:55

---
title: Is there a drop in JS Array-compatible React/Vue-friendly linked-list library?
published: true
description: Trying to solve very annoying bug without rewriting the entire thing.
tags: help, vue, javascript, datastructures
---

Hello friends!

I have the following collection:

```javascript
messages = [{ ... }, { ... } ]
```

Which I sometimes map over, unshift, and push onto. It hit me... 2 months ago... that _really_ it needs to be a linked list, and not an array; as sometimes I need to render different things depending on information in the next or previous message.

I've procrastinated swapping out the collection's underlying data structure because most of the bugs were not related to the array-ness of the messages collection.

However I'm finally butting up against some bugs (again) where swapping the array for a linked list seems like the most reasonable course of action.

Do any of you know about a drop-in JavaScript Array replacement that plays nicely with the reactive nature of Vue 2?

I've found that most drop-in replacements don't take into account that Vue requres you to use `Vue.set` when adding new properties to an Object; and most LinkedList implementations use an object as their underlying data structure.

Any help would be greatly appreciated!

Zee
Day 21: Swift macOS password manager for people who hate the cloud
Tags: macos, swift, passwordmanager, cloud
Published: 2019-01-21 23:09:56

---
title: Day 21: Swift macOS password manager for people who hate the cloud
published: true
description: Follow along as I make a 100% cloudless and 100% native password manager for macOS. That's 200% raw password managing power.
tags: macos, swift, password manager, cloud
series: Making a swift MacOS password manager for people who hate the cloud
cover_image: https://thepracticaldev.s3.amazonaws.com/i/q6r73zbfbm3mpfs98bu5.jpg
---

[<- For Day 20 go here](https://dev.to/swlkr/day-20-swift-macos-password-manager-for-people-who-hate-the-cloud-5cn9)

📅 01/21/2019
🚀 [9 days until launch](https://www.producthunt.com/upcoming/all-your-passwords)
🔥 20 day streak
💰 $2.99 price
🤑 $0 revenue
📈 0 customers
⌚️ 34 hours spent
💻 82 files changed, 247751 insertions(+), 545 deletions(-)
🏁 Today's goal: **Fix favicon parsing because it sucks. Add copy buttons (and actually commit them this time)**

**7:00 AM**
I wanted to take a minute to talk about all of the things that are still missing with 9 days left until I launch this on [product hunt](https://www.producthunt.com/upcoming/all-your-passwords)

- No logo
- No beta testers (let me know if you want to beta test this thing 😬)
- No landing page (I really like [this one](https://twizzy.app), but [ain't nobody got time for that](https://www.youtube.com/watch?v=zGxwbhkDjZM))
- No copy buttons (still)
- No companion iphone app for the cloudless syncing
- No 1password import
- No csv import
- No csv export
- No json export
- No browser extensions (I don't use these anyway for [securitay](https://twitter.com/SwiftOnSecurity) purposes)
- No upvote army on product hunt or hacker news (unless I can count you guys/gals/bots in 😉)

Now that I've listed all of the missing things, I should list some things that aren't missing

- Moxie

Moving on.

**4:00 PM**
Check it out, copy buttons back in, now I mean the design isn't too [hot](https://www.youtube.com/watch?v=lZPRhmR3-I4) 🔥 but this thing is fully functional, minus the wifi/bluetooth syncing to my phone, which I'll have to get to … later, but don't you worry, your $2.99 is going to get you much more than a tall white chocolate mocha.

![](https://thepracticaldev.s3.amazonaws.com/i/cu1f6udl79tdxv9ht6qj.png)

I'll be back 🕶 to work on this later probably, or I might just watch [pewdiepie](https://youtube.com/pewdiepie) and then get lost in netflix's autoplay feature, you never know. Oh and for the love of t-series, subscribe to [pewdiepie](https://youtube.com/pewdiepie)

Never did come back to my computer, but as always I'll be back tomorrow.
Search Ruby Method Declarations in vim
Tags: vim, ruby
Published: 2019-01-21 23:03:20

---
title: Search Ruby Method Declarations in vim
published: true
description: 
tags: vim, ruby
---

While searching method declarations in vim can be tricky and you can use `ctags`, I found that using `ag` or [the silver searcher](https://github.com/ggreer/the_silver_searcher) yields great results.

I've been an active vim user for almost 3 years now and primarily develop Rails apps. I started using vim because I really liked the idea of having your entire development environment on one screen.

Run your server, tests, install gems, write code, without leaving or `Alt + Tab`'ing out.

As developers, we occasionally find the need to search for the method declaration. Here are a couple `vimscript` functions you can use along with `<Leader>` commands to efficiently search for the method declarations and increase productivity.

```vim
function! SearchForDeclarationCursor()
  let searchTerm = expand("<cword>")
  call SearchForDeclaration(searchTerm)
endfunction
```

Here we just expand and capture the word where the cursor is.

```vim
function! SearchForDeclaration(term)
  let definition = 'def ' . a:term
  cexpr system('ag -w ' . shellescape(definition))
endfunction
```

This function prepends the word `def` with the search term. This will give you a string like `def some_method`. `system` function executes any `bash` commands provided to it. The `-w` option matches the exact search term, thereby giving us accurate results.

And finally, we can map this to a `<Leader>` command.

```vim
map <Leader>cd :call SearchForDeclarationCursor()<CR>
```

Hope this helps ya'll!
After Software Development what's next?
Published: 2020-11-08 00:50:51

---
title: After Software Development what's next?
published: true
tags: 
canonical_url: http://andrewmiracle.com/posts/after-software-development-what-next
---

I recently came across an acquaintaince who had about 20 years of experience in the software development field, and was wondering what next he should do at this point in his career and life, though I didnt have the opportunity to share my answers to him, at the top of my head, these were my thoughts

- Management
- Mentorship

### Management

With over 20 years in your belt, you should have the opportunity to notice how trends have been shaped, improved and change, move to the top of the Product Development Cycle which is either **(idea =\> design)** or _(design =\> implementation)_ or **(design =\> user adoption)** you should be able to match any of these with your personal capacity and strengths.

### Mentorship

Give back to the community, what is it that you have learnt over this years that you can share with the younger generation of budding software developers and enthusiasts, trust me, its a very lonely journey for those starting and having someone with long term experience to talk to can be de-stressing and comforting, the side benefit is that, it helps you keep up with the latest trends in technology and also keep you abreast with industry trends too.

However, after spending over 20 years in any field, I tend think that there are a broad spectrum of choices after that long period of time, anyone should have figured their edge and strengths by now to know where they can focus the remaining part of their time and energy on.
why do I still use cakephp
Tags: cakephp, php
Published: 2019-01-21 22:57:51

---
title: why do I still use cakephp
published: true
description: 
tags: cakephp, php
---

I have been working with cakephp for over an year now and I love working with it. Here are some of the best things I find about it.

1. **Convention**: although it's not mandatory to use it, I can't find a reason not to use it. Things that looked so stupid a year ago is a must have in every framework I am introduced to these days. It makes your life so easy.

2. **Simple setup**: I have setup dynamic websites with admin panels in a night using this baby. All thanks to it's crud scaffolding and templates.

3. **Routing**: even though this is used by many, it feels so good that you get friendly URLs everytime.

4. **Power of PHP**: PHP is a very powerful language. Sure there are lots of new ones in the market, but to have such a big community and speedy results to any queries on Google is a God sent. P.S. am not against JS frameworks. I just don't feel the need to use it yet.

5. **Debugging**: oh the log files always save you. 

6. **ORM**: another awesome way to help you while running multiple queries at once. 

7. **Plugins**: lots of wonderful snippets. Even some of the biggest companies provide cakephp sdks of their products. 


I am yet to feel the power of PHP 7 which boasts of being atleast 2x faster than the older version. Fingers crossed.

**Please correct me if I am wrong**