Sunday, December 13, 2015

My GOPATH dir only gets bigger and bigger

I've just ran cloc on my $GOPATH and I'm a bit surprised.
Turns out that the Go plugin for IntelliJ IDEA can really process it's way into almost 35k Go files with about 8.8 million lines of code....


Monday, November 23, 2015

Are we there yet?

I'm reading this http://www.telegraph.co.uk/technology/12008689/Why-is-Silicon-Valley-helping-the-tech-savvy-jihadists.html and I'm wondering: wtf?! I mean sure, the right tools in the wrong hands can do shit load of damage but does it mean we have to stop building the tools? Or should we rather try to improve ourselves as a civilization, not like a bunch of kindergarteners fighting each-other for who has the better toys? If only people would learn to live with together, we could accomplish so, so much more than what we have today. There are so many things to be solved, here on Earth and then... Space. The final frontier. :)

Friday, September 25, 2015

Omenirea are un viitor, civilizatia se pare ca nu

Dovada ca ne pierdem din ce in ce mai mult din umanitatea pe care o avem? Faptul ca atunci cand calcam un animal in timp ce suntem la volan / pe motor, punem repede pe Facebook / Youtube niste poze sau un filmulet sau cand altii critica acest lucru suntem indiferenti, sarim sa le aparam dreptul la libera exprimare sau faptul ca "e pe net". Si nu vorbesc de "straini", vorbesc de romanasi de-ai nostrii. Pacat, mare pacat.

Tuesday, September 1, 2015

Generate passwords in Linux

As generating passwords happens often enough I wanted to have a generator that's local and no one else has access to it when it's generating the password.

As such, here's a simple bash script to generate a password:
It has a special case for AWS RDS as they don't like passwords like everyone else.

Hope someone else will find it useful.

Wednesday, August 19, 2015

Go as a client side language

I was talking to a colleague of mine and we were both expressing the same feeling towards Javascript: bleah.

As I was going home, I've noticed this "piece of joy" on Reddit https://www.reddit.com/r/golang/comments/3hlfo6/do_you_guys_think_go_will_explode_the_same_way/ and I got frustrated with the answers there. One of them frustrated me in particular: https://www.reddit.com/r/golang/comments/3hlfo6/do_you_guys_think_go_will_explode_the_same_way/cu8c7rb (in case it disappears it says: "No because go isn't a language used by the web browsers.").

Leaving aside the lack of technical understanding that the user displayed, it got me thinking: what would be the reason that would get in the way of Go being used browser (client) side? Turns out that I can't find any, or at least my lack of technical understanding says: none.

How would it work?

There are two major approaches on this: ship the code or ship the compiled module.

I've tweeted the idea of creating a runtime for browsers and someone said: yeah but in this case you'll end up just like NaCL did. As I actually didn't knew why NaCL didn't took off, I've searched for NaCL on Wikipedia and discovered that Mozilla made a stupid decision to focus on HTML (Picard facepalm).

So, it's possible that Mozilla will again say no to this because in their stupidity they'll focus on HTML again, or maybe they'll say that they now have Rust and they should build a runtime on that, it's their language after all, no?

And this is such a pity as Go really is a beautiful language and the use of channels for events and all the concurrency stuff would be a nice fit for the modern web.

Too bad we all can't play along and personal (and corporate) interests dictate the free web and how we, the developers, have to suffer from it.

Sunday, August 9, 2015

How AWS Lambda works - if I'd implement it

Disclaimer: I don't work at AWS or Amazon nor do I have access to any privileged information. This is purely an exercise of imagination, if Lambda actually works like this then yey me :)

AWS Lambda is a new toy from AWS which promises you that you won't have to care about infrastructure anymore when running code. It's the next level after BeanStalk and even AppEngine and the closest thing we have to a "Code As A Service" that we have to date.

Since AWS is pretty sure not to release anything about the inner most working of it anytime soon, everyone is up for guessing what's under the hood, so I asked myself: How would I implement it?

