I’ll be speaking at … PowerShell VG!

This year has been a blast so far. Ever since I’ve started to attend to local user groups, I’ve always been interested on what speakers bring and the way they show their content. Because I was only getting started on this [programming] world, I’ve always felt that there was nothing that I could bring to the community that would be useful/new. As the time passed, I’ve began to feel more comfortable and I’ve noticed that sometimes you don’t even need to bring something new, it can be as simple as a different approach to a problem.

PowerShell Core was release for the RaspberryPi. That was the BOOM for me. I saw not only something new and challenging, but also a possibility to bring some input to the community. So I’ve decided to explore its possibilities and see where it would take me. I’ve learned a lot about PowerShell and the Linux ecoSystem in that process (and still learning 🙂 ). During that time, I’ve also challenged myself (and was challenged) to start doing presentations, so I did! I’ve always been greeted with a warm welcome and never felt pressured about presenting (let’s not talk about those 5 minutes before the presentation where it seems that everything can go wrong 🙂 ).

All of this to say…

… that as the title states, I’ll be presenting on the PowerShell Virtual Group! This is a great achievement for me, since this is a well-known place where you can share and learn. I’ll be presenting about PowerShell Core and RaspberryPi! This session will be full of examples, walkthroughs, shiny LEDs, sensors and so on!

LEDs…sensors… PowerShell… what?!

I know right?! That does seem a little bit off…

If that’s something that you have interest, or even if you are just curious about it, tune in next Wednesday, September 26th! Register here!

A special thanks

To Aaron Nelson (b|t) for his availability and patience to organize this (and always fix the damn time zone errors :D)!

Advertisements

This is … PsPowerHour!

In case you are not aware of the awesome community news, let me tell you one: as you might know, in some conferences there’s something called “Lightning talks”, which consist in talks around 10 minutes (hence lightning), where the presenter presents you ANYTHING related to a subject. It can be slides, code, demo or even just talk about something. With this idea in mind, Warren F. (b|t) and Michael T Lombardi (t) decided to take the same approach… but virtually. Which means that ANYONE can assist and talk!

They have been doing an awesome job organizing it and the first session kicks tomorrow, Aug 21st @ 6pm EST.

Where can you see it?

It will be streamed on Youtube. But be sure to check out the PsPowerHour repository for more information.

With that said…

I’m really happy to say that I’ll be talking on the day this whole thing starts 😀 and I bet that you already know about what…

yep that’s right. I’ll have less than 10 minutes to give an idea to the community about what can you do with the PowerShell and a RaspberryPi (and other hardware).

 

See you there!

 

TUGA IT conference – First as Staff, now as Speaker!

I’m very proud to announce that I’ll be speaking on one of the biggest Portuguese technological conference, the TUGA IT . This conference gathers speakers from all around the world, who are passionate about what they do and want to share their experiences/knowledge.

This has an ever bigger meaning for me, since it was the first conference organization that I’ve attended other than the local User Groups. Highly motivated by Cláudio (b|t), last year I’ve helped the organization, and this year I’m a speaker. It was also where I was able to meet awesome folks such as Jaap (b|t) and Rob (b|t).

For me this is a HUGE achievement, both personally and professionally.

“But what will you be talking about?”

I will talk about using PowerShell on a RaspberryPi. I’ll share my experience with, what have I done with it, how, and what I expect to do. If you like PowerShell but don’t know RaspberryPi or the other way around, this might be a good session to attend to.

“Oh, that sound awesome but I can’t attend to it.”

If you just thought something like this don’t worry. You can always check out a previous presentation here, although I will probably have something new (but the core is still the same) 🙂 .

And as if speaking sessions weren’t enough, they also have WORKSHOPS

Registrations are open!

If you are not still convinced, check out the speakers list, and the schedule!

If you have interest (and you should!) I have good news for you: you can grab your seat today !

Final words…

I’m really excited about this event and I really hope that if you attend to the event, you sure to say hello!

 

 

I’ve shared Internet connection between Linux and headless RaspberryPi but can’t SSH

TL:DR;

1 – Follow the first 4 steps described here;

