Archive

Archive for June, 2016

Powershell cheatsheet for C++/C#

June 22nd, 2016 Comments off

This is just a small post to help my ageing memory remember where things are located.

  • Powershell C#
    Locate the dll, System.Management.Automation.dll, and add it to your project, (or add it via Nuget).

    • See this blog for a good introduction on creating a project, (works for vs2015).
  • Check what version is installed
    • According to the official site you need to check the registry
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1
      or
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3
      And check that the value Install is set to ‘1’.
  • Debuging
    • The external program is C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    • But the actual location is:
      • Powershell 1: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine\{ApplicationBase}
      • Powershell 3:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine\{ApplicationBase}
    • Launching from debuger:
      • For a script:
        PowerShell -Command “& {.\myscript.ps1}” or
        PowerShell -File “.\myscript.ps1”
      • For a CmdLet/Module:
        -noexit -command “&{ import-module .\AMPowerShellCmdLets.dll -Verbose}”
  • Some links
Categories: development Tags: , ,

Using Github from command line

June 11th, 2016 Comments off

This assumes that you have all the permissions needed to access your repo, (passwords and so on).

Start Git Shell and navigate to your local repo.

Create a branch

git checkout -b <branch-name>
git push <remote-name> <branch-name>

In the case of github the remote name is ‘origin’

Source

Add your changes to the branch

git add .

The ‘.’ means ‘everything’ that was changed.

You can use ‘status’ to check what needs to be staged, (or what has been staged).

git status

Commit branch

git commit -m "You message here"

Push branch
The first time you need to tell where you are pushing this to.

git push --set-upstream <remote-name> <branch-name>

The afterwards you just need to do…

git push

Delete your branch

To remotely delete it

git push <remote-name> --delete <branch-name>

To locally delete it


git branch --delete <branch-name>

Source

Categories: Cheat-sheet, development Tags: ,

How to compare multiple folders with BeyondCompare 4 and Piger

June 2nd, 2016 Comments off
Why?

In some cases you might often need to compare folders using beyond compare and using a Piger command might just do the trick.

The problem is that you might want to open/compare more than one folder at a time, so here is how to do it.

How

First of all, go and download your version of Beyond compare and get the latest version of Piger.

Open a blank file with your favourite editor, we will create a LUA file in this case.

— the path to the BC4 exe.
local bCompare = [[%ProgramFiles%\Beyond Compare 4\BCompare.exe]];

— compare folder A and folder B
am_execute( bCompare, [[/filters=”-bin\;-*.exe” “c:\folderA” “c:\folderB”]]);

— also compare folder X and folder Y
am_execute( bCompare, [[/filters=”-lib\;-*.user” “c:\folderX” “c:\folderY”]]);

The part “/filter=” contains the files you want to filter out, in the first example, the folder(s) “bin\” will be filtered out as well as files with the executable extension, (*.exe).

Finally, the 2 folders are listed one after the other, I suggest that you add quotes around them, especially if they have spaces, (but do it anyway).

Admin or not?

You might not access to all the folders, (for whatever reason), but you might have access as an admin, so, when in doubt, set the admin flag to true, this might help a little.

But it is not generally needed…

am_execute( bCompare, [[/filters=”-lib” “c:\X” “c:\Y”]], true);

String in LUA

A small note about the way I escaped the strings in my example.

normally special characters are ‘escaped’ in LUA, (characters like quotes and so on).

local x = “This is how you do it, \”normally\””

but you can use double square brackets to make your life slightly easier, (and more importantly, easier to read).

local x = [[This is how you do it, “normally”]]

See Lua String for more info.

Finally

Save you file with whatever command you want to call it, for example “compare.lua”, make sure that it has the “.lua” extension.

Move the file to your command folder, ( located in “%appdata%\MyOddWeb\ActionMonitor\RootCommands\” by default).

Reload Piger, (use the command “this.reload”).

And your new command should now appear.