The description says:
AWS Lambda is a compute service that runs your code in response to events and automatically manages the compute resources for you, making it easy to build applications that respond quickly to new information. 
AWS Lambda starts running your code within milliseconds of an event such as an image upload, in-app activity, website click, or output from a connected device. 
You can also use AWS Lambda to create new back-end services where compute resources are automatically triggered based on custom requests. 
With AWS Lambda you pay only for the requests served and the compute time required to run your code. Billing is metered in increments of 100 milliseconds, making it cost-effective and easy to scale automatically from a few requests per day to thousands per second.
The developer in me is happy with this. I get to write code only, deployment is as simple as uploading a zip file to S3 and done, things run, people get their data, I don't manage the infrastructure and everyone's happy and sleeps at night.

The only thing that I have to worry about is getting my code to run as fast as possible, as the billing is done in increments of 100s of ms, and use as little amount of memory, that's being billed as well.

Can we make the specifications out for Lambda based on the information we have?

What we know about Lambda?
  • it runs in an isolated environment
  • it runs quickly in response to events
  • it scales in response to events
  • it has constraints for memory (which also controls how much CPU you get)
  • it has a timeout of 60 seconds for the function it runs
  • it has a "temporary" space you can use but you are not supposed to rely on it
  • you should not rely on the fact that subsequent requests will run on the same machine

What can we dig up about Lambda?
  • first run is a little bit slower
  • subsequent runs will be fast if they are in a within a certain interval
  • CloudWatch logs seems to indicate that it will favor reusing the existing instances vs spawning new ones regardless of the throughput levels if it scaled enough to accommodate for the throughput
  • it scales horizontally
  • it's between t2.micro and t2.small in terms of maximum memory (or t1.micro and m1.small if you prefer older instances types)

So where does this gets us?
Based on the above capabilities and requirements, if I were to implement Lambda over the AWS I'd use:
  • ECS
  • some smart container scheduler, tailored for the workload type that Lambda has
  • communication adapter: this one acts as a "translator" from the various input sources to RPC (or HTTP?) and back
    • definitely with ELB in front of it for mediating the traffic
    • SNS for anything that can react to events inside AWS
  • one dedicated container built for every function that you upload which packs the communication adapter
  • CloudWatch: monitoring is needed, no? No?

Lets look at the information we have from a different perspective.
Aside from the dedicated instances, Lambda potentially has the whole AWS infrastructure to run on.

It's not hard to imagine that even with probably an extremely intelligent scheduler for placing instances there are still empty "spots" in the infrastructure. Those spots means servers are not used to their maximum and given the above description for how to build Lambda, they would be perfect to run it as well.

Looking out on how the AWS rolls out the services, ECS and Lambda, I think it only goes forward into proving that they went for a similar approach described above.

What does it miss?
Lambda would be beautiful to put in front of medium or even large workloads with quick response times but there's a critical part missing. Due to the way it works, if you want to use persistent connections to RDS there's no way to do this yet. If I were to implement it, I would definitely have an AWS DB connection pool somewhere in the middle between Lambda and RDS (AWS if you read this, *wink* *wink*).

To sum it up:
I can totally build it from the building blocks AWS provides, as well as any other cloud provider. And I hope who had the idea to do it got a fat bonus for it as I didn't (had the idea before it). Lambda is also a good way for AWS to better utilize their hardware and for people who don't need a complicated backend to just care about the code.

I think this might be the future for small business or very young / incubation period startups or hackers and tinkerers who just want a quick way to make their code run over the web without headaches and I'm definitely going to use it pretty soon in production.

I'd be happy to hear what other people think, if someone digs this one up.

A thank you goes to +Onur for providing suggestions on how to improve the readability of my post: Thank you!

Reddit thread: https://www.reddit.com/r/aws/comments/3gih4a/how_aws_lambda_works_if_id_implement_it/
HackerNews: https://news.ycombinator.com/item?id=10037476
Tweet: https://twitter.com/dlsniper/status/630853292768251904

