ADAMKDEAN

List all files changed in last commit

Published Monday, 8 February 2016

List all files changed in the last commit by using git diff-tree on HEAD.

git diff-tree --no-commit-id --name-only -r HEAD

For example, if you changed README.md in your last commit:

adam@macbook:project (master) $ git diff-tree --no-commit-id --name-only -r HEAD
README.md

Clutter free Unity/VSCode

Published Sunday, 24 January 2016

So, it's 2016. It's been over two months since my last post. I've just been so busy recently, with work being emotionally tiring and with a baby on the way, I've just been busy with real life and not really had much chance to do much else. I've decided that I need to enjoy programming. I need to use my ability for good. So I'm going to make games.

I've dabbled in game development before but it's always been unchannelled, uncontrolled, and that isn't a good thing. The first step to being able to enjoy something is to enjoy your environment, and for us devs, that means our development environment. I'm using OS X, so things are sometimes different to 90% of the internet. Unity ships with MonoDevelop, which fair enough, does it's job, but it's pretty shit. Luckily, VSCode works on OS X and though I'm now a convert, I have always like Visual Studio ever since I started using it 16 years ago with VB6.

A chap named @reapazor wrote a VSCode integration script for Unity which works really well, but my OCD goes wild at all the miscellaneous files which show up in the treeview. It just doesn't look good. Note: I had to install VSCode from the asset store for it to work properly.

Cluttered treeview

This can be fixed by exlcuding a few files/directories in your user settings.json file (which you can access with cmd + ,). If you ever need to access these files, just remove them from the exclusion list.

Update I've realised just now (25/01/16 14:39) that the VSCode plugin actually has an option to do this for you, in the preferences, "Write Workspace Settings". I guess it didn't jump out at me at the time but this also works. All you need to do is append two lines to the .vscode/settings.json file to clear up a few other files you may not want to see:

"**/*.csproj":true,
"**/*.sln":true

The full list is at the end of this post. It will result in lower blood pressure:

Lower blood pressure with Unity + VSCode

Well, hopefully I'll be posting some interesting posts this year. I'll be using C# for game dev, ES6 at work, and with a baby on the way, there will be lots of non-computer related discoveries too I'm sure.

Here is to a great 2016, and here is your complete settings.json file:

{
    "files.exclude":
    {
        "**/.DS_Store":true,
        "**/.git":true,
        "**/.gitignore":true,
        "**/.gitmodules":true,
        "**/*.booproj":true,
        "**/*.pidb":true,
        "**/*.suo":true,
        "**/*.user":true,
        "**/*.userprefs":true,
        "**/*.unityproj":true,
        "**/*.dll":true,
        "**/*.exe":true,
        "**/*.pdf":true,
        "**/*.mid":true,
        "**/*.midi":true,
        "**/*.wav":true,
        "**/*.gif":true,
        "**/*.ico":true,
        "**/*.jpg":true,
        "**/*.jpeg":true,
        "**/*.png":true,
        "**/*.psd":true,
        "**/*.tga":true,
        "**/*.tif":true,
        "**/*.tiff":true,
        "**/*.3ds":true,
        "**/*.3DS":true,
        "**/*.fbx":true,
        "**/*.FBX":true,
        "**/*.lxo":true,
        "**/*.LXO":true,
        "**/*.ma":true,
        "**/*.MA":true,
        "**/*.obj":true,
        "**/*.OBJ":true,
        "**/*.asset":true,
        "**/*.cubemap":true,
        "**/*.flare":true,
        "**/*.mat":true,
        "**/*.meta":true,
        "**/*.prefab":true,
        "**/*.unity":true,
        "build/":true,
        "Build/":true,
        "Library/":true,
        "library/":true,
        "obj/":true,
        "Obj/":true,
        "ProjectSettings/":true,
        "temp/":true,
        "Temp/":true,
        "**/*.csproj":true,
        "**/*.sln":true
    }
}

Change keyboard layout on Ubuntu + Xrdp

Published Monday, 30 November 2015

If you're using Ubuntu with Xrdp, and you find the keyboard to be infuriatingly inaccurate, you should probably change it. To do this, you need to have the ability to open the System Settings window, which you can't always do over RDP. In there, go to Text Entry, and click the little plus at the bottom. Now select the keyboard layout that applies to you, and test it works.

Now, finally, to make these settings apply to Xrdp, run the following command:

sudo xrdp-genkeymap /etc/xrdp/km-0409.ini

Logout, log back in with Xrdp and it should now work.

Available devtools for webpack

Published Friday, 6 November 2015

In case the webpack docs ever lose this, here is a list of available devtools. Choose a developer tool to enhance debugging.

eval - Each module is executed with eval and //@ sourceURL.
source-map - A SourceMap is emitted. See also output.sourceMapFilename.
hidden-source-map - Same as source-map, but doesn't add a reference comment to the bundle.
inline-source-map - A SourceMap is added as DataUrl to the JavaScript file.
eval-source-map - Each module is executed with eval and a SourceMap is added as DataUrl to the eval.
cheap-source-map - A SourceMap without column-mappings. SourceMaps from loaders are not used.
cheap-module-source-map - A SourceMap without column-mappings. SourceMaps from loaders are simplified to a single mapping per line.

Prefixing @, # or #@ will enforce a pragma style. (Defaults to #, recommended)

Combinations are possible. hidden, inline, eval and pragma style are exclusive.
i. e. cheap-module-inline-source-map, cheap-eval-source-map, #@source-map

Encapsulating console.log with spread operator

Published Wednesday, 4 November 2015

ES6 or ES2015 contains lots of goodies. One of them, my favourite, is the spread operator. It "allows an expression to be expanded in places where multiple arguments (for function calls) or multiple elements (for array literals) are expected."

For example, you can combine two arrays like so:

var start = ['a', 'b', 'c'],
    end = ['d', 'e', 'f'];

var combined = [...start, ...end];

console.log(combined);

// => ['a', 'b', 'c', 'd', 'e', 'f']

What I like even more, is that you can do this with function arguments. Let's say we wanted to wrap console.log so we can do something funky with it. This can easily be done using the spread operator.

var log = function (format, ...args) {
    if (args.length > 0) console.log(format, args);
    else console.log(format);
}

log('test');
log('this is an %s test', 'interpolation');

// => test
// => this is an interpolation test

This changes things. Read more at MDN.

ES7 should also bring object spread operators, so you can do { ...initial, ...change }.

 
Showing posts 1-5 of 178