teleren/devto huggingface dataset:
Getting Back to an Old PostgreSQL Specific Version
Tags: tutorial, postgres
Published: 2018-08-16 09:26:17

---
title: Getting Back to an Old PostgreSQL Specific Version
published: true
description: 
tags: tutorial, postgresql
---

# TL;DR

## Exemple about getting back to 9.6.6 from 9.6.7

```bash
brew services stop postgresql 
brew services stop postgresql@9.6

brew uninstall postgresql 
brew uninstall postgresql@9.6

rm -rf /usr/local/var/postgres .psql_history .psqlrc .psql.local .pgpass .psqlrc.local
```

Select the Postgres.app release having the desired version [here](https://github.com/PostgresApp/PostgresApp/releases/). Install it, "Initialize" the server then run:

```bash
sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/9.6/bin | sudo tee /etc/paths.d/postgresapp
```

Reboot the shell.

# Details

The PostgreSQL version of the project I'm working on at work is `9.6.6`. The problem is that my machine uses a later version. It results in conflicts with the `db/structure` file each time I run a `db:migrate`.

Like most dev running on macOS, I usually use Homebrew. It allows to easily switch to another installed version of a formula by running `brew switch formula@version`. As you guess I tried, but the problem is that Homebrew only handles major versions of each release and I need a specific **minor** version.

Because I also need to switch between old and recent Rails projects, I often have to change the running PostgreSQL version. My current solution is to use the [Postgres.app](https://postgresapp.com).

![Alt Postgres.app](https://thepracticaldev.s3.amazonaws.com/i/uiu88odsbeque9vpswzi.png)

If you already have PostgreSQL installed on your system via Homebrew but want to use a specific version (like a previous one) with Postgres.app, just follow these steps:

## 1. Remove all PostgreSQL version installed

- Check running version `brew services list` then stop them `brew services stop postgresql`.

- Delete all installed formulas with `brew uninstall postgresql` and `brew uninstall postgresql@version` per installed version.

- Then delete the related files `rm -rf /usr/local/var postgres .psql_history .psqlrc .psql.local .pgpass .psqlrc.local`.

## 2. Install Postgres.app

- [Download the release](https://github.com/PostgresApp/PostgresApp/releases/) having the desired version.

- Install it and create a new server:

![Alt Postgres.app](https://thepracticaldev.s3.amazonaws.com/i/rylmc6d1j63yoo1cjbnq.png)

- Initialize it.

## 3. Make PostgreSQL related tools usable with the terminal

This last step allows you to use tools like pg_dump etc. Just run: 

```bash
sudo mkdir -p /etc/paths.d &&
echo /Applications/Postgres.app/Contents/Versions/9.6/bin | sudo tee /etc/paths.d/postgresapp`
```

(Don't forget to replace 9.6 with your version).

Relaunch your shell. Welcome back to the past!

If you have better solution to switch between specific versions of PostgreSQL without external app like I did, don't hesitate to share it! :)
Tell Your Story with Office 365 Sway
Tags: office365, office365sway, sway
Published: 2018-08-16 09:25:12

---
title: Tell Your Story with Office 365 Sway
published: true
description: Create presentations, newsletters, personal storytelling, and visual reports with Office 365 Sway
tags: Office 365, Office 365 Sway, Sway
---

{% youtube GVrygrlZcKI %}
How old have you been when you started programming and what was your first project? 
Tags: discuss
Published: 2018-08-16 08:29:10

---
title: How old have you been when you started programming and what was your first project? 
published: true
description: 
tags: #discuss
cover_image: https://images.unsplash.com/photo-1502342908201-d246470e2526?ixlib=rb-0.3.5&s=bc09d63448afc58154d508ce520fa00a&auto=format&fit=crop&w=1650&q=80
---

When I was about 14 I got in touch with Photoshop and "designed" some themes for [Woltlab Burning Board 2] (https://www.woltlab.com/) (if someone of you even knows this) in my sparetime. After the designing I also wanted to write the templates and CSS for it. I adopted some other CMS and did the same there but my dream was always to become a web designer. So I did an internship and realized that I can't force myself to be creative 8 hours per day.

I did another internship in the same company as developer. I knew HTML and CSS quite okay but PHP came on top. My first project there was a guestbook with an administration panel. Simple CRUD things with self written BB code parser (str_replace ROCKED 🤘!!!), fancy gif smileys, pagination and SQLi + XSS prevention (I exaggerate a bit 😛).

I'm curious what your first project was!
Uninstalling npm packages
Tags: node, npm
Published: 2018-08-16 18:33:34

---
title: Uninstalling npm packages
published: true
tags: node, npm
canonical_url: https://flaviocopes.com/npm-uninstall-packages/
---

To uninstall a package you have previously installed **locally** (using `npm install <package-name>` in the `node_modules` folder, run

```sh
npm uninstall <package-name>
```

from the project root folder (the folder that contains the node\_modules folder).

Using the `-S` flag, or `--save`, this operation will also remove the reference in the [`package.json` file](https://flaviocopes.com/package-json/).

If the package was a development dependency, listed in the devDependencies of the `package.json` file, you must use the `-D` / `--save-dev` flag to remove it from the file:

```sh
npm uninstall -S <package-name>
npm uninstall -D <package-name>
```

If the package is installed **globally** , you need to add the `-g` / `--global` flag:

```sh
npm uninstall -g <package-name>
```

for example:

```sh
npm uninstall -g webpack
```

and you can run this command from anywhere you want on your system because the folder where you currently are does not matter.
Going Into Open-Source Projects as A Way to Brush Up
Tags: opensource, learning, discuss
Published: 2018-08-16 04:52:38

---
title: Going Into Open-Source Projects as A Way to Brush Up
published: true
description: 
tags: #Open-Source #Learning #discuss
---

I want to know if it is a good idea to jump into an Open-Source project as a means to brush off any rust on anything that might be an obstacle.

I have been meaning to jump on a project but have been apprehensive due to the fact that i might not know enough to contribute. Should i let that stop me or jump head on?
A Quick and Dirty Primer to Pointers in C/C++
Tags: c, pointers, guide
Published: 2018-08-16 04:38:17

---
title: A Quick and Dirty Primer to Pointers in C/C++
published: true
description: A quick and dirty little primer on pointers straight from my notes.
tags: C, Pointers, Guide
---
**Note**: This is not meant to teach you how everything works under the hood. This is just for understanding the syntax of pointers and for giving good intuition on how to read and write code which utilizes them.

Anyways,
I was going through some old notes and found a bunch of stuff I wrote about pointers and remembered I had an account on here and figured "why not throw something out there", so here ya go.

##Terminology
**Pointer**: A variable which holds the address of another variable.
**Reference**: Setting a pointer to equal the address of a variable.
**De-Reference**: Reading or Writing to the value at the address pointed to by a pointer.

##Examples
###Modifying a variable via pointer
{% gist https://gist.github.com/AWilliams17/0781b7f3991ac416295d0b1c1319df49 %}

###Passing by Reference vs Passing by Value
{% gist https://gist.github.com/AWilliams17/789be8c1eb8d88f17a9851d9709e8a17 %}

###Pointers to Pointers
{% gist https://gist.github.com/AWilliams17/d99bdb165d1790e188f4b4bac5fbb1e3 %}

###Pointer Arithmetic
{% gist https://gist.github.com/AWilliams17/5e656eeab940274e0fcee8a3378d9a4e %}

###Quick Note About Multiple Pointers in One Line
{% gist https://gist.github.com/AWilliams17/2d2e58fadedec93a93a69297edc5816c %}
##References Used
https://denniskubes.com/2017/01/24/the-5-minute-guide-to-c-pointers/
https://stackoverflow.com/questions/14224831/meaning-of-referencing-and-dereferencing
https://www.studytonight.com/c/pointer-to-pointer.php
https://stackoverflow.com/questions/11598361/why-a-pointer-1-add-4-actually

##In Closing
There you go.
This was pretty fun to write up. Maybe I'll do some more little
primers like this. Hopefully someone found it useful, as
this is all admittedly pretty elementary.
React.js jquery.ripples integration component
Tags: react, opensource, showdev
Published: 2018-08-16 03:25:31

---
title: React.js jquery.ripples integration component
published: true
description: Add a water ripple effect to your background using WebGL.
tags: #react, #opensource, showdev
---
# React Water Wave 💧

<a href="https://xxhomey19.github.io/react-water-wave/" target="_blank"><img width="1440" alt="screen shot 2018-08-16 at 01 22 16" src="https://user-images.githubusercontent.com/12113222/44156457-3fe9509e-a0f3-11e8-9eb3-c045a3323506.png"></a>

[**Demo link**](https://xxhomey19.github.io/react-water-wave/)

[sirxemic/jquery.ripples](https://github.com/sirxemic/jquery.ripples) is so cool, so I decided to build a React component for it. This will make it easier for React developers to use.

Repo: [xxhomey19/react-water-wave](https://github.com/xxhomey19/react-water-wave)
Exposing localhost server to the internet in one minute
Tags: webdev, beginners, testing, devtips
Published: 2018-08-16 01:40:09

---
title: Exposing localhost server to the internet in one minute
published: true
description: Learn how to use ngrok to expose your local server to the internet.
tags: [webdev, beginners, testing, devtips]
---


Sometimes, we found a situation due to multiple reasons, where we need to expose our local server to internet, maybe we need to show our website to a client and doesn't have enough time for deploying, others, we need to test it out a webhook from a third service and we don't want to create a new deployment just for testing purpose.


So, let's go for it.

## ngrok

 There services that offer you to set up a tunnel between their servers and your local machine. There are several of them, nevertheless, my recommendation is `ngrok`.


 It has a freemium model, it fits the most basic requirements.

### How it works

We download and run a program(__ngrok__), specifying which port is our local server listening to. __ngrok__ will connect to their external cloud service, creating a public endpoint redirecting all the traffic from it to your server. That's it, simple.

### Download and setup


1. Download it from [official site](https://ngrok.com/download)
2. Unzip `/path/to/ngrok.zip` into any folder
3. Start an HTTP tunnel in any port you want. Let's do it on 80

```bash
$ ./ngrok http 80 # this command should be run from where ngrok was unzipped
```

```bash
...........
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://82330e5b.ngrok.io -> localhost:80
Forwarding                    https://82330e5b.ngrok.io -> localhost:80
...........

```

That's it. We just need to run our web server in port 80 and starting to receive traffic.

If you want to test it out. You may send a request using curl to our public ngrok domain, `http://82330e5b.ngrok.io` or just open it in a browser. Additionally, ngrok allows `https` connections, this is a great feature when we are testing external services needing a secure connection. 

Note: remember you need to have your local server running on port 80 (for this example).

```bash
$ curl -v http://82330e5b.ngrok.io
```


You can check all requests details using built-in dashboard for ngrok at `http://localhost:4040`

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


That's all. For some people, it could look like a trivial task, but for beginners, this is a starting point.

If you like it, spread the word.

Disclosure: This is for testing purpose, if you are handling sensitive data, avoid using this method because all your traffic is going to pass through a third service.
thumbing nose at my crippling social anxiety and introducing myself to you fine folks :)
Tags: introduction, fun, beginners
Published: 2018-08-16 01:36:21

---
title: thumbing nose at my crippling social anxiety and introducing myself to you fine folks :)
published: true
description:  hey y'all, i'm brand-new to the community, and relatively new to web development as a hobby/passion. i just started using an app called enki for quick daily learning sessions and started a 'social' group there - any other newbies out there who would like to [join me in this enki group](https://enki.com/team/join/rogues_gallery) will be greeted with a smile and plenty of good vibes.
tags: introduction,fun,beginner
---
The Introvert's Guide to Office Networking
Tags: networking, introvert, office, tips
Published: 2018-08-16 01:29:33

---
title: The Introvert's Guide to Office Networking
published: true
description: Networking and office survival tips for introverts
tags: networking, introvert, office, tips
---
Next week I'm starting a new job. The first day at a new job feels like the first day of school to me. I have many of the same questions. 
- When am I supposed to be there? 
- Will someone sit with me at lunch? 
- Will I spill something on my shirt? 
- Where is the bathroom? 

A key to surviving my first day is to allow myself to **not** know everything.  I will need to **ask** and that is okay! It is expected! I am new.

## Introduction and Question Template
You may feel weird asking where simple things are, that is okay, you are new.  I use the following template when asking questions.

- "Hi! I'm Jenn, and I'm new.  Do you know where the extra office supplies are?"
- "Hi! I'm new. Can you tell me where the bathroom is?"

This format is the same as the one Inigo Montoya uses in the Princess Bride.

{% twitter 1027445459353096192 %}


## Tips for Office Networking
I use five simple rules to help guide me when networking at work.  These help me feel more effective and less like I am a cog.

1. **When possible, eat lunch in the lunchroom or with coworkers.**
    This way you can get to know your coworkers and maybe find some great recipes or restaurants.
2. **Befriend the office administrator and the janitorial staff.**
    They know where the good supplies are and can help get you get boxes.  Learn their names and thank them often.
3. **Introduce yourself to your neighbor at large meetings.**
    Don't just network with your own team or office.  Try to learn one new person's name a quarter.
4. **Decorate your desk.**
    A picture, plant, or figurine can tell others about your interests.  This is like your desk is wearing a conversation piece.
5. **Have a bowl of candy or small toys.**
    This is an easy way to get people to come to your desk.  People like candy and little trinkets.  Being that I have food allergies, I have a bowl of erasers, stickers, and small plastic frogs for people to grab from.

In addition to these, I also use the tips from my conference guide.
{% link https://dev.to/geekgalgroks/the-introverts-guide-to-tech-conferences-22nf %}

Over the years, I have had several different careers and I have used these tips in all of them.  They have helped me in factory, office, and laboratory settings.  

Remember to be kind to yourself when starting a new position, no one knows everything on the first day.
Using Custom Types in JavaScript Docs
Tags: discuss, vscode, javascript, documentation
Published: 2018-08-16 01:01:50

---
title: Using Custom Types in JavaScript Docs
published: true
description: What's the best way to reference custom types in JavaScript method docs?
tags: discuss, vscode, javascript, documentation
---

Hey dev community,

I come to you again with another question, this one less polarizing as my last one regarding gifs 😅 What I'm curious about is how you handle referencing custom types when writing method documentation in JavaScript with Visual Studio Code.

I'm sure that's not the best way of describing it, so I'll show what I mean instead. Take the following example:

```javascript
// Used for JSDocs
const Window = require('vscode').window

/**
 * @typedef {Object} MessageOptions
 * @property {boolean} modal Indicates that this message should be modal.
 */

/**
 *
 * @param {Window} window
 * @param {string} text
 * @param {MessageOptions} [options]
 * @param {*[]} [items]
 */
module.exports.showMessage = (window, text, options = false, items = false) => {
  if (options && items) return window.showInformationMessage(text, options, items)
  else if (items) return window.showInformationMessage(text, items)
  else return window.showInformationMessage(text)
}

```

It's a file I've created in order to help with my new project, [Enmeti][0]. For the one method it exports, I have two parameters that are custom, `MessageOptions` and `Window`. 

For `Window`, the **vscode** module exports a [window][1] namespace so I can reference it as a variable and then use that in the comments. `MessageOptions`, on the other hand, isn't exported, so I created a custom definition and reference that.

While I'm fine with the definition for `MessageOptions`, I'm not too fond of creating a variable reference for `Window` just for the sake of having the parameter info available when referencing the method. This is something I've done in a number of my projects but I know there _has_ to be a better way of doing this.

Any suggestions?

[0]: https://github.com/HF-Solutions/Enmeti
[1]: https://code.visualstudio.com/docs/extensionAPI/vscode-api#_window
Kotlin coroutine based KafkaProducer extension
Tags: kotlin, kafka
Published: 2018-08-16 00:23:53

---
title: Kotlin coroutine based KafkaProducer extension
published: true
description: 
tags: kotlin, kafka
---
# Getting rid of Callback hell in KafkaProducer

Kotlin's [coroutines](https://github.com/Kotlin/kotlinx.coroutines/blob/master/coroutines-guide.md) provides a nice way to write async code. It makes it easy to write and compose asynchronous computation using a very light-weight model.

This post is not about what coroutines are, the link with the docs have a very deep and easy to read explanation of that. Instead I'm offering a solution to using `KafkaProducer.send` method.

The issue is `send()` leverages a `Callback` strategy, and we all know that there's a special place in hell for those who use callbacks.

Fortunately Kotlin coroutines offer a solution: `suspendCoroutine` function, that allows us to transform a callback into a suspend function call.

[Receiver](https://kotlinlang.org/docs/reference/lambdas.html#function-literals-with-receiver) functions are also another nice treat of Kotlin language. It allows us to augment regular types with custom functions.

I decided to call the new function `dispatch` instead of `send` because I find a bit confusing when people decide to extend original function using the same name, and imports can get a bit messy.

So the extension function you need to write is very simple:

```kotlin
suspend inline fun <reified K : Any, reified V : Any> KafkaProducer<K, V>.dispatch(record: ProducerRecord<K, V>) =
    suspendCoroutine<RecordMetadata> { continuation ->
        val callback = Callback { metadata, exception ->
            if (metadata == null) {
                continuation.resumeWithException(exception!!)
            } else {
                continuation.resume(metadata)
            }
        }
        this.send(record, callback)
    }
```

Now you can just use it from your regular `KafkaProducer` instance:

```kotlin
val props = Properties()
props["bootstrap.servers"] = "localhost:9092"
props["key.serializer"] = StringSerializer::class.java
props["value.serializer"] = JacksonSerializer::class.java
val kafkaProducer = KafkaProducer<String, SensorReading>(props)
async {
    kafkaProducer.dispatch(ProducerRecord("sample", SensorReading("Bedroom", 72.0, false)))
}

```

Just remember that you can only call a `suspend` function within the boundaries of a coroutine, hence the need for `async`, same could be achieved with `launch` or `runBlocking` for testing.

Happy coding!
gRPC quick start in Go
Tags: networking, grpc, go
Published: 2018-08-16 15:07:02

---
title: gRPC quick start in Go
published: true
tags: networking,gRPC,golang
canonical_url: https://dannypsnl.github.io//networking/grpc/golang/2018/08/16/gRPC-basic-tutorial.html
---

What is RPC? RPC means “remote procedure call”. The concept is called a remote function as a local function.

Then gRPC? It is a framework that helps you create RPC.

Traditional RPC has some problem making it hard to use. For example, how do you know, what type of message you get?

Usually, we use JSON or others format. But marshal & unmarshal quickly became a big issue. Because as time goes on, we don’t actually know which service use which field, thus we can’t reduce anything.

And server & client will get further farther for the same reason.

These all, won’t be an issue in gRPC.

In gRPC, you define a `*.proto` file for your service.

At here, we will create one named `UserService`

```go
syntax = "proto3";

package user;

service UserService {
  rpc GetUser (Empty) returns (User) {}
}

// define message type
message Empty {}
message User {
  string name = 1;
  int32 age = 2;
}
```

To generate code, I usually use `go generate ./...`

So let’s have a file `gen.go`, just leave a comment about what command you want to execute.

```go
//go:generate sh -c "protoc -I./user --go_out=plugins=grpc:./user ./user/*.proto"
```

Implement service:

```go
import "path/to/grpc_generated/user"

type UserService struct{}

func (us *UserService) GetUser(ctx context.Context, u *user.Empty) (*user.User, error) {
    return &user.UserName{
        Name: "Danny",
		Age: 21,
    }, nil
}
```

Create server:

```go
import (
	"net"
	"path/to/grpc_generated/user"
	"google.golang.org/grpc"
)

func main() {
	l, err := net.Listen("tcp", ":50051")
	// handle err
	server := grpc.NewServer()

	service := user.UserServiceServer(&UserService{})
	user.RegisterUserServiceServer(server, service)

	err = server.Serve(l)
	// handle err
}
```

Final is our client:

```go
import (
	"fmt"
	"net"
	"path/to/grpc_generated/user"
	"google.golang.org/grpc"
)

func main() {
	conn, err := grpc.Dial("localhost:50051", grpc.WithInsercure())
	// handle err
	defer conn.Close()
	client := user.NewUserServiceClient(conn)
	u, err := client.GetUser(context.Background(), &user.Empty{})
	// handle err
	fmt.Printf("Name: %s, Age: %d", u.Name, u.Age)
}
```

After that, run `go generate ./...` from project root dir.

Then `go run server.go`, open another terminal, `go run client.go`

I usually won’t commit generated code(unless commit it makes sense), so I usually will write `*.pb.go` in file `.gitignore`

More info:

- [grpc.io](https://grpc.io/)
Dev.to on Discord
Tags: dev, discord
Published: 2018-08-15 22:49:08

---
title: Dev.to on Discord
published: true
description: Let us connect on Discord.
tags: dev, discord
cover_image: https://thepracticaldev.s3.amazonaws.com/i/83k8cijf03y8t4ckn4l0.png
---

People expressed they would like to meet others in the community outside the website, exchange ideas and have a place to hang out and make friends. Discord was suggested to be the number one place to do that.

That is why I created a [Dev.to Discord channel](https://discord.gg/RPgNn3). Everything we do is a team effort here so I invite anyone to join me here and help  make things in order.

[https://discord.gg/RPgNn3](https://discord.gg/RPgNn3)