Friday, January 12, 2018

Pre-compiled libraries in nix-shell

I've been using nix-shell as a way to have an easily reproducible environment.  I was using Docker but it's overkill for what I was looking for and it gave me the opportunity to explore the Nix ecosystem a little further.

The project I'm currently working on used Elm for the front-end, Elixir for managing the API and connecting to SQL Server.  Microsoft have open sourced the necessary libraries to use ODBC through Erlang so I was able to get it working on my development environment pretty quickly. 

The MS libraries are here with complete installation instructions.

However, when I tried to incorporate into my actual project I ran into a few issues.  I am using nix-shell to load up my environment so I know that its the same across machines and it's been working very well.  After I had everything installed, I attempted to connect to the database only to be informed by the ODBC Driver Manager that /opt/microsoft/msodbcsql/lib64/ did not exist.  I checked the filesystem and the file was there so I used the ldd utility to inspect the libraries and found that most of the required libraries could not be found:

$> ldd /opt/microsoft/msodbcsql/lib64/ (0x00007fff71ba5000) => /nix/store/.../lib/ (0x00007f8c4ce9a000) => not found => not found => not found => not found => not found => not found => not found => not found => /nix/store/.../lib/ (0x00007f8c4cb4e000) => /nix/store/.../lib/ (0x00007f8c4c938000) => /nix/store/.../lib/ (0x00007f8c4c71a000) => /nix/store/.../lib/ (0x00007f8c4c368000)
/nix/store/.../lib64/ (0x00007f8c4d49a000)

After doing some research I found a few links to help me better understand the problem.  From this StackOverflow issue
"So, the path to the dynamic linker is hard-coded in the binary. And the dynamic linker being used is from the system (from the host glibc), not from nix. And because the dynamic linker doesn't match the glibc which we want and need to use, it doesn't work.
A simple and working solution is patchelf."
So I followed along and tried to get these tools to work with the MS libraries but no glory.  I kept getting "cannot find section .interp" when attempting to set the interpreter using patchelf.  I wasn't able to get past this issue as I had limited time and was already pretty deep down the rabbit hole.  I was able to find the source for the MSODBC drivers version 11 but the compiled version was 13 and I was still unable to get the older code to compile.  Again, limited time and pressure to move on.
So undoing the nix-shell environment did allow me to get everything working.  I hope to have time to figure this out in the future but wanted to post my findings in the event anyone else is experiencing these issues with the MS drivers.

Other links:

Monday, November 11, 2013

Getting started with erlcloud (Erlang AWS Client)

I've been reading up on Erlang and wanted to find a project to read through and gain a better understanding the the language.  I decided on erlcloud as I'm doing a lot of work with AWS.  Here are a few things I learned the hard way in the hopes of saving someone else some time.

After cloning the package from Github, you should run "make" to get all the dependencies and compile the code.  Rebar should work as well.

Make sure to check out the README file and setup your AWS credentials so they can be found.

To get everything started in the shell, you need to tell Erlang where to find the beam files:
MBP:/home/code/erlcloud$ erl -pa ./ebin -pa ./deps/jsx/ebin

Then once in the shell:

I'm guessing there is any easier to get all this started but I'm still learning.

Monday, September 9, 2013

Functionally Thinking ...

I've been trying to better understand functional programming for a while and wanted to document the steps.

Think about expected results, not steps to get there.

1. Learn you a haskell
3. PrgProg's Elixir book.
4. O'Reilly's Elixir book.
5. Some Erlang research ...
6. PeepCode Elixir intro.

Good Talk by Neal Ford!

Tangible Function Functional Programming

I'll come back and update further as I better understand the concepts.

Tuesday, August 13, 2013

Willful Blindness

Aug. 12, 2013

Margaret Heffernan: The dangers of "willful blindness"

Gayla Benefield was just doing her job -- until she uncovered an awful secret about her hometown that meant its mortality rate was 80 times higher than anywhere else in the U.S. But when she tried to tell people about it, she learned an even more shocking truth: People didn’t want to know. In a talk that’s part history lesson, part call-to-action, Margaret Heffernan demonstrates the danger of "willful blindness" and praises ordinary people like Benefield who are willing to speak up. (Filmed at TEDxDanubia.)

Saturday, June 22, 2013

What is Leadership?

via Caesura Letters

Leadership Doodle

By James Shelley

This is one of my favourite napkin doodles:

I draw a circle to represent “a goal”. Another circle to represent “the people”. An arrow pointing from the “people circle” to the “goal circle”.

The question: what is leadership?

What does it mean to move people — the rather finicky creatures that we are — to actually do something together?