Monday, July 27, 2015

Find out the uptime of your Samsung SmartTV

Lately I've been playing around with some stuff, among which I've decided to see what's around me in my home network. Today I've stopped by my TV, which is a Samsung 6500 Series from 2013 (45" model). Turns out that it has some open ports...

PORT     STATE SERVICE
80/tcp   open  http
443/tcp  open  https
4443/tcp open  pharos
6000/tcp open  X11
7676/tcp open  imqbrokerd

Now, I've only had time to check out port 80... and this is how I've found out the uptime of my TV.

curl -I http://TvIP/

HTTP/1.1 404 Not Found
Content-Type: text/html
Content-Length: 345
Date: Thu, 01 Jan 1970 00:31:52 GMT
Server: Swift1.0

Turns out that the date is set to 0 (Unix timestamp ftw) every time the TV starts and the server starts with that and tadam.. this is how you get your TV uptime :)

In the weekend I plan to dedicate some time to my car, this should be fun :D

Saturday, July 25, 2015

Github is not my CV

The other week I've got a call from a person who said something about being a "professional headhunter", "recruitment professional", something something dark side, and the dialog was like this:

(the person) - hey, my name is "headhunter something something", I work for "dark side inc." and I'd like to tell you about a great opportunity for you. I've seen your github profile and I think you will be a good fit.
(me) - hi, no thanks, I'm happy with my career right now, have a nice day.

I seriously hate this. Really. Github is not my CV and it should never be.

Github, among many others, is a place where people collaborate on projects or release things they'd like others to use or give feedback for. My contributions to the community are done in the spare time that I have, in almost 99% of the cases, or because I encounter a bug while I'm at work so either I file a bug or a bug fix to the project that I'm using (yeah, Tapglue is awesome in this regard, I can actually fix something in the community if we use it and I can do it).

Many people do this in their own spare time as well. Granted, there are companies like Google or others which allow people to work on open-source projects directly and thus they are more visible, but hey, they actually get payed for that, it's not only because they are cool persons and want to give something back to the community (not saying that they aren't cool and al, you get the picture).

But seriously, I have a job, usually 9 to 18 (more often than not 10 to whenever something in the late evening) and sometimes I have enough time to do something useful for a project that I use or for the community so... Yeah, don't hire me based on that. Hire me because I'm a good engineer, hire me because I have quite a few years of experience in what I'm doing, hire me because I enjoy what I'm doing and I always try to best myself and finally, hire me because I've seen sh*t and I'll fix it faster and better than your average ninja superstar cowboy guru hipster that advertises himself/ herself as such. And if you decided that you want to hire me, after seeing my LinkedIn profile, and after I pass whatever tests / recruitment procedure you have, and you say: hey, he's a nice guy, we want him. Oh and look, he's also contributing to the community back, then yeah, that's cool, it's a bonus, not a feature, not a mandatory activity.

Why I rant? Because it's called Software Engineering, not Social Media monkey typing, ok? We are supposed to help the others automate things, making them better, improving their life and quality of life, supporting people that have disabilities with better, smarter, technology and overall do our small part of the contribution for advancing the humankind to the next stage. But because of the myth that "everyone can code", we've got hispsters and all those self-promoted ninjas and cowboys and whatever else they are who are not even related to what a Software Engineer is or should be. Please promote quality not quantity, pretty please.

Fragmentation on Android is hilarious

I was trying to create a new Android app today and using Android Studio (latest canary release, ofc).

Obviously in the process I've got to the platform targeting part. And then the shock came in.


Look at it... Seriously, look at it. There's more than 50% of the people who don't run on 4.4 or later. I mean c'mon, really?

I know forcing users to upgrade on mobile devices is hard, especially since the mobile manufactures don't really seem to care about existing users, security or otherwise getting latest version of the OS to their users (I guess it's not profitable, no?) But I seriously hope that Google can find a way to fix this sooner rather than later because it's getting hilarious at this point. Android M will be out soon-ish (September or close, right?) and by then there will be not two, not three but nine different versions if you want to target 100% of the platform and four versions in order to target about 50% of the users.

