Here is a riddle, I encountered recently when browsing newly acquired discrete mathematics textbook. It’s really simple, when you remind yourself basics about mathematical logic, but I must admit that I was confused ath the beginning. So here’s the riddle: You are wandering through a magical forest and suddenly you encounter three magical trolls guarding the bridge, which you must pass, in order to continue your travel. Every troll may either say the truth or either lie.
They say static methods are hard to test. They are wrong. Static methods are easy to test, but hard to mock. Unfortunately developing software inside Drupal requires implementing several static method calls. Some of them may be avoided, like getting services, which may be easily injected as a dependencies (and that’s actually how it should be done). Some would say, you can mock container and then set services’ mocks, but this is really wrong approach.
Markov chain is a graph model which describes transfering from one state to another with certain probability. In daily life you can experience it, when using smart keyboard on your portable device. You may notice, that keyboard is slowly learning what you are typing and after some time, can predict next word. This characteristics can be used to create simple chat bot or application which mimics someones writing. For example, if your job requires you to fill yearly performance review, this might be helpful ;) In following paragraphs I’m going to show you, how to create your own Markov chain from provided text file.
Previously I wrote about setting Messenger bot environment on own VPS. Today I’m writing about setting basic bot with Java and Spring Framework. To do so I’m needed: Facebook application Facebook page Java web application After setting up basic Facebook page and creation of Facebook app, I had to select Messenger product, which will be used with my application. After that there is no much to do. Wee need to get:
Recently I decided to move my pet project further on and create messenger bot for setting hook on fully booked crossfit workouts and getting notification when vacancy occurs. It’s not rocket science, but required some effort, which I thought would be nice to document here. To write your own Messenger bot you need to set a web server and get trusted SSL certificate. And this note could be easily ended if I used Heroku to host my application, but I decided to get my hands a little dirty and try myself with own VPS.
There are many pros associates with new technologies. You can easily chat with friends without leaving your bed, order things online and get them brought to your place without leaving home and even get pizza and pay for it, before it gets delivered. One of those super fancy features is possibility to register for sports activities. This way you can be sure, that there would be place waiting for you, but it also gives you convenient way to change your plans and change your booking activity.
I am enjoying my new smart TV from Sony for a for quite a bit of time, and truly speaking I do not regret I haven’t bought plain one which I would connect to one of my Raspberry Pis and have fun with much more funtionalities. Well, I don’t loose any functionalities here, because little device can be still plugged in. But having TV which can do more than simple one has it’s limits.
This is second post in series of web scraping FB for creation of own API. Today I will show how to accept friend request. Previously in entry Your own Facebook API - logging in I showed how to log into your Facebook account. Getting list of friend request is quite simple using low-end Facebook interface. You just need to go to https://mbasic.facebook.com/friends/center/requests/ and parse every “a” tag which “href” attribute starts with “/a/notifications.
Facebook API is a powerfull tool which provides you an interface to create games, authorize for an application or utility application, like wall content analyser, etc. But there are couple things you cannot use API to. For example, you can easily send message to your friends, but there is no way to receive messages from them. For such and other reasons I decided to web scrape FB in order to create own API.
This is a little lifehack I found recently. For sure you ended up, at least once, in a situation when provided some changes to file in vi and then realised that you forget to open edito as a superuser. In such situation, you don’t really need to leave your editor. You can easily gain root just for writing operation. Vi let’s you invoke any shell command when you are in. So for example, you can check if your script is working correctly, just after providing changes and get back to it’s source, just when it ends execution.