Push. It seems that some leaders get behind the people circle and push it towards the goal. Well, they call it “encourage,” actually. Nelson Mandela said, “It is wise to persuade people to do things and make them think it was their own idea.” (Stengel, 2008) Classic push-leaders often find second careers as motivational speakers: “Yes, you can do it!” is their primary message.

Pull. Some leaders get in front of the people circle and pull everyone along, in a way that conjures up the stereotypical image of an alpha personality, akin to the image of a face-painted William Wallace persona leading the charge. In less euphoric times these are the leaders who, in the words of John Naisbitt, settle for “finding a parade and getting ahead of it.” (Naisbitt, 1982) When they are actually sitting still they are busy fine-tuning endless drafts of vision, purpose, objective, and mission statements.

Insiders. Some leaders like to dive into the people circle and lead from within. Disciples of Dale Carnegie and John Maxwell come quickly to mind. These are the people who are out to save corporate America one coffee appointment and “checking in on you” email at a time. Of course, we all love these kinds of leaders—and we know full well that these leaders love for us to love them too.

If I am the crunched up end of a coffee stir stick, bouncing around the metaphorical napkin of leadership, I find myself most in sync with my convictions when I just ignore the people circle altogether and move myself toward “the goal” circle. Trying to manipulate and alter people’s thinking (not to mention their habits) is hard work, in fact it is a never-ending pipe-dream into which one can easily flush many years.

Ironically, most of the leaders who we revere as our idols did not invest their lives into trying to subvert the conscious landscape of the people circle. No, the greatest leaders in history seem to have just gone after the goal because they believed in it. The following hypothesis lands outside of the realm of provability, but perhaps it carries anecdotal truth nonetheless: humans seem almost lustful to follow an individual with an audacious, personal commitment to practical action.

We instinctively want to trust leaders who are really going to “make it happen” — so it seems logical that there is no leader more enticing than the one who is already doing it. We know that the leader who cares the most is the leader who will die for the goal, even if no one else is following. Yet, these are the people who become the magnetic centres of movement, change, and accomplishment.

The adage is as old as the hills: if no one follows you, you are not really a leader. The problem is that most people who call themselves leaders do not really know if anyone is following them. They are too busy trying to create alignment — something about getting the right people on the right seats on the right bus. You can invest so much energy into managing, motivating, and manipulating the people circle in the name of “leadership” that the actual task itself is forgotten in the pile of self-help books.

“Leadership” has become more of a psycho-persuasion exercise than doing an action that other people repeat, mimic and respond to in turn.

Doers. As an alternative to general push, pull, and insider models of leadership, I want to suggest a third idea: go and do it and see who follows you. To really test your leadership capacity, quit trying to lead people and actually try doing “the thing” you want others to do. If people come along then you have followers — then and only then are you truly a leader.

The first concern of the leader is the goal circle, not the people circle. Yes, you should care deeply and genuinely for your followers — caring for those around you is indispensable — but don’t confuse your “followers” with people who you are merely trying to coerce into doing something that they would never find you yourself doing.

Leadership, as a methodology, sells a lot of books.
Leadership, as a job title, is an institutional invention.
Leadership, as a discipline, is the pathway to dogmatism.
Leadership, as an ideal, is the instigator of disillusionment.
Leadership, as a status symbol, breeds resentment.
Leadership, in a reality, will simply change your neighbourhood.

Friday, June 7, 2013

Peering through the veil of "It's for your protection".

Recently our government has been collecting data on ALL phone traffic from Verizon. Today it was revealed that they were actually collecting data from 9 different internet companies including Google, Facebook and Twitter. U.S. mining data from 9 leading Internet firms This program apparently costs 20 mill a year to run. When you think about it, it's pretty amazing ... all this coordination and only 20 mill a year and it's all for our protection. If this were true, then the people charged with protecting us should should be truly treated like heroes ... right?

Of course not, because this isn't about protecting americans. This is about power plain and simple. Think of how much power the IRS will wield the next time it wants to attack opposing political parties. Or how much power the DOJ will wield the next time it needs to track down the source of a leak.

We should be ashamed that we allow this to continue. While at the same time make the men and women out on the battlefield giving their lives for our so called freedom wait on average ONE YEAR to provide the benefits they so desperately need. Average Wait times for Veterans Administration Services!

Friday, February 1, 2013

Unprotect PDFwith password

I continually receive PDF's from either my accountant or my bank that are password protected which means if I want to extract a page or two and then fax to a bank to verify funds for a purchase, the print to PDF option won't work. So I have done this a few times now and wanted to document for others and myself since I keep forgetting how to do it.

gs \ -sPDFPassword=pass \ -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \ -sOutputFile=unencrypted.pdf \ -f password_protected.pdf

This will open the file using GhostScript and then create a new file and the new file will not be protected. The important part here is the first param giving the password to gs.