1.1 – Additionally, just to be sure, ignore IPV6 on IPV6 tab;

2 – Instead of trying to ssh into the given network (10.42.0.1 in my case), run

cat /var/lib/misc/dnsmasq.leases

connect to the given IP address.

Background

I’ll be presenting using my raspberry and my laptop, so I have the need to be able to connect to it (raspberry) via SSH. In order to be able to do that, I need to have both devices on the same network. Connecting the laptop to the network is usually easy, since you are given an username and password and in the worst case you need to open the browser and login into some page.

As for the raspberry, that’s another story. I could carry around a keyboard, mouse and monitor just to establish the connection, but even that could not be enough… what if I have the lite version (just the console)? If the network provider want me to login into a webpage, that will be an headache.

After a quick word with André Melancia (t) he mentioned that Internet Connection Sharing (ICS) was easy since Windows XP. But… I’m using Linux 😀

A quick search on Google yielded this thread . Although many people there said that the first 4 steps were enough, for me they weren’t, because even so I wasn’t able to connect (you will understand why later).

Let’s see what we got

After following those steps, I’ve ended with the same output as the person who posted it

ip_address.png

Ok, cool! Let’s test it.

ping.png

We got it! Now I can SSH into my Pi…

pi_ssh_fail.png

Hum… I’m sure that I’ve entered the correct credentials (it is a fresh install, so in raspbian the user will always be pi and the password raspberry). What’s wrong?

nmap.png

Nmap (used for network descovery) even says that it allows SSH and it’s open…

Re-reading that thread, someone posts something that he states as relevant which is basically to ignore ipv6. Still no luck.

So what’s wrong?

Well, turns out I was targeting the wrong address. At first, everything was matching:

  • I was able to ping;
  • I was able to SSH into it, but I was getting permission denied;

 

How did you know that you were targeting the wrong address?

Digging a little bit more, I found this post , which suggests a command to run that will give us the correct address:

cat /var/lib/misc/dnsmasq.leases

 

which yielded something like:

1526507253 xx:xx:xx:xx:xx:xx 10.42.0.17 raspberrypi xx:xx:xx:xx:xx:xx

pi_ssh_success.png

It worked!

 

So what’s dnsmasq and how did it help finding/solving the problem?

According to  the official website and I quote:

Dnsmasq provides network infrastructure for small networks: DNS, DHCP, router advertisement and network boot

In resume, this tool scans the smaller network (in this case the ethernet one that only have one device) and gives us the ip address.

Do you have another methods? Please share!

Thanks for reading!

Simple Tip: How do I open explorer on current path in Powershell? Explore different ways

See what I did there? “Explore different ways”… “explorer”… no? ok…

The post today is really simple. I fell like I’m failing by not writing content more often, but there’s not always time and/or subject.

The things that might look pretty simple and obvious for some, is not for the others, and that’s what happened to me today.

On my working environment, I’ve set my Powershell window to always start on a specific folder (which is my Workspace folder). That is cool because I’ve a script that I usually need to make some modifications and run, so setting the path to point there was a good start. Even after that, I’ve always ended up opening explorer and navigating to the desired folder (mainly because I need to use other files from there). So today I asked myself “Why don’t I simply open Powershell and open the explorer from there?”

Failed attempts

  • explorer – First attempt, simply type explorer. That launched explorer (as expected, but not on the current directory);
  • Get-Location | explorer – Also launched explorer, but not on the desired directory;
  • explorer Get-Location – This one made plenty of sense to me, although it opened the “My documents” folder instead of the current directory. Funny enough, I was only missing the brackets between the CmdLet – we will see it ahead
  • . – Because I know that the dot “represents” the current directory, I thought that simply typing that would launch the explorer (but why would it ?)

(Funny, because I’ve tried with  explorer  and  but never occurred me to try explorer .)

So, what does work?

Like almost everything in this area, there are many ways to achieve this. After getting help from people @ SQL Server Community Slack (t), here are some options:

  • start .
  • start -filepath “C:\some\path” (start is an alias for start-process)
  • explorer $path (Thank you Gareth (t|b) for all the above)
  • explorer .
  • explorer (Get-Location) (the one that I almost got right).
  • invoke-item . (or even simpler ii .) (Thank you Andy (t|b) )

