tools (7) programming (5) cluj (4) misc (4) rails (4) productivity (3) startups (3) internet (2) meetup (2) software (2) emberjs (1) hack (1) science (1) zencash (1)

Saturday, November 26, 2016

Blending OAuth2 authorization with Devise using Ember Simple Auth

My Rails app already had authentication implemented using Devise and was serving some custom session data. Everything was elegantly tied together using Ember Simple Auth. I wanted to allow customers to sign-in / sign-up with Google using the OAuth2 mechanism.
I turned to Torii. Specifically, I was looking into Torii's OAuth2 provider to help me handle these OAuth2 phases:

1. Select & authorize APIs

This requires user consent; the user logs in with their Google account and is asked whether they are willing to grant the permissions that the application is requesting.

// in config/environment.js
var torii = ENV.torii = { providers: {} };
torii.providers['google-oauth2'] = {
      redirectUri: 'http://redirect.uri',
      apiKey:      '',
      scope:       'email profile' // NODOC: scopes should be space-separated!

Tuesday, November 10, 2015

Less cat tail, more less! (Why I stopped using the UNIX cat)

I've been using cat for ages to display contents of files. I used it very rarely to actually concatenate files together.

And I've been using tail -f to follow logs, since I started doing web development. I always had the problem that I wanted to scroll back but, as new items were added, it would automatically scroll me back to the end of the file.

At one point I stumbled upon a good alternative, namely using less +F. I loved that you can switch between examine (^C) and follow mode (⇧F).

I was still using cat until the final blow came and revealed that cat interprets escaped sequences. If you've been doing any kind of programming, you know how that can turn bad.

Tuesday, September 8, 2015

Get your Amazon WishList with a UNIX one liner

I was trying to export my entire Amazon WishList. Which is actually my reading list. The web version displays only 10 entries per page, and they deprecated their API endpoint for retrieving wish lists. Other solutions that I found online seemed clunky so I set out to find the simplest way of doing it.

Sunday, June 21, 2015

Ask Me Anything! announced a new feature a couple of months ago: "Ask me anything" events, and I decided to create one, even though I never mentored anyone over there. At first, no one asked me anything until @codementorIO announced my event on Twitter and a bunch of questions came pouring.

I felt quite pleased of the answers, since it gave me a chance to voice a few of my current beliefs. I'm sharing them here. Feel free to ask me more questions in the comments below.

John S.: What are some projects that you been part of that lead you to see creating technology as a futurist? What exactly makes you a futurist? (also, I think that's a very apt and great way to explain your tech skill).

Your first question is interesting since I realize that it wasn't something specific I worked on. It's just something I realized and it might go back as far as my childhood. Most of my projects are related to software, and none of them are very extravagant. But they are enabling me to learn and do something extravagant in the future. I hope.

Friday, February 6, 2015

Cluj.rb: Speeding up your testflow

After a long hiatus, Cluj.rb brought together Thomas Morris of and myself to talk about our development setup. The discussions was, naturally, succeeded by beers.

Here's the demo app, and below, the slides.

Friday, September 26, 2014

What happens after your 15 minutes of fame?

I had the pleasure to talk about product development at a Spart'up meetup organized by Simplon Romania. First time talking about ZenCash to a large group. It went surprisingly well!

©Nicolas Friess

Saturday, June 28, 2014

The inflexion point of programming confidence (or an outline to the benefits of Rails)

I've been working as Rails developer at a startup for more than a year. It was quite a change from working at an outsourcing company, on a mammoth written in Fortran/C/C++, with legacy code coming back from the 80s.

When I started working with Rails it felt like "starting to watch a soap opera in the 7th season." I was reluctant to blog about the new things I was learning because I felt I'm not yet at a point in which I'm capable of insights into this world.

I recently watched a talk by Yehuda Katz and I was glad to see that I've came across most of the things which make the Rails approach to web development so beneficial. The following are taken from the said talk.

Friday, April 12, 2013

Startup Weekend Cluj: The great clipboard in the sky

Friday, first day of spring, 7:30 PM. 150 people in a wedding venue. The atmosphere was pretty dull. After walking in, I knew I wasn’t going to pitch. Not only that, but I was asking myself what I was doing there in the first place.

I had an idea, and I made a short presentation in my head in the previous days, which I polished it until it got to one minute. At first I didn’t know whether I wanted to present my idea or not, but I came to terms with myself that I will make a final decision when I’ll arrive at the event, depending on the atmosphere.

“Pure cross platform file system.” It wasn’t an idea for a startup. Well, at that moment I didn’t even know what a startup was. I later found out... it’s an idea which longs to become a product. It’s not something exclusively tied to the IT world, only in our environment it’s relatively easy to come up with a prototype and do some market research. There’s one more essential thing: huge growth potential - index, spirals, segment - and other terminology I’m bewildered about.

Tuesday, December 11, 2012

CodeRetreat Cluj 2012: A quick, dirty and inaccurate recap

- "Ruby guy?"
- "Yes..."
- "Willing to teach?"
- "Yes, no problem."

This was Saturday morning. Cluj Cowork. A two storey house, with tall, airy rooms. Inner staircase and sturdy timber vintage furniture. A thin balcony upstairs, traced with wrought steel. Back in the days of my small internet marketing empire, I remember dreaming of working in a such a dynamic place.

The first round had started. It was a loose warmup. I was surprised how quickly you could hack something together in Ruby. "I'm in love", I confessed to my pair. No, not with him, with Ruby.

Saturday, November 24, 2012

Numbers and other delights in pure lambda calculus

In pure lambda calculus there aren't any numbers. There's this 3 things and that's it: variables, function definitions and function application

That's all you've got.

No objects, no numbers, no if statements, no true or false.
So... how can you build anything with lambda calculus?

Express it as functions:

0 := λ f x. x
1 := λ f x. f x
2 := λ f x. f (f x)
3 := λ f x. f (f (f x))
PLUS := λ m n f x. n f (m f x)
MULT := λ m n f. n (n f)
TRUE := λ x y. x
FALSE := λ x y. y
AND := λ p q. p q p
OR := λ p q. p q p
NOT := λ p a b. p b a
IFTHENELSE := λ p a b. p a b
PAIR := λ x y f. f x y
FIRST := λ p. p TRUE
SECOND := λ p. p FALSE
NIL := λ x. TRUE
NOTNIL := λ p. p (λx y. FALSE)

Taken from André Peng's talk on Foundations Of Objective-C
Transcript of the slides is available here.

Friday, August 10, 2012

Finite Element Method for Programmers: A shotgun introduction

Back in highschool you learned about the laws of physics. Whether you had fun with your teacher's theories of extraterrestrial life or struggled to pass, I'm sure  "Maxwell", "Newton", "mass" and "energy" are still familiar terms, and if you're proud to admit you're a geek perhaps you occasionally mention them in conversation about the origin of the Universe, the "God" particle, time travel.

Coming back to the real world - as real as Formula 1 cars, let's assume - finite element method (abbreviated FEM) is the "dominant discretization technique in structural mechanics." It's based on subdiving the model/representation into simpler components called... *tada* elements.

Meshing of a gear drive

Degrees of freedom and unknown functions

Now, if you took robotics (which sounds a lot cooler when you mention it in conversations then what you actually studied at your university - at least in my case) you might recall what degrees of freedom (DOF) are. They are the (unknown) functions which characterize the response of each finite element.

To get a feel of "degrees of freedom": an automobile with highly stiff suspension can be considered to be a rigid body traveling on a plane (a flat, two-dimensional space). This body has three independent degrees of freedom consisting of two components of translation and one angle of rotation. Skidding or drifting is a good example of an automobile's three independent degrees of freedom.

(3 x 2) degrees of freedom

Friday, July 27, 2012

sed replace inside quotes

Here's a useful sed one-liner:

echo "printf(\"foo\");" > quotemeonthat
sed -i.bak 's/printf("\(.*\)")/printf("\1 is just too lonely without bar")/' quotemeonthat
cat quotemeonthat 

-i.bak - edits the file, preserving the original in quotemeonthat.bak
\1 - refers to the first matched group

printf("foo is just too lonely without bar");

Suggestions for improvements are always welcome :)

Friday, July 6, 2012

An essay on Buddhism

To shed some light on some of my personal views and beliefs, below is an essay on Buddhism and science. Authored by yours truly.

Thursday, July 5, 2012

How Google is forcing Chrome on me

iGoogle will be retired in 16 months, on November 1, 2013. The mobile version will be retired on July 31, 2012.
If you’re a fan of Google Chrome, the Chrome Web Store provides a similar range of options like productivity tools and applications to check the weather. In addition, just like iGoogle, you can personalize Chrome with a theme.

What's your daily amount of Google?

EDIT: Using NetVibes as alternative to iGoogle. I'm very pleased.

Automobile engineer + war-free summer = ?

Precisely 66 years ago, while "Western Europeans joyously greeted the first war-free summer in years", French designer and automobile engineer Louis Réard unveils a daring two-piece swimsuit to "match the liberated mood of the people": the bikini.



Tuesday, July 3, 2012

Three things I learned on a Tuesday

MVC is dead, it's time to MOVE on.
  • Models encapsulate everything that your application knows.
  • Operations encapsulate everything that your application does.
  • Views mediate between your application and the user.
  • Events are used to join all these components together safely.

What is a closure?
I'll give an example (in Scheme):

(define (make-counter)
  (let ((count 0))
    (lambda ()
      (set! count (+ count 1))

(define x (make-counter))

(x) returns 1
(x) returns 2

What this function, make-counter, does is it returns a function, which we've called x, that will count up by one each time its called. Since we're not providing any parameters to x it must somehow remember the count. It knows where to find it based on what's called lexical scoping - it must look to the spot where it's defined to find the value. This "hidden" value is what is called a closure.

Measuring added value of code refactoring
So an idea I recently came to my mind is to use the size of test code as an approximation for the added value. Then, an equation for the bonus point can be like below:
score = k1 * number_of_new_test_cases - k2 * net_amount_of_code_added

What did you learn this Tuesday?

Saturday, June 23, 2012

Why don't we use our feet as input?

I came across the VIM clutch.

VIM Clutch is a hardware pedal for improved text editing speed for users of the magnificent VIM text editor

As an emacs user, I could use one.

Is it worth the effort for a nifty shortcut key?

Friday, June 22, 2012

6 mistakes I was making that were killing my productivity and my focus

1. Grinding the tabs

The problem: opening 34 new links as soon as you start working and start grinding through them.

The fix: Stay mindful. Do one thing at a time: see a link, open it, read it immediately, close it.

Not staying in control of my browsing activity. I use iGoogle to keep everything in one place (feeds, to do, bookmarks, email, weather). I also use Instapaper (with a sweet RSS feed to my iGoogle) to and Gimmebar (this is great for when you just want to quickly save snippets of text instead of bookmarking and tagging entire pages).

Coming back to iGoogle, naturally when I'm going through that huge list of headlines I would open everything that looked interesting in a new tab (if you've browsed Wikipedia, you've been there too, not surprisingly it's called the Wikipedia effect); wanting to go through everything and know everything about a certain subject.

If your mind is wandering, jumping one thought to the other and you can't seem to compose it to actually get something figured out, when you start surfing, it will lead you to "grinding the tabs".

2. Perfectionism

The problem: Getting lost in the details.

The fix:

Do not wait; the time will never be just right. Start where you stand, and work with whatever tools you may have at your command, and better tools will be found as you go along."

Hill, Napoleon

Thursday, June 21, 2012

A faster and more fun way of drawing diagrams

If you're like me, you don't like dragging and dropping items to make UML diagrams. On the other hand, although I'm a complete anti-talent at drawing, I find it helpful to sketch and map out things. I always take hand written notes even if it would be more comfortable simply to type things in a text editor of choice. I like to repeat in my head and visualize the sentences I'm tackling. Things seem to settle down better. Coming back to the topic:

You can get to this:

Just by typing this:
Mind->Body: sleep(6.5h)
    alt onWakeup
        Body->Mind: setEyesFeeling(TIRED)
        Mind->Body: snooze(10m)
            loop rand(1,9) times
                Body->Clock: press(snooze)


What do you think?

Wednesday, June 20, 2012

10 German words every programmer should know

Well, I'm taking German classes and for the last couple of days I've been looking over code mit Deutsch Kommentare. Alas:

Mittelung = averaging
(Such)Schleife = (search)loop
Betrag = amount
Verteilen = distribute
Vertrag = contract
Umsetzung = implementation
Stand = status
Eingabe - Ausgabe = input / output
Eigenwert = intrinsic value
Entwickler = developer

If you think I missed anything, feel free to add more in the comments below :)

Coming from a reader:
it struck me how many original German words exist for computer terms, which in the Netherlands have all been borrowed from the English language. Same case in French, by the way. But in Germany there still exist such nice words as "Rechner" (computer), Tastatur (keyboard) and many others.
In Romanian, "calculator" stuck as the word for "computer".

Wednesday, March 14, 2012

So what if ACTA didn't pass?

EU suspends ratification of copyright treaty ACTA

but soon after...

The ITU began discussing changes that would bring in international governance of the internet.

Update, July 10: ACTA Lives: How the EU & Canada Are Using CETA as Backdoor Mechanism To Revive ACTA

So what's there to do?
Well, boycotting a pending regulation won't do much, boycott the people and the companies generating those regulations. This is what I mean.

But wait, they don't have valid arguments for imposing Internet control, right? Wrong! Ongoing security concerns, break-ins, cyberterrorism, malware, child pornography, Anonymous striking everywhere. Wasn't the Internet intended to be a repository for information and services in the first place? All of this could sounds very convincing for a lawmaker.

How will they do it?
IP, DNS, URL, packet filtering
Connection reset / router cutoff
portal censorship (blocking sites from popular social networks and search engines)

or just go for the classic approach -- censorship methods used with traditional media.

So how will the Internet look if it goes dark? Pretty dull, I'd guess.

Monday, March 12, 2012

How to install libXm on Fedora 16

error while loading shared libraries:
To get the libXm library you need to get OpenMotif package, which is available from the RPMFusion repository.

Fire up a terminal:

sudo yum install wget
RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to ship.
sudo rpm -if rpmfusion-free-release-stable.noarch.rpm rpmfusion-nonfree-release-stable.noarch.rpm
Motif is the industry standard toolkit for UNIX systems and Open Motif, based on the Motif source code, provides a freely available version for open source developers.
sudo yum install openmotif.x86_64

Now just link the package to where it should usually be found:

sudo ln -s /usr/lib64/openmotif/ /lib64/

P.S.: You can always use yum whatprovides * to see what package provides a missing library.