And people were moaning about fragmentation on desktop (Windows) just a few years ago when there were like 2-3 different versions only. 

As a last fun thing, HTC HD2 launched in ~2009 can run: Windows XP, Ubuntu MeeGo, Windows Phone 7, Android 5.0 (last I've checked) and I'm almost willing to bet it will run Android M as well. That's a six years phone who can run most of the OSes from out there proving that's in fact possible to have an updated phone if manufacturers would only care (oh and HD2 was meant for Windows 6.5, the community managed to do all the wonderful things I've just mentioned).

Sunday, July 19, 2015

Poor horse

Aside from developing some really awesome things at Tapglue, I also have to make sure that the infrastructure purrs as happy kitten and all things run as smooth as possible.
This means from time to time, I have to have a look on what's going on our servers, get some alerts about things running and, my favorite so far, get alerts when we detect new user agents.

The winner for this week is this one:
Someone is clearly in the very dark side of the Internet but hey, I'm not judging. Also, this horse appears to be just another attack on the cookies...
I hope someday people will stop trying to hack around things and contribute to the greater good of the humanity instead. That would be so much better.

Oh and yes, that's our server replying in 45 microseconds. It's fun, no?

IDEs, large code bases and speed

People often fear IDEs because they are heavy and bloated and slow. Turns out that if you at least give some of the good ones a try those reasons suddenly don't don't make any sense.

For example, I've been working for the past two years with Go and the Go Plugin for IntelliJ Platform and I keep hearing other Go developers that they don't want IDEs to be slow and bloated... So today I decided to have a look in my GOPATH and see what's the status there.
 
cloc $GOPATH/src

   82632 text files.
   60097 unique files.                                          
   64918 files ignored.

http://cloc.sourceforge.net v 1.60  T=147.84 s (139.7 files/s, 104402.4 lines/s)
--------------------------------------------------------------------------------
Language                      files          blank        comment           code
--------------------------------------------------------------------------------
Go                             8059         284504         421962        1676304
Javascript                     9136         255587         402064        1647059
HTML                            863          13471            639         193480
XML                             244           3343           1658         106258
C++                              95          15362           2627          80513
CSS                             504           7217           2036          71332
YAML                            206            412            458          66475
SASS                            434       10003298           2829          43960
C/C++ Header                    148           3805           3771          29219
ActionScript                    112           1231           2593          16451
LESS                            168           1098            425           9209
Java                             15            642           1809           6947
Bourne Shell                    141           1237           1267           5707
Objective C                      46           1571           1261           5596
Python                           23            957           1029           4785
Assembly                         49            351            342           4665
C                                19            558            217           3178
Bourne Again Shell               65            515            401           2791
QML                              33            330            757           2269
CoffeeScript                     71            350            284           2024
Perl                             14            283            382           1823
make                             84            563            752           1618
Ruby                             53            312            293           1547
C#                               19            255            285           1372
DTD                               2            192            182            551
Lisp                              4             45             86            252
SQL                               5             64            103            237
Maven                             2             11              0            203
CMake                             3             29             31            150
MSBuild scripts                   2              0             14            132
JavaServer Faces                  3              3              0            109
vim script                        4             24             45             93
D                                 9              0              0             87
Smarty                            6             17             30             86
m4                                1             17              0             76
DOS Batch                         2             27             16             68
XSLT                              1              5              0             32
IDL                               1              8              0             25
ASP.Net                           2              5              0             23
--------------------------------------------------------------------------------
SUM:                          20648       10597699         850648        3986706
--------------------------------------------------------------------------------

And you know what? Turns out that the plugin handles this just fine. It takes about 30 seconds to do the initial indexing, which is one time only and then that's it (it took cloc almost five times more just to count the lines).

Auto-completion works like it would have only two-three files to get the data from, which is astonishing fast when you consider the numbers.

So yeah, definitely a nice one so far.

My system:
- CPU Intel Core i7 4720HQ
- RAM 16GB
- SSD Samsung 850 Evo 120GB
- OS Kubuntu 15.04
- Java 1.8.0_45
- IntelliJ IDEA Ultimate 15 EAP
- Go plugin compiled from master (you can use nightly or alpha just fine)

Oh and get this, it helps you save key presses, cool no?

Friday, July 17, 2015

Debian goodies, literally

Today I've learned about a nice little package called debian-goodies, https://packages.debian.org/jessie/debian-goodies

Once installed it will add a few commands to the system of which I've found "checkrestart" to be amazing useful. It will tell you which running processes need a restart so that you don't need to restart your whole machine. Here's the man page for it http://manpages.debian.org/cgi-bin/man.cgi?query=checkrestart

Speaking of restarting the machine, if you want to know if you should restart it because of an upgrade or something, you should perform a "ls /var/run/reboot-required". If output is 0 well, restart time :)

Back on debian-goodies, there's also the dpigs command which will tell you who uses the most space of the installed packages (it doesn't include the files that the app(s) from that package will generate but still useful)