Fred (t|b) also mentioned a module called PSUtil  that has some functions for explorer (besides many others). I also recommend you to read his post about some things that this module contains.

Conclusion

The purpose of this post was not only (or mainly) to show how to open the current directory on the explorer, but to show that there are many commands and combinations that can be performed to achieve the same purpose. This can also be applied for other cases

Getting started with SignalR Alpha for ASP.NET Core 2.0! – My experience

This looks like a long post but it has lots of code and little explanations since SignalR is on an early stage. Stick until the end 🙂

Previously I’ve overheard about SignalR, which I’ve been told that it’s a library to allow “real time” communication with multiple web clients. My first thought was that it was some kind of message broker (like I’ve used before the RabbitMQ and MQTT protocol), but after a little reading and talking, I found out it’s much easier than that.

A couple of weeks ago, Microsoft announced SignalR (Alpha) for ASP.NET Core 2.0. This blog post is a really good entry point, and if you read it, you get a pretty straightforward idea of what’s new/different, like:

  • JavaScript/TypeScript Client
  • Support for Binary Protocols and Custom Protocols
  • Streaming
  • Scale-out

And many more things like “What’s Changed” (which I won’t cover because like I said, I’ve had zero experience with SignalR before this Alpha) and even the other topics won’t be covered here.

So what will you be talking about?

I will give you my approach/idea about how to work with SignalR in a scenario which is similar to my job’s needs.

My test case scenario and examples

First of all, keep in mind that I will not cover the javascript client, only the C# one. I’ll probably have the necessity to create an implementation on javascript, when I need to I’ll blog about it :).

In order to show a similar “real world” scenario, I’ll build a simple application simulating the following :

There are different type of workers on their workspace and they want to communicate between them. There are 3 groups:

  • Cool employees
  • Way Cooler Employees
  • Bosses

For obvious reasons, they only want to talk to the others on the same group (Cool employees with cool employees, etc etc).

To simulate this interaction we will have another application that simply perform 3 actions, according to correspondent button pressed:

  • C  key pressed – send message only to Cool employees
  • W key pressed – send message only to Way cooler employees
  • B  key pressed – send message only to Bosses

OK… so how does all of this work? Let’s try to visualize it:

Resuming: we want to have employees that belong to the “Cool Employees” group, others to the “Way Cooler Employees” group and the bosses that belong to the “Bosses”group. Have you noticed that I’ve been repeating the word “Groups”? It was with a purpose. With this post, I will show you how can you send messages to specific groups. But before jumping into it, let’s start from the beginning.

Hub

On the previous image, everything points to a hub, but what’s a hub? A hub is a “kind of” point-of-access (or bridge if you prefer) between the caller and the receiver(s). Having a quick look at this class:

It gives us access to properties like the Context, Clients and Groups, which we will explore next.

Starting with clients

The default Clients property is of the type IHubClients

This one, also implements an IHubClients interface, which has the following methods:

Since in this case T is of the type IClientProxy, we will have the following available:

We are getting somewhere! With this we already know that when sending a message, we will send it to a group and our code will be something like:

But how do we register a client on a group? We’ve seen that the hub has a Groups property.

Groups

Consists on a property of the type IGroupManager, which has two methods:

This is it! We already have the knowledge on how to register a client on a group and how to send a message to a specific group. Let’s implement our Hub. We need to allow each connecting client to register himself on a group, in order to receive only the messages that he wants to, and we need to create the method that will say “ok, I will send this information to this group”.

The Hub implementation

Please note that the Groups.AddAsync() method requires a connectionId, which in this case is the connectionId of the client that is registering himself on a group. To get the connectionId for the current client, we can use the Context.ConnectionId property.

A little parenthesis:

I had a doubt on how the groups were created: did I need to create if before trying to add a connection to it, or would it try to add and if the group did not exist it would be created? Due to the amazing community, it was easy to get some of my questions answered pretty quickly, and it even generated a little and quick discussion. Share your questions/ideas with the community, join ASP.NET slack. Here’s an example of what I’m talking about:

