Archive

Archive for the ‘Uncategorized’ Category

show my position on the map

June 21, 2016 Leave a comment

The site http://ipinfo.io/ gives you back not only your IP address, but your geolocation too. Example (with a fake IP):

$ curl http://ipinfo.io/
{
  "ip": "734.675.653.542",
  "hostname": "No Hostname",
  "city": "Debrecen",
  "region": "Debrecen",
  "country": "HU",
  "loc": "47.5333,21.6333",
  "org": "...",
  "postal": "..."
}

Let’s visualize my location:

<img src="https://maps.googleapis.com/maps/api/staticmap?center=47.5333,21.6333&zoom=9&size=480x240&sensor=false">


Debrecen, Hungary, center of the world :)

Categories: Uncategorized Tags: , , ,

How to update a GitHub forked repository?

Categories: Uncategorized Tags: , , ,

[vim] I’m back to (neo)vim

May 15, 2016 2 comments

A week ago I returned to vim, more precisely to neovim.

Here is my story…

When I started the university (geez, that was 20 years ago) we got an account to a Unix server. On the first week I logged in and launched Midnight Commander. I wanted to check out the content of a file in my HOME folder so I pressed F3 (view) on it. However, the default editor was “vi” :) I had no idea how to quit this program so I had to ask a senior student in the lab to help me. He was kind and showed me the trick: “:q<Enter>“. So this is how I met vi and after this I avoided it for 3 years. Then I had a Java class where there was a guy who was a big zero in programming. One day he was sitting next to me and he was using Vim! And I was using Joe. He had nice syntax highlighting and he showed me some vim tricks. And I thought “WTF? If this guy could learn it, then I can learn it too.” I asked him about it and he told me that he started it with the command “vimtutor“. I went home and that very afternoon I went through the vimtutor too. I made some notes but I couldn’t memorize all those keyboard shortcuts. In the next few days I went through the tutorial two more times. Then I forced myself to use vim for all my text editing works and I got to like it. When I needed something I looked up how to do it with vim. The commands were logical and soon it was a pain to use any other editor.

Several years passed and I was very satisfied with Vim. I wasn’t a guru and I didn’t use many plugins, but I could solve all my problems with it. Then 2 years ago I heard that Emacs can be vimmified with the Evil plugin. I gave it a try and it was like a “better vim”. It had a nice GUI, I liked its default color scheme, it had a plugin manager, etc. I spent two weeks with its configuration and I could reproduce the majority of my vim settings. It was good.

I have several machines (desktops, laptops) and I used Emacs+Evil everywhere. I keep my settings in Dropbox, so I have the same configuration on all my computers. However, on my older machines Emacs started very slowly. Sometimes I had to wait 20 seconds! So when I wanted to edit a little script, I just launched vim. And it happened more and more often…

And now it’s present time. Two weeks ago I read about Neovim and I liked its features: a modernized vim, async job control, built-in terminal. I decided to give it a try. I created an empty init.vim file (it’s Neovim’s .vimrc equivalent) and transferred from .vimrc the necessary things. It turned out that my .vimrc had lots of obsolete settings that I could drop. On the forums I looked after the popular plugins. I even started learning vimscript :) Now my settings are better than my old Vim settings. I like Neovim and I am going to use it from now on.

If you are interested, then here is my init.vim configuration file for Neovim. It’s a work in progress but it’s already usable.

Expect some (neo)vim posts in the future :)

Categories: Uncategorized, vim Tags: , , ,

listen to Pandora Radio, even if you are not a US citizen

April 21, 2016 Leave a comment

Problem
If you are a peasant like me living outside of the US but you still want to listen to Pandora Radio, which is only available in the center of world (USA), then what can you do?

Solution
There is a very simple solution now. Opera offers free VPN, built directly in the browser. You can choose between German, Canadian or American VPNs. Currently this feature is only available in the development version of Opera. So here are the steps:

  1. install Opera (development version)
  2. install Flash player for Opera (Pandora is a Flash-based website)
  3. visit pandora.com just to see that you are kicked out
  4. enable VPN: with Alt+P you can access the Settings, go to Privacy & security, then enable VPN
  5. Open an arbitrary site. On the left side of the URL bar you’ll see that VPN is activated. Click on it and select United States.
  6. Visit pandora.com again. Strangely, you are let in this time…

hacking with URL shorteners

April 18, 2016 Leave a comment

This article (https://freedom-to-tinker.com/blog/vitaly/gone-in-six-characters-short-urls-considered-harmful-for-cloud-services/) just gave me an excellent idea…

In a nutshell: these URLs are so short that you can explore a lot of them with a simple brute force approach. Just generate a random hash and there is a high chance that it points to somewhere.

Example: with bit.ly I generated a link: http://bit.ly/1bNGJd3 . I tried to modify some characters in the hash and in most cases it pointed to somewhere…

syntax highlight your code and paste in Word

April 14, 2016 1 comment

At http://planetb.ca/syntax-highlight-word you can find a nice syntax highlighter. It supports Python, HTML, Java, and several other languages. The rendered output can be copy-pasted to a Word document and it’ll look the same and remains editable in Word. Pretty cool.

It’s also useful if you want to make a screenshot of the syntax highlighted code. Here is an example:

sum

Thanks to Peter F. for the link.

using git like svn

March 15, 2016 Leave a comment

Problem
I have a Digital Ocean virtual private server (VPS) where I want to run a Python-Flask project of mine. The application works well on localhost, so it’s time to make it public.

However, it’s very likely that I will have to customize it a bit on the server, and thus I would like to get those changes on my localhost too. And vice versa, if I do some changes on localhost, I want to upload the new version to the server too. Copying everything via FTP for instance is out of the question. How to do it then?

Solution
Let’s use Git. Bitbucket offers free private repositories, so let’s profit of that :) I want to use that repo similarly to SVN: it’s the central repo, it must contain the latest version.

git_like_svn

Let “client A” be the VPS and “client B” my home machine (see the figure). When I modify something on localhost, upload the changes to the central repo, log in to the server and download the latest edition. If I modify something on the server, upload the changes to the central repo, and download them on my localhost. This way the two clients are nicely synchronized.

How to upload?
Upload your local changes to the central repo:

$ git status
$ git add -A .
$ git commit -m "your commit message"
$ git push
$ git status

How to download?
Download changes from the central repo (update your local copy):

#!/usr/bin/env bash

# git_down_from_central_repo.sh

git fetch
git pull
git status

But… it’s SVN like this!
Works for me :)

Follow

Get every new post delivered to your Inbox.

Join 90 other followers