Monday, April 27, 2015

Make your Spotify client for Linux work on Ubuntu 15.04

Here are the steps to install and make Spotify client for Linux work on Ubuntu 15.04:

First, download the client following the instructions here: https://www.spotify.com/download/previews/

Then, follow the instructions from here: http://www.webupd8.org/2015/04/fix-missing-libgcrypt11-causing-spotify.html

If you then want to get your mp3 files play on the client you need to do this:

sudo apt-get install ffmpeg ubuntu-restricted-extras

After that, install the libs that you need by following this post: https://community.spotify.com/t5/Help-Desktop-Linux-Mac-and/Linux-Local-files-do-not-play-on-Ubuntu-14-04/m-p/1072805/highlight/true#M119043

Now things should properly work.

Tuesday, April 7, 2015

Kinesalite - Use an AWS Kinesis emulator for your dev work

AWS Kinesis is an amazing tool which is also very cheap.
But sometimes there might be cases where you just want to have a local machine in place to emulate it. 
Here's where Kinesalite, https://github.com/mhart/kinesalite, comes into play.
If you'd rather skip all the nonsense of installing nodejs and g++ and whatnot in order to make it work, you can now use it with docker: docker run -d -t -p 4567:4567 dlsniper/kinesalite:1.4.1
More info about the docker instance here: https://registry.hub.docker.com/u/dlsniper/kinesalite
As it's my first ever docker image, if you see any issues, please let me know.
Hope you like it and find it useful.

Sunday, March 29, 2015

Handling SSL certificates with Go

Recently I needed to implement an SSL certificate to a Go server I was working on.
The certificate provider I had to use is Wildcard SSL from Comodo.
And of course things are never as easy as they should be and it was a bit more pain that I expected.
First of all, they don't know how to export the certificates for a Go server but fortunately they do it properly for nginx so I didn't had to copy paste certificates in the correct order or something.

What I've ended up with was something along the lines:

There are a few things that still don't work but I do get an A rating with almost perfect scores in the SSL Test here: https://www.ssllabs.com/ssltest/analyze.html

Tuesday, February 24, 2015

Go plugin for IntelliJ gets the "Christmas tree lights" update and what is alpha about

UPDATE:
Seems I was a bit too trigger happy to announce the release but since then, we had to revert it. The new one should be up again soon I hope. The things below still apply (minus the links ofc).

UPDATE 2:
All good!

I'm happy to announce that the latest release of the Go plugin for IntelliJ IDEA 1.0.0.alpha#134 supports a high degree of customization for highlighting (among many other things).

See the screenshots below on how it can look like:

Settings page

 
Possible configuration (don't worry, the default setup is much better ;) )


The release is available on the Github releases section (please read the docs before installing and install the zip file).

Also, I'd like to address some questions about the "alpha state" of the plugin.

Q: When will we have a stable, official release?
A: When it's good enough for us and our users.

Q: Should I install this at all? It has an alpha in it's name.
A: See below for the lengthy detail on why it's named alpha

Q: Should I install the version from the plugin manager? (0.9.15.3)
A: No, at this point 1.0.0-alpha releases are in a much better state than the 0.9.x releases.

Q: Is the plugin written in Go? Or can it be written in Go?
A: No. IntelliJ Platform is written in Java and can run a great deal of plugins that compile into a JVM compatible output (I believe, I've seen plugins written in Groovy, Scala and Kotlin) but Go is a no go for it

Q: Can you include oracle, golint, gofmt or other tools?
A: It depends on the tool itself. For example, for gofmt, while the plugin will have support for it initially, the functionality should be ported for the IntelliJ Platform and not rely on the tool itself. In case of oracle, that's one of the main features the Platform is providing for us native ;)

Q: Can you include X / Y / Z in the release? Or change A / B / C feature?
A: It all depends on the issue or feature you are requesting. It also depends if we can find people to help with the implementation. Or if you want / can implement it yourself even better.

Currently there are a great deal of efforts to bring the plugin in line with what the users of IntelliJ platform expect from a professional plugin. There's a bunch of work to be done to get there but some very talented people help us, the community, to get there.

The releases are currently labeled as alpha as they don't have all the functionality we'd like to have but it is already used by a lot of people in their day to day work.

You can view the list of 1.0 issues as well as a list of possible issues to be included in the 1.0 release.  

A big Thank you! goes to Sergey (@ignatov) and Alexander (@zolotov) who are helping us quite a lot to bring this together as almost all you can see is their work in play, and also to our early adopters and people contributing to the plugin itself.

Wednesday, February 4, 2015

The state of Go plugin for IntelliJ IDEA plugin

I've started to write this after someone asked for some details on what's happening with the plugin and where is it going.

To start with, there have been some major developments in 2014.

We've stopped using my dropbox link and started using an automated build process which builds the plugin for us and releases it at: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/releases

Towards the end of the year, the master branch, aka 0.9.x received some major refactorings for the internals in order to fix some underlying issues that otherwise would have been next to impossible to fix.

We've also got a major contribution in terms of a completely rewritten plugin for some friends of ours, which is now known as 1.0.0-alpha0 branch.

Meanwhile, Mihai and me, both got stuck with availability issues, as we contribute to the plugin from our spare time. As you can imagine, that's very hard to do when there are many things in your personal life. So this is a major problem (maybe the biggest).

The second major problem we have is that despite the huge interest in the plugin, and people willing to use it, we've only had 4 other guys helping us out with active code contributions during 2014. And we had them for at most 1-2 months.

Maybe a big reason for people contributing to the plugin is that it's written in Java... Maybe it's because despite their best efforts, the documentation on how to do / solve different issues with the plugin framework provided by JetBrains, writing a language plugin is still a really really hard task.

Fortunately, one way or the other, my availability issues will finish after 1st of March 2015 but still, there are many things I don't know how to do. Fortunately, both Sergey and Alexander will be there to help me out but when I get stuck, but working 3-4 hours / day at best won't come near to working 8+ hours / day on it.

I'll start working on the 1.0.0-alpha0 branch, and port things from 0.9.x while working on the documentation for the steps I'm doing. I hope this would help others learn things faster.

Definitely in 2015 we'll have a better Go plugin for IntelliJ IDEA and other IDEs while building the way to the best experience possible for go.

If you are reading this and made it this far, and want to help, you can always start here: https://github.com/go-lang-plugin-org/go-lang-idea-plugin/blob/v1.0.0-alpha0/CONTRIBUTING.md It should provide all the information that you need to work on the plugin.

You can also join our Gitter channel here https://gitter.im/go-lang-plugin-org/go-lang-idea-plugin


Thank you for reading this, I hope I'll see your PR soon ;)