slack.pngAnother awesome “feature” of the open source, is that we can have things like this. Gurgen developed an android client library for SignalR that according to him:

“At the moment, it works only by websockets transport, but later I will add all other transports
The plus is that, this is only implementation of .net core signal r for android”

 

Ok, so before we can run our code and see things happening, there are two things that we need to add to the Startup.cs

With the routes.MapHub(“entryPoint”) we are specifying that in order to connect to the hub, the route must be ourAddress/entryPoint (in my case it was http://localhost:52846/entryPoint)

Testing what we’ve just created

In order to test this, we need to have a total of three projects: the project with the hub, one to simulate our clients (employees and bosses), and other to send the messages. We already know that our clients must register themselves on a group so that they can receive the desired messages.

In order to simulate the referred scenarios, on the project that simulates the employees and bosses, I decided to create Tasks, in which each simulate a client application, by connecting to the Hub, register itself on a group and setting the callback. Afterwards it just stays on a forever loop. With this in mind, some of the code that I will show isn’t obviously the best approach, but it’s just to make the simulation easier/doable.

Connect to the hub and prepare to receive the messages (employees and bosses project)

The connection itself is pretty straightforward, all we need to do is create a HubConnection object and call the StartAsync method. When the connection is established, we register ourselves on a group, by calling the RegisterConnectionOnGroup method that we created on the hub. For last, we set the callback, defining what should be done when we receive a message. Let’s have a look on the code that simulates a “Cool Employee” client:

NOTE: As I just mentioned above, the connection.StartAsync().GetAwaiter().GetResult() should not be done like that for obvious reasons (it will not be async at all), but honestly I couldn’t figure out how could I await that call inside a Task, because since I’m using Task.Factory.StartNew(new Action(…)) I can’t set the await on the method, because it would change the signature, hence it wouldn’t be an Action. In this case it is just to ensure that we invoke the RegisterConnectionOnGroup only after the connection is established. Do you know how to solve this? Please PM me or even better, comment down below!

The MessageSender project

This application just sits on a forever loop after establishing connection to the hub (via the same HubConnection logic) and “implements” the logic that I previously referred:

  • Send a message only to the bosses? Press B
  • Send a message only to the Cool Employees? Press C
  • Send a message only to the Way Cooler Employees? Press W

With this, we can finally test what was developed. First launch the project that has the Hub (SignalR project, in this case the EmployeeSignalR), then the SignalRClient1 which will create the various clients referred, and finally the MessageSender. Place the SignalRClient1 and MessageSenderconsoles side by side, and press the desired key on the MessageSender‘s console. See the magic happening!

Here’s an example:

Conclusion

For me, this was a whole new world since I’ve never really had contact with SignalR until I had created this project. Obviously, there might be some things that I said that are not exactly like i said, but as I stated at the beginning I tried to “give you my approach/idea about how to work with SignalR in a scenario which is similar to my job’s need”. Since none of us know everything, if you spot a mistake or you have another approach, please let me know!

A special thanks to David Fowler (b | t) for his help and quick replies to my questions! And also, thanks to Gurgen for his intervention on the explanation and his availability to talk to me about signalR.

You can download the full example from my github repo

Thank you very much for reading

PowerShell Modules Central – Share with community – What PowerShell modules are you using?

I think that this is an awesome initiative 🙂

Cláudio Silva's Blog

Like the blog post title states this is all about sharing with others! My idea is to share with the community which PowerShell modules you are using.

Let me introduce to you the PowerShell Modules Central

PowerShellModulesCentral is a GitHub repository that was founded as a central hub to a list of PowerShell modules that people know/use. Each module has a file describing its name, basic information about the module, as well as one or more blog posts/videos from people that have written about or used them.

This way we can reduce friction when people are starting out or are trying to solve similar problems.

Why?

When a new module appears on the PowerShell scene it can be difficult to advertise and gain mindshare among developers/end users who could be interested in it. There are also times when difficulties arise in finding if a good tool exists or not, if…

View original post 517 more words