Welcome to the wonderful world of Andrei!

Mirroring a Git Repository

Mar 25

For the past couple of years, I’ve been mirroring repositories locally so that I always have the code accessible even without Internet access. When I saw that FoundationDB’s GitHub account was wiped when Apple bought them, I figured other people might be interested in mirroring repositories, too.

I currently mirror Git, Mercurial and Subversion repositories, but here I’ll just focus on how to mirror Git. The other two will be separate articles.

How to do it

First, you want to do the initial clone. This is slightly different than a regular clone because you want to get ...

~ read more ~

How Pocket Parses Titles

Mar 22

Based on a few trials, and looking at many other people’s sites, I think I figured out how to get Pocket to show the correct title when people add your article to the app.

It figures out where the article is (I use <article>), but initially it didn’t realize that the <h1> within the article <header> was the title of the article. This seemed to be because the nav bar also had an <h1> (because I copied a Foundation example), as did the banner at the top of the page. These extra top level headers confused Pockets, so ...

~ read more ~

Upgrade Gnome Terminal on Ubuntu 14.04

Mar 11

In Ubuntu 14.10, Gnome Terminal can rewrap long lines when you resize the window. Unfortunately this feature wasn’t ready for 14.04, so we’ll have to upgrade gnome-terminal and libvte-2.90 to the latest versions ourselves.

The easiest way to grab the new versions is to get them from the Gnome3 Staging PPA. We don’t want all the packages from that PPA, though, so we’ll use apt pinning to specify which packages we want to upgrade.

First, add the PPA:

$ sudo add-apt-repository ppa:gnome3-team/gnome3-staging
$ sudo apt-get update

Next, we’ll create our apt pins ...

~ read more ~

Endless Reboot with Cron

Mar 06

Sometimes I come up with bad ideas. This is one of them.

* * * * * root /sbin/shutdown -r now

And yes, it does work perfectly. Needless to say, you shouldn’t do this. You might be able to make it worse by using @reboot, but I’m not sure which version will end up executing earlier. To be safe, use both!

~ read more ~

TOTP and HOTP in Rust

Mar 02

Lately I’ve started writing libraries which implement missing functionality in Rust. This is my second library and it implements OATH protocols in Rust according to the relevant RFCs. So far it supports HOTP and TOTP.

This blog post is intended to show some simple usage for version 0.1.1 of the library; if I change the API, I’ll put a link here to an updated blog post.

If you’re interested, the code for this library is on GitHub.

Using rust-oath

First, you need to add the dependency to your Cargo.toml:

oath = "0.1.1 ...
~ read more ~

My First Rust Crate

Feb 27

Today I created my first Rust Crate and published it on Crates.io! Check it out: https://crates.io/crates/changecase

I’m used to being able to change the case of strings in Python, but unfortunately Rust doesn’t provide an equivalent; you can only change case of individual characters. Clearly, the solution is to write a library for it.

Currently the library supports uppercase, lowercase, AlTeRnAtInG cAsE, inverting case, and capitalizing. Future work is to implement title case. I’ve already started to work on it by porting titlecase.py. The regex syntax is identical as far as ...

~ read more ~

My Attempt at Inbox Zero

Feb 21

I’ve taken a few steps today in an attempt at Inbox Zero. I tend to leave mail in my inbox to deal with it later, but it’s been bugging me lately and so I decided to do something about it.

Inbox Zero is an approach by Merlin Mann to maintain an empty (or almost empty) inbox. The benefit is that you get through your email more efficiently and spend less time thinking about it.

I’ve decided to go a bit further than only maintaining an empty inbox; I now aim to keep my entire mail account clean ...

~ read more ~

Getting That GitHub Green

Jan 29

Does your GitHub profile look empty? Want to appear productive, although you haven’t done anything all year? Fake those green boxes!

Git lets you amend old commits to change their dates, but you don’t really want to be ruining your repositories just for this, so set up a new repository and run the following script in it to generate a random number of commits for each day in the past year.

touch dates;
for x in {365..0}; do
    commit_date=$(date --date="$x days ago" --rfc-2822);
    num_commits=$(awk 'BEGIN{srand();print int(rand()*100) }');
    for ((n=0; n ...
~ read more ~

Rust Echo Server Example

Jan 21

There are many examples of TCP servers in Rust, and even echo servers, but I found many of them to be too complex. I think echo servers to be the best example for getting started writing servers in a new language, so I figured I’d write my own.

Note: A lot of this stuff is marked ‘unstable’, so you’ll get compiler warnings. If they turn into errors, please let me know so I can update the example.

The code itself should be fairly self-explanatory:

use std::net::{TcpListener, TcpStream};
use std::thread::Thread;

// traits
use std::io::Read ...
~ read more ~
Page 1 / 5   older »