All posts by Torleif

How to add certificates to the Windows certificate store

There’s a command-line tool called certutil one can use to add (among other things) certificates to the certificate store in windows.

Some examples:

REM Add pfx-file to Personal
certutil -ent -p pfxpassword -importpfx my some.pfx

REM Add pfx-file to Trusted Root Certification Authorities
certutil -ent -p pfxpassword -importpfx root some.pfx

REM Add cer-file to Trusted Root Certification Authorities
certutil -ent -addstore root some.cer

Manage saved windows passwords

Logged into a windows share via explorer and hit the Remember Password option. Even though the login was accepted (and saved) it turned out I had used the wrong ad domain name…

Couldn’t find where to reset/change/”logout” again, but eventually found there’s a built-in command-line tool one can use for managing these saved passwords. Think I’ve seen a control panel type thing to do this too in the past, but just couldn’t find it today… Anyways, command-line is nice, so, using imaginary share \\foobar.int, here’s some stuff one can do:

> cmdkey /list
> cmdkey /list:foobar.int

> cmdkey /delete:foobar.int

> cmdkey /add:foobar.int /user:domain\username /pass

Heroku deploy sub-directory

Going through a couple of Udemy courses, and figured it was nice to keep all the code I wrote while doing them in a single github repository.

Was working nicely until I started the Node with React where part of the course is to deploy the app to Heroku which wants a full repository pushed to a certain git repo it creates for deployment. But in my case the app I want to deploy is of course a sub-directory…

Turns out there’s a git command called subtree one can use here:

# Setup
heroku login
heroku create

git remote add heroku/some-name https://git.heroku.com/{created-heroku-app-id}.git

# Deploy
git subtree push --force --prefix path/to/app heroku/some-name master

The subtree command needs to be run from the top-level directory of the git repository, but one can add a script command to the apps package.json, for example like this:

{
  "scripts": {
    "deploy": "cd ../../.. && git subtree push --prefix path/to/app heroku/some-name master"
  }
}

Unfortunately, subtree push doesn’t support --force, but a workaround for that is running it nested like this:

git push heroku/some-name `git subtree split --prefix path/to/app master`:master --force

Which unfortunately doesn’t work on Windows… but you can do it in two steps instead:

git subtree split --prefix path/to/app master
git push heroku/some-name {id-from-previous-command}:master --force

Stop Git from messing with my newlines

I’m sorry, but I just hate when Git is messing with my files…

warning: CRLF will be replaced by LF in some/file.ext.
The file will have its original line endings in your working directory.

That’s just not its job! If I want to enforce a certain new line regime, there’s linting tools, pre-commit hooks, etc.

The following should stop it, but frankly, sometimes it feels like git just keeps inventing new ways of reverting to its hyper annoying default…

# First run this to see where it's configured now
> git config --list --show-origin

# Then run whichever works...
> git config --global core.autocrlf false
> git config --system core.autocrlf false
> git config --local core.autocrlf false

Enable SQL logging in Play 2.5+

Just a note to self on how to get (in my case) IntelliJ to spit out all SQL statements happening during unit tests.

  1. Add the following to application.conf
    db.default.logSql=true
  2. Add the following to logback.xml
    <logger name="org.jdbcdslog.ConnectionLogger" level="OFF"  />
    <logger name="org.jdbcdslog.StatementLogger"  level="INFO" />
    <logger name="org.jdbcdslog.ResultSetLogger"  level="OFF"  />

Source: